New system windows forms painteventargs

Paint Event Args Класс

Определение

Предоставляет данные для события Paint. Provides data for the Paint event.

Примеры

В следующем примере демонстрируется обработка Paint события и использование PaintEventArgs класса для рисования прямоугольников в форме. The following example demonstrates handling the Paint event and using the PaintEventArgs class to draw rectangles on the form. MouseDownСобытия и MouseUp обрабатываются для определения размера прямоугольника. The MouseDown and MouseUp events are handled to determine the size of the rectangle. В примере также демонстрируется Invalidate метод для недействительности области прямоугольника, что приводит к его перерисовке. The example also demonstrates the Invalidate method to invalidate the area of the rectangle, causing it to be redrawn.

Комментарии

Это Paint событие возникает при перерисовке элемента управления. The Paint event occurs when a control is redrawn. Объект PaintEventArgs задает объект, Graphics используемый для рисования элемента управления и для ClipRectangle рисования. A PaintEventArgs specifies the Graphics to use to paint the control and the ClipRectangle in which to paint.

Дополнительные сведения о модели событий см. в разделе обработка и вызов событий. For information about the event model, see Handling and Raising Events.

Конструкторы

Инициализирует новый экземпляр класса PaintEventArgs с указанной графикой и прямоугольником отсечения. Initializes a new instance of the PaintEventArgs class with the specified graphics and clipping rectangle.

Свойства

Возвращает прямоугольник, в котором будет осуществляться рисование. Gets the rectangle in which to paint.

Возвращает рисунок для окрашивания. Gets the graphics used to paint.

Методы

Освобождает все ресурсы, занятые модулем PaintEventArgs. Releases all resources used by the PaintEventArgs.

Освобождает неуправляемые ресурсы, используемые объектом PaintEventArgs, а при необходимости освобождает также управляемые ресурсы. Releases the unmanaged resources used by the PaintEventArgs and optionally releases the managed resources.

Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.

(Унаследовано от Object) Finalize()

Позволяет объекту попытаться освободить ресурсы и выполнить другие операции очистки, перед тем как он будет уничтожен во время сборки мусора. Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

Читайте также:  Как узнать какого разряда система 32 или 64 windows 10

Служит хэш-функцией по умолчанию. Serves as the default hash function.

(Унаследовано от Object) GetType()

Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.

(Унаследовано от Object) MemberwiseClone()

Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.

(Унаследовано от Object) ToString()

Возвращает строку, представляющую текущий объект. Returns a string that represents the current object.

(Унаследовано от Object)

Явные реализации интерфейса

Возвращает дескриптор контекста устройства Windows. Returns the handle to a Windows device context.

Освобождает дескриптор контекста устройства Windows. Releases the handle of a Windows device context.

Paint Event Handler Делегат

Определение

Представляет метод, обрабатывающий событие Paint объекта Control. Represents the method that will handle the Paint event of a Control.

Параметры

Источник события. The source of the event.

Объект PaintEventArgs, содержащий данные события. A PaintEventArgs that contains the event data.

Примеры

В следующем примере кода строки и текст рисуются на PictureBox элементе управления. The following code examples draws lines and text on a PictureBox control.

Комментарии

При создании делегата PaintEventHandler необходимо указать метод, обрабатывающий событие. When you create a PaintEventHandler delegate, you identify the method that will handle the event. Чтобы связать событие с обработчиком событий, нужно добавить в событие экземпляр делегата. To associate the event with your event handler, add an instance of the delegate to the event. Обработчик событий вызывается всякий раз, когда происходит событие, если делегат не удален. The event handler is called whenever the event occurs, unless you remove the delegate. Дополнительные сведения об обработке событий с помощью делегатов см. в разделе обработка и вызов событий. For more information about handling events with delegates, see Handling and Raising Events.

Методы расширения

Получает объект, представляющий метод, представленный указанным делегатом. Gets an object that represents the method represented by the specified delegate.

Paint Event Args Class

Definition

Provides data for the Paint event.

Examples

The following example demonstrates handling the Paint event and using the PaintEventArgs class to draw rectangles on the form. The MouseDown and MouseUp events are handled to determine the size of the rectangle. The example also demonstrates the Invalidate method to invalidate the area of the rectangle, causing it to be redrawn.

Читайте также:  Dji assistant mac os

Remarks

The Paint event occurs when a control is redrawn. A PaintEventArgs specifies the Graphics to use to paint the control and the ClipRectangle in which to paint.

For information about the event model, see Handling and Raising Events.

Constructors

Initializes a new instance of the PaintEventArgs class with the specified graphics and clipping rectangle.

Properties

Gets the rectangle in which to paint.

Gets the graphics used to paint.

Methods

Releases all resources used by the PaintEventArgs.

Releases the unmanaged resources used by the PaintEventArgs and optionally releases the managed resources.

Determines whether the specified object is equal to the current object.

(Inherited from Object) Finalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

Serves as the default hash function.

(Inherited from Object) GetType()

Gets the Type of the current instance.

(Inherited from Object) MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object) ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

Returns the handle to a Windows device context.

Releases the handle of a Windows device context.

Control. On Paint(PaintEventArgs) Метод

Определение

Вызывает событие Paint. Raises the Paint event.

Параметры

Объект PaintEventArgs, содержащий данные события. A PaintEventArgs that contains the event data.

Примеры

В следующем примере кода пользователь может перетащить изображение или файл изображения на форму и отобразить его в той точке, где он был удален. The following code example enables the user to drag an image or image file onto the form, and have it be displayed at the point on which it is dropped. OnPaintМетод переопределен для перерисовки изображения при каждой прорисовке формы; в противном случае изображение сохраняется только до следующего перерисовки. The OnPaint method is overridden to repaint the image each time the form is painted; otherwise the image would only persist until the next repainting. DragEnterМетод обработки событий определяет тип данных, которые перетаскиваются в форму, и предоставляет соответствующий отзыв. The DragEnter event-handling method determines the type of data being dragged into the form and provides the appropriate feedback. DragDropМетод обработки событий отображает изображение в форме, если Image может быть создан из данных. The DragDrop event-handling method displays the image on the form, if an Image can be created from the data. Так как DragEventArgs.X DragEventArgs.Y значения и являются экранными координатами, в примере используется PointToClient метод для преобразования их в клиентские координаты. Because the DragEventArgs.X and DragEventArgs.Y values are screen coordinates, the example uses the PointToClient method to convert them to client coordinates.

Читайте также:  How to fix windows update windows 10

Комментарии

При возникновении события через делегат вызывается обработчик события. Raising an event invokes the event handler through a delegate. Дополнительные сведения см. в разделе обработка и вызов событий. For more information, see Handling and Raising Events.

OnPaintМетод также позволяет производным классам выполнять обработку события без присоединения делегата. The OnPaint method also enables derived classes to handle the event without attaching a delegate. Это предпочтительная методика обработки событий в производном классе. This is the preferred technique for handling the event in a derived class.

Примечания для тех, кто наследует этот метод

При переопределении метода OnPaint(PaintEventArgs) в производном классе нужно убедиться, что вызывается метод OnPaint(PaintEventArgs) базового класса, чтобы зарегистрированные делегаты получили событие. When overriding OnPaint(PaintEventArgs) in a derived class, be sure to call the base class’s OnPaint(PaintEventArgs) method so that registered delegates receive the event.

Data Grid View. On Paint(PaintEventArgs) Метод

Определение

Вызывает событие Paint. Raises the Paint event.

Параметры

Объект PaintEventArgs, содержащий данные события. A PaintEventArgs that contains the event data.

Исключения

Во время выполнения этого метода игнорируются любые возникающие исключения, кроме каких-либо из следующих: Any exceptions that occur during this method are ignored unless they are one of the following:

Комментарии

При возникновении события через делегат вызывается обработчик события. Raising an event invokes the event handler through a delegate. Дополнительные сведения см. в разделе обработка и вызов событий. For more information, see Handling and Raising Events.

Метод OnPaint также позволяет производным классам обрабатывать событие, не присоединяя делегат. The OnPaint method also allows derived classes to handle the event without attaching a delegate. Это предпочтительная методика обработки событий в производном классе. This is the preferred technique for handling the event in a derived class.

Примечания для тех, кто наследует этот метод

При переопределении метода OnPaint(PaintEventArgs) в производном классе нужно убедиться, что вызывается метод OnPaint(PaintEventArgs) базового класса, чтобы зарегистрированные делегаты получили событие. When overriding OnPaint(PaintEventArgs) in a derived class, be sure to call the base class’s OnPaint(PaintEventArgs) method so that registered delegates receive the event.

Оцените статью