Class MainWindowクラスの全コード
Class MainWindow
Private Sub MenuItem2_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItem2.Click
Grid1.Children.Clear()
Dim myLine As New Line()
myLine.Stroke = Brushes.LightSteelBlue
myLine.X1 = 20
myLine.X2 = 150
myLine.Y1 = 30
myLine.Y2 = 250
myLine.HorizontalAlignment = HorizontalAlignment.Left
myLine.VerticalAlignment = VerticalAlignment.Top
myLine.StrokeThickness = 2
Grid1.Children.Add(myLine)
Dim myPath2 As New Path()
myPath2.Stroke = Brushes.DarkViolet
myPath2.StrokeThickness = 6
Dim myGeometry2 As New LineGeometry()
myGeometry2.StartPoint = New System.Windows.Point(30, 50)
myGeometry2.EndPoint = New System.Windows.Point(250, 250)
myPath2.Data = myGeometry2
Grid1.Children.Add(myPath2)
End Sub
Private Sub MenuItem3_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItem3.Click
Grid1.Children.Clear()
Dim myRectangle = New Rectangle()
Dim myThickness As New Thickness()
myThickness.Left = 120
myThickness.Top = 120
myThickness.Right = 0
myThickness.Bottom = 0
myRectangle.HorizontalAlignment = Windows.HorizontalAlignment.Left
myRectangle.VerticalAlignment = Windows.VerticalAlignment.Top
myRectangle.Margin = myThickness
myRectangle.Stroke = Brushes.SaddleBrown
myRectangle.Width = 100
myRectangle.Height = 60
myRectangle.Fill = Brushes.SeaGreen
Grid1.Children.Add(myRectangle)
Dim myPath3 As New Path()
myPath3.Stroke = Brushes.Red
myPath3.Fill = Brushes.RoyalBlue
myPath3.StrokeThickness = 4
Dim myGeometry3 As New RectangleGeometry()
myGeometry3.Rect = New System.Windows.Rect(150, 200, 70, 100)
myPath3.Data = myGeometry3
Grid1.Children.Add(myPath3)
End Sub
Private Sub MenuItem4_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItem4.Click
Grid1.Children.Clear()
Dim myEllipse = New Ellipse()
Dim myThickness2 As New Thickness()
myThickness2.Left = 20
myThickness2.Top = 120
myThickness2.Right = 0
myThickness2.Bottom = 0
myEllipse.HorizontalAlignment = Windows.HorizontalAlignment.Left
myEllipse.VerticalAlignment = Windows.VerticalAlignment.Top
myEllipse.Margin = myThickness2
myEllipse.Stroke = Brushes.Aquamarine
myEllipse.Width = 100
myEllipse.Height = 60
myEllipse.Fill = Brushes.Coral
Grid1.Children.Add(myEllipse)
Dim myPath4 As New Path()
myPath4.Stroke = Brushes.Black
myPath4.Fill = Brushes.MediumSlateBlue
myPath4.StrokeThickness = 2
Dim myGeometry4 As New EllipseGeometry()
myGeometry4.Center = New System.Windows.Point(250, 50)
myGeometry4.RadiusX = 25
myGeometry4.RadiusY = 25
myPath4.Data = myGeometry4
Grid1.Children.Add(myPath4)
End Sub
Private Sub MenuItem5_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItem5.Click
Grid1.Children.Clear()
Dim myImage = New Image()
Dim imageUri = New Uri("http://homepage3.nifty.com/skomo/f30/99-3-20b.jpg")
myImage.Source = New BitmapImage(imageUri)
myImage.Width = 200
myImage.Height = 200
myImage.HorizontalAlignment = Windows.HorizontalAlignment.Center
myImage.VerticalAlignment = Windows.VerticalAlignment.Center
Dim myEllipseGeometry = New EllipseGeometry()
myEllipseGeometry.Center = New Point(100, 100)
myEllipseGeometry.RadiusX = 90
myEllipseGeometry.RadiusY = 100
myImage.Clip = myEllipseGeometry
Grid1.Children.Add(myImage)
End Sub
Private Sub MenuItem6_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItem6.Click
Grid1.Children.Clear()
Dim myPath5 As New Path()
myPath5.Stroke = Brushes.Black
myPath5.Fill = Brushes.MediumSlateBlue
myPath5.StrokeThickness = 2
Dim myPathFigure As New PathFigure
myPathFigure.StartPoint = New Point(10, 30)
myPathFigure.Segments.Add(New BezierSegment(New Point(100, 0), New Point(200, 200), New Point(300, 100), True))
myPathFigure.Segments.Add(New LineSegment(New Point(400, 100), True))
myPathFigure.Segments.Add(New ArcSegment(New Point(200, 100), New Size(50, 50), 45, True, SweepDirection.Clockwise, True))
Dim myPathGeometry = New PathGeometry
myPathGeometry.Figures.Add(myPathFigure)
myPath5.Data = myPathGeometry
Grid1.Children.Add(myPath5)
End Sub
End Class