diff --git a/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs b/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs
index 9f2c305..2a83709 100644
--- a/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs
+++ b/stormchat-client-csharp/StormChatWPF/LogWindow.xaml.cs
@@ -1,36 +1,36 @@
-using Interact;
-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 StormChatWPF
-{
- ///
- /// MainWindow.xaml 的交互逻辑
- ///
- public partial class LogWindow : Window
- {
- public static LogWindow Instence;
- public LogWindow()
- {
- InitializeComponent();
+using Interact;
+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 StormChatWPF
+{
+ ///
+ /// MainWindow.xaml 的交互逻辑
+ ///
+ public partial class LogWindow : Window
+ {
+ public static LogWindow Instence;
+ public LogWindow()
+ {
+ InitializeComponent();
Instence = this;
- }
- private void Login_button_Click(object sender, RoutedEventArgs e)
- {
- Login_button.IsEnabled = false;
- Chat.Log(AccountBox.Text,passwordBox.Password);
- }
- }
-}
+ }
+ 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 72d33dc..f13788d 100644
--- a/stormchat-client-csharp/StormChatWPF/MainWindow.xaml
+++ b/stormchat-client-csharp/StormChatWPF/MainWindow.xaml
@@ -19,7 +19,8 @@
-
+
+
@@ -27,6 +28,6 @@
-
+
diff --git a/stormchat-client-csharp/StormChatWPF/MainWindow.xaml.cs b/stormchat-client-csharp/StormChatWPF/MainWindow.xaml.cs
index 976de23..4053648 100644
--- a/stormchat-client-csharp/StormChatWPF/MainWindow.xaml.cs
+++ b/stormchat-client-csharp/StormChatWPF/MainWindow.xaml.cs
@@ -1,83 +1,89 @@
-using Interact;
+using Interact;
using StormChatWPF.UI;
using System;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace StormChatWPF
-{
- ///
- /// UserWindow.xaml 的交互逻辑
- ///
- public partial class MainWindow : Window
- {
- public static MainWindow Instence;
- public MainWindow()
- {
- InitializeComponent();
- LoadContactsList();
- Instence = this;
- }
- private void LoadContactsList()
- {
- if (Chat.ContactsList.Any())
- {
- foreach (var user in Chat.ContactsList)
- {
- UsersList.Items.Add(user.NickName);
- }
- }
- }//向联系人列表listview中添加元素
-
- private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (UsersList.SelectedItem != null)
- {
- Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex];
- }
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- if (Chat.CurrentContact == null)
- {
- MessageBox.Show("请选择联系人!");
- return;
- }
- if (InputBox.Text!="")
- {
- Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact);
- InputBox.Text = "";
- }
- }
-
- internal void ShowMessage(Message message)
- {
- if (message.To == User.Me)
- {
- App.Current.Dispatcher.Invoke(
- (Action)delegate()
- {
- OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message,HorizontalAlignment.Left));
- });
- }//接受到的的消息
- else
- {
- App.Current.Dispatcher.Invoke(
- (Action)delegate()
- {
- OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Right));
- });
- }//发送的的消息
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace StormChatWPF
+{
+ ///
+ /// UserWindow.xaml 的交互逻辑
+ ///
+ public partial class MainWindow : Window
+ {
+ public static MainWindow Instence;
+ public MainWindow()
+ {
+ InitializeComponent();
+ LoadContactsList();
+ Instence = this;
+ }
+ private void LoadContactsList()
+ {
+ if (Chat.ContactsList.Any())
+ {
+ foreach (var user in Chat.ContactsList)
+ {
+ if (user.Name !=User.Me.Name)
+ {
+ UsersList.Items.Add(new UI.ContactsInfo(user)
+ {
+ HorizontalAlignment = HorizontalAlignment.Center
+ });
+ }
+ }
+ }
+ }//向联系人列表listview中添加元素
+
+ private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (UsersList.SelectedItem != null)
+ {
+ Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex];
+ }
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ if (Chat.CurrentContact == null)
+ {
+ MessageBox.Show("请选择联系人!");
+ return;
+ }
+ if (InputBox.Text != "")
+ {
+ Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact);
+ InputBox.Text = "";
+ }
+ }
+
+ internal void ShowMessage(Message message)
+ {
+ if (message.To == User.Me)
+ {
+ App.Current.Dispatcher.Invoke(
+ (Action)delegate ()
+ {
+ OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Left));
+ });
+ }//接受到的的消息
+ else
+ {
+ App.Current.Dispatcher.Invoke(
+ (Action)delegate ()
+ {
+ OutBox.Children.Add(new StormChatWPF.UI.ChatBubble(message, HorizontalAlignment.Right));
+ });
+ }//发送的的消息
}//将消息展现于UI界面
private void button_Click_1(object sender, RoutedEventArgs e)
{
- App.Current.Dispatcher.Invoke(
- (Action)delegate ()
+ App.Current.Dispatcher.Invoke(
+ (Action)delegate ()
{
});
}
- }
-}
+ }
+}
diff --git a/stormchat-client-csharp/StormChatWPF/StormChatWPF.csproj b/stormchat-client-csharp/StormChatWPF/StormChatWPF.csproj
index c954828..b8c6c14 100644
--- a/stormchat-client-csharp/StormChatWPF/StormChatWPF.csproj
+++ b/stormchat-client-csharp/StormChatWPF/StormChatWPF.csproj
@@ -69,7 +69,7 @@
Contacts.xaml
-
+
Window1.xaml
diff --git a/stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml b/stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml
index afa8829..9319f29 100644
--- a/stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml
+++ b/stormchat-client-csharp/StormChatWPF/UI/Contacts.xaml
@@ -5,13 +5,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StormChatWPF.UI"
mc:Ignorable="d"
- d:DesignHeight="40" d:DesignWidth="120">
-
-
+ d:DesignHeight="40" d:DesignWidth="120" HorizontalAlignment="Stretch">
+
+
-
+
-
+
diff --git a/stormchat-client-csharp/StormChatWPF/UI/UserInfo.cs b/stormchat-client-csharp/StormChatWPF/UI/ContactsInfo.cs
similarity index 80%
rename from stormchat-client-csharp/StormChatWPF/UI/UserInfo.cs
rename to stormchat-client-csharp/StormChatWPF/UI/ContactsInfo.cs
index 454015b..07fefd8 100644
--- a/stormchat-client-csharp/StormChatWPF/UI/UserInfo.cs
+++ b/stormchat-client-csharp/StormChatWPF/UI/ContactsInfo.cs
@@ -4,9 +4,9 @@ using System.IO;
namespace StormChatWPF.UI
{
- internal class UserInfo : Contacts
+ internal class ContactsInfo : Contacts
{
- public UserInfo(User user)
+ public ContactsInfo(User user)
{
image.BeginInit();
image.StreamSource = user.Photo;