代码调整,重构,v1.6.10

This commit is contained in:
dathlin
2017-10-11 22:12:20 +08:00
parent 1a85ef8588
commit 0a7ace0ca7
17 changed files with 130 additions and 63 deletions

View File

@@ -320,7 +320,6 @@
this.Controls.Add(this.userButton1); this.Controls.Add(this.userButton1);
this.Controls.Add(this.userButton_login); this.Controls.Add(this.userButton_login);
this.Name = "FormLogView"; this.Name = "FormLogView";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "日志查看器"; this.Text = "日志查看器";
this.Load += new System.EventHandler(this.FormLogView_Load); this.Load += new System.EventHandler(this.FormLogView_Load);

View File

@@ -14,6 +14,8 @@ namespace ClientsLibrary
{ {
public partial class FormLogView : Form public partial class FormLogView : Form
{ {
#region Constructor
public FormLogView() public FormLogView()
{ {
InitializeComponent(); InitializeComponent();
@@ -23,13 +25,26 @@ namespace ClientsLibrary
net_simplify_client = UserClient.Net_simplify_client; net_simplify_client = UserClient.Net_simplify_client;
} }
#endregion
#region Window Load
private void FormLogView_Load(object sender, EventArgs e) private void FormLogView_Load(object sender, EventArgs e)
{ {
} }
#endregion
#region Private Member
private NetSimplifyClient net_simplify_client = null; private NetSimplifyClient net_simplify_client = null;
#endregion
#region Button Click
private void ReadFromServer(int head_code) private void ReadFromServer(int head_code)
{ {
OperateResultString result = net_simplify_client.ReadFromServer(head_code); OperateResultString result = net_simplify_client.ReadFromServer(head_code);
@@ -129,19 +144,8 @@ namespace ClientsLibrary
{ {
ClearFromServer(CommonHeadCode.SimplifyHeadCode.); ClearFromServer(CommonHeadCode.SimplifyHeadCode.);
} }
//private void userButton17_Click(object sender, EventArgs e)
//{
// ReadFromServer(CommonHeadCode.SimplifyHeadCode.头像日志查看);
//}
//private void userButton16_Click(object sender, EventArgs e) #endregion
//{
// ClearFromServer(CommonHeadCode.SimplifyHeadCode.头像日志清空);
//}
private void logNetAnalysisControl1_Load(object sender, EventArgs e)
{
}
} }
} }

View File

@@ -14,17 +14,20 @@ using ClientsLibrary.FileSupport;
namespace ClientsLibrary namespace ClientsLibrary
{ {
//===================================================================================== /************************************************************************************************
// *
// 用途: 本窗口用于实现对本系统的客户端进行全面的远程更新的操作。 * 用途: 本窗口用于实现对本系统的客户端进行全面的远程更新的操作。
// 第一步: 先将新版本的所有客户端传送到服务器端进行覆盖。 * 第一步: 先将新版本的所有客户端传送到服务器端进行覆盖。
// 第二步: 再将版本号传送到服务器进行更新,这样所有的客户端登录后就会自动更新新的版本了 * 第二步: 再将版本号传送到服务器进行更新,这样所有的客户端登录后就会自动更新新的版本了
// *
//===================================================================================== **************************************************************************************************/
public partial class FormUpdateRemote : Form public partial class FormUpdateRemote : Form
{ {
#region Constructor
public FormUpdateRemote() public FormUpdateRemote()
{ {
InitializeComponent(); InitializeComponent();
@@ -32,6 +35,11 @@ namespace ClientsLibrary
Icon = UserClient.GetFormWindowIcon(); Icon = UserClient.GetFormWindowIcon();
} }
#endregion
#region Select File And Upload
private void userButton_file_Click(object sender, EventArgs e) private void userButton_file_Click(object sender, EventArgs e)
{ {
using (OpenFileDialog ofd = new OpenFileDialog()) using (OpenFileDialog ofd = new OpenFileDialog())
@@ -53,6 +61,12 @@ namespace ClientsLibrary
} }
} }
#endregion
#region Update Version
private void userButton_version_Click(object sender, EventArgs e) private void userButton_version_Click(object sender, EventArgs e)
{ {
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., textBox1.Text); OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., textBox1.Text);
@@ -66,9 +80,16 @@ namespace ClientsLibrary
} }
} }
#endregion
#region Form Load
private void FormUpdateRemote_Load(object sender, EventArgs e) private void FormUpdateRemote_Load(object sender, EventArgs e)
{ {
textBox1.Text = UserClient.CurrentVersion.ToString(); textBox1.Text = UserClient.CurrentVersion.ToString();
} }
#endregion
} }
} }

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="软件系统客户端Wpf.Views.Palette" <UserControl x:Class="软件系统客户端Wpf.Views.Controls.Palette"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@@ -13,7 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace Wpf.Views namespace Wpf.Views.Controls
{ {
/// <summary> /// <summary>
/// Palette.xaml 的交互逻辑 /// Palette.xaml 的交互逻辑

View File

@@ -23,12 +23,20 @@ namespace 软件系统客户端Wpf.Views.Controls
/// </summary> /// </summary>
public partial class UserClientRenderItem : UserControl public partial class UserClientRenderItem : UserControl
{ {
#region Constructor
public UserClientRenderItem() public UserClientRenderItem()
{ {
InitializeComponent(); InitializeComponent();
} }
#endregion
#region Public Property
/// <summary>
/// 当前会话的唯一ID
/// </summary>
public string UniqueId public string UniqueId
{ {
get get
@@ -37,6 +45,9 @@ namespace 软件系统客户端Wpf.Views.Controls
} }
} }
#endregion
#region Show Client Information
public void SetClientRender(NetAccount account) public void SetClientRender(NetAccount account)
{ {
@@ -47,17 +58,18 @@ namespace 软件系统客户端Wpf.Views.Controls
Factory.Text = $"({account.Factory})"; Factory.Text = $"({account.Factory})";
Roles.Children.Clear(); Roles.Children.Clear();
if(account.Roles?.Length>0)
if (account.Roles?.Length > 0)
{ {
foreach(var m in account.Roles) foreach (var m in account.Roles)
{ {
TextBlock block = new TextBlock(); TextBlock block = new TextBlock
block.Background = Brushes.LightSkyBlue; {
block.Foreground = Brushes.Blue; Background = Brushes.LightSkyBlue,
block.Margin = new Thickness(0, 0, 4, 0); Foreground = Brushes.Blue,
Margin = new Thickness(0, 0, 4, 0),
block.Text = m; Text = m
};
Roles.Children.Add(block); Roles.Children.Add(block);
} }
} }
@@ -66,11 +78,14 @@ namespace 软件系统客户端Wpf.Views.Controls
Roles.Children.Add(new TextBlock()); Roles.Children.Add(new TextBlock());
} }
// 启动线程池去显示头像
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), account); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), account);
} }
} }
#endregion
#region Update Portrait
public void UpdatePortrait(string userName) public void UpdatePortrait(string userName)
{ {
@@ -79,6 +94,7 @@ namespace 软件系统客户端Wpf.Views.Controls
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), netAccount); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), netAccount);
} }
} }
private void ThreadPoolLoadPortrait(object obj) private void ThreadPoolLoadPortrait(object obj)
{ {
// 向服务器请求小头像 // 向服务器请求小头像
@@ -102,12 +118,17 @@ namespace 软件系统客户端Wpf.Views.Controls
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); UserClient.LogNet?.WriteException("Thread Download Portrait Failed", ex);
} }
} }
} }
#endregion
#region Pricvate Member
private NetAccount netAccount = null; private NetAccount netAccount = null;
#endregion
} }
} }

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="软件系统客户端Wpf.Views.UserFileRenderItem" <UserControl x:Class="软件系统客户端Wpf.Views.Controls.UserFileRenderItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@@ -20,7 +20,7 @@ using System.IO;
using System.Net; using System.Net;
using ClientsLibrary.FileSupport; using ClientsLibrary.FileSupport;
namespace Wpf.Views namespace Wpf.Views.Controls
{ {
/// <summary> /// <summary>
/// UserFileRenderItem.xaml 的交互逻辑 /// UserFileRenderItem.xaml 的交互逻辑

View File

@@ -21,14 +21,18 @@ namespace 软件系统客户端Wpf.Views
/// </summary> /// </summary>
public partial class UserChat : UserControl public partial class UserChat : UserControl
{ {
#region Constructor
public UserChat(Action<string> send) public UserChat(Action<string> send)
{ {
InitializeComponent(); InitializeComponent();
SendString = send; SendString = send;
} }
#endregion
#region Add Chat Show
private Action<string> SendString = null;
public void DealwithReceive(string str) public void DealwithReceive(string str)
{ {
@@ -41,6 +45,7 @@ namespace 软件系统客户端Wpf.Views
} }
ScrollToDown(); ScrollToDown();
} }
/// <summary> /// <summary>
/// 新增聊天的历史记录 /// 新增聊天的历史记录
/// </summary> /// </summary>
@@ -62,11 +67,31 @@ namespace 软件系统客户端Wpf.Views
ScrollToDown(); ScrollToDown();
} }
#endregion
#region Chat Focus Scroll
public void InputFocus() public void InputFocus()
{ {
//textBox1.Focus(); //textBox1.Focus();
} }
/// <summary>
/// 光标滚动到最底端
/// </summary>
public void ScrollToDown()
{
TextBox_ChatHistory.ScrollToEnd();
}
#endregion
#region Text Send
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)
{ {
if (!string.IsNullOrEmpty(TextBox_Send.Text)) if (!string.IsNullOrEmpty(TextBox_Send.Text))
@@ -76,27 +101,22 @@ namespace 软件系统客户端Wpf.Views
} }
} }
private void TextBox_KeyDown(object sender, KeyEventArgs e) private void TextBox_KeyDown(object sender, KeyEventArgs e)
{ {
//按下Enter键后进行发送数据到服务器 if (e.Key == Key.Enter)
if (!string.IsNullOrEmpty(TextBox_Send.Text))
{ {
if (e.Key == Key.Enter) Button_Click(sender, new RoutedEventArgs());
{
SendString?.Invoke(TextBox_Send.Text);
TextBox_Send.Text = "";
}
} }
} }
#endregion
#region Private Member
/// <summary> private Action<string> SendString = null;
/// 光标滚动到最底端
/// </summary> #endregion
public void ScrollToDown()
{
TextBox_ChatHistory.ScrollToEnd();
}
} }
} }

View File

@@ -18,6 +18,7 @@ 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;
using Wpf.Views.Controls;
namespace Wpf.Views namespace Wpf.Views
{ {

View File

@@ -6,6 +6,7 @@
xmlns:materialDesignColors="clr-namespace:MaterialDesignColors;assembly=MaterialDesignColors" xmlns:materialDesignColors="clr-namespace:MaterialDesignColors;assembly=MaterialDesignColors"
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf" xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
xmlns:local="clr-namespace:软件系统客户端Wpf.Views" xmlns:local="clr-namespace:软件系统客户端Wpf.Views"
xmlns:local1="clr-namespace:软件系统客户端Wpf.Views.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="400" Loaded="UserControl_Loaded"> d:DesignHeight="700" d:DesignWidth="400" Loaded="UserControl_Loaded">
<UserControl.Resources> <UserControl.Resources>
@@ -84,7 +85,7 @@
<DockPanel> <DockPanel>
<wpf:Card DockPanel.Dock="Top" Margin="2,0,2,0"> <wpf:Card DockPanel.Dock="Top" Margin="2,0,2,0">
<DockPanel> <DockPanel>
<local:Palette DockPanel.Dock="Left" Width="200" /> <local1:Palette DockPanel.Dock="Left" Width="200" />
<TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色可以在app.xaml中进行配置和初始化 <TextBlock Margin="16" TextWrapping="Wrap" VerticalAlignment="Center">这是你当前的主题配色可以在app.xaml中进行配置和初始化
也可以在运行的时候进行更改。</TextBlock> 也可以在运行的时候进行更改。</TextBlock>
</DockPanel> </DockPanel>

View File

@@ -78,23 +78,23 @@
<Compile Include="Views\Controls\UserClientRenderItem.xaml.cs"> <Compile Include="Views\Controls\UserClientRenderItem.xaml.cs">
<DependentUpon>UserClientRenderItem.xaml</DependentUpon> <DependentUpon>UserClientRenderItem.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\Palette.xaml.cs"> <Compile Include="Views\Controls\Palette.xaml.cs">
<DependentUpon>Palette.xaml</DependentUpon> <DependentUpon>Palette.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\PaletteSelectorViewModel.cs" /> <Compile Include="Views\PaletteSelectorViewModel.cs" />
<Compile Include="Views\UserChat.xaml.cs"> <Compile Include="Views\UIControls\UserChat.xaml.cs">
<DependentUpon>UserChat.xaml</DependentUpon> <DependentUpon>UserChat.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserFileRender.xaml.cs"> <Compile Include="Views\UIControls\UserFileRender.xaml.cs">
<DependentUpon>UserFileRender.xaml</DependentUpon> <DependentUpon>UserFileRender.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserFileRenderItem.xaml.cs"> <Compile Include="Views\Controls\UserFileRenderItem.xaml.cs">
<DependentUpon>UserFileRenderItem.xaml</DependentUpon> <DependentUpon>UserFileRenderItem.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserHome.xaml.cs"> <Compile Include="Views\UIControls\UserHome.xaml.cs">
<DependentUpon>UserHome.xaml</DependentUpon> <DependentUpon>UserHome.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\UserPaletteSelector.xaml.cs"> <Compile Include="Views\UIControls\UserPaletteSelector.xaml.cs">
<DependentUpon>UserPaletteSelector.xaml</DependentUpon> <DependentUpon>UserPaletteSelector.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="LoginWindow.xaml"> <Page Include="LoginWindow.xaml">
@@ -120,27 +120,27 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\Palette.xaml"> <Page Include="Views\Controls\Palette.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserChat.xaml"> <Page Include="Views\UIControls\UserChat.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserFileRender.xaml"> <Page Include="Views\UIControls\UserFileRender.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserFileRenderItem.xaml"> <Page Include="Views\Controls\UserFileRenderItem.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserHome.xaml"> <Page Include="Views\UIControls\UserHome.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\UserPaletteSelector.xaml"> <Page Include="Views\UIControls\UserPaletteSelector.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>