merge到master

This commit is contained in:
2018-12-23 15:09:24 +08:00
parent c3d163dfa8
commit bac637213b
35 changed files with 322 additions and 322 deletions
@@ -1,87 +1,87 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Interact; using Interact;
using System.Drawing; using System.Drawing;
using System.Windows; using System.Windows;
namespace StormChatWPF namespace StormChatWPF
{ {
class Chat class Chat
{ {
public static List<User> ContactsList;//联系人集合 public static List<User> ContactsList;//联系人集合
public static Chat chat=new Chat(); public static Chat chat=new Chat();
private Chat() private Chat()
{ {
StormClient.OnLoginDone += OnHaveLogin; StormClient.OnLoginDone += OnHaveLogin;
StormClient.OnGetUserListDone += OnGetContactsList; StormClient.OnGetUserListDone += OnGetContactsList;
StormClient.OnMessage +=OnMessage; StormClient.OnMessage +=OnMessage;
} }
internal static User CurrentContact { get; set; }//设置当前联系人对象 internal static User CurrentContact { get; set; }//设置当前联系人对象
/// <summary> /// <summary>
/// 获取联系人列表(完成后打开主窗体) /// 获取联系人列表(完成后打开主窗体)
/// </summary> /// </summary>
private void OnGetContactsList(ResultHead head, User[] users) private void OnGetContactsList(ResultHead head, User[] users)
{ {
if (head.Error != "") if (head.Error != "")
{ {
MessageBox.Show("无法获取联系人列表"); MessageBox.Show("无法获取联系人列表");
return; return;
} }
App.Current.Dispatcher.Invoke( App.Current.Dispatcher.Invoke(
(Action)delegate () (Action)delegate ()
{ {
ContactsList = new List<User>(users); ContactsList = new List<User>(users);
MainWindow mainWindow = new MainWindow(); MainWindow mainWindow = new MainWindow();
mainWindow.Show(); mainWindow.Show();
LogWindow.Instence.Close(); LogWindow.Instence.Close();
}); });
} }
private void OnHaveLogin(ResultHead head, User user) private void OnHaveLogin(ResultHead head, User user)
{ {
if (head.Error == "") if (head.Error == "")
{ {
User.Me = user; User.Me = user;
StormClient.QueueGetUserList(); StormClient.QueueGetUserList();
} }
else else
{ {
MessageBox.Show("请核对账号密码!"); MessageBox.Show("请核对账号密码!");
} }
}//登录完成 }//登录完成
private void OnMessage(Message message) private void OnMessage(Message message)
{ {
if (MainWindow.Instence != null) if (MainWindow.Instence != null)
{ {
MainWindow.Instence.ShowMessage(message); MainWindow.Instence.ShowMessage(message);
} }
}//接受到新消息 }//接受到新消息
internal void SendMessage(string text,User target) internal void SendMessage(string text,User target)
{ {
Message msg = new Message(text,target); Message msg = new Message(text,target);
Action<ResultHead> f = delegate (ResultHead head) Action<ResultHead> f = delegate (ResultHead head)
{ {
MainWindow.Instence.ShowMessage(msg); MainWindow.Instence.ShowMessage(msg);
}; };
StormClient.QueueSendMessage(msg,f); StormClient.QueueSendMessage(msg,f);
}//发送消息 }//发送消息
internal static void Log(string user, string password) internal static void Log(string user, string password)
{ {
if (StormClient.Initialize()) if (StormClient.Initialize())
{ {
if (!StormClient.QueueLogin(user, password)) if (!StormClient.QueueLogin(user, password))
{ {
MessageBox.Show("登录失败"); MessageBox.Show("登录失败");
} }
} }
else else
{ {
MessageBox.Show("连接服务器失败!"); MessageBox.Show("连接服务器失败!");
} }
}//登录 }//登录
} }
} }
@@ -1,37 +1,37 @@
using Interact; using Interact;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace StormChatWPF namespace StormChatWPF
{ {
/// <summary> /// <summary>
/// MainWindow.xaml 的交互逻辑 /// MainWindow.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class LogWindow : Window public partial class LogWindow : Window
{ {
public static LogWindow Instence; public static LogWindow Instence;
public LogWindow() public LogWindow()
{ {
InitializeComponent(); InitializeComponent();
Instence = this; Instence = this;
} }
private void Login_button_Click(object sender, RoutedEventArgs e) private void Login_button_Click(object sender, RoutedEventArgs e)
{ {
Chat.Log(AccountBox.Text,passwordBox.Password); Chat.Log(AccountBox.Text,passwordBox.Password);
} }
} }
} }
@@ -1,83 +1,83 @@
using Interact; using Interact;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace StormChatWPF namespace StormChatWPF
{ {
/// <summary> /// <summary>
/// UserWindow.xaml 的交互逻辑 /// UserWindow.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public static MainWindow Instence; public static MainWindow Instence;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
LoadContactsList(); LoadContactsList();
Instence = this; Instence = this;
} }
private void LoadContactsList() private void LoadContactsList()
{ {
if (Chat.ContactsList.Any()) if (Chat.ContactsList.Any())
{ {
foreach (var user in Chat.ContactsList) foreach (var user in Chat.ContactsList)
{ {
UsersList.Items.Add(user.NickName); UsersList.Items.Add(user.NickName);
} }
} }
}//向联系人列表listview中添加元素 }//向联系人列表listview中添加元素
private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e) private void UsersList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (UsersList.SelectedItem != null) if (UsersList.SelectedItem != null)
{ {
Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex]; Chat.CurrentContact = Chat.ContactsList[UsersList.SelectedIndex];
} }
} }
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)
{ {
if (Chat.CurrentContact == null) if (Chat.CurrentContact == null)
{ {
MessageBox.Show("请选择联系人!"); MessageBox.Show("请选择联系人!");
return; return;
} }
if (InputBox.Text!="") if (InputBox.Text!="")
{ {
Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact); Chat.chat.SendMessage(InputBox.Text, Chat.CurrentContact);
InputBox.Text = ""; InputBox.Text = "";
} }
} }
internal void ShowMessage(Message message) internal void ShowMessage(Message message)
{ {
if (message.To == User.Me) if (message.To == User.Me)
{ {
App.Current.Dispatcher.Invoke( App.Current.Dispatcher.Invoke(
delegate () delegate ()
{ {
OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Left)); OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Left));
}); });
}//接受到的的消息 }//接受到的的消息
else else
{ {
App.Current.Dispatcher.Invoke( App.Current.Dispatcher.Invoke(
delegate () delegate ()
{ {
OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Right)); OutBox.Children.Add(new ChatBubble(message,HorizontalAlignment.Right));
}); });
}//发送的的消息 }//发送的的消息
}//将消息展现于UI界面 }//将消息展现于UI界面
} }
} }

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

@@ -1,124 +1,124 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CF4D6BE0-A862-401F-A3A6-4FDAC32F5B70}</ProjectGuid> <ProjectGuid>{CF4D6BE0-A862-401F-A3A6-4FDAC32F5B70}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>StormChatWPF</RootNamespace> <RootNamespace>StormChatWPF</RootNamespace>
<AssemblyName>StormChatWPF</AssemblyName> <AssemblyName>StormChatWPF</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<StartupObject>StormChatWPF.App</StartupObject> <StartupObject>StormChatWPF.App</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xaml"> <Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Include="App.xaml"> <ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Chat.cs" /> <Compile Include="Chat.cs" />
<Compile Include="MainWindow.xaml.cs"> <Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ScrollViewer.cs" /> <Compile Include="ScrollViewer.cs" />
<Compile Include="UI\ChatBubble.cs" /> <Compile Include="UI\ChatBubble.cs" />
<Page Include="LogWindow.xaml"> <Page Include="LogWindow.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="LogWindow.xaml.cs"> <Compile Include="LogWindow.xaml.cs">
<DependentUpon>LogWindow.xaml</DependentUpon> <DependentUpon>LogWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Properties\Settings.Designer.cs"> <Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Interact\Interact.csproj"> <ProjectReference Include="..\Interact\Interact.csproj">
<Project>{cef054af-95b7-4b88-934e-02705feea554}</Project> <Project>{cef054af-95b7-4b88-934e-02705feea554}</Project>
<Name>Interact</Name> <Name>Interact</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="UI\Resources\登录界面底.png" /> <Resource Include="UI\Resources\登录界面底.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="UI\Resources\闪电.png" /> <Resource Include="UI\Resources\闪电.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="UI\Resources\聊天气泡.png" /> <Resource Include="UI\Resources\聊天气泡.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB