diff --git a/chatclient/Data/ChatDataModel.cs b/chatclient/Data/ChatDataModel.cs
index 27b02d2..255987a 100644
--- a/chatclient/Data/ChatDataModel.cs
+++ b/chatclient/Data/ChatDataModel.cs
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Imaging;
+using System.Windows.Controls;
+using System.Windows.Input;
namespace chatclient.Data
{
@@ -21,7 +23,7 @@ namespace chatclient.Data
///
/// 消息类型(文本、图片、文件、系统消息等)
///
- public required MessageType Type { get; set; } = MessageType.Text;
+ public required MessageType MsgType { get; set; } = MessageType.Text;
///
/// 消息发送者的头像图片
///
diff --git a/chatclient/Data/TrayIconManager.cs b/chatclient/Data/TrayIconManager.cs
index b4207c7..a0c34ca 100644
--- a/chatclient/Data/TrayIconManager.cs
+++ b/chatclient/Data/TrayIconManager.cs
@@ -51,13 +51,13 @@ namespace chatclient.Data
};
// 添加菜单项
- contextMenu.Items.Add(CreateMenuItem("Open Application", PackIconKind.WindowRestore, OpenApp_Click));
- contextMenu.Items.Add(CreateMenuItem("Settings", PackIconKind.Cog, Settings_Click));
+ contextMenu.Items.Add(CreateMenuItem("打开程序", PackIconKind.WindowRestore, OpenApp_Click));
+ contextMenu.Items.Add(CreateMenuItem("设置", PackIconKind.Cog, Settings_Click));
contextMenu.Items.Add(new Separator { Style = (Style)Application.Current.Resources["MaterialDesignLightSeparator"] });
- contextMenu.Items.Add(CreateMenuItem("Check for Updates", PackIconKind.Update, Updates_Click));
- contextMenu.Items.Add(CreateMenuItem("Help", PackIconKind.HelpCircle, Help_Click));
- contextMenu.Items.Add(new Separator { Style = (Style)Application.Current.Resources["MaterialDesignLightSeparator"] });
- contextMenu.Items.Add(CreateMenuItem("Exit", PackIconKind.Power, Exit_Click));
+ //contextMenu.Items.Add(CreateMenuItem("Check for Updates", PackIconKind.Update, Updates_Click));
+ //contextMenu.Items.Add(CreateMenuItem("Help", PackIconKind.HelpCircle, Help_Click));
+ //contextMenu.Items.Add(new Separator { Style = (Style)Application.Current.Resources["MaterialDesignLightSeparator"] });
+ contextMenu.Items.Add(CreateMenuItem("退出", PackIconKind.Power, Exit_Click));
return contextMenu;
}
@@ -109,7 +109,6 @@ namespace chatclient.Data
private void Exit_Click(object sender, RoutedEventArgs e)
{
- // 释放托盘图标资源
Dispose();
Application.Current.Shutdown();
}
diff --git a/chatclient/LoginWindow.xaml b/chatclient/LoginWindow.xaml
index eeaa12e..61fab8c 100644
--- a/chatclient/LoginWindow.xaml
+++ b/chatclient/LoginWindow.xaml
@@ -7,7 +7,7 @@
xmlns:local="clr-namespace:chatclient"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" x:Class="chatclient.LoginWindow"
mc:Ignorable="d"
- Title="LoginWindow" Height="590" Width="360" MinHeight="590" MinWidth="360" MaxHeight="590" MaxWidth="360"
+ Title="LoginWindow" Height="590" Width="330" MinHeight="590" MinWidth="330" MaxHeight="590" MaxWidth="330"
ResizeMode="NoResize" Closing="Window_Closing">
diff --git a/chatclient/MainWindow.xaml b/chatclient/MainWindow.xaml
index af3ebf5..cce7b90 100644
--- a/chatclient/MainWindow.xaml
+++ b/chatclient/MainWindow.xaml
@@ -80,9 +80,9 @@
-
-
-
+
+
+
@@ -96,6 +96,12 @@
+
+
+
+
+
+
@@ -119,7 +125,7 @@
+ TextWrapping="Wrap" MinHeight="50" MaxHeight="100" Margin="5" BorderBrush="#00000000" CaretBrush="#00673AB7" SelectionBrush="#00B39DDB"/>
diff --git a/chatclient/MainWindow.xaml.cs b/chatclient/MainWindow.xaml.cs
index 34bef44..1c252b4 100644
--- a/chatclient/MainWindow.xaml.cs
+++ b/chatclient/MainWindow.xaml.cs
@@ -149,6 +149,17 @@ namespace chatclient
var loginWindow = Application.Current.Windows.OfType().FirstOrDefault();
loginWindow?.Close();
mainWindow.Activate();
+ var chatmessage = new ChatMessage
+ {
+ Sender = "System",
+ MsgType = MessageType.System,
+ Image = new BitmapImage(new Uri("pack://application:,,,/resource/user.png")),
+ Content = $"你好 {UserName} !",
+ Timestamp = DateTime.Now,
+ Alignment = HorizontalAlignment.Center,
+ SenderColor = new SolidColorBrush(Colors.Gray)
+ };
+ mainWindow?.Messages.Add(chatmessage);
}
});
log.Info($"用户 {UserName} 登录成功(token:{token})");
@@ -190,7 +201,7 @@ namespace chatclient
var chatmessage = new ChatMessage
{
Sender = chat.user ?? "未知用户",
- Type = MessageType.Text,
+ MsgType = MessageType.Text,
Image = new BitmapImage(new Uri(chat.image ?? "pack://application:,,,/resource/user.png", UriKind.Absolute)),
Content = chat.message ?? "(无内容)",
Timestamp = DateTime.Now,
@@ -205,7 +216,7 @@ namespace chatclient
var chatmessage = new ChatMessage
{
Sender = chat.user ?? "未知用户",
- Type = MessageType.Text,
+ MsgType = MessageType.Text,
Image = new BitmapImage(new Uri(chat.image ?? "pack://application:,,,/resource/user.png", UriKind.Absolute)),
Content = chat.message ?? "(无内容)",
Timestamp = chat.timestamp,
@@ -215,7 +226,6 @@ namespace chatclient
var mainWindow = Application.Current.Windows.OfType().FirstOrDefault();
mainWindow?.Messages.Add(chatmessage);
}
-
});
}
else