From b918b132a767f97e8b53c9d5076d405679b263cd Mon Sep 17 00:00:00 2001
From: Kaniu Tayou <1056879522@qq.com>
Date: Mon, 17 Dec 2018 17:17:44 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=AE=A2=E6=88=B7=E7=AB=AF?=
=?UTF-8?q?=E6=96=B9=E6=B3=95=E6=A1=86=E6=9E=B6=E7=9A=84=E6=90=AD=E5=BB=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
StormChatWPF/App.xaml | 2 +-
StormChatWPF/Chat.cs | 69 +++++++++
StormChatWPF/LogWindow.xaml | 17 +++
StormChatWPF/LogWindow.xaml.cs | 40 ++++++
StormChatWPF/MainWindow.xaml | 18 ++-
StormChatWPF/MainWindow.xaml.cs | 47 ++-----
StormChatWPF/StormChatWPF.csproj | 235 ++++++++++++++++---------------
StormChatWPF/UserWindow.xaml | 14 --
StormChatWPF/UserWindow.xaml.cs | 27 ----
9 files changed, 269 insertions(+), 200 deletions(-)
create mode 100644 StormChatWPF/Chat.cs
create mode 100644 StormChatWPF/LogWindow.xaml
create mode 100644 StormChatWPF/LogWindow.xaml.cs
delete mode 100644 StormChatWPF/UserWindow.xaml
delete mode 100644 StormChatWPF/UserWindow.xaml.cs
diff --git a/StormChatWPF/App.xaml b/StormChatWPF/App.xaml
index 3292a54..1fc1979 100644
--- a/StormChatWPF/App.xaml
+++ b/StormChatWPF/App.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StormChatWPF"
- StartupUri="MainWindow.xaml">
+ StartupUri="LogWindow.xaml">
diff --git a/StormChatWPF/Chat.cs b/StormChatWPF/Chat.cs
new file mode 100644
index 0000000..6377be9
--- /dev/null
+++ b/StormChatWPF/Chat.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Interact;
+using System.Drawing;
+using System.Windows;
+
+namespace StormChatWPF
+{
+ class Chat
+ {
+ public static List userlist = new List();//联系人集合
+
+
+ internal static void GetUsers(ResultHandler head, User user)
+ {
+
+ }//获取联系人对象
+ internal static void GetUserList(ResultHead head, User[] users)
+ {
+ if (head.Error != "")
+ {
+ MessageBox.Show("无法获取联系人列表");
+ }
+ else
+ return;
+ }//获取用户列表
+ internal static void GetUserPhoto(ResultHead head, Image image)
+ {
+ if (head.Error != "")
+ {
+ MessageBox.Show("无法读取用户图片");
+ }
+ }//对用户头像进行赋值
+ internal void Log(string user,string password)
+ {
+ if (StormClient.Initialize())
+ {
+ StormClient.QueueLogin(user,password);
+ }
+ else
+ {
+ MessageBox.Show("连接服务器失败!");
+ }
+ }//登录
+ internal static void HaveLogin(ResultHead head, User user)
+ {
+ App.Current.Dispatcher.Invoke(
+ (Action)delegate ()
+ {
+ if (head.Error == "")
+ {
+ User.Me = user;
+ MainWindow userWindow = new MainWindow();
+ userWindow.Show();
+ LogWindow.a.Close();
+ }
+ else
+ {
+ MessageBox.Show("登录失败!");
+ }
+ });
+ }//登录完成
+
+
+ }
+}
diff --git a/StormChatWPF/LogWindow.xaml b/StormChatWPF/LogWindow.xaml
new file mode 100644
index 0000000..0e46e9f
--- /dev/null
+++ b/StormChatWPF/LogWindow.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/StormChatWPF/LogWindow.xaml.cs b/StormChatWPF/LogWindow.xaml.cs
new file mode 100644
index 0000000..2775cfa
--- /dev/null
+++ b/StormChatWPF/LogWindow.xaml.cs
@@ -0,0 +1,40 @@
+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 a;
+ public LogWindow()
+ {
+ InitializeComponent();
+ StormClient.OnLoginDone += Chat.HaveLogin;
+ StormClient.OnGetUserListDone += Chat.GetUserList;
+ StormClient.OnGetUserPhotoDone += Chat.GetUserPhoto;
+ a = this;
+ }
+ Chat chat = new Chat();
+ private void Login_button_Click(object sender, RoutedEventArgs e)
+ {
+ chat.Log(AccountBox.Text,passwordBox.Password);
+ }
+
+ }
+}
diff --git a/StormChatWPF/MainWindow.xaml b/StormChatWPF/MainWindow.xaml
index 7ac6f61..806cd35 100644
--- a/StormChatWPF/MainWindow.xaml
+++ b/StormChatWPF/MainWindow.xaml
@@ -5,13 +5,17 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StormChatWPF"
mc:Ignorable="d"
- Title="MainWindow" Height="450" Width="800">
-
-
-
-
-
-
+ Title="UserWindow" Height="450" Width="800"
+
+ >
+
+
+
+
+
+
+
+
diff --git a/StormChatWPF/MainWindow.xaml.cs b/StormChatWPF/MainWindow.xaml.cs
index ee20688..59f1481 100644
--- a/StormChatWPF/MainWindow.xaml.cs
+++ b/StormChatWPF/MainWindow.xaml.cs
@@ -1,5 +1,4 @@
-using Interact;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -11,50 +10,30 @@ 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 的交互逻辑
+ /// UserWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
- StormClient.OnLoginDone += HaveLogin;
}
+ private void AddUserList()
+ {
+ if (Chat.userlist.Any())
+ {
+ foreach (var user in Chat.userlist)
+ {
+ UsersList.Items.Add(user);
+ }
+ }
+ }//向联系人列表listview中添加元素
+
- private void Login_button_Click(object sender, RoutedEventArgs e)
- {
- if (StormClient.Initialize())
- {
- StormClient.QueueLogin(AccountBox.Text, passwordBox.Password, null);
- }
- else
- {
- MessageBox.Show("连接服务器失败!");
- }
- }
-
- private void HaveLogin(ResultHead head, User user)
- {
- App.Current.Dispatcher.Invoke((Action)delegate ()
- {
- if (head.Error == "")
- {
- User.Me = user;
- UserWindow userWindow = new UserWindow();
- userWindow.Show();
- this.Close();
- }
- else
- {
- MessageBox.Show("登录失败!");
- }
- });
- }
}
}
diff --git a/StormChatWPF/StormChatWPF.csproj b/StormChatWPF/StormChatWPF.csproj
index 41589ed..de5ebf1 100644
--- a/StormChatWPF/StormChatWPF.csproj
+++ b/StormChatWPF/StormChatWPF.csproj
@@ -1,118 +1,119 @@
-
-
-
-
- Debug
- AnyCPU
- {CF4D6BE0-A862-401F-A3A6-4FDAC32F5B70}
- WinExe
- StormChatWPF
- StormChatWPF
- v4.6.1
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- true
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- StormChatWPF.App
-
-
-
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- UserWindow.xaml
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- MainWindow.xaml
- Code
-
-
- Designer
- MSBuild:Compile
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
-
-
-
-
- {cef054af-95b7-4b88-934e-02705feea554}
- Interact
-
-
-
+
+
+
+
+ Debug
+ AnyCPU
+ {CF4D6BE0-A862-401F-A3A6-4FDAC32F5B70}
+ WinExe
+ StormChatWPF
+ StormChatWPF
+ v4.6.1
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ StormChatWPF.App
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ MainWindow.xaml
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ LogWindow.xaml
+ Code
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+ {cef054af-95b7-4b88-934e-02705feea554}
+ Interact
+
+
+
\ No newline at end of file
diff --git a/StormChatWPF/UserWindow.xaml b/StormChatWPF/UserWindow.xaml
deleted file mode 100644
index 4f0b28f..0000000
--- a/StormChatWPF/UserWindow.xaml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
diff --git a/StormChatWPF/UserWindow.xaml.cs b/StormChatWPF/UserWindow.xaml.cs
deleted file mode 100644
index 990aa17..0000000
--- a/StormChatWPF/UserWindow.xaml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-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.Shapes;
-
-namespace StormChatWPF
-{
- ///
- /// UserWindow.xaml 的交互逻辑
- ///
- public partial class UserWindow : Window
- {
- public UserWindow()
- {
- InitializeComponent();
- }
- }
-}