From 4f8a269007fd96c247ae203a1735aec66637a1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=9F=8Evia?= <969954321@qq.com> Date: Mon, 26 Jul 2021 10:36:42 +0800 Subject: [PATCH] v2.2.11.1 (#22) * v2.2.11.1-alpha (#21) --- DotNet/WPF/Src/Samples/Views/MainView.xaml | 3 +- .../Converters/DropDownMinWidthConverter.cs | 2 +- .../Panuon.UI.Silver.Internal.projitems | 2 +- .../Styles/ContextMenuStyle.xaml | 34 ++++++++----- .../Styles/FormGroupStyle.xaml | 3 +- .../Templates/ContextMenuTemplate.xaml | 4 +- ...upTemplate.xaml => FormGroupTemplate.xaml} | 4 +- .../Templates/ToggleButtonTemplate.xaml | 4 +- .../Panuon.UI.Silver/Controls/FormGroup.cs | 49 +++++++++++++------ .../Helpers/ContextMenuHelper.cs | 45 ----------------- .../Properties/AssemblyInfo.cs | 4 +- readme.md | 4 +- readme.zh-CN.md | 6 +-- 13 files changed, 72 insertions(+), 92 deletions(-) rename DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/{FromGroupTemplate.xaml => FormGroupTemplate.xaml} (98%) diff --git a/DotNet/WPF/Src/Samples/Views/MainView.xaml b/DotNet/WPF/Src/Samples/Views/MainView.xaml index fe6d28b4..2f9a2b6f 100644 --- a/DotNet/WPF/Src/Samples/Views/MainView.xaml +++ b/DotNet/WPF/Src/Samples/Views/MainView.xaml @@ -30,7 +30,8 @@ ToolTip="Panuon IconFont Browser" Style="{StaticResource {ComponentResourceKey ResourceId=WindowXMinimizeButtonStyle, TypeInTargetAssembly={x:Type pu:WindowX}}}" Content="" - Click="BtnIconFont_Click" /> + Click="BtnIconFont_Click"> + diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Converters/DropDownMinWidthConverter.cs b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Converters/DropDownMinWidthConverter.cs index 0bee3bde..040be517 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Converters/DropDownMinWidthConverter.cs +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Converters/DropDownMinWidthConverter.cs @@ -10,7 +10,7 @@ public override object Convert(object[] values, Type targetType, object paramete { var actualWidth = (double)values[0]; var blurRadius = (double)values[1]; - return actualWidth + blurRadius * 2; + return actualWidth - blurRadius * 2; } } } diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Panuon.UI.Silver.Internal.projitems b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Panuon.UI.Silver.Internal.projitems index ef19bb50..3b52c37a 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Panuon.UI.Silver.Internal.projitems +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Panuon.UI.Silver.Internal.projitems @@ -294,7 +294,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/ContextMenuStyle.xaml b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/ContextMenuStyle.xaml index 3913d850..0c2bd023 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/ContextMenuStyle.xaml +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/ContextMenuStyle.xaml @@ -107,6 +107,10 @@ diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/FormGroupStyle.xaml b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/FormGroupStyle.xaml index 9e2d9b7d..cfd44f30 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/FormGroupStyle.xaml +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Styles/FormGroupStyle.xaml @@ -6,7 +6,7 @@ xmlns:rs="clr-namespace:Panuon.UI.Silver.Resources" xmlns:irs="clr-namespace:Panuon.UI.Silver.Internal.Resources"> - + @@ -71,7 +71,6 @@ Value="{Binding Foreground, RelativeSource={RelativeSource Self}}" /> - diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ContextMenuTemplate.xaml b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ContextMenuTemplate.xaml index 55324298..51050644 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ContextMenuTemplate.xaml +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ContextMenuTemplate.xaml @@ -17,11 +17,11 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" - CornerRadius="{Binding Path=(local:ContextMenuHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" + CornerRadius="{Binding Path=(local:DropDownHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" Margin="{Binding Path=(local:ShadowHelper.BlurRadius), Converter={StaticResource {x:Static irs:ConverterKeys.DropDownMarginConverter}}, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"> - - + - + diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ToggleButtonTemplate.xaml b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ToggleButtonTemplate.xaml index e9b66d9e..0b5ae3fc 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ToggleButtonTemplate.xaml +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver.Internal/Templates/ToggleButtonTemplate.xaml @@ -36,7 +36,7 @@ Style="{Binding Path=(local:ToggleButtonHelper.PendingSpinnerStyle), RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" /> - - + diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Controls/FormGroup.cs b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Controls/FormGroup.cs index 498fa90e..be0196f0 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Controls/FormGroup.cs +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Controls/FormGroup.cs @@ -230,8 +230,8 @@ public string GroupName #region Overrides public override void OnApplyTemplate() { - - + + _headerControl = GetTemplateChild(HeaderContentControlTemplateName) as ContentControl; _headerControl.SizeChanged += HeaderControl_SizeChanged; } @@ -295,12 +295,12 @@ private void FormGroup_CollectSize(object sender, FormGroupCollectSizeEventArgs { if (e.Orientation == Orientation.Horizontal) { - var width = GetComputedWidth(); + var width = GetComputedWidth(false); e.Maximuim = Math.Max(e.Maximuim, width); } else { - var height = GetComputedHeight(); + var height = GetComputedHeight(false); e.Maximuim = Math.Max(e.Maximuim, height); } } @@ -328,20 +328,36 @@ private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyCha #region Functions private void DeteminingSize() { - if(_headerControl == null) + if (_headerControl == null) { return; } var size = 0d; if (Orientation == Orientation.Horizontal) { - size = GetComputedWidth(); - InternalHeaderHeight = GetComputedHeight(); + size = GetComputedWidth(false); + var internalHeight = GetComputedHeight(true); + if (double.IsNaN(internalHeight)) + { + FrameworkElementUtil.BindingProperty(this, InternalHeaderHeightProperty, this, ActualHeightProperty); + } + else + { + InternalHeaderHeight = internalHeight; + } } else { - size = GetComputedHeight(); - InternalHeaderWidth = GetComputedWidth(); + size = GetComputedHeight(false); + var internalWidth = GetComputedWidth(true); + if (double.IsNaN(internalWidth)) + { + FrameworkElementUtil.BindingProperty(this, InternalHeaderWidthProperty, this, ActualWidthProperty); + } + else + { + InternalHeaderWidth = internalWidth; + } } var collectSizeEventArgs = new FormGroupCollectSizeEventArgs(Orientation, size); if (!string.IsNullOrEmpty(GroupName)) @@ -350,7 +366,7 @@ private void DeteminingSize() } if (Orientation == Orientation.Horizontal) { - if(collectSizeEventArgs.Maximuim == InternalHeaderWidth) + if (collectSizeEventArgs.Maximuim == InternalHeaderWidth) { return; } @@ -371,23 +387,24 @@ private void DeteminingSize() } } - private double GetComputedWidth() + private double GetComputedWidth(bool allowNaN) { var size = GridLengthUtil.ComputeValue(RenderSize.Width, HeaderWidth); - if (double.IsNaN(size)) + if (double.IsNaN(size) && !allowNaN) { _headerControl.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); - size = _headerControl.DesiredSize.Width; + return _headerControl.DesiredSize.Width; } return size; } - private double GetComputedHeight() + private double GetComputedHeight(bool allowNaN) { var size = GridLengthUtil.ComputeValue(RenderSize.Height, HeaderHeight); - if (double.IsNaN(size)) + if (double.IsNaN(size) && !allowNaN) { - size = _headerControl.DesiredSize.Height; + _headerControl.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); + return _headerControl.DesiredSize.Height; } return size; } diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Helpers/ContextMenuHelper.cs b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Helpers/ContextMenuHelper.cs index cf7c2ed2..532722d3 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Helpers/ContextMenuHelper.cs +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Helpers/ContextMenuHelper.cs @@ -117,51 +117,6 @@ public static void SetPadding(ContextMenu contextMenu, Thickness value) #endregion - #region CornerRadius - public static CornerRadius GetCornerRadius(ContextMenu contextMenu) - { - return (CornerRadius)contextMenu.GetValue(CornerRadiusProperty); - } - - public static void SetCornerRadius(ContextMenu contextMenu, CornerRadius value) - { - contextMenu.SetValue(CornerRadiusProperty, value); - } - - public static readonly DependencyProperty CornerRadiusProperty = - DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ContextMenuHelper)); - #endregion - - #region ShadowColor - public static Color? GetShadowColor(ContextMenu contextMenu) - { - return (Color?)contextMenu.GetValue(ShadowColorProperty); - } - - public static void SetShadowColor(ContextMenu contextMenu, Color? value) - { - contextMenu.SetValue(ShadowColorProperty, value); - } - - public static readonly DependencyProperty ShadowColorProperty = - DependencyProperty.RegisterAttached("ShadowColor", typeof(Color?), typeof(ContextMenuHelper), new PropertyMetadata(Colors.LightGray)); - #endregion - - #region Placement - public static PopupXPlacement GetPlacement(ContextMenu contextMenu) - { - return (PopupXPlacement)contextMenu.GetValue(PlacementProperty); - } - - public static void SetPlacement(ContextMenu contextMenu, PopupXPlacement value) - { - contextMenu.SetValue(PlacementProperty, value); - } - - public static readonly DependencyProperty PlacementProperty = - DependencyProperty.RegisterAttached("Placement", typeof(PopupXPlacement), typeof(ContextMenuHelper), new PropertyMetadata(PopupXPlacement.BottomRight)); - #endregion - #region Items #region ItemsIcon diff --git a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Properties/AssemblyInfo.cs b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Properties/AssemblyInfo.cs index 0cdcea04..c82c7697 100644 --- a/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Properties/AssemblyInfo.cs +++ b/DotNet/WPF/Src/SharedResources/Panuon.UI.Silver/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.11")] -[assembly: AssemblyFileVersion("2.2.11")] +[assembly: AssemblyVersion("2.2.11.1")] +[assembly: AssemblyFileVersion("2.2.11.1")] diff --git a/readme.md b/readme.md index 6f8fccaa..ae2880f5 100644 --- a/readme.md +++ b/readme.md @@ -11,8 +11,8 @@ ### This project is still under development. Do not upgrade to this version rashly from the previous version, or use this version on urgent projects. # Contributors - - +[](https://github.com/Mochengvia) +[](https://github.com/GodLeaveMe) # Samples `These pages were included in the Samples project. Download this repository to get the source code.` diff --git a/readme.zh-CN.md b/readme.zh-CN.md index 711a3bb2..68de5dc4 100644 --- a/readme.zh-CN.md +++ b/readme.zh-CN.md @@ -13,10 +13,8 @@ [中文文档地址](http://yuque.com/mochengvia/silver2.2) # 贡献 - - - - +[](https://github.com/Mochengvia) +[](https://github.com/GodLeaveMe) # 示例 `这些界面已包含在"Samples"项目中。下载本仓库即可获得这些页面的源码。`