diff --git a/src/WCTDataMiner.Wpf/App.xaml b/src/WCTDataMiner.Wpf/App.xaml index ebfa722..5e2c2cf 100644 --- a/src/WCTDataMiner.Wpf/App.xaml +++ b/src/WCTDataMiner.Wpf/App.xaml @@ -1,8 +1,10 @@ + xmlns:local="clr-namespace:WCTDataMiner.Wpf" + xmlns:converters="clr-namespace:WCTDataMiner.Wpf.Converters"> - + + \ No newline at end of file diff --git a/src/WCTDataMiner.Wpf/App.xaml.cs b/src/WCTDataMiner.Wpf/App.xaml.cs index be0ab14..d4fbc2b 100644 --- a/src/WCTDataMiner.Wpf/App.xaml.cs +++ b/src/WCTDataMiner.Wpf/App.xaml.cs @@ -29,12 +29,14 @@ public partial class App : Application services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); // 注册 Views services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); }) .Build(); diff --git a/src/WCTDataMiner.Wpf/Converters/BooleanConverters.cs b/src/WCTDataMiner.Wpf/Converters/BooleanConverters.cs new file mode 100644 index 0000000..582319d --- /dev/null +++ b/src/WCTDataMiner.Wpf/Converters/BooleanConverters.cs @@ -0,0 +1,53 @@ +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace WCTDataMiner.Wpf.Converters; + +/// +/// Boolean to Visibility 转换器 +/// +public class BooleanToVisibilityConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool boolValue) + { + return boolValue ? Visibility.Visible : Visibility.Collapsed; + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is Visibility visibility) + { + return visibility == Visibility.Visible; + } + return false; + } +} + +/// +/// 反转 Boolean 转换器 +/// +public class InverseBooleanConverter : IValueConverter +{ + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool boolValue) + { + return !boolValue; + } + return true; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool boolValue) + { + return !boolValue; + } + return false; + } +} \ No newline at end of file diff --git a/src/WCTDataMiner.Wpf/MainWindow.xaml b/src/WCTDataMiner.Wpf/MainWindow.xaml index a7f7e16..64e3b8b 100644 --- a/src/WCTDataMiner.Wpf/MainWindow.xaml +++ b/src/WCTDataMiner.Wpf/MainWindow.xaml @@ -3,16 +3,11 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:WCTDataMiner.Wpf" xmlns:views="clr-namespace:WCTDataMiner.Wpf.Views" xmlns:viewmodels="clr-namespace:WCTDataMiner.Wpf.ViewModels" - xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF" mc:Ignorable="d" Title="WCTDataMiner - FOD 数据分析工具" Height="600" Width="900" WindowStartupLocation="CenterScreen"> - - - @@ -25,6 +20,10 @@ +