Browse Source

Indeterminate checkbox status #157

Ruben 7 tháng trước cách đây
mục cha
commit
9c68c4a376

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 23
src/PicView.Avalonia/Views/FileAssociationsView.axaml


+ 8 - 7
src/PicView.Avalonia/Views/FileAssociationsView.axaml.cs

@@ -19,12 +19,12 @@ public partial class FileAssociationsView : UserControl
     {
         InitializeComponent();
 
-        Loaded += delegate
+        AttachedToVisualTree += delegate
         {
             FilterBox.TextChanged += FilterBox_TextChanged;
             
             // Setup binding for the buttons
-            SelectAllButton.Click += (s, e) =>
+            SelectAllButton.Click += delegate
             {
                 foreach (var checkBox in FileTypesContainer.Children.OfType<CheckBox>())
                 {
@@ -36,7 +36,7 @@ public partial class FileAssociationsView : UserControl
                     var tag = checkBox.Tag?.ToString();
                     if (tag.StartsWith(".zip") || tag.StartsWith(".rar") || tag.StartsWith(".7z") || tag.StartsWith(".gzip")) 
                     {
-                        checkBox.IsChecked = false;
+                        checkBox.IsChecked = null;
                     }
                     else
                     {
@@ -46,13 +46,13 @@ public partial class FileAssociationsView : UserControl
                 }
             };
             
-            UnSelectAllButton.Click += (s, e) =>
+            UnSelectAllButton.Click += delegate
             {
                 foreach (var checkBox in FileTypesContainer.Children.OfType<CheckBox>())
                 {
                     if (checkBox is not null)
                     {
-                        checkBox.IsChecked = false;
+                        checkBox.IsChecked = null;
                     }
                 }
             };
@@ -125,7 +125,7 @@ public partial class FileAssociationsView : UserControl
             _allCheckBoxes.Add((groupCheckBox, fileTypeGroup.Name));
                 
             // Handle group checkbox changes to update all items in the group
-            groupCheckBox.IsCheckedChanged += (s, e) =>
+            groupCheckBox.IsCheckedChanged += delegate
             {
                 var isChecked = groupCheckBox.IsChecked;
                 if (!isChecked.HasValue)
@@ -148,6 +148,7 @@ public partial class FileAssociationsView : UserControl
                     Classes = { "altHover", "x" },
                     Tag = fileType.Extension,
                     IsChecked = fileType.IsSelected,
+                    IsThreeState = true
                 };
                     
                 var fileTextBlock = new TextBlock
@@ -167,7 +168,7 @@ public partial class FileAssociationsView : UserControl
                 _allCheckBoxes.Add((fileCheckBox, $"{fileType.Description} {fileType.Extension}"));
                     
                 // Bind the checkbox to the file type's IsSelected property
-                fileCheckBox.IsCheckedChanged += (s, e) =>
+                fileCheckBox.IsCheckedChanged += delegate
                 {
                     if (fileCheckBox.IsChecked.HasValue)
                     {

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác