diff --git a/HFUTCourseSimulation/Dialog/Simulator.xaml.cs b/HFUTCourseSimulation/Dialog/Simulator.xaml.cs index 743ac7a..73f6dad 100644 --- a/HFUTCourseSimulation/Dialog/Simulator.xaml.cs +++ b/HFUTCourseSimulation/Dialog/Simulator.xaml.cs @@ -159,6 +159,7 @@ namespace HFUTCourseSimulation.Dialog { var courseNameLabel = new TextBlock(); courseNameLabel.Text = lesson.name; + courseNameLabel.TextWrapping = TextWrapping.Wrap; courseNameLabel.Foreground = new SolidColorBrush(lesson.color.Foreground); courseNameLabel.HorizontalAlignment = HorizontalAlignment.Left; courseNameLabel.VerticalAlignment = VerticalAlignment.Center; diff --git a/HFUTCourseSimulation/HFUTCourseSimulation.csproj b/HFUTCourseSimulation/HFUTCourseSimulation.csproj index 32f71fc..61ba82e 100644 --- a/HFUTCourseSimulation/HFUTCourseSimulation.csproj +++ b/HFUTCourseSimulation/HFUTCourseSimulation.csproj @@ -94,6 +94,7 @@ + diff --git a/HFUTCourseSimulation/Util/ColorConsistency.cs b/HFUTCourseSimulation/Util/ColorConsistency.cs index 109d71a..fc82504 100644 --- a/HFUTCourseSimulation/Util/ColorConsistency.cs +++ b/HFUTCourseSimulation/Util/ColorConsistency.cs @@ -15,7 +15,7 @@ namespace HFUTCourseSimulation.Util { /// /// UI界面的背景色(白天或夜晚(然而没有实现,现在全是白天模式)) /// - public static ColorPair Backboard = new ColorPair(Colors.Black, Colors.White); + public static ColorPair Backboard => new ColorPair(Colors.Black, Colors.White); //public static ColorPair Backboard = new ColorPair(Colors.White, Colors.Black); /// @@ -48,6 +48,11 @@ namespace HFUTCourseSimulation.Util { /// public static Color ChessboardColor => Color.FromArgb(20, 127, 127, 127); + + public static ColorPair InfoColor => new ColorPair(Colors.Black, Colors.White); + public static ColorPair WarningColor => ColorPreset.MdColors.Amber; + public static ColorPair ErrorColor => ColorPreset.MdColors.Red; + } } diff --git a/HFUTCourseSimulation/Util/WpfValueConv.cs b/HFUTCourseSimulation/Util/WpfValueConv.cs new file mode 100644 index 0000000..21fb773 --- /dev/null +++ b/HFUTCourseSimulation/Util/WpfValueConv.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace HFUTCourseSimulation.Util.WpfValueConv { + + [ValueConversion(typeof(bool), typeof(Visibility))] + public class EnableToVisibility : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + var v = (bool)value; + return v ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotImplementedException(); + } + } + + [ValueConversion(typeof(Kernel.ReporterKind), typeof(Color))] + public class MsgKindToForegroundColor : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + var v = (Kernel.ReporterKind)value; + switch (v) { + case Kernel.ReporterKind.Info: + return ColorConsistency.InfoColor.Foreground; + case Kernel.ReporterKind.Warning: + return ColorConsistency.WarningColor.Foreground; + case Kernel.ReporterKind.Error: + return ColorConsistency.ErrorColor.Foreground; + default: + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotImplementedException(); + } + } + + [ValueConversion(typeof(Kernel.ReporterKind), typeof(Color))] + public class MsgKindToBackgroundColor : IValueConverter { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + var v = (Kernel.ReporterKind)value; + switch (v) { + case Kernel.ReporterKind.Info: + return ColorConsistency.InfoColor.Background; + case Kernel.ReporterKind.Warning: + return ColorConsistency.WarningColor.Background; + case Kernel.ReporterKind.Error: + return ColorConsistency.ErrorColor.Background; + default: + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotImplementedException(); + } + } + + [ValueConversion(typeof(Kernel.ReporterKind), typeof(BitmapSource))] + public class MsgKindToIcon : IValueConverter { + private static BitmapSource CreateWpfSystemIcon(System.Drawing.Icon icon) { + return Imaging.CreateBitmapSourceFromHIcon( + icon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); + } + private static readonly BitmapSource InfoIcon = CreateWpfSystemIcon(System.Drawing.SystemIcons.Information); + private static readonly BitmapSource WarningIcon = CreateWpfSystemIcon(System.Drawing.SystemIcons.Warning); + private static readonly BitmapSource ErrorIcon = CreateWpfSystemIcon(System.Drawing.SystemIcons.Error); + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { + var v = (Kernel.ReporterKind)value; + switch (v) { + case Kernel.ReporterKind.Info: + return InfoIcon; + case Kernel.ReporterKind.Warning: + return WarningIcon; + case Kernel.ReporterKind.Error: + return ErrorIcon; + default: + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { + throw new NotImplementedException(); + } + } + +} diff --git a/HFUTCourseSimulation/Widget/LogChecker.xaml b/HFUTCourseSimulation/Widget/LogChecker.xaml index 636c988..9f1ec11 100644 --- a/HFUTCourseSimulation/Widget/LogChecker.xaml +++ b/HFUTCourseSimulation/Widget/LogChecker.xaml @@ -5,9 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:HFUTCourseSimulation.Widget" xmlns:uidata="clr-namespace:HFUTCourseSimulation.Kernel" + xmlns:converter="clr-namespace:HFUTCourseSimulation.Util.WpfValueConv" mc:Ignorable="d" x:Name="uiMainWindow" Title="检查器日志" Height="500" Width="400" WindowStyle="ToolWindow" Closed="uiMainWindow_Closed" Loaded="uiMainWindow_Loaded"> + + + + @@ -26,7 +31,12 @@ - + + + + + +