新增主界面的多界面管理及切换动画
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
xmlns:local="clr-namespace:软件系统客户端Wpf"
|
xmlns:local="clr-namespace:软件系统客户端Wpf"
|
||||||
xmlns:y="clr-namespace:ClientsLibrary;assembly=ClientsLibrary"
|
xmlns:y="clr-namespace:ClientsLibrary;assembly=ClientsLibrary"
|
||||||
mc:Ignorable="d"
|
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">
|
Loaded="Window_Loaded">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@@ -152,9 +152,12 @@
|
|||||||
|
|
||||||
<Grid Width="100" DockPanel.Dock="Left">
|
<Grid Width="100" DockPanel.Dock="Left">
|
||||||
<Border BorderThickness="0,1,1,1" BorderBrush="LightGray">
|
<Border BorderThickness="0,1,1,1" BorderBrush="LightGray">
|
||||||
|
<TextBlock>随便放点什么东西</TextBlock>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
<!--右侧的账户信息和登录消息-->
|
||||||
<Grid DockPanel.Dock="Right" Width="230">
|
<Grid DockPanel.Dock="Right" Width="230">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -240,12 +243,21 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!--主界面,应该设置成可以放置其他东西-->
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<ContentControl Margin="3" x:Name="UserContentControl">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock>asdasdasd</TextBlock>
|
||||||
|
<TextBlock>asdasdasddasdasd</TextBlock>
|
||||||
|
<TextBlock>asdasdasd</TextBlock>
|
||||||
|
<TextBlock>asdasasdasdasd</TextBlock>
|
||||||
|
<TextBlock>asdasdasdasd</TextBlock>
|
||||||
|
<TextBlock>asdasasdadasd</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</ContentControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}"
|
<materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}" x:Name="SoftSnackbar" />
|
||||||
x:Name="SoftSnackbar" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ using System.Windows.Navigation;
|
|||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using ClientsLibrary;
|
using ClientsLibrary;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using 软件系统客户端Wpf.Views;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace 软件系统客户端Wpf
|
namespace 软件系统客户端Wpf
|
||||||
{
|
{
|
||||||
@@ -157,7 +159,7 @@ namespace 软件系统客户端Wpf
|
|||||||
TextBlock_Version.Text = UserClient.CurrentVersion.ToString();
|
TextBlock_Version.Text = UserClient.CurrentVersion.ToString();
|
||||||
|
|
||||||
//初始化窗口
|
//初始化窗口
|
||||||
//MainRenderInitialization();
|
MainRenderInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddStringRenderShow(string str)
|
private void AddStringRenderShow(string str)
|
||||||
@@ -277,14 +279,15 @@ namespace 软件系统客户端Wpf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int index = 1;
|
|
||||||
private void MenuItem聊天信息_Click(object sender, RoutedEventArgs e)
|
private void MenuItem聊天信息_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var messageQueue = SoftSnackbar.MessageQueue;
|
//var messageQueue = SoftSnackbar.MessageQueue;
|
||||||
var message = "这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据" + index++;
|
//var message = "这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据这是一条测试数据" + index++;
|
||||||
|
|
||||||
//the message queue can be called from any thread
|
////the message queue can be called from any thread
|
||||||
Task.Factory.StartNew(() => messageQueue.Enqueue(message));
|
//Task.Factory.StartNew(() => messageQueue.Enqueue(message));
|
||||||
|
|
||||||
|
SetShowRenderControl(UIControls_Chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuItem头像更改_Click(object sender, RoutedEventArgs e)
|
private void MenuItem头像更改_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -606,6 +609,91 @@ namespace 软件系统客户端Wpf
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 多界面管理块
|
||||||
|
|
||||||
|
private List<UserControl> all_main_render = new List<UserControl>();
|
||||||
|
|
||||||
|
|
||||||
|
private UserChat UIControls_Chat { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 正在显示的子界面
|
||||||
|
/// </summary>
|
||||||
|
private UserControl CurrentRender { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主界面的初始化
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
软件系统客户端Wpf/Views/UserChat.xaml
Normal file
26
软件系统客户端Wpf/Views/UserChat.xaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<UserControl x:Class="软件系统客户端Wpf.Views.UserChat"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:软件系统客户端Wpf.Views"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"></RowDefinition>
|
||||||
|
<RowDefinition Height="auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="auto"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Margin="2">按Enter键发送消息:</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
80
软件系统客户端Wpf/Views/UserChat.xaml.cs
Normal file
80
软件系统客户端Wpf/Views/UserChat.xaml.cs
Normal file
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserChat.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class UserChat : UserControl
|
||||||
|
{
|
||||||
|
public UserChat(Action<string> send)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
SendString = send;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Action<string> 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();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 新增聊天的历史记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 光标滚动到最底端
|
||||||
|
///// </summary>
|
||||||
|
//public void ScrollToDown()
|
||||||
|
//{
|
||||||
|
// richTextBox1.SelectionStart = richTextBox1.Text.Length;
|
||||||
|
// richTextBox1.ScrollToCaret();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
软件系统客户端Wpf/Views/UserHome.xaml
Normal file
12
软件系统客户端Wpf/Views/UserHome.xaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<UserControl x:Class="软件系统客户端Wpf.Views.UserHome"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:软件系统客户端Wpf.Views"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
28
软件系统客户端Wpf/Views/UserHome.xaml.cs
Normal file
28
软件系统客户端Wpf/Views/UserHome.xaml.cs
Normal file
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserHome.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class UserHome : UserControl
|
||||||
|
{
|
||||||
|
public UserHome()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,12 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Views\UserChat.xaml.cs">
|
||||||
|
<DependentUpon>UserChat.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Views\UserHome.xaml.cs">
|
||||||
|
<DependentUpon>UserHome.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Page Include="LoginWindow.xaml">
|
<Page Include="LoginWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -92,6 +98,14 @@
|
|||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="Views\UserChat.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Views\UserHome.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
@@ -120,5 +134,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user