From 9f181c57d596938e9abc57469652920b5f5f8e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sun, 10 Mar 2024 23:15:28 +0800 Subject: [PATCH 001/103] update in AnimationNavigationBar3D update in AnimationNavigationBar3D --- .../AnimationNavigationBar3D.cs | 19 ++----- .../AnimationNavigationBar3DItem.cs | 56 ++++++------------- .../Core/Helpers/ControlsHelper.cs | 20 +++++++ .../Themes/AnimationNavigationBar3D.xaml | 46 +++++++-------- 4 files changed, 66 insertions(+), 75 deletions(-) diff --git a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs index 48ce751c..9a60824f 100644 --- a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs +++ b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3D.cs @@ -3,29 +3,20 @@ namespace WPFDevelopers.Controls { - public class AnimationNavigationBar3D : ItemsControl + public class AnimationNavigationBar3D : ListBox { - public static readonly DependencyProperty ColumnsProperty = - DependencyProperty.Register("Columns", typeof(int), typeof(AnimationNavigationBar3D), - new PropertyMetadata(null)); - static AnimationNavigationBar3D() { DefaultStyleKeyProperty.OverrideMetadata(typeof(AnimationNavigationBar3D), new FrameworkPropertyMetadata(typeof(AnimationNavigationBar3D))); } - - - public int Columns + protected override bool IsItemItsOwnContainerOverride(object item) { - get => (int)GetValue(ColumnsProperty); - set => SetValue(ColumnsProperty, value); + return item is AnimationNavigationBar3DItem; } - - public override void OnApplyTemplate() + protected override DependencyObject GetContainerForItemOverride() { - base.OnApplyTemplate(); - Columns = Items.Count; + return new AnimationNavigationBar3DItem(); } } } \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs index d717cbad..dd1444d0 100644 --- a/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs +++ b/src/WPFDevelopers.Shared/Controls/AnimationNavigationBar3D/AnimationNavigationBar3DItem.cs @@ -1,69 +1,49 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using WPFDevelopers.Helpers; namespace WPFDevelopers.Controls { - public class AnimationNavigationBar3DItem : Control + public class AnimationNavigationBar3DItem : ListBoxItem { - public static readonly DependencyProperty FileBackgroundProperty = - DependencyProperty.Register("FileBackground", typeof(Brush), typeof(AnimationNavigationBar3DItem), + public static readonly DependencyProperty FillProperty = + DependencyProperty.Register("Fill", typeof(Brush), typeof(AnimationNavigationBar3DItem), new PropertyMetadata(null)); - public static readonly DependencyProperty BackFileBackgroundProperty = - DependencyProperty.Register("BackFileBackground", typeof(Brush), typeof(AnimationNavigationBar3DItem), + public static readonly DependencyProperty ContentBackProperty = + DependencyProperty.Register("ContentBack", typeof(object), typeof(AnimationNavigationBar3DItem), new PropertyMetadata(null)); - public static readonly DependencyProperty PathDateProperty = - DependencyProperty.Register("PathDate", typeof(Geometry), typeof(AnimationNavigationBar3DItem), - new PropertyMetadata()); - - public static readonly DependencyProperty TextProperty = - DependencyProperty.Register("Text", typeof(string), typeof(AnimationNavigationBar3DItem), - new PropertyMetadata()); - static AnimationNavigationBar3DItem() { DefaultStyleKeyProperty.OverrideMetadata(typeof(AnimationNavigationBar3DItem), new FrameworkPropertyMetadata(typeof(AnimationNavigationBar3DItem))); } - /// - /// 默认颜色 - /// - public Brush FileBackground + public override void OnApplyTemplate() { - get => (Brush)GetValue(FileBackgroundProperty); - set => SetValue(FileBackgroundProperty, value); + base.OnApplyTemplate(); + if (ContentBack == null) + ContentBack = ControlsHelper.GetXmlReader(Content); } /// - /// 背面颜色 + /// Color fore /// - public Brush BackFileBackground + public Brush Fill { - get => (Brush)GetValue(BackFileBackgroundProperty); - set => SetValue(BackFileBackgroundProperty, value); + get => (Brush)GetValue(FillProperty); + set => SetValue(FillProperty, value); } - - /// - /// 设置PathData - /// - public Geometry PathDate - { - get => (Geometry)GetValue(PathDateProperty); - set => SetValue(PathDateProperty, value); - } - - /// - /// 文本显示内容 + /// The content after the mouse is moved in /// - public string Text + public object ContentBack { - get => (string)GetValue(TextProperty); - set => SetValue(TextProperty, value); + get => (object)GetValue(ContentBackProperty); + set => SetValue(ContentBackProperty, value); } } } \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs index 524012af..601604c4 100644 --- a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs +++ b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs @@ -8,9 +8,11 @@ using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Interop; +using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using System.Xml; namespace WPFDevelopers.Helpers { @@ -215,6 +217,24 @@ public static T FindVisualChild(DependencyObject parent) where T : Dependency return null; } + public static object GetXmlReader(object Content) + { + var originalContent = Content as UIElement; + string contentXaml = XamlWriter.Save(originalContent); + using (StringReader stringReader = new StringReader(contentXaml)) + { + using (XmlReader xmlReader = XmlReader.Create(stringReader)) + { + object clonedContent = XamlReader.Load(xmlReader); + + if (clonedContent is UIElement clonedElement) + { + return clonedElement; + } + } + } + return null; + } } diff --git a/src/WPFDevelopers.Shared/Themes/AnimationNavigationBar3D.xaml b/src/WPFDevelopers.Shared/Themes/AnimationNavigationBar3D.xaml index a18d9c66..6c837b39 100644 --- a/src/WPFDevelopers.Shared/Themes/AnimationNavigationBar3D.xaml +++ b/src/WPFDevelopers.Shared/Themes/AnimationNavigationBar3D.xaml @@ -6,12 +6,16 @@ + + + - - - + - + - + - + - + - + From eb46895a940076e2a73589d603511c5c4a7a7ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sun, 24 Mar 2024 21:03:42 +0800 Subject: [PATCH 009/103] Add basic controls to support rounded corners Add basic controls to support rounded corners --- .../BaseControls/SliderRepeatButton.cs | 32 ++++++++++ .../CornerRadiusToSurroundConverter.cs | 63 +++++++++++++++++++ .../Converts/WidthHeightToRectConverter.cs | 21 +++++++ .../WPFDevelopers.Shared.projitems | 3 + 4 files changed, 119 insertions(+) create mode 100644 src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs create mode 100644 src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs create mode 100644 src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs diff --git a/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs b/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs new file mode 100644 index 00000000..fd744614 --- /dev/null +++ b/src/WPFDevelopers.Shared/Controls/BaseControls/SliderRepeatButton.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; + +namespace WPFDevelopers.Controls +{ + public class SliderRepeatButton: RepeatButton + { + public RadiusOrientation RadiusOrientation + { + get { return (RadiusOrientation)GetValue(RadiusOrientationProperty); } + set { SetValue(RadiusOrientationProperty, value); } + } + + public static readonly DependencyProperty RadiusOrientationProperty = + DependencyProperty.Register("RadiusOrientation", typeof(RadiusOrientation), typeof(SliderRepeatButton), new PropertyMetadata(null)); + + } + + [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] + public enum RadiusOrientation + { + Down = ExpandDirection.Down, + Up = ExpandDirection.Up, + Left = ExpandDirection.Left, + Right = ExpandDirection.Right, + TopLeft, + TopRight, + BottomRight, + BottomLeft + } +} diff --git a/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs new file mode 100644 index 00000000..aff165bc --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Converts/CornerRadiusToSurroundConverter.cs @@ -0,0 +1,63 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using WPFDevelopers.Controls; + +namespace WPFDevelopers.Converts +{ + public class CornerRadiusToSurroundConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is CornerRadius cornerRadius && parameter != null) + { + if (cornerRadius != new CornerRadius(0)) + { + CornerRadius _cornerRadius = cornerRadius; + RadiusOrientation _radiusOrientation; + if (Enum.TryParse(parameter.ToString(), out _radiusOrientation)) + { + switch (_radiusOrientation) + { + case RadiusOrientation.Down: + _cornerRadius.BottomRight = 0; + _cornerRadius.BottomLeft = 0; + break; + case RadiusOrientation.Up: + _cornerRadius.TopLeft = 0; + _cornerRadius.TopRight = 0; + break; + case RadiusOrientation.Left: + _cornerRadius.TopLeft = 0; + _cornerRadius.BottomLeft = 0; + break; + case RadiusOrientation.Right: + _cornerRadius.TopRight = 0; + _cornerRadius.BottomRight = 0; + break; + case RadiusOrientation.TopLeft: + _cornerRadius.TopRight = 0; + _cornerRadius.BottomRight = 0; + _cornerRadius.BottomLeft = 0; + break; + case RadiusOrientation.TopRight: + _cornerRadius.TopLeft = 0; + _cornerRadius.BottomRight = 0; + _cornerRadius.BottomLeft = 0; + break; + } + } + return _cornerRadius; + } + } + return DependencyProperty.UnsetValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + +} diff --git a/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs new file mode 100644 index 00000000..cca9f677 --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Converts/WidthHeightToRectConverter.cs @@ -0,0 +1,21 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace WPFDevelopers.Converts +{ + public class WidthHeightToRectConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length == 2 && values[0] is double width && values[1] is double height) + return new System.Windows.Rect(0, 0, width, height); + return Binding.DoNothing; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems index ac8b3ddf..7369bc90 100644 --- a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems +++ b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems @@ -9,6 +9,7 @@ WPFDevelopers + @@ -37,12 +38,14 @@ + + From fa5bce881d5ca9b2992bd551212381450751dc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sun, 24 Mar 2024 21:03:51 +0800 Subject: [PATCH 010/103] Update Styles.DataGrid.xaml --- .../Styles/Styles.DataGrid.xaml | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml b/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml index 04e107c6..1d8c5a33 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.DataGrid.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:WPFDevelopers.Controls" xmlns:converts="clr-namespace:WPFDevelopers.Converts" + xmlns:helpers="clr-namespace:WPFDevelopers.Helpers" xmlns:sys="clr-namespace:System;assembly=mscorlib"> @@ -38,14 +39,6 @@ - - - - - - - - @@ -62,7 +55,7 @@ BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type DataGrid}"> - + @@ -75,22 +68,45 @@ + + + + + + + + + + + + + + + + + + + + + @@ -98,6 +114,7 @@ - - - @@ -863,7 +863,7 @@ - + @@ -943,9 +943,9 @@ - + - + @@ -1629,6 +1629,9 @@ + @@ -1641,6 +1644,23 @@ + + + + + + + + + + + + + + + + + @@ -2220,7 +2240,7 @@ - + @@ -2427,24 +2447,8 @@ - - - - - - - - - - - - - - - - - - + + @@ -2474,7 +2478,7 @@ - + @@ -2812,24 +2816,8 @@ - - - - - - - - - - - - - - - - - - + + @@ -2845,7 +2833,7 @@ - + @@ -2904,6 +2892,9 @@ + @@ -2913,6 +2904,16 @@ + + + + + + + + + + @@ -3299,27 +3300,11 @@ - - - - - - - - - - - - - - - - - - + + - + @@ -3528,28 +3513,12 @@ - - - - - - - - - - - - - - - - - + - + - + @@ -3557,7 +3526,7 @@ - + @@ -3573,7 +3542,6 @@ - @@ -3633,11 +3601,11 @@ - - + + - + @@ -3761,7 +3729,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -