Преглед на файлове

转换器 - 添加bool值转换成相反值

chenrongqian преди 2 години
родител
ревизия
7ef1ac86e6
променени са 2 файла, в които са добавени 39 реда и са изтрити 0 реда
  1. 38 0
      PDF Office/DataConvert/InvertBoolConvert.cs
  2. 1 0
      PDF Office/PDF Office.csproj

+ 38 - 0
PDF Office/DataConvert/InvertBoolConvert.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace PDF_Office.DataConvert
+{
+    public class InvertBoolConvert : IValueConverter
+    {
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value is bool)
+            {
+                if ((bool)value)
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            }
+            else
+            {
+                return false;
+            }
+
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 1 - 0
PDF Office/PDF Office.csproj

@@ -218,6 +218,7 @@
       <DependentUpon>WritableComboBox.xaml</DependentUpon>
     </Compile>
     <Compile Include="DataConvert\FileFormatToIconConvert.cs" />
+    <Compile Include="DataConvert\InvertBoolConvert.cs" />
     <Compile Include="DataConvert\ObjectConvert.cs" />
     <Compile Include="DataConvert\PropertyPanelVisible.cs" />
     <Compile Include="DataConvert\StringToVisibleConvert.cs" />