图4 下棋和聊天的界面(未开始对羿和聊天)
从图4所示的界面可以看出,该界面的左侧是棋盘,右侧可以进行聊天。Game.xaml文件设置了该界面中的控件,代码如下:
<Window x:Class="WpfMSNGame.Game"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Game" Height="684" Width="1076" ResizeMode="NoResize" Icon="images/logo.ico" Loaded="Window_Loaded" MouseDown="imgChessboard_MouseUp" Unloaded="Window_Unloaded" >
<Grid>
<!-- 显示棋盘的Image控件的配置代码 -->
<Image Margin="17,30,437,16" Name="imgChessboard" Stretch="Fill"
IsHitTestVisible="False" ClipToBounds="False" />
<!-- 用于输入聊天信息的文本框的配置代码 -->
<TextBox Height="23" HorizontalAlignment="Right" Margin="0,0,27,16" Name="txtMsg" VerticalAlignment="Bottom" Width="354" KeyUp="txtMsg_KeyUp" TextChanged="txtMsg_TextChanged" IsEnabled="True" />
<!-- 用于显示聊天记录的RichTextBox控件的配置代码 -->
<RichTextBox HorizontalAlignment="Right" Margin="0,279,27,59" Name="rtxtMsgList" Width="354" VerticalScrollBarVisibility="Auto" IsReadOnly="True" />
<!-- 用于控制棋子位置的Canvas控件的配置代码 -->
<Canvas Name="myCanvas" Margin="0,0,437,16"></Canvas>
<!-- 其他控件的配置代码 -->
<Image Margin="899,156,0,0" Name="imgBlack" Stretch="Fill" Height="31" Visibility="Hidden" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Image Height="31" HorizontalAlignment="Right" Margin="0,156,84,0" Name="imgWhite" Stretch="Fill" VerticalAlignment="Top" Visibility="Hidden" Width="31" ClipToBounds="True" />
<Label Height="35" HorizontalAlignment="Right" Foreground="Blue"
Margin="0,172,196,0" Name="lblStatus" VerticalAlignment="Top" Width="185"
FontWeight="Normal" SnapsToDevicePixels="True" FontSize="20"></Label>
<Image Height="120" HorizontalAlignment="Right" Margin="0,30,115,0"
Name="image1" Source="images/wpf_logo.jpg" Stretch="Fill" VerticalAlignment="Top" Width="152" />
|