如何调用方法 [英] how to call the method

查看:137
本文介绍了如何调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#.NET创建图形
我有以下编码
我无法获得方法的调用方法.请注意

I am creating graphics using C#.NET
I have following coding
I am not able to get how to call method..Just see to it

public void paint(object sender,PaintEventArgs e) 
        {
            e.Graphics.PageUnit = GraphicsUnit.Inch;
            TextureBrush tb = new TextureBrush(Image.FromStream(GetType().Assembly.GetManifestResourceStream("tbinch.Bitmap1.bmp")));
            Matrix mx = new Matrix(1f / e.Graphics.DpiX, 0, 0, 1f / e.Graphics.DpiY, 0, 0);
            tb.Transform = mx;
            e.Graphics.FillRectangle(tb, 0, 0, 5, 5);
        }



我已经按了一个按钮
如何在该click_event中调用绘画方法
paint();
将在此处传递哪些参数


Thanks



I have taken one button
how to call paint method in that click_event
paint();
what arguments will be passed over here


thanks

推荐答案

您不会直接调用Paint方法-它通常作为Paint事件的处理程序附加,并在需要显示元素时自动调用已更新.

您可以使用Control.Invalidate()方法强制框架向我的Paint事件发出信号.例如:
You do not call the Paint method directly - it is normally attached as a handler to the Paint event, and is called automatically when the display element need to be updated.

You can force the framework to signal the Paint event my using the Control.Invalidate() method. For example:
myPanel.Invalidate();


paint方法可以在继承自窗口控件(或其后代)的类中重写,并且重新绘制控件时自动调用).您可以直接调用Repaint,但这将是一个坏习惯,因为您会召唤应用程序必须执行重绘,即使它仍在忙,并且已经在等待一些调用.这会使您的应用程序停顿,因此不应该这样做.您应该调用Invalidate ,这将尽快重绘控件,但不会排队多个调用,因此不会暂停您的应用程序.

它已经成为一个故事,带有一些额外的背景信息,最终总之可以归结为... Invalidate

祝你好运!
The paint method can be overridden in classes inheriting from window control (or a descendant of that) and is called automatically when the control is repainted). You could call Repaint directly, but that would be a bad practice because you summon the application that it must execute the repaint, even if it is still busy doing so and already a few calls to it are waiting. This would stall your application and should therefor not be done. You should call Invalidate instead which would repaint the control as soon a possible but without queuing multiple calls and therefor won''t stall your application.

It''s become quite a story with some extra background information that eventually in short would comes down to... Invalidate

Good luck!


这篇关于如何调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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