回 帖 发 新 帖 刷新版面

主题:急切求助:在编椭圆的用户控件时遇到了麻烦

以下是一个制作椭圆控件的全部程序,根据项目的需要,我在椭圆中心绘制了一圆点,现在我想但给这个圆点定义一visible属性,当其 pointctlvisible为 true 即圆点的可视性为真时,圆点可视,为假时,圆点不可视。我在程序中设置了pointctlvisible此属性,但实际的控件中却没有pointctlvisible属性( Public Shared Property pointctlvisible_set() As Boolean

        Get
            Return pointctlvisible
        End Get

        Set(ByVal Value As Boolean)
            pointctlvisible = Value
        End Set

是怎么回事?

以下是完整的程序代码:

Imports System.Drawing.Drawing2D

Public Class ellipsectl
    Inherits System.Windows.Forms.UserControl
    Private Shared pointctlvisible As Boolean
    Public Shared Property pointctlvisible_set() As Boolean

        Get
            Return pointctlvisible
        End Get

        Set(ByVal Value As Boolean)
            pointctlvisible = Value
        End Set

    End Property

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    'UserControl1 重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'ellipsectl
        '
        Me.Cursor = System.Windows.Forms.Cursors.No
        Me.Name = "ellipsectl"
        Me.Size = New System.Drawing.Size(163, 30)

    End Sub

#End Region
    '画椭圆
    Private startX As Integer
    Private startY As Integer


    Protected Sub ellipsectl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim pen As New System.Drawing.Pen(Me.ForeColor)

        e.Graphics.DrawEllipse(pen, startX, startY, startX + Me.Width - 1, startY + Me.Height - 1)
    End Sub
    '随时更新
    Private Sub ReDrawellipse()
        Me.Refresh()
    End Sub
    Private Sub ellipsectl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        ReDrawellipse()
    End Sub
    '在椭圆的中心画一圆点

    Protected Sub pointctl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        pointctlvisible = True
        Dim sb As System.Drawing.Brush
        Dim visible As Boolean

        sb = New SolidBrush(System.Drawing.Color.Red)

        If pointctlvisible = True Then
            e.Graphics.FillEllipse(sb, New Rectangle(startX + Me.Width / 2 - 4, startY + Me.Height / 2 - 4, 8, 8))
        End If

    End Sub
    '随时更新
    Private Sub ReDrawpoint()
        Me.Refresh()
    End Sub
    Private Sub pointctl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        ReDrawpoint()
    End Sub
End Class

回复列表 (共2个回复)

沙发

http://netron.sourceforge.net/wp
这个图形控件很不错的,完成了很多类似visio的功能,而且开源。

板凳

师妹先在这里谢谢您!但是安装后,找不到画箭头、椭圆的控件啊?能不能提供画箭头、椭圆的用户程序啊谢谢!

我来回复

您尚未登录,请登录后再回复。点此登录或注册