circleliner阅读笔记

Posted on 2005-12-31 17:41  岳洋  阅读(237)  评论(0)    收藏  举报

很久没有做过circleliner了,主要是不知道.net里面怎么画图。

Imports System.Windows.Forms
Imports System.Drawing

Public Class circle
    
Inherits UserControl


    
Public BackgroundColor As Color = Color.GreenYellow
    
Public InsideColor As Color = Color.Red
    
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

        
Dim graphics As Graphics = e.Graphics
        
Dim penWidth As Integer = 1
        
Dim pen As Pen = New Pen(Color.Black, penWidth)
        
Dim fontHeight As Integer = 10
        
Dim font As Font = New Font("Arial", fontHeight)

        
Dim brush1 As SolidBrush = New SolidBrush(BackgroundColor)
        
Dim brush2 As SolidBrush = New SolidBrush(InsideColor)
        graphics.FillEllipse(brush1, 
00, Width, Height)
        graphics.FillEllipse(brush2, 
CInt((Width - penWidth) / 4), CInt((Height - penWidth) / 4), CInt((Width - penWidth) / 2), CInt((Height - penWidth) / 2))
        
Dim textBrush As SolidBrush = New SolidBrush(Color.Black)

        graphics.DrawEllipse(pen, 
CInt(penWidth / 2), CInt(penWidth / 2), Width - penWidth, Height - penWidth)
        

        
'graphics.DrawString(Text, font, textBrush, penWidth, _Height / 2 - fontHeight)
    End Sub

End Class


http://aowind.cnblogs.com/archive/2005/03/11/116696.html
现在尝试新建控件,按照轻剑傲风的说法,继承usercontrol类,这里搞一个class circle.
system.windows.drawing.graphics.DrawEllipse

pen
Pen 对象,它确定椭圆的颜色、宽度和样式。
x
定义椭圆的边框的左上角的 x 坐标。
y
定义椭圆的边框的左上角的 y 坐标。
width
定义椭圆的边框的宽度。
height
定义椭圆的边框的高度。

 

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3