From 9092fe6ec7a75142fb1d14cfae0ee4b8e7c125d1 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Sat, 13 Jul 2024 14:56:37 +0800
Subject: [PATCH 1/9] fix: memory leak of some controls. (#1482)
---
.../Controls/ImageBrowserDemoCtl.xaml | 2 +-
.../Controls/ImageBrowserDemoCtl.xaml.cs | 9 ++++++-
.../Controls/Image/ImageViewer.cs | 25 ++++++++++++++++++-
.../Controls/Window/ImageBrowser.cs | 7 ++++++
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
index f39b909f9..e7249c995 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
@@ -8,7 +8,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
index f76998021..57416c6a8 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
@@ -1,10 +1,17 @@
+using System;
+
namespace HandyControlDemo.UserControl;
-public partial class ImageBrowserDemoCtl
+public partial class ImageBrowserDemoCtl : IDisposable
{
public ImageBrowserDemoCtl()
{
InitializeComponent();
}
+
+ public void Dispose()
+ {
+ ImageViewerDemo.Dispose();
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
index 8865004de..f6ef284a1 100644
--- a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
@@ -23,7 +23,7 @@ namespace HandyControl.Controls;
[TemplatePart(Name = ElementBorderMove, Type = typeof(Border))]
[TemplatePart(Name = ElementBorderBottom, Type = typeof(Border))]
[TemplatePart(Name = ElementImageMain, Type = typeof(Image))]
-public class ImageViewer : Control
+public class ImageViewer : Control, IDisposable
{
#region Constants
@@ -167,6 +167,8 @@ public class ImageViewer : Control
private ImageBrowser _imageBrowser;
+ private bool _isDisposed;
+
#endregion Data
#region ctor
@@ -989,4 +991,25 @@ static BitmapFrame GetBitmapFrame(Uri source)
}
}
}
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_isDisposed)
+ {
+ if (disposing)
+ {
+ ImageSource = null;
+ _imageMain.Source = null;
+ _imageMain.UpdateLayout();
+ }
+
+ _isDisposed = true;
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs b/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs
index c9039cbd6..92ecc955c 100644
--- a/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Window/ImageBrowser.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
@@ -110,6 +111,12 @@ public override void OnApplyTemplate()
}
}
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ _imageViewer?.Dispose();
+ base.OnClosing(e);
+ }
+
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
private void PanelTopOnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
From adb63558848d156554ee12e79b440de75e3de7ac Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Sat, 13 Jul 2024 17:59:42 +0800
Subject: [PATCH 2/9] enhance: add IsReadOnly property for CheckComboBox.
---
.../Styles/Base/CheckComboBoxBaseStyle.xaml | 15 +-
.../Themes/Styles/Window.xaml | 97 +++----
.../HandyControl_Net_40/Themes/Theme.xaml | 19 +-
.../Controls/CheckComboBoxDemoCtl.xaml | 8 +-
.../Common/InputElementDemoViewModel.cs | 13 +
.../Input/CheckComboBox/CheckComboBox.cs | 33 ++-
.../Styles/Base/CheckComboBoxBaseStyle.xaml | 23 +-
.../Themes/Styles/CheckComboBox.xaml | 3 +-
.../Themes/Styles/Window.xaml | 242 +++++++++---------
.../HandyControl_Shared/Themes/Theme.xaml | 19 +-
10 files changed, 262 insertions(+), 210 deletions(-)
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
index 0c4eaec8f..49f70524d 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/CheckComboBoxBaseStyle.xaml
@@ -7,8 +7,9 @@
xmlns:langs="clr-namespace:HandyControl.Properties.Langs">
@@ -190,6 +190,7 @@
+
@@ -248,21 +249,21 @@
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
index ecb8e7453..16f2e9797 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
@@ -4911,6 +4911,7 @@
+
@@ -7261,8 +7262,9 @@
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -153,23 +153,23 @@
-
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
@@ -199,47 +199,47 @@
-
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
@@ -248,82 +248,82 @@
diff --git a/src/Shared/HandyControl_Shared/Themes/Theme.xaml b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
index aa6132b21..eddbafd10 100644
--- a/src/Shared/HandyControl_Shared/Themes/Theme.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Theme.xaml
@@ -4911,6 +4911,7 @@
+
@@ -7345,8 +7346,9 @@
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Button.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Button.axaml
index dfb8ebed4..59670c001 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Button.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Button.axaml
@@ -1,102 +1,141 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
+
-
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ContentControl.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ContentControl.axaml
index 229114f9a..3676da9e9 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ContentControl.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ContentControl.axaml
@@ -1,19 +1,19 @@
-
+
-
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ItemsControl.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ItemsControl.axaml
new file mode 100644
index 000000000..8860b0829
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ItemsControl.axaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBox.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBox.axaml
new file mode 100644
index 000000000..b84bd017b
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBox.axaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBoxItem.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBoxItem.axaml
new file mode 100644
index 000000000..471b18671
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ListBoxItem.axaml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollBar.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollBar.axaml
new file mode 100644
index 000000000..0a7da509d
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollBar.axaml
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollViewer.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollViewer.axaml
new file mode 100644
index 000000000..2e327235b
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/ScrollViewer.axaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml
index c3b84f020..d45e0da78 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Style.axaml
@@ -1,17 +1,27 @@
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabControl.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabControl.axaml
new file mode 100644
index 000000000..5ff351a6b
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabControl.axaml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabItem.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabItem.axaml
new file mode 100644
index 000000000..533f67cdc
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/TabItem.axaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/UserControl.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/UserControl.axaml
index 619491302..8c2c431bc 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/UserControl.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/UserControl.axaml
@@ -1,19 +1,19 @@
-
+
-
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Window.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Window.axaml
index 9de37a332..6cde86101 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Window.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Window.axaml
@@ -1,31 +1,40 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
+
+
+
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml b/src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml
index 13ee12e2a..50ec525c0 100644
--- a/src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml
+++ b/src/Avalonia/HandyControl_Avalonia/Themes/Theme.axaml
@@ -4,11 +4,11 @@
-
+
-
-
+
+
diff --git a/src/Avalonia/HandyControl_Avalonia/Tools/Converter/BorderClipConverter.cs b/src/Avalonia/HandyControl_Avalonia/Tools/Converter/BorderClipConverter.cs
new file mode 100644
index 000000000..0c79f5da3
--- /dev/null
+++ b/src/Avalonia/HandyControl_Avalonia/Tools/Converter/BorderClipConverter.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using Avalonia;
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+
+namespace HandyControl.Tools.Converter;
+
+public class BorderClipConverter : IMultiValueConverter
+{
+ private static readonly Geometry Empty = new StreamGeometry();
+
+ public object Convert(IList