diff --git a/chatclient/App.xaml b/chatclient/App.xaml index 768ad24..eed1546 100644 --- a/chatclient/App.xaml +++ b/chatclient/App.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:chatclient" + xmlns:data="clr-namespace:chatclient.Data" StartupUri="MainWindow.xaml"> diff --git a/chatclient/Data/ChatDataModel.cs b/chatclient/Data/ChatDataModel.cs index af99423..69dbf2c 100644 --- a/chatclient/Data/ChatDataModel.cs +++ b/chatclient/Data/ChatDataModel.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media; +using System.Windows.Media; using System.Windows; using System.Windows.Media.Imaging; -using System.Windows.Controls; -using System.Windows.Input; using System.Globalization; using System.Windows.Data; @@ -62,9 +55,6 @@ namespace chatclient.Data public string? UserName { get; set; } public string? UserPassword { get; set; } } - /// - /// 时间格式转换器类 - /// public class TimeFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) @@ -81,7 +71,6 @@ namespace chatclient.Data } else if (timestamp.Kind == DateTimeKind.Unspecified) { - // 假设未指定时间是UTC时间(常见实践) localTime = DateTime.SpecifyKind(timestamp, DateTimeKind.Utc).ToLocalTime(); } else @@ -127,7 +116,15 @@ namespace chatclient.Data } return value; } - + /// + /// 将格式化的时间字符串转换回DateTime对象 + /// + /// + /// + /// + /// + /// + /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); diff --git a/chatclient/MainWindow.xaml b/chatclient/MainWindow.xaml index a81236f..144a7c0 100644 --- a/chatclient/MainWindow.xaml +++ b/chatclient/MainWindow.xaml @@ -10,6 +10,9 @@ mc:Ignorable="d" Title="ChatWindow" Height="450" Width="800" MinHeight="240" MinWidth="380" Style="{StaticResource MaterialDesignWindow}" Closed="MainWindow_Closed" Loaded="MainWindow_Loaded"> + + +