Graphics.DrawImageAbort 代理人

定義

提供回呼 (Callback) 方法來決定 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);
[System.Runtime.InteropServices.ComVisible(false)]
public delegate bool Graphics.DrawImageAbort(IntPtr callbackdata);
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.DrawImageAbort委派的簡單執行。This 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只會有參數, 而且不會傳遞任何資料; DrawImageAbort有些callbackdata多載同時具有和參數, 而且可以傳遞資料)。如果未傳遞任何資料, 它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 Graphics類別的方法搭配使用。This 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.DrawImageAbort委派宣告相同的參數。A 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.

適用於