From 96c128b2957403761d1d0dc4e17f8b0f636331d6 Mon Sep 17 00:00:00 2001 From: Kaniu Tayou <1056879522@qq.com> Date: Tue, 25 Dec 2018 22:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stormchat-client-csharp/StormChatWPF/Chat.cs | 21 +++++- .../StormChatWPF/LogWindow.xaml.cs | 3 +- .../StormChatWPF/MainWindow.xaml | 62 +++++++++--------- .../StormChatWPF/MainWindow.xaml.cs | 8 +-- .../StormChatWPF/StormChatWPF.csproj | 11 +++- .../StormChatWPF/UI/ChatBubble.cs | 2 +- .../StormChatWPF/UI/Contacts.xaml | 17 +++++ .../StormChatWPF/UI/Contacts.xaml.cs | 27 ++++++++ .../StormChatWPF/UI/HeadPicture.cs | 32 --------- .../StormChatWPF/UI/Resources/默认头像.png | Bin 0 -> 138640 bytes .../StormChatWPF/UI/UserInfo.cs | 34 ++++------ .../StormChatWPF/Window1.xaml | 12 ++-- .../StormChatWPF/Window1.xaml.cs | 10 +++ 13 files changed, 137 insertions(+), 102 deletions(-) create mode 100644 stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml create mode 100644 stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml.cs delete mode 100644 stormchat-client-csharp/StormChatWPF/UI/HeadPicture.cs create mode 100644 stormchat-client-csharp/StormChatWPF/UI/Resources/默认头像.png diff --git a/stormchat-client-csharp/StormChatWPF/Chat.cs b/stormchat-client-csharp/StormChatWPF/Chat.cs index 743bdd4..7c36c87 100644 --- a/stormchat-client-csharp/StormChatWPF/Chat.cs +++ b/stormchat-client-csharp/StormChatWPF/Chat.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Interact; using System.Drawing; using System.Windows; +using System.IO; namespace StormChatWPF { @@ -17,7 +18,8 @@ namespace StormChatWPF { StormClient.OnLoginDone += OnHaveLogin; StormClient.OnGetUserListDone += OnGetContactsList; - StormClient.OnMessage +=OnMessage; + StormClient.OnMessage +=OnMessage;//事件挂接 + User.DefaultPhoto = new MemoryStream(File.ReadAllBytes(@"../../UI/Resources/默认头像.png")); } internal static User CurrentContact { get; set; }//设置当前联系人对象 /// @@ -38,7 +40,7 @@ namespace StormChatWPF mainWindow.Show(); LogWindow.Instence.Close(); }); - } + }//获取联系人列表完成 private void OnHaveLogin(ResultHead head, User user) { if (head.Error == "") @@ -48,6 +50,11 @@ namespace StormChatWPF } else { + App.Current.Dispatcher.Invoke( + (Action)delegate () + { + LogWindow.Instence.Login_button.IsEnabled = true; + }); MessageBox.Show("请核对账号密码!"); } }//登录完成 @@ -74,11 +81,21 @@ namespace StormChatWPF { if (!StormClient.QueueLogin(user, password)) { + App.Current.Dispatcher.Invoke( + (Action)delegate () + { + LogWindow.Instence.Login_button.IsEnabled = true; + }); MessageBox.Show("登录失败"); } } else { + App.Current.Dispatcher.Invoke( + (Action)delegate () + { + LogWindow.Instence.Login_button.IsEnabled = true; + }); MessageBox.Show("连接服务器失败!"); } }//登录 diff --git a/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs b/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs index 63c1f06..9f2c305 100644 --- a/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs +++ b/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs @@ -29,9 +29,8 @@ namespace StormChatWPF } private void Login_button_Click(object sender, RoutedEventArgs e) { + Login_button.IsEnabled = false; Chat.Log(AccountBox.Text,passwordBox.Password); } - - } } diff --git a/stormchat-client-csharp/StormChatWPF/MainWindow.xaml b/stormchat-client-csharp/StormChatWPF/MainWindow.xaml index dffa90a..72d33dc 100644 --- a/stormchat-client-csharp/StormChatWPF/MainWindow.xaml +++ b/stormchat-client-csharp/StormChatWPF/MainWindow.xaml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - -