从Java也可以在C#中重画功能吗? [英] Repaint function from java also in c#?

查看:56
本文介绍了从Java也可以在C#中重画功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/*非常感谢您所做的一切.您说得对,这是个好主意.
我希望我能够付诸实践!
PS.我希望我以正确的方式投票.
*/

我意识到我的解释很烂.
所以,我有一个Windows窗体应用程序.
还有一个画框

我希望在doubleClick上更改btton_clicked函数中pictureBox的图像源(jpg文件):

/* Thanks alot for everything . You are right ,this is a good idea .
I hope i will be able to put it to practice !
PS . I hope i voted the right way .
*/

I realised my explanation sucked .
So , i have a windows form application .
And a picturebox

I want that on a doubleClick to change the image source(a jpg file) of the pictureBox in the btton_clicked function :

int i=0;
       private void pictureBox1_DoubleClick(object sender, EventArgs e)
       {
           if( i%2==0)
           pictureBox1.BackgroundImage = Image.FromFile("stars.jpg");
           else
               pictureBox1.BackgroundImage = Image.FromFile("cim.jpg");
           i++;
// pictureBox1.Invalidate();
       }



我如何对pict​​ureBox说,我需要它来重新粉刷Itsel,这样我才能
看到图片了吗? Invalidate不起作用!



How do i say to the pictureBox that i need it to repaint itsel so i can
see an image ? Invalidate doesnt work !

推荐答案

Invalidate()不起作用吗?还是不能只在块所在的位置绘制一个空白正方形,然后在要做的位置绘制该块?

您的解释有点糟透了.
Doesn''t Invalidate() work? Or couldn''t you just draw a blank square where the piece was, and draw the piece where it''s doing to be?

Your explanation kinda sucks.


pictureBox1.Refresh();
怎么样
或者也许是这样:

How about pictureBox1.Refresh();

Or maybe this:

pictureBox1.Image = new Bitmap(strFilename);



我只是有个想法...

为什么不创建一个代表棋盘的画框,以及一堆显示各个棋子的较小的画框,然后将棋子在棋盘顶部移动.

这样,您可以添加特殊的图形效果(例如使选定的片段发光),并逐个片段地进行适当的处​​理.



I just had a thought...

Why don''t you create a picturebox that repesents the chessboard, and a bunch of smaller picture boxes that show the various pieces, and move the pieces around on top of the board.

That way,, you can add special graphical effects (like making the selected piece glow), and appropriate handling on a per-piece basis.


这篇关于从Java也可以在C#中重画功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆