Graphics.DrawImageAbort 委托

定义

提供一个回调方法,用于决定 DrawImage 方法应何时过早地取消执行并停止绘制图像。Provides a callback method for deciding when the DrawImage method should prematurely cancel execution and stop drawing an image.

public: delegate bool Graphics::DrawImageAbort(IntPtr callbackdata);
public delegate bool Graphics.DrawImageAbort(IntPtr callbackdata);
[System.Runtime.InteropServices.ComVisible(false)]
public delegate bool Graphics.DrawImageAbort(IntPtr callbackdata);
type Graphics.DrawImageAbort = delegate of nativeint -> bool
[<System.Runtime.InteropServices.ComVisible(false)>]
type Graphics.DrawImageAbort = delegate of nativeint -> bool
Public Delegate Function Graphics.DrawImageAbort(callbackdata As IntPtr) As Boolean 

参数

callbackdata
IntPtr

指定回调方法数据的内部指针。Internal pointer that specifies data for the callback method. 该参数不是由所有的 DrawImage 重载传递的。This parameter is not passed by all DrawImage overloads. 可以通过检查 Zero 值来测试它是否存在。You can test for its absence by checking for the value Zero.

返回值

Boolean

如果此方法决定 DrawImage 方法应过早停止执行,则此方法返回 trueThis method returns true if it decides that the DrawImage method should prematurely stop execution. 否则返回 false,指示 DrawImage 方法应继续执行。Otherwise it returns false to indicate that the DrawImage method should continue execution.

继承
Graphics.DrawImageAbort
属性

示例

此示例是委托的简单实现 Graphics.DrawImageAbortThis example is a simplistic implementation of the Graphics.DrawImageAbort delegate. 它仅检查 DrawImage 方法是否已使用 callbackdata 参数向其传递数据。It merely checks to see if the DrawImage method has passed it data using the callbackdata parameter. (某些 DrawImage 重载只包含一个 DrawImageAbort 参数并且未传递任何数据; 某些重载具有 DrawImageAbortcallbackdata 参数并且可以传递数据。如果未传递任何数据,则 ) 如果未传递任何数据,它将返回 true 到调用方法的信号,该 DrawImage 方法应取消绘制。(Some DrawImage overloads have only a DrawImageAbort parameter and pass no data; some overloads have both DrawImageAbort and callbackdata parameters and can pass data.) If no data was passed, it returns true to signal to the calling DrawImage method that it should cancel the drawing. 如果传递了数据,则它会返回 false 信号,指示绘制应继续。If data was passed, it returns false to signal that drawing should continue.

此回调的现实实现涉及某些条件的实际审查,以取消或继续执行。A realistic implementation of this callback would involve the actual scrutiny of some criteria to cancel or continue the execution.

Private Function DrawImageCallback(callBackData As IntPtr) As Boolean  
     ' Test for call that passes callBackData parameter.  
     If callBackData.Equals(IntPtr.Zero) Then  
         ' If no callBackData passed, abort DrawImage method.  
         Return True  
     Else  
         ' If callBackData passed, continue DrawImage method.  
         Return False  
     End If  
 End Function 'DrawImageCallback  
// Define DrawImageAbort callback method.  
 private bool DrawImageCallback(IntPtr callbackdata)  
 {  
    // Test for call that passes callBackData parameter.  
    if(callbackdata==IntPtr.Zero)  
    {  
       // If no callbackdata passed, cancel DrawImage method.  
       return true;  
    }  
    else  
    {  
       // If callbackdata passed, continue DrawImage method.  
       return false;  
    }  
 }  

注解

此方法与类的方法结合使用 DrawImage GraphicsThis method is used in conjunction with the DrawImage method of the Graphics class. 方法的某些重载 DrawImage 调用此类型的应用程序定义的回调方法,以查明重载应停止还是继续执行。Certain overloads of the DrawImage method call an application-defined callback method of this type to find out if the overloads should stop or continue execution.

在执行期间,相关 DrawImage 重载会频繁调用此回调方法,以查明是否应停止绘制指定的图像,或是否应继续绘制图像。During execution, the relevant DrawImage overloads frequently call this callback method to find out if they should stop drawing the specified image or if they should continue drawing the image. Graphics.DrawImageAbort回调方法可以确定是继续还是不基于其中包含的所选算法,还可以选择使用通过 callbackdata 参数传递给它的数据。The Graphics.DrawImageAbort callback method can determine whether to continue or not based on a chosen algorithm included in it, optionally using the data passed to it by the callbackdata parameter. 例如,算法可以确定图像是否已滚动到屏幕,并向方法发出取消信号以 DrawImage 停止绘制。For example, an algorithm might determine if the image has scrolled off the screen and signal a cancellation to the DrawImage method to stop drawing.

此事件处理方法的用户声明必须具有与委托声明相同的参数 Graphics.DrawImageAbortA user declaration of this event-handling method must have the same parameters as the Graphics.DrawImageAbort delegate declaration.

扩展方法

GetMethodInfo(Delegate)

获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.

适用于