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 @@ - - - - - - - - - - - - - - - -