From 9f28dbbb672320e2c249b640bdf52f4da54d4a50 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 4 Jun 2019 22:44:32 +0800 Subject: [PATCH] init branch --- .../HandyControlDemo_Core30.csproj | 9 +- .../HandyControlDemo_Net_40.csproj | 3 + .../HandyControlDemo_Net_GE45.csproj | 3 + .../Data/MessageToken.cs | 2 + .../Data/MessageToken.tt | 3 +- .../HandyControlDemo_Shared.projitems | 12 +- .../Properties/Langs/Lang.Designer.cs | 9 ++ .../Properties/Langs/Lang.en.resx | 3 + .../Properties/Langs/Lang.resx | 3 + .../Img/LeftMainContent/PaneLayout_16x.png | Bin 0 -> 164 bytes .../Controls/RelativePanelDemoCtl.xaml | 6 + .../Controls/RelativePanelDemoCtl.xaml.cs | 10 ++ .../UserControl/Main/LeftMainContent.xaml | 7 +- .../Controls/Panel/RelativePanel.cs | 132 ++++++++++++++++++ .../Data/Enum/RelativeStatus.cs | 37 +++++ .../HandyControl_Shared.projitems | 3 + .../Tools/Converter/NameReferenceConverter.cs | 17 +++ 17 files changed, 248 insertions(+), 11 deletions(-) create mode 100644 src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/PaneLayout_16x.png create mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml create mode 100644 src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs create mode 100644 src/Shared/HandyControl_Shared/Controls/Panel/RelativePanel.cs create mode 100644 src/Shared/HandyControl_Shared/Data/Enum/RelativeStatus.cs create mode 100644 src/Shared/HandyControl_Shared/Tools/Converter/NameReferenceConverter.cs diff --git a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj index 796f9876..b0f2f73d 100644 --- a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj +++ b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj @@ -8,6 +8,7 @@ 1.5.5 ..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico Debug;Release + Copyright © HandyOrg 2018-2019 TRACE;Core @@ -316,7 +317,7 @@ Resources\Img\LeftMainContent\WindowsForm_16x.png - + Resources\Img\LeftMainContent\GridPane_16x.png @@ -346,12 +347,12 @@ Resources\fabric-icons.ttf - - Resources\Img\LeftMainContent\MainMenuControl_16x.png - Resources\Img\LeftMainContent\brackets_Square_16xLG.png + + Resources\Img\LeftMainContent\PaneLayout_16x.png + diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj index 61536a9e..c46db263 100644 --- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj +++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj @@ -395,6 +395,9 @@ TextTemplatingFileGenerator MessageToken.cs + + Resources\Img\LeftMainContent\PaneLayout_16x.png + Resources\Img\LeftMainContent\brackets_Square_16xLG.png diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj index b301587b..d61b5420 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj @@ -414,6 +414,9 @@ TextTemplatingFileGenerator MessageToken.cs + + Resources\Img\LeftMainContent\PaneLayout_16x.png + Resources\Img\LeftMainContent\brackets_Square_16xLG.png diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs index 10cb3212..ae9773a7 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs +++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs @@ -98,6 +98,8 @@ public static readonly string RangeSliderDemoCtl = nameof(RangeSliderDemoCtl); + public static readonly string RelativePanelDemoCtl = nameof(RelativePanelDemoCtl); + public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl); public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl); diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt index 23421817..c2da95c5 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt +++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt @@ -51,7 +51,8 @@ var controlList = new List "DialogDemoCtl", "SideMenuDemoCtl", "GridDemoCtl", - "RangeSliderDemoCtl" + "RangeSliderDemoCtl", + "RelativePanelDemoCtl" }; var styleList = new List { diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems index 421dc7aa..86a11012 100644 --- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems +++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems @@ -50,6 +50,9 @@ RangeSliderDemoCtl.xaml + + RelativePanelDemoCtl.xaml + BadgeDemoCtl.xaml @@ -398,6 +401,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -753,9 +760,4 @@ MSBuild:Compile - - - RangeSliderDemoCtl.xaml - - \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs index 84333b73..c7bbd51a 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs @@ -1113,6 +1113,15 @@ namespace HandyControlDemo.Properties.Langs { } } + /// + /// 查找类似 相对布局 的本地化字符串。 + /// + public static string RelativePanel { + get { + return ResourceManager.GetString("RelativePanel", resourceCulture); + } + } + /// /// 查找类似 备注 的本地化字符串。 /// diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx index fa60bc80..05550cb0 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx @@ -609,4 +609,7 @@ RangeSlider + + RelativePanel + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx index 0869eed4..1ee1deb2 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx @@ -609,4 +609,7 @@ 范围滑块 + + 相对布局 + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/PaneLayout_16x.png b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/PaneLayout_16x.png new file mode 100644 index 0000000000000000000000000000000000000000..9ee0b4319cd69ea28db2515d45f3bf79b6ca6c0c GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP%zBX z#WAEJ?(Jl2E(Svm7vB#RW;boq%cRez&5l=OVbWaYF*&@$xZ^>?!82Tp1^P-xEvu^b zAAGLdILE#*^WgOVp7!}sRlGLMpSf=wt+{`$_=7-x#}ECGnVRZLRqUJlfi^IBy85}S Ib4q9e06_>fs{jB1 literal 0 HcmV?d00001 diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml new file mode 100644 index 00000000..50fa38b9 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml @@ -0,0 +1,6 @@ + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs new file mode 100644 index 00000000..39b53914 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs @@ -0,0 +1,10 @@ +namespace HandyControlDemo.UserControl +{ + public partial class RelativePanelDemoCtl + { + public RelativePanelDemoCtl() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml index be2ebe00..619c18bb 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml @@ -325,6 +325,11 @@ + + + + + @@ -415,7 +420,7 @@ - + diff --git a/src/Shared/HandyControl_Shared/Controls/Panel/RelativePanel.cs b/src/Shared/HandyControl_Shared/Controls/Panel/RelativePanel.cs new file mode 100644 index 00000000..85993180 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Controls/Panel/RelativePanel.cs @@ -0,0 +1,132 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using HandyControl.Tools.Converter; + +namespace HandyControl.Controls +{ + public class RelativePanel : Panel + { + public static readonly DependencyProperty AboveProperty = DependencyProperty.RegisterAttached( + "Above", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAbove(DependencyObject element, DependencyObject value) => element.SetValue(AboveProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAbove(DependencyObject element) => (DependencyObject)element.GetValue(AboveProperty); + + public static readonly DependencyProperty AlignBottomWithProperty = DependencyProperty.RegisterAttached( + "AlignBottomWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignBottomWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignBottomWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignBottomWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignBottomWithProperty); + + public static readonly DependencyProperty AlignBottomWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignBottomWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignBottomWithPanel(DependencyObject element, bool value) => element.SetValue(AlignBottomWithPanelProperty, value); + + public static bool GetAlignBottomWithPanel(DependencyObject element) => (bool)element.GetValue(AlignBottomWithPanelProperty); + + public static readonly DependencyProperty AlignHorizontalCenterWithProperty = DependencyProperty.RegisterAttached( + "AlignHorizontalCenterWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignHorizontalCenterWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignHorizontalCenterWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignHorizontalCenterWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignHorizontalCenterWithProperty); + + public static readonly DependencyProperty AlignHorizontalCenterWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignHorizontalCenterWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignHorizontalCenterWithPanel(DependencyObject element, bool value) => element.SetValue(AlignHorizontalCenterWithPanelProperty, value); + + public static bool GetAlignHorizontalCenterWithPanel(DependencyObject element) => (bool)element.GetValue(AlignHorizontalCenterWithPanelProperty); + + public static readonly DependencyProperty AlignLeftWithProperty = DependencyProperty.RegisterAttached( + "AlignLeftWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignLeftWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignLeftWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignLeftWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignLeftWithProperty); + + public static readonly DependencyProperty AlignLeftWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignLeftWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignLeftWithPanel(DependencyObject element, bool value) => element.SetValue(AlignLeftWithPanelProperty, value); + + public static bool GetAlignLeftWithPanel(DependencyObject element) => (bool)element.GetValue(AlignLeftWithPanelProperty); + + public static readonly DependencyProperty AlignRightWithProperty = DependencyProperty.RegisterAttached( + "AlignRightWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignRightWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignRightWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignRightWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignRightWithProperty); + + public static readonly DependencyProperty AlignRightWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignRightWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignRightWithPanel(DependencyObject element, bool value) => element.SetValue(AlignRightWithPanelProperty, value); + + public static bool GetAlignRightWithPanel(DependencyObject element) => (bool)element.GetValue(AlignRightWithPanelProperty); + + public static readonly DependencyProperty AlignTopWithProperty = DependencyProperty.RegisterAttached( + "AlignTopWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignTopWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignTopWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignTopWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignTopWithProperty); + + public static readonly DependencyProperty AlignTopWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignTopWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignTopWithPanel(DependencyObject element, bool value) => element.SetValue(AlignTopWithPanelProperty, value); + + public static bool GetAlignTopWithPanel(DependencyObject element) => (bool)element.GetValue(AlignTopWithPanelProperty); + + public static readonly DependencyProperty AlignVerticalCenterWithProperty = DependencyProperty.RegisterAttached( + "AlignVerticalCenterWith", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetAlignVerticalCenterWith(DependencyObject element, DependencyObject value) => element.SetValue(AlignVerticalCenterWithProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetAlignVerticalCenterWith(DependencyObject element) => (DependencyObject)element.GetValue(AlignVerticalCenterWithProperty); + + public static readonly DependencyProperty AlignVerticalCenterWithPanelProperty = DependencyProperty.RegisterAttached( + "AlignVerticalCenterWithPanel", typeof(bool), typeof(RelativePanel), new PropertyMetadata(default(bool))); + + public static void SetAlignVerticalCenterWithPanel(DependencyObject element, bool value) => element.SetValue(AlignVerticalCenterWithPanelProperty, value); + + public static bool GetAlignVerticalCenterWithPanel(DependencyObject element) => (bool)element.GetValue(AlignVerticalCenterWithPanelProperty); + + public static readonly DependencyProperty BelowProperty = DependencyProperty.RegisterAttached( + "Below", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetBelow(DependencyObject element, DependencyObject value) => element.SetValue(BelowProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetBelow(DependencyObject element) => (DependencyObject)element.GetValue(BelowProperty); + + public static readonly DependencyProperty LeftOfProperty = DependencyProperty.RegisterAttached( + "LeftOf", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetLeftOf(DependencyObject element, DependencyObject value) => element.SetValue(LeftOfProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetLeftOf(DependencyObject element) => (DependencyObject)element.GetValue(LeftOfProperty); + + public static readonly DependencyProperty RightOfProperty = DependencyProperty.RegisterAttached( + "RightOf", typeof(DependencyObject), typeof(RelativePanel), new PropertyMetadata(default(DependencyObject))); + + public static void SetRightOf(DependencyObject element, DependencyObject value) => element.SetValue(RightOfProperty, value); + + [TypeConverter(typeof(NameReferenceConverter))] + public static DependencyObject GetRightOf(DependencyObject element) => (DependencyObject)element.GetValue(RightOfProperty); + } +} \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Data/Enum/RelativeStatus.cs b/src/Shared/HandyControl_Shared/Data/Enum/RelativeStatus.cs new file mode 100644 index 00000000..9712713f --- /dev/null +++ b/src/Shared/HandyControl_Shared/Data/Enum/RelativeStatus.cs @@ -0,0 +1,37 @@ +namespace HandyControl_Shared.Data.Enum +{ + public enum RelativeStatus + { + LeftOf, + + Above, + + RightOf, + + Below, + + AlignLeftWith, + + AlignTopWith, + + AlignRightWith, + + AlignBottomWith, + + AlignHorizontalCenterWith, + + AlignVerticalCenterWith, + + AlignLeftWithPanel, + + AlignTopWithPanel, + + AlignRightWithPanel, + + AlignBottomWithPanel, + + AlignHorizontalCenterWithPanel, + + AlignVerticalCenterWithPanel + } +} diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index 4b26b7e4..9fdd777a 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -18,10 +18,13 @@ + + + diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/NameReferenceConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/NameReferenceConverter.cs new file mode 100644 index 00000000..29a6924c --- /dev/null +++ b/src/Shared/HandyControl_Shared/Tools/Converter/NameReferenceConverter.cs @@ -0,0 +1,17 @@ +using System; +using System.ComponentModel; +using System.Globalization; +// ReSharper disable ConditionIsAlwaysTrueOrFalse +// ReSharper disable HeuristicUnreachableCode + +namespace HandyControl.Tools.Converter +{ + public class NameReferenceConverter : System.Windows.Markup.NameReferenceConverter + { + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + => context == null ? null : base.ConvertFrom(context, culture, value); + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + => context == null ? null : base.ConvertTo(context, culture, value, destinationType); + } +} \ No newline at end of file