Рисование заполненного прямоугольника в форме
В этом примере показано, как в форме нарисовать заполненный прямоугольник.
Пример[25]
System.Drawing.SolidBrush brush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.FillRectangle(brush1, new System.Drawing.Rectangle(0,0,200,300)); brush1.Dispose(); formGraphics.Dispose(); |
Компиляция кода
Для этого примера необходимы следующие компоненты.
· Проект приложения Windows Forms с формой, имеющей имя formGraphics.
Код должен находиться в области действия класса Form. Экземпляр формы представлен this.
Надежное программирование
Для любого объекта, потребляющего системные ресурсы (например, для объектов Brush и Graphics), всегда нужно вызывать метод Dispose.
How to: Draw a Filled Ellipse on a Form
This example demonstrates how to draw a filled ellipse on a form.
Example
System.Drawing.SolidBrush brush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.FillEllipse(brush1, new System.Drawing.Rectangle(0,0,200,300)); brush1.Dispose(); formGraphics.Dispose(); |
Compiling the Code
This example requires:
· A Windows Forms Application project with a form named formGraphics.
The code must be in the scope of the form class. The instance of the form is represented by this.
Robust Programming
You should always call Dispose on any objects that consume system resources, such as Brush and Graphics objects.
Рисование заполненного эллипса в форме
В этом примере показано, как в форме нарисовать заполненный эллипс.
Пример[26]
System.Drawing.SolidBrush brush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.FillEllipse(brush1, new System.Drawing.Rectangle(0,0,200,300)); brush1.Dispose(); formGraphics.Dispose(); |
Компиляция кода
Для этого примера необходимы следующие компоненты.
· Проект приложения Windows Forms с формой, имеющей имя formGraphics.
Код должен находиться в области действия класса form. Экземпляр формы представлен this.
Надежное программирование
Для любого объекта, потребляющего системные ресурсы (например, для объектов Brush и Graphics), всегда нужно вызывать метод Dispose.
Adding Multimedia to an Application
You can enhance applications by adding multimedia components such as audio, video, and graphic files. This section provides links to topics that describe common programming tasks for adding multimedia to an application.
Дата добавления: 2022-05-27; просмотров: 121;