更改menustrip中的画笔大小以在Visual Basic中绘制不同的大小

时间:2016-10-16 04:25:41

标签: vb.net colors drawing menustrip

好的,我目前有一个可以在上面绘制的应用程序。我使用单选按钮来选择" Pen"的颜色和绘图尺寸。为绘图。我想摆脱这些单选按钮并在MDI表单上使用MenuStrip来影响MDI表单中新子表单上笔的颜色和大小。

目前,这是我可以绘制的包含单选按钮的表单。

Public Class Form1


Private shouldPaint As Boolean = False
Dim paintColor As Color

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.MdiParent = ParentMdiForm

    'Color Radio Buttons
    Me.redRadio.Tag = Color.Red
    Me.blueRadio.Tag = Color.Blue
    Me.greenRadio.Tag = Color.Green
    Me.blackRadio.Tag = Color.Black

    Me.blackRadio.Checked = True

    'Size Radio Buttons
    Me.smallRadio.Checked = True
End Sub

'Draw while mouse button is pressed
Private Sub Painter_MouseDown(sender As Object, e As MouseEventArgs) Handles MyBase.MouseDown
    shouldPaint = True
End Sub

'Stop drawing when mouse button is not pressed
Private Sub Painter_MouseUp(Sender As Object, e As MouseEventArgs) Handles MyBase.MouseUp
    shouldPaint = False
End Sub

'Change the size of the pen
Private Sub Painter_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
    If (shouldPaint) Then
        If smallRadio.Checked = True Then

            Using g As Graphics = CreateGraphics()
                g.FillEllipse(New SolidBrush(paintColor), e.X, e.Y, 4, 4)
            End Using
        ElseIf mediumRadio.Checked = True Then
            Using g As Graphics = CreateGraphics()
                g.FillEllipse(New SolidBrush(paintColor), e.X, e.Y, 8, 8)
            End Using
        ElseIf largeRadio.Checked = True Then
            Using g As Graphics = CreateGraphics()
                g.FillEllipse(New SolidBrush(paintColor), e.X, e.Y, 12, 12)
            End Using
        End If

    End If
End Sub

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles redRadio.CheckedChanged, blueRadio.CheckedChanged, greenRadio.CheckedChanged, blackRadio.CheckedChanged
    If CType(sender, RadioButton).Checked = True Then
        paintColor = CType(CType(sender, RadioButton).Tag, Color)
    End If
End Sub

Private Sub SizeRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smallRadio.CheckedChanged, mediumRadio.CheckedChanged, largeRadio.CheckedChanged
    If CType(sender, RadioButton).Checked = True Then

    End If
End Sub
End Class

我的问题是,如何使用menustrip选择图纸尺寸?我想出了如何用颜色来做,但我无法弄清楚它的大小。我只是不明白如何编写代码。

0 个答案:

没有答案