头像功能完善,头像同步更新机制,BUG修复,接下来一段时间针对代码重构,v1.6.9
BIN
软件系统客户端Wpf/Image/person_1.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
@@ -160,7 +160,7 @@
|
||||
<TextBlock x:Name="TextBlock_Information" Foreground="DodgerBlue"></TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" >
|
||||
<TextBlock>时间:</TextBlock>
|
||||
<TextBlock x:Name="TextBlock_ServerTime">0000-00-00 00:00:00</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">延迟:</TextBlock>
|
||||
@@ -278,8 +278,12 @@
|
||||
</Border>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0">在线信息:</TextBlock>
|
||||
<!--<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>
|
||||
|
||||
<ScrollViewer Grid.Row="2" Grid.ColumnSpan="2" >
|
||||
<StackPanel Name="ClientsOnline" Orientation="Vertical"
|
||||
Margin="0,4,0,0" ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"></StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace 软件系统客户端Wpf
|
||||
//SendServerUdpData(0, "显示了窗体");
|
||||
|
||||
//是否显示更新日志,显示前进行判断该版本是否已经显示过了
|
||||
if (UserClient.JsonSettings.IsNewVersionRunning)
|
||||
if (!UserClient.JsonSettings.IsNewVersionRunning)
|
||||
{
|
||||
UserClient.JsonSettings.IsNewVersionRunning = false;
|
||||
UserClient.JsonSettings.SaveToFile();
|
||||
@@ -432,29 +432,29 @@ namespace 软件系统客户端Wpf
|
||||
{
|
||||
if (customer == CommonHeadCode.MultiNetHeadCode.弹窗新消息)
|
||||
{
|
||||
if(IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
FormPopup fpp = new FormPopup(data, System.Drawing.Color.DodgerBlue, 10000);
|
||||
fpp.Show();
|
||||
}));
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
FormPopup fpp = new FormPopup(data, System.Drawing.Color.DodgerBlue, 10000);
|
||||
fpp.Show();
|
||||
}));
|
||||
}
|
||||
else if (customer == CommonHeadCode.MultiNetHeadCode.总在线信息)
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
// ListBox_Onlines.ItemsSource = data.Split('#');
|
||||
//if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
//{
|
||||
// // ListBox_Onlines.ItemsSource = data.Split('#');
|
||||
|
||||
ClientsOnline.Children.Clear();
|
||||
NetAccount[] accounts = JArray.Parse(data).ToObject<NetAccount[]>();
|
||||
// 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);
|
||||
}
|
||||
// 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.关闭客户端)
|
||||
{
|
||||
@@ -482,11 +482,24 @@ namespace 软件系统客户端Wpf
|
||||
List<string> chats = JArray.Parse(json["chats"].ToString()).ToObject<List<string>>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
chats.ForEach(m => { sb.Append(m + Environment.NewLine); });
|
||||
|
||||
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
TextBlock_ServerTime.Text = UserClient.DateTimeServer.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
TextBlock_FileCount.Text = json["FileCount"].ToObject<int>().ToString();
|
||||
UIControls_Chat.AddChatsHistory(sb.ToString());
|
||||
|
||||
|
||||
ClientsOnline.Children.Clear();
|
||||
NetAccount[] accounts = JArray.Parse(json["ClientsOnline"].ToString()).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.文件总数量)
|
||||
@@ -503,6 +516,40 @@ namespace 软件系统客户端Wpf
|
||||
UIControls_Chat?.DealwithReceive(data);
|
||||
}));
|
||||
}
|
||||
else if (customer == CommonHeadCode.MultiNetHeadCode.新用户上线)
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Views.Controls.UserClientRenderItem userClient = new Views.Controls.UserClientRenderItem();
|
||||
userClient.SetClientRender(JObject.Parse(data).ToObject<NetAccount>());
|
||||
ClientsOnline.Children.Add(userClient);
|
||||
}));
|
||||
}
|
||||
else if (customer == CommonHeadCode.MultiNetHeadCode.用户下线)
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Views.Controls.UserClientRenderItem item = null;
|
||||
foreach (Views.Controls.UserClientRenderItem m in ClientsOnline.Children)
|
||||
{
|
||||
if(m?.UniqueId == data)
|
||||
{
|
||||
item = m;
|
||||
}
|
||||
}
|
||||
if (item != null) ClientsOnline.Children.Remove(item);
|
||||
}));
|
||||
}
|
||||
else if(customer == CommonHeadCode.MultiNetHeadCode.新头像更新)
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
foreach (Views.Controls.UserClientRenderItem m in ClientsOnline.Children)
|
||||
{
|
||||
m.UpdatePortrait(data);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void Net_socket_client_AcceptByte(AsyncStateOne object1, NetHandle customer, byte[] object2)
|
||||
@@ -642,26 +689,25 @@ namespace 软件系统客户端Wpf
|
||||
|
||||
private void SoftUserPortraitInitialization()
|
||||
{
|
||||
SoftUserPortrait = new UserPortrait(AppDomain.CurrentDomain.BaseDirectory + @"Portrait\" + UserClient.UserAccount.UserName,
|
||||
m => {
|
||||
SoftUserPortrait = new UserPortrait(AppDomain.CurrentDomain.BaseDirectory +
|
||||
@"Portrait\" + UserClient.UserAccount.UserName, ShowSmallPortrait);
|
||||
}
|
||||
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
byte[] content = File.ReadAllBytes(m);
|
||||
BitmapImage bi = new BitmapImage();
|
||||
bi.BeginInit();
|
||||
bi.StreamSource = new MemoryStream(content);
|
||||
bi.EndInit();
|
||||
private void ShowSmallPortrait(System.Drawing.Bitmap bitmap)
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
bitmap.Save(ms, bitmap.RawFormat);
|
||||
bitmap.Dispose();
|
||||
|
||||
AccountPortrait.Source = bi;
|
||||
}));
|
||||
},
|
||||
()=>
|
||||
{
|
||||
if (IsWindowShow) Dispatcher.Invoke(new Action(() => {
|
||||
AccountPortrait.Source = null;
|
||||
}));
|
||||
});
|
||||
BitmapImage bi = new BitmapImage();
|
||||
bi.BeginInit();
|
||||
bi.StreamSource = ms;
|
||||
bi.EndInit();
|
||||
|
||||
AccountPortrait.Source = bi;
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
70
软件系统客户端Wpf/Properties/Resources.Designer.cs
generated
@@ -1,71 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.42000
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能导致不正确的行为,如果
|
||||
// 重新生成代码,则所做更改将丢失。
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace 软件系统客户端Wpf.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace 软件系统客户端Wpf.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强类型资源类,用于查找本地化字符串等。
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存 ResourceManager 实例。
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("软件系统客户端Wpf.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖当前线程的 CurrentUICulture 属性
|
||||
/// 使用此强类型的资源类的资源查找。
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap person_1 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("person_1", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,13 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="person_1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Image\person_1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -9,7 +9,7 @@
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<materialDesign:Chip HorizontalAlignment="Stretch">
|
||||
<materialDesign:Chip.Icon>
|
||||
<Image Name="Image1" />
|
||||
<Image Name="Image1"/>
|
||||
</materialDesign:Chip.Icon>
|
||||
<materialDesign:Chip.Content>
|
||||
<Grid>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using CommonLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -28,12 +29,20 @@ namespace 软件系统客户端Wpf.Views.Controls
|
||||
}
|
||||
|
||||
|
||||
public string UniqueId
|
||||
{
|
||||
get
|
||||
{
|
||||
return netAccount == null ? string.Empty : netAccount.UniqueId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetClientRender(NetAccount account)
|
||||
{
|
||||
if (account != null)
|
||||
{
|
||||
netAccount = account;
|
||||
UserName.Text = string.IsNullOrEmpty(account.Alias) ? account.UserName : account.Alias;
|
||||
Factory.Text = $"({account.Factory})";
|
||||
|
||||
@@ -63,7 +72,13 @@ namespace 软件系统客户端Wpf.Views.Controls
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void UpdatePortrait(string userName)
|
||||
{
|
||||
if(netAccount?.UserName == userName)
|
||||
{
|
||||
System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadPoolLoadPortrait), netAccount);
|
||||
}
|
||||
}
|
||||
private void ThreadPoolLoadPortrait(object obj)
|
||||
{
|
||||
// 向服务器请求小头像
|
||||
@@ -71,31 +86,19 @@ namespace 软件系统客户端Wpf.Views.Controls
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
||||
System.Drawing.Bitmap bitmap = UserPortrait.DownloadSmallPortraint(m_NetAccount.UserName);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
bitmap.Save(ms, bitmap.RawFormat);
|
||||
bitmap.Dispose();
|
||||
|
||||
HslCommunication.OperateResult result = UserClient.Net_File_Client.DownloadFile(
|
||||
PortraitSupport.SmallPortrait,
|
||||
"Files",
|
||||
"Portrait",
|
||||
m_NetAccount.UserName,
|
||||
null,
|
||||
ms
|
||||
);
|
||||
if (result.IsSuccess)
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
BitmapImage bi = new BitmapImage();
|
||||
bi.BeginInit();
|
||||
bi.StreamSource = ms;
|
||||
bi.EndInit();
|
||||
Image1.Source = bi;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(result.Message);
|
||||
}
|
||||
BitmapImage bi = new BitmapImage();
|
||||
bi.BeginInit();
|
||||
bi.StreamSource = ms;
|
||||
bi.EndInit();
|
||||
Image1.Source = bi;
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -103,5 +106,8 @@ namespace 软件系统客户端Wpf.Views.Controls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private NetAccount netAccount = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 105 KiB |
@@ -172,6 +172,8 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<None Include="Image\person_1.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||