提交 f4f31e53 编写于 作者: Richard__Hu's avatar Richard__Hu

新增主界面的多界面管理及切换动画

上级 5946f341
......@@ -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">
<Window.Resources>
......@@ -152,9 +152,12 @@
<Grid Width="100" DockPanel.Dock="Left">
<Border BorderThickness="0,1,1,1" BorderBrush="LightGray">
<TextBlock>随便放点什么东西</TextBlock>
</Border>
</Grid>
<!--右侧的账户信息和登录消息-->
<Grid DockPanel.Dock="Right" Width="230">
<Grid>
<Grid.RowDefinitions>
......@@ -240,12 +243,21 @@
</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>
</DockPanel>
<materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}"
x:Name="SoftSnackbar" />
<materialDesign:Snackbar MessageQueue="{materialDesign:MessageQueue}" x:Name="SoftSnackbar" />
</Grid>
</Window>
......@@ -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<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
}
}
<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>
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();
//}
}
}
<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>
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>
<SubType>Designer</SubType>
</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">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -92,6 +98,14 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</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>
<Compile Include="Properties\AssemblyInfo.cs">
......@@ -120,5 +134,6 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册