发布时间:2022-10-03 23:00
1、配置文件L:App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IService1">
<security>
<transport sslProtocols="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:51888/Service1/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
name="NetTcpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
2、启动界面:MainWindow.xaml
<Window x:Class="GuessClient.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GuessClient"
mc:Ignorable="d"
Title="主界面" Height="300" Width="400">
<Grid>
<Button Name="button1" Content="同时启动两个客户端(测试用)" HorizontalAlignment="Left" Margin="91,80,0,159" Width="196" Click="button1_Click"/>
<Button Name="button2" Content="只启动一个客户端(实际情况)" HorizontalAlignment="Left" Width="196" Margin="91,150,0,89" Click="button2_Click"/>
</Grid>
</Window>
3、MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GuessClient
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void StartWindow(string username, int left, int top)
{
GuessWindow w = new GuessWindow();
w.Left = left;
w.Top = top;
w.UserName = username;
w.Owner = this;
w.Show();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
StartWindow("西西", 100, 100);
StartWindow("瓜瓜", 500, 200);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
GuessWindow w = new GuessWindow();
w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
w.Owner = this;
w.Show();
}
}
}
4、程序主页面窗体:GuessWindow.xaml
<Window x:Class="GuessClient.GuessWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GuessClient"
mc:Ignorable="d"
Title="群聊客户端" Height="400" Width="600">
<Window.Resources>
<Style x:Key="Change_color" TargetType="Button">
<EventSetter Event="Click" Handler="Brush_Color_change"/>
</Style>
</Window.Resources>
<Grid>
<Grid.Background>
<SolidColorBrush Color="#FF0A5EFB" Opacity="0.7"/>
</Grid.Background>
<Viewbox Name="loginwindow" Visibility="Visible">
<Grid Height="241" Width="384">
<Grid.Background>
<ImageBrush ImageSource="images/login.png"/>
</Grid.Background>
<Border Background="#FFFFFEFE" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="1" BorderBrush="Black" CornerRadius="20">
<StackPanel>
<DockPanel Width="200" Height="50">
<Label Content="昵称:" Margin="20,5,0,0" Height="30" Width="50" Foreground="#FF797979" />
<Border Height="35" Width="120" BorderThickness="2" BorderBrush="#FF797979" CornerRadius="10" >
<TextBox Height="26" Width="110" Name="username" VerticalContentAlignment="Center" TextWrapping="Wrap" FontSize="18" Foreground="#FF797979" BorderThickness="0"/>
</Border>
</DockPanel>
<DockPanel>
<Border Width="80" Height="30" BorderBrush="Black" BorderThickness="2" CornerRadius="15">
<Button Width="60" Height="20" Name="login" Content="开始游戏" Click="login_Click" FontSize="12" Foreground="#001b4d" Background="White" FontWeight="Bold" BorderThickness="0"/>
</Border>
</DockPanel>
</StackPanel>
</Border>
</Grid>
</Viewbox>
<!--游戏大厅-->
<Viewbox Name="lobby" Visibility="Hidden">
<Grid Height="556" Width="893">
<Grid.Background>
<ImageBrush ImageSource="images/gamebackground.jpg"/>
</Grid.Background>
<Label Content="对话信息" FontSize="22" HorizontalContentAlignment="Center" Margin="593,139,20,373" FontWeight="Bold"/>
<ListBox BorderThickness="2" BorderBrush="Black" Name="messagelist" Background="Transparent" Margin="593,183,20,43" FontSize="18" RenderTransformOrigin="0.5,0.5"/>
<Border BorderBrush="Black" BorderThickness="2" HorizontalAlignment="Left" Height="43" VerticalAlignment="Top" Width="225" Margin="593,513,0,0">
<TextBox Name="message" Background="Transparent" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontSize="16" KeyDown="message_KeyDown" Height="42" Margin="0.2,0.2,0,-0.6"/>
</Border>
<Button BorderBrush="Black" BorderThickness="2" Name="send_button" Background="Transparent" Content="发送" HorizontalAlignment="Left" Margin="818,513,0,0" Width="55" FontSize="16" Click="send_button_Click"/>
<Label Content="欢迎来到你画我猜" FontSize="30" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="882" Height="134" Margin="5,0,6,0" VerticalContentAlignment="Center">
<Label.Background>
<ImageBrush ImageSource="images/title.png"/>
</Label.Background>
</Label>
<Canvas HorizontalAlignment="Left" Height="160" Margin="52,183,0,0" VerticalAlignment="Top" Width="160">
<Label Content="1号房间" Height="30" Canvas.Top="100" Canvas.Left="10" Width="70" FontSize="16"/>
<Label Name="room1_user_count" Content="房间人数:0" Height="30" Canvas.Top="100" Width="90" Canvas.Left="80" FontSize="14"/>
<Image x:Name="room1" Source="images/room1.png" MouseDown="room_MouseDown" Height="100" Canvas.Left="39" Width="100"/>
</Canvas>
<Canvas HorizontalAlignment="Left" Height="160" Margin="337,183,0,0" VerticalAlignment="Top" Width="160">
<Label Content="2号房间" Height="30" Canvas.Top="100" Canvas.Left="10" Width="70" FontSize="16"/>
<Label Name="room2_user_count" Content="房间人数:0" Height="30" Canvas.Top="100" Width="90" Canvas.Left="80" FontSize="14"/>
<Image x:Name="room2" Source="images/room2.png" MouseDown="room_MouseDown" Height="100" Canvas.Left="31" Width="100" Canvas.Top="-5"/>
</Canvas>
<Canvas HorizontalAlignment="Left" Height="160" Margin="56,329,0,0" VerticalAlignment="Top" Width="160">
<Label Content="3号房间" Height="30" Canvas.Top="100" Canvas.Left="10" Width="70" FontSize="16"/>
<Label Name="room3_user_count" Content="房间人数:0" Height="30" Canvas.Top="100" Width="90" Canvas.Left="80" FontSize="14"/>
<Image x:Name="room3" Source="images/room3.png" MouseDown="room_MouseDown" Height="100" Canvas.Left="31" Width="100" Canvas.Top="-5"/>
</Canvas>
<Canvas HorizontalAlignment="Left" Height="160" Margin="337,329,0,0" VerticalAlignment="Top" Width="160">
<Label Content="4号房间" Height="30" Canvas.Top="100" Canvas.Left="10" Width="70" FontSize="16"/>
<Label Name="room4_user_count" Content="房间人数:0" Height="30" Canvas.Top="100" Width="90" Canvas.Left="80" FontSize="14"/>
<Image x:Name="room4" Source="images/room4.png" MouseDown="room_MouseDown" Height="100" Canvas.Left="31" Width="100" Canvas.Top="-5"/>
</Canvas>
</Grid>
</Viewbox>
<!--游戏房间-->
<Viewbox Name="gameroom" Visibility="Hidden">
<Grid Width="800" Height="480" >
<Grid.Background>
<ImageBrush ImageSource="images/login.png"/>
</Grid.Background>
<DockPanel>
<!-- 玩家列表 -->
<Border Margin="10,0,0,0" Height="480" Width="100" BorderBrush="White" VerticalAlignment="Top" BorderThickness="2" CornerRadius="20" Background="White">
<StackPanel >
<Label Content="玩家列表" Background="White" Margin="0,10,0,0" HorizontalContentAlignment="Center" Width="80"/>
<ListBox BorderThickness="0" Name="userlist" Background="White" FontSize="20" HorizontalAlignment="Center" Height="410" VerticalAlignment="Top" Width="80"/>
</StackPanel>
</Border>
<!--画布+聊天-->
<StackPanel>
<DockPanel >
<Border Margin="15,0,0,0" Width="280" Height="30" Background="White" BorderBrush="White" BorderThickness="2" CornerRadius="5">
<DockPanel>
<Label Margin="0,0,0,0" Name="timu_label" Content="题目:" Width="44" Height="27" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Margin="0,5,0,0" Name="timu" TextAlignment="Center" Text="电脑" Height="25" Width="60" FontWeight="Bold" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Button Name="refersh_timu" Content="刷新" Width="60" Height="27" HorizontalAlignment="Center" VerticalAlignment="Center" Click="refersh_timu_Click" Margin="15,0,0,0" />
<Button Name="Roomout" Content="退出" Width="60" Height="27" Click="Roomout_Click">
</Button>
</DockPanel>
</Border>
<Border Margin="10,0,0,0" Width="270" Height="30" Background="White" BorderBrush="White" BorderThickness="2" CornerRadius="5">
<DockPanel Name="tool_Color">
<Label Width="75" Height="30" Content="画笔颜色" VerticalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Bold"/>
<Button Style="{StaticResource Change_color}" Width="30" Background="Red"/>
<Button Style="{StaticResource Change_color}" Margin="10,0,0,0" Width="30" Background="Black"/>
<Button Style="{StaticResource Change_color}" Margin="10,0,0,0" Width="30" Background="Blue"/>
<Button Style="{StaticResource Change_color}" Margin="10,0,0,0" Width="30" Background="Green"/>
<Button Style="{StaticResource Change_color}" Margin="10,0,0,0" Width="30" Background="Yellow"/>
</DockPanel>
</Border>
<Border Width="100" Height="30" Background="White" BorderBrush="White" BorderThickness="2" CornerRadius="5">
<DockPanel Name="tool_Clear">
<Label Width="40" Height="30" Content="擦除" VerticalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Bold"/>
<Button Name="clearButton" BorderThickness="0" Width="40" Click="clearButton_Click" >
<Button.Background>
<ImageBrush ImageSource="/images/drop.png" Stretch="UniformToFill"/>
</Button.Background>
</Button>
</DockPanel>
</Border>
</DockPanel>
<!--画布-->
<Border BorderBrush="White" BorderThickness="2" Height="250" Width="680" Background="White" CornerRadius="20">
<InkCanvas Name="myink" Background="Transparent" MouseUp="InkCanvas_MouseUp"/>
</Border>
<DockPanel Margin="25,20,0,0">
<!--回答-->
<Border Background="White" BorderBrush="White" BorderThickness="2" Height="180" Width="300" CornerRadius="10">
<StackPanel>
<Border Height="30" Width="120" Background="#0a5efb" BorderBrush="#0a5efb" BorderThickness="2" CornerRadius="10" Margin="150,-20,0,0">
<Label Content="回答" Background="#0a5efb" HorizontalContentAlignment="Center" Width="108" Height="26" Foreground="#FFF4EFEF" FontSize="14" FontWeight="Bold" />
</Border>
<ListBox Name="guess_message_list" BorderThickness="0" FontSize="12" Background="Transparent" Height="140" Width="280" VerticalAlignment="Top" />
<DockPanel>
<Border Width="190" Height="20" BorderBrush="#a9c8d3" BorderThickness="2" CornerRadius="5" Margin="20,0,-20,0">
<TextBox Name="guess_message" BorderThickness="0" FontSize="12" Width="180" Height="20" KeyDown="guess_message_KeyDown"/>
</Border>
<Border Width="30" Height="20" CornerRadius="5" BorderThickness="2" BorderBrush="#a9c8d3">
<Button Name="guess_messagesend" Content="发送" Background="Transparent" BorderThickness="0" FontSize="12" Width="25" Height="20" Click="guess_messagesend_Click" HorizontalAlignment="Left" Margin="0.4,-0.6,0,-2.6"/>
</Border>
</DockPanel>
</StackPanel>
</Border>
<!--聊天-->
<Border Background="White" BorderBrush="White" BorderThickness="2" Height="180" Width="300" CornerRadius="10">
<StackPanel>
<Border Height="30" Width="120" Background="#0a5efb" BorderBrush="#0a5efb" BorderThickness="2" CornerRadius="10" Margin="150,-20,0,0">
<Label Content="聊天" Background="#0a5efb" HorizontalContentAlignment="Center" Width="108" Height="26" Foreground="#FFF4EFEF" FontSize="14" FontWeight="Bold" />
</Border>
<ListBox Name="game_message" BorderThickness="0" FontSize="12" Background="Transparent" Height="140" Width="280" VerticalAlignment="Top" />
<DockPanel>
<Border Width="190" Height="20" BorderBrush="#a9c8d3" BorderThickness="2" CornerRadius="5" Margin="20,0,-20,0">
<TextBox Name="room_message" BorderThickness="0" FontSize="12" Width="180" Height="20" KeyDown="room_message_KeyDown"/>
</Border>
<Border Width="30" Height="20" CornerRadius="5" BorderThickness="2" BorderBrush="#a9c8d3">
<Button Name="room_messagesend" BorderThickness="0" Content="发送" Background="Transparent" FontSize="10" Width="25" Height="20" Click="room_messagesend_Click" HorizontalAlignment="Left" Margin="0.4,-0.6,0,-2.6"/>
</Border>
</DockPanel>
</StackPanel>
</Border>
</DockPanel>
</StackPanel>
</DockPanel>
</Grid>
</Viewbox>
</Grid>
</Window>
5、GuessWindow.xaml.cs
using GuessClient.ServiceReference1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GuessClient
{
///
/// GuessWindow.xaml 的交互逻辑
///
public partial class GuessWindow : Window, IService1Callback
{
public GuessWindow()
{
InitializeComponent();
this.Closing += GuessWindow_Closing;
}
private void GuessWindow_Closing(object sender, CancelEventArgs e) //退出系统
{
if (client != null)
{
client.Logout(UserName);
client = null;
//client.Close();
}
}
private Service1Client client; //连接服务器
public string UserName //该用户的用户名
{
get { return this.username.Text; } //获取用户名框的内容
set { this.username.Text = value; }
}
private void login_Click(object sender, RoutedEventArgs e) //登录按钮事件
{
InstanceContext context = new InstanceContext(this);
client = new Service1Client(context);
try
{
if (this.username.Text != "")
{
client.Login(this.username.Text);
}
else
{
MessageBox.Show("用户名不能为空!");
}
}
catch (Exception ex)
{
MessageBox.Show("与服务器连接失败:" + ex.Message);
return;
}
}
private void AddMessage(string str) //在大厅发言,消息加入消息列表
{
TextBlock t = new TextBlock();
t.Text = str;
t.FontSize = 15;
this.messagelist.Items.Add(t);
}
public void InitRoomUsersInfo(string RoomUsersInfo, string ink, bool hua_or_cai, string timu) //初始化新进房间用户的界面
{
this.game_message.Items.Clear();
if (RoomUsersInfo.Length == 0) //等于0说明是第一个进入房间的,担当画画角色
{
this.guess_message.IsEnabled = false;
this.guess_messagesend.IsEnabled = false;
this.timu.Text = timu;
return;
}
this.guess_message.IsEnabled = true;
this.guess_messagesend.IsEnabled = true;
this.tool_Color.IsEnabled = false;
this.tool_Clear.IsEnabled = false;
//不等于0,不是第一个进入房间的,猜
//初始化玩家列表
string[] users = RoomUsersInfo.Split('、');
this.userlist.Items.Clear();
for (int i = 0; i < users.Length; i++)
{
this.userlist.Items.Add(users[i]);
}
this.myink.IsEnabled = false;
//初始化画板笔迹
if (ink != null)
Showink(ink);
//初始化按钮和题目信息
if (hua_or_cai == false)
{
this.timu_label.Content = "提示:";
int len = timu.Length;
string str = "";
for (int i = 0; i < len; i++)
{
str += "?";
}
str += "\0";
this.timu.Text = str;
this.refersh_timu.IsEnabled = false;
}
}
private void send_button_Click(object sender, RoutedEventArgs e) //大厅发送消息事件
{
client.Talk(UserName, this.message.Text);
message.Text = "";
}
private void message_KeyDown(object sender, KeyEventArgs e) //大厅按回车发送消息事件
{
if (e.Key == Key.Enter)
{
client.Talk(UserName, this.message.Text);
message.Text = "";
}
}
public void ShowLogin(string loginUserName, int[] roomcount) //显示新用户登录游戏,进入大厅
{
if (loginUserName == UserName) //如果是这个正在登录的用户,初始化界面
{
MessageBox.Show("登录成功!正在进入大厅……");
for (int i = 0; i < 4; i++)
{
string str = "room" + (i + 1) + "_user_count";
Showlabel(str, roomcount[i]);
}
this.loginwindow.Visibility = Visibility.Hidden;
this.lobby.Visibility = System.Windows.Visibility.Visible;
}
AddMessage(loginUserName + "进入大厅。");
}
public void ShowLogout(string userName) //显示用户退出游戏
{
AddMessage(userName + "退出游戏。");
}
public void ShowTalk(string userName, string message) //在大厅发消息显示消息内容
{
AddMessage(userName + ": " + message);
}
public void ShowInRoom(string userName) //显示用户进入房间
{
//如果是正在进入房间的用户,进行初始化
if (this.UserName == userName)
{
MessageBox.Show("正在进入房间……");
this.lobby.Visibility = Visibility.Hidden;
this.gameroom.Visibility = System.Windows.Visibility.Visible;
}
//在房间玩家列表显示新进来的玩家
this.userlist.Items.Add(userName);
//在房间消息列表中显示新玩家进入
this.game_message.Items.Add(userName + "进入房间。");
}
public void ShowOutRoom(string userName) //显示用户退出房间
{
//清空正在退出的玩家的画板墨迹
if (this.UserName == userName)
this.myink.Strokes.Clear();
this.game_message.Items.Add(userName + "退出房间。");
this.userlist.Items.Remove(userName);
}
public void Showlabel(string labelname, int roomusercount) //大厅界面显示四个房间的人数
{
if (labelname == "room1_user_count")
this.room1_user_count.Content = "房间人数:" + roomusercount;
else if (labelname == "room2_user_count")
this.room2_user_count.Content = "房间人数:" + roomusercount;
else if (labelname == "room3_user_count")
this.room3_user_count.Content = "房间人数:" + roomusercount;
else if (labelname == "room4_user_count")
this.room4_user_count.Content = "房间人数:" + roomusercount;
}
public void Show_Room_Talk(string userName, string message) //显示在房间里聊天的消息
{
this.game_message.Items.Add(userName + ":" + message);
}
public void Show_Room_Talk_error(string message)
{
this.game_message.Items.Add(message);
}
public void Show_Guess_Talk(string userName, string message, string daan) //显示猜测聊天框中的聊天消息
{
this.guess_message_list.Items.Add(userName + ":" + message);
//判断猜测的答案是否正确
if (userName == this.UserName)
{
if (message != daan)
MessageBox.Show("猜测答案错误!");
else
{
client.Gusee_win(userName);
}
}
}
public void Showink(string ink) //显示墨迹信息
{
//清除画板原来的墨迹
this.myink.Strokes.Clear();
//字符串类型墨迹画迹转化为墨迹数据
StrokeCollection strokes =(StrokeCollection)(new StrokeCollectionConverter()).ConvertFrom(ink);
//将传送来的墨迹添加到画板中
myink.Strokes = strokes;
}
public void Show_Guess_win(string username) //显示用户猜中
{
if (this.UserName == username)
MessageBox.Show("你猜中了!");
else
MessageBox.Show(username + "猜中了!");
myink.Strokes.Clear();
}
private void room_MouseDown(object sender, MouseButtonEventArgs e) //鼠标点击房间按钮事件
{
try
{
//获得进入的房间名
Image image = e.Source as Image;
client.InRoom(UserName, image.Name);
}
catch (Exception ex)
{
MessageBox.Show("进入房间失败:" + ex.Message);
}
}
private void room_messagesend_Click(object sender, RoutedEventArgs e) //房间聊天框发送按钮事件
{
client.Room_Talk(UserName, this.room_message.Text);
room_message.Text = "";
}
private void room_message_KeyDown(object sender, KeyEventArgs e) //房间聊天框回车发送事件
{
if (e.Key == Key.Enter)
{
client.Room_Talk(UserName, this.room_message.Text);
room_message.Text = "";
}
}
private void InkCanvas_MouseUp(object sender, MouseButtonEventArgs e) //画板笔迹事件,鼠标落下后起来传送笔迹信息
{
//墨迹打包为字符串发送到服务端
StrokeCollection strokes = this.myink.Strokes;
string ink_str = (new StrokeCollectionConverter()).ConvertToString(strokes);
client.sendink(UserName, ink_str);
}
private void guess_messagesend_Click(object sender, RoutedEventArgs e) //房间内猜测聊天框发送按钮事件
{
client.Guess_talk(UserName, this.guess_message.Text);
guess_message.Text = "";
}
private void guess_message_KeyDown(object sender, KeyEventArgs e) //房间内猜测聊天框回车发送事件
{
if (e.Key == Key.Enter)
{
client.Guess_talk(UserName, this.guess_message.Text);
guess_message.Text = "";
}
}
public void refersh_timu_Click(object sender, RoutedEventArgs e)
{
client.Refersh_Timu(UserName);
} //刷新题目按钮事件
public void Show_Refersh_Timu(string username, string Timu)
{
if (this.UserName == username)
{
this.timu.Text = Timu;
this.timu_label.Content = "题目";
}
else
{
int len = Timu.Length;
string str = "";
for (int i = 0; i < len; i++)
{
str += "?";
}
str += "\0";
this.timu.Text = str;
this.timu_label.Content = "提示";
}
} //展示刷新题目的结果
public void Show_Cannot_login()
{
MessageBox.Show("用户已存在!请重新登录!");
} //提示用户不能登录
public void InitNewchutiren(string timu)
{
MessageBox.Show("你成为画题人");
this.timu_label.Content = "题目";
this.timu.Text = timu;
this.myink.IsEnabled = true;
tool_Color.IsEnabled = true;
tool_Clear.IsEnabled = true;
this.guess_message.IsEnabled = false;
this.guess_messagesend.IsEnabled = false;
this.refersh_timu.IsEnabled = true;
} //初始化新的出题人界面
private void Roomout_Click(object sender, RoutedEventArgs e)
{
client.RoomOut(UserName);
this.gameroom.Visibility = Visibility.Hidden;
this.lobby.Visibility = Visibility.Visible;
} //退出房间按钮事件
private void Brush_Color_change(object sender, RoutedEventArgs e)
{
DrawingAttributes drawingAttributes = new DrawingAttributes();
drawingAttributes.Color = (Color)ColorConverter.ConvertFromString((e.Source as Button).Background.ToString());
myink.DefaultDrawingAttributes = drawingAttributes;
myink.EditingMode = InkCanvasEditingMode.Ink;
} //画刷颜色改变事件
private void clearButton_Click(object sender, RoutedEventArgs e)
{
myink.EditingMode = InkCanvasEditingMode.EraseByPoint;
} //擦除墨迹按钮事件
public void change_hua_or_cai(bool hua, string username)
{
myink.IsEnabled = hua;
tool_Color.IsEnabled = hua;
tool_Clear.IsEnabled = hua;
guess_message.IsEnabled = !hua;
guess_messagesend.IsEnabled = !hua;
this.refersh_timu.IsEnabled = hua;
client.Refersh_Timu(username);
} //改变画题人和猜题人
}
}