更新两种客户端的在线显示模型,v1.6.8

This commit is contained in:
dathlin
2017-10-09 22:18:51 +08:00
parent 8252e4d356
commit 1c4181363e
23 changed files with 966 additions and 40 deletions

View File

@@ -277,7 +277,9 @@
Foreground="{DynamicResource PrimaryHueMidForegroundBrush}">0</TextBlock>
</Border>
<TextBlock Grid.Row="1" Grid.Column="0">在线信息:</TextBlock>
<ListBox Grid.Row="2" Grid.ColumnSpan="2" x:Name="ListBox_Onlines" FontSize="10.5"></ListBox>
<!--<ListBox Grid.Row="2" Grid.ColumnSpan="2" x:Name="ListBox_Onlines" FontSize="10.5"></ListBox>-->
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Name="ClientsOnline" Orientation="Vertical"
Margin="0,4,0,0"></StackPanel>
</Grid>
</GroupBox>
</Grid>

View File

@@ -23,6 +23,7 @@ using System.Threading;
using Wpf.Views;
using System.Windows.Media.Animation;
using MaterialDesignThemes.Wpf;
using CommonLibrary;
namespace Wpf
{
@@ -441,7 +442,18 @@ namespace 软件系统客户端Wpf
{
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
{
ListBox_Onlines.ItemsSource = data.Split('#');
// ListBox_Onlines.ItemsSource = data.Split('#');
ClientsOnline.Children.Clear();
NetAccount[] accounts = JArray.Parse(data).ToObject<NetAccount[]>();
foreach(var m in accounts)
{
Views.Controls.UserClientRenderItem userClient = new Views.Controls.UserClientRenderItem();
userClient.SetClientRender(m);
ClientsOnline.Children.Add(userClient);
}
}));
}
else if (customer == CommonHeadCode.MultiNetHeadCode.)

View File

@@ -0,0 +1,33 @@
<UserControl x:Class="软件系统客户端Wpf.Views.Controls.UserClientRenderItem"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" HorizontalAlignment="Stretch"
d:DesignHeight="50" d:DesignWidth="300" Margin="0,3,0,0">
<Grid HorizontalAlignment="Stretch">
<materialDesign:Chip HorizontalAlignment="Stretch">
<materialDesign:Chip.Icon>
<Image Name="Image1" />
</materialDesign:Chip.Icon>
<materialDesign:Chip.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<TextBlock Margin="2,0,6,0" Name="UserName">admin</TextBlock>
<TextBlock Name="Factory">(总公司)</TextBlock>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Name="Roles" Margin="2,0,0,0">
<TextBlock Background="LightBlue" Foreground="Blue">计划员</TextBlock>
</StackPanel>
</Grid>
</materialDesign:Chip.Content>
</materialDesign:Chip>
</Grid>
</UserControl>

View File

@@ -0,0 +1,107 @@
using ClientsLibrary;
using CommonLibrary;
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.Controls
{
/// <summary>
/// UserClientRenderItem.xaml 的交互逻辑
/// </summary>
public partial class UserClientRenderItem : UserControl
{
public UserClientRenderItem()
{
InitializeComponent();
}
public void SetClientRender(NetAccount account)
{
if (account != null)
{
UserName.Text = string.IsNullOrEmpty(account.Alias) ? account.UserName : account.Alias;
Factory.Text = $"({account.Factory})";
Roles.Children.Clear();
if(account.Roles?.Length>0)
{
foreach(var m in account.Roles)
{
TextBlock block = new TextBlock();
block.Background = Brushes.LightSkyBlue;
block.Foreground = Brushes.Blue;
block.Margin = new Thickness(0, 0, 4, 0);
block.Text = m;
Roles.Children.Add(block);
}
}
else
{
Roles.Children.Add(new TextBlock());
}
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), account);
}
}
private void ThreadPoolLoadPortrait(object obj)
{
// 向服务器请求小头像
if (obj is NetAccount m_NetAccount)
{
try
{
System.IO.MemoryStream ms = new System.IO.MemoryStream();
HslCommunication.OperateResult result = UserClient.Net_File_Client.DownloadFile(
PortraitSupport.SmallPortrait,
"Files",
"Portrait",
m_NetAccount.UserName,
null,
ms
);
if (result.IsSuccess)
{
Dispatcher.Invoke(new Action(() =>
{
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
Image1.Source = bi;
}));
}
else
{
MessageBox.Show(result.Message);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}

View File

@@ -75,6 +75,9 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Views\AnotherCommandImplementation.cs" />
<Compile Include="Views\Controls\UserClientRenderItem.xaml.cs">
<DependentUpon>UserClientRenderItem.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Palette.xaml.cs">
<DependentUpon>Palette.xaml</DependentUpon>
</Compile>
@@ -113,6 +116,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\Controls\UserClientRenderItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Palette.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>