From f4f31e53bab07d2efcd129a9d7a9625bff69d3c1 Mon Sep 17 00:00:00 2001 From: dathlin Date: Fri, 14 Jul 2017 15:27:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E5=A4=9A=E7=95=8C=E9=9D=A2=E7=AE=A1=E7=90=86=E5=8F=8A?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 软件系统客户端Wpf/MainWindow.xaml | 20 +++- 软件系统客户端Wpf/MainWindow.xaml.cs | 104 +++++++++++++++++++-- 软件系统客户端Wpf/Views/UserChat.xaml | 26 ++++++ 软件系统客户端Wpf/Views/UserChat.xaml.cs | 80 ++++++++++++++++ 软件系统客户端Wpf/Views/UserHome.xaml | 12 +++ 软件系统客户端Wpf/Views/UserHome.xaml.cs | 28 ++++++ 软件系统客户端Wpf/软件系统客户端Wpf.csproj | 15 +++ 7 files changed, 273 insertions(+), 12 deletions(-) create mode 100644 软件系统客户端Wpf/Views/UserChat.xaml create mode 100644 软件系统客户端Wpf/Views/UserChat.xaml.cs create mode 100644 软件系统客户端Wpf/Views/UserHome.xaml create mode 100644 软件系统客户端Wpf/Views/UserHome.xaml.cs diff --git a/软件系统客户端Wpf/MainWindow.xaml b/软件系统客户端Wpf/MainWindow.xaml index 4a7cdcd..ad82826 100644 --- a/软件系统客户端Wpf/MainWindow.xaml +++ b/软件系统客户端Wpf/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:软件系统客户端Wpf" xmlns:y="clr-namespace:ClientsLibrary;assembly=ClientsLibrary" mc:Ignorable="d" - Title="MainWindow" Height="350" Width="525" WindowState="Maximized" Activated="Window_Activated" Closing="Window_Closing" ContentRendered="Window_ContentRendered" Initialized="Window_Initialized" + Title="MainWindow" Height="550" Width="825" WindowState="Maximized" Activated="Window_Activated" Closing="Window_Closing" ContentRendered="Window_ContentRendered" Initialized="Window_Initialized" Loaded="Window_Loaded"> @@ -152,9 +152,12 @@ + 随便放点什么东西 + + @@ -240,12 +243,21 @@ + - + + + asdasdasd + asdasdasddasdasd + asdasdasd + asdasasdasdasd + asdasdasdasd + asdasasdadasd + + - + diff --git a/软件系统客户端Wpf/MainWindow.xaml.cs b/软件系统客户端Wpf/MainWindow.xaml.cs index eb84937..3fdf87c 100644 --- a/软件系统客户端Wpf/MainWindow.xaml.cs +++ b/软件系统客户端Wpf/MainWindow.xaml.cs @@ -19,6 +19,8 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ClientsLibrary; using System.Threading; +using 软件系统客户端Wpf.Views; +using System.Windows.Media.Animation; namespace 软件系统客户端Wpf { @@ -157,7 +159,7 @@ namespace 软件系统客户端Wpf TextBlock_Version.Text = UserClient.CurrentVersion.ToString(); //初始化窗口 - //MainRenderInitialization(); + MainRenderInitialization(); } private void AddStringRenderShow(string str) @@ -276,15 +278,16 @@ namespace 软件系统客户端Wpf fpm.ShowDialog(); } } - - private int index = 1; + private void MenuItem聊天信息_Click(object sender, RoutedEventArgs e) { - var messageQueue = SoftSnackbar.MessageQueue; - var message = "这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据" + index++; + //var messageQueue = SoftSnackbar.MessageQueue; + //var message = "这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据" + index++; - //the message queue can be called from any thread - Task.Factory.StartNew(() => messageQueue.Enqueue(message)); + ////the message queue can be called from any thread + //Task.Factory.StartNew(() => messageQueue.Enqueue(message)); + + SetShowRenderControl(UIControls_Chat); } private void MenuItem头像更改_Click(object sender, RoutedEventArgs e) @@ -606,6 +609,91 @@ namespace 软件系统客户端Wpf #endregion - + #region 多界面管理块 + + private List all_main_render = new List(); + + + private UserChat UIControls_Chat { get; set; } + + + /// + /// 正在显示的子界面 + /// + private UserControl CurrentRender { get; set; } + + /// + /// 主界面的初始化 + /// + private void MainRenderInitialization() + { + //将所有的子集控件添加进去 + + /******************************************************************************* + * + * 例如此处展示了文件控件是如何添加进去的 + * 1.先进行实例化,赋值初始参数 + * 2.添加进项目 + * 3.显示 + * + *******************************************************************************/ + + //UIControls_Files = new UIControls.ShareFilesRender() + //{ + // Visible = false, + // Parent = panel_main,//决定了放在哪个界面显示,此处示例 + // Dock = DockStyle.Fill, + //}; + //all_main_render.Add(UIControls_Files); + + UIControls_Chat = new UserChat((m) => + { + net_socket_client.Send(CommonHeadCode.MultiNetHeadCode.留言版消息, m); + }); + all_main_render.Add(UIControls_Chat); + + } + + private void SetShowRenderControl(UserControl control) + { + if (!ReferenceEquals(CurrentRender, control)) + { + CurrentRender = control; + //UserContentControl.Content = control; + + DoubleAnimation d_opacity = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(100)); + DoubleAnimation d_y = new DoubleAnimation(0, -10, TimeSpan.FromMilliseconds(100)); + TranslateTransform tt = new TranslateTransform(); + UserContentControl.RenderTransform = tt; + d_opacity.Completed += delegate + { + UserContentControl.Content = control; + DoubleAnimation d_opacity2 = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(100)); + DoubleAnimation d_y2 = new DoubleAnimation(10, 0, TimeSpan.FromMilliseconds(100)); + TranslateTransform tt2 = new TranslateTransform(); + UserContentControl.RenderTransform = tt2; + UserContentControl.BeginAnimation(OpacityProperty, d_opacity2); + tt.BeginAnimation(TranslateTransform.XProperty, d_y2); + }; + + UserContentControl.BeginAnimation(OpacityProperty, d_opacity); + tt.BeginAnimation(TranslateTransform.XProperty, d_y); + } + } + private void SetShowRenderControl(Type typeControl) + { + UserControl control = null; + foreach (var c in all_main_render) + { + if (c.GetType() == typeControl) + { + control = c; + break; + } + } + if (control != null) SetShowRenderControl(control); + } + + #endregion } } diff --git a/软件系统客户端Wpf/Views/UserChat.xaml b/软件系统客户端Wpf/Views/UserChat.xaml new file mode 100644 index 0000000..ec2878f --- /dev/null +++ b/软件系统客户端Wpf/Views/UserChat.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + 按Enter键发送消息: + + diff --git a/软件系统客户端Wpf/Views/UserChat.xaml.cs b/软件系统客户端Wpf/Views/UserChat.xaml.cs new file mode 100644 index 0000000..7b6e28d --- /dev/null +++ b/软件系统客户端Wpf/Views/UserChat.xaml.cs @@ -0,0 +1,80 @@ +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 软件系统客户端Wpf.Views +{ + /// + /// UserChat.xaml 的交互逻辑 + /// + public partial class UserChat : UserControl + { + public UserChat(Action send) + { + InitializeComponent(); + SendString = send; + } + + + private Action SendString = null; + + public void DealwithReceive(string str) + { + //richTextBox1.AppendText(str + Environment.NewLine); + //int length = str.IndexOf(Environment.NewLine) + 1; + //if (length > 0) + //{ + // richTextBox1.Select(richTextBox1.Text.Length - str.Length + 1, length); + // richTextBox1.SelectionColor = Color.Blue; + //} + //ScrollToDown(); + } + /// + /// 新增聊天的历史记录 + /// + /// + public void AddChatsHistory(string str) + { + //richTextBox1.Text = str; + //MatchCollection mc = Regex.Matches(str, @"\u0002.+\r\n"); + //int indexrow = 0; + //if (str != "") + //{ + // foreach (Match m in mc) + // { + // richTextBox1.Select(m.Index - indexrow * 2, m.Length - 2); + // richTextBox1.SelectionColor = Color.Blue; + // indexrow++; + // } + //} + //ScrollToDown(); + } + + public void InputFocus() + { + //textBox1.Focus(); + } + + + + ///// + ///// 光标滚动到最底端 + ///// + //public void ScrollToDown() + //{ + // richTextBox1.SelectionStart = richTextBox1.Text.Length; + // richTextBox1.ScrollToCaret(); + //} + } +} diff --git a/软件系统客户端Wpf/Views/UserHome.xaml b/软件系统客户端Wpf/Views/UserHome.xaml new file mode 100644 index 0000000..2397aa0 --- /dev/null +++ b/软件系统客户端Wpf/Views/UserHome.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/软件系统客户端Wpf/Views/UserHome.xaml.cs b/软件系统客户端Wpf/Views/UserHome.xaml.cs new file mode 100644 index 0000000..60e19e6 --- /dev/null +++ b/软件系统客户端Wpf/Views/UserHome.xaml.cs @@ -0,0 +1,28 @@ +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 软件系统客户端Wpf.Views +{ + /// + /// UserHome.xaml 的交互逻辑 + /// + public partial class UserHome : UserControl + { + public UserHome() + { + InitializeComponent(); + } + } +} diff --git a/软件系统客户端Wpf/软件系统客户端Wpf.csproj b/软件系统客户端Wpf/软件系统客户端Wpf.csproj index a6b1211..3ebd5bc 100644 --- a/软件系统客户端Wpf/软件系统客户端Wpf.csproj +++ b/软件系统客户端Wpf/软件系统客户端Wpf.csproj @@ -73,6 +73,12 @@ MSBuild:Compile Designer + + UserChat.xaml + + + UserHome.xaml + MSBuild:Compile Designer @@ -92,6 +98,14 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -120,5 +134,6 @@ + \ No newline at end of file