XAMLの全コード
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:self="clr-namespace:WpfMaze"
Title="MainWindow" Height="432" Width="507" AllowsTransparency="False" IsTabStop="False">
<Grid Name="Grid1">
<Grid.RowDefinitions>
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="48*" />
<RowDefinition Height="0*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
<RowDefinition Height="24*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<WindowsFormsHost x:Name="wfHost" >
<self:UserControl1 x:Name="myControl" />
</WindowsFormsHost>
<Label Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="2" Grid.RowSpan="19" Name="Label1" Background="Cyan"></Label>
<Label Grid.Column="3" Grid.ColumnSpan="18" Grid.Row="0" Grid.RowSpan="1" Name="Label2" Background="Cyan"></Label>
<Label Grid.Column="21" Grid.ColumnSpan="1" Grid.Row="1" Grid.RowSpan="20" Name="Label3" Background="Cyan"></Label>
<Label Grid.Column="1" Grid.ColumnSpan="18" Grid.Row="21" Grid.RowSpan="1" Name="Label4" Background="Cyan"></Label>
<Label Background="Cyan" Grid.ColumnSpan="17" Name="Label5" Grid.Column="1" Grid.Row="2" />
<Label Background="Cyan" Grid.RowSpan="14" Name="Label6" Grid.Column="2" Grid.Row="4" />
<Label Background="Cyan" Grid.ColumnSpan="17" Grid.RowSpan="2" Margin="0,0,0,23" Name="Label7" Grid.Column="2" Grid.Row="4" />
<Label Background="Cyan" Grid.RowSpan="13" Margin="0,0,0,1" Name="Label8" Grid.Column="4" Grid.Row="6" />
<Label Background="Cyan" Grid.ColumnSpan="13" Grid.RowSpan="2" Margin="0,0,0,23" Name="Label9" Grid.Column="6" Grid.Row="6" />
<Label Background="Cyan" Grid.RowSpan="10" Margin="0,1,0,24" Name="Label10" Grid.Column="6" Grid.Row="7" />
<Label Background="Cyan" Grid.RowSpan="9" Margin="0,0,0,1" Name="Label11" Grid.Column="8" Grid.Row="10" />
<Label Background="Cyan" Grid.ColumnSpan="11" Grid.RowSpan="2" Margin="0,0,0,23" Name="Label12" Grid.Column="8" Grid.Row="8" />
<Label Background="Cyan" Grid.RowSpan="9" Margin="0,0,0,1" Name="Label13" Grid.Column="13" Grid.Row="9" />
<Label Background="Cyan" Grid.ColumnSpan="3" Grid.RowSpan="2" Margin="0,0,0,23" Name="Label14" Grid.Column="10" Grid.Row="12" />
<Label Content="Finish " Grid.Column="17" Grid.ColumnSpan="2" Grid.Row="18" Grid.RowSpan="1" Name="finishLabel" />
</Grid>
</Window>
Class MainWindowクラスの全コード
Class MainWindow
Dim startSoundPlayer = New System.Media.SoundPlayer("C:\Windows\Media\chord.wav")
Dim finishSoundPlayer = New System.Media.SoundPlayer("C:\Windows\Media\tada.wav")
Public Sub New()
' この呼び出しはデザイナーで必要です。
InitializeComponent()
MoveToStart()
End Sub
Private Sub MoveToStart()
startSoundPlayer.Play()
Dim startingPoint = myControl.Panel1.Location
startingPoint.Offset(10, 10)
Forms.Cursor.Position = myControl.PointToScreen(startingPoint)
End Sub
Private Sub Label_MouseEnter(sender As System.Object, e As System.Windows.Input.MouseEventArgs) Handles Label4.MouseEnter, Label14.MouseEnter, Label13.MouseEnter, Label12.MouseEnter, Label11.MouseEnter, Label10.MouseEnter, Label9.MouseEnter, Label8.MouseEnter, Label7.MouseEnter, Label6.MouseEnter, Label5.MouseEnter, Label3.MouseEnter, Label1.MouseEnter, Label2.MouseEnter
MoveToStart()
End Sub
Private Sub finishLabel_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles finishLabel.MouseEnter
finishSoundPlayer.Play()
MessageBox.Show("Congratulations!")
Close()
End Sub
End Class