From d5ad57eb9376705a9ab02224b14de1cfdd95bdfa Mon Sep 17 00:00:00 2001 From: Dino Chan Date: Sun, 26 Jan 2020 23:21:12 +0800 Subject: [PATCH 01/99] Update index.md --- .../extend_controls/clock/index.md | 73 ++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/clock/index.md b/doc/source/handycontrol/extend_controls/clock/index.md index ca12ad62..e797191e 100644 --- a/doc/source/handycontrol/extend_controls/clock/index.md +++ b/doc/source/handycontrol/extend_controls/clock/index.md @@ -1,5 +1,74 @@ --- -title: 建设中 +title: Clock --- -建设中 \ No newline at end of file +Clock 控件允许用户通过在文本框中键入日期或使用下拉的日历控件来选择日期。 + +``` CS +[TemplatePart(Name = ElementTextBox, Type = typeof(DatePickerTextBox))] +public class DatePicker : System.Windows.Controls.DatePicker, IDataInput +``` + +# 创建DatePicker + +``` XML + +``` + +``` CS +var datePicker = new DatePicker(); +``` + +生成的DatePicker如下图所示: + +![DatePicker](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/DatePicker_1.png) + + + +# 选择日期 + +可以通过文本框输入日期,或者点击文本框右边的按钮打开下拉的日历控件选择日期。 + +![DatePicker](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/DatePicker_2.png) + +也可以在XAML钟或代码中这样设置日期。 + +``` XML + +``` + +``` CS +datePicker.SelectedDate = DateTime.Now; +``` + +# 设置标题和占位符文本 + +你可以将 Header(标题)和 Placeholder(占位符)添加到DatePicker,以向用户指示其用途。 + +``` XML + +``` + + + + +# 属性 + +| 属性 | 描述 | +| ---------------- | ------------------ | +| SelectedDate | 获取或设置当前选中的日期 | +| VerifyFunc | 获取或设置数据验证委托 | +| IsError | 获取或设置数据是否错误 | +| ErrorStr | 获取或设置错误提示 | +| TextType | 获取或设置文本类型 | +| ShowClearButton | 获取或设置是否显示清除按钮 | + +# 方法 + +| 方法 | 描述 | +| ---------------- | ------------------ | +| VerifyData() | 验证数据 | + From b2545050c1f7907fc718bfdec3f9ab730b686148 Mon Sep 17 00:00:00 2001 From: guanguanchuangyu <3246907890@qq.com> Date: Sat, 15 Feb 2020 18:05:18 +0800 Subject: [PATCH 02/99] add doc of animationPath --- .../extend_controls/animationPath/index.md | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/animationPath/index.md b/doc/source/handycontrol/extend_controls/animationPath/index.md index ca12ad62..c40d140c 100644 --- a/doc/source/handycontrol/extend_controls/animationPath/index.md +++ b/doc/source/handycontrol/extend_controls/animationPath/index.md @@ -1,5 +1,63 @@ --- -title: 建设中 +title: AnimationPath 动画路径 --- -建设中 \ No newline at end of file +`AnimationPath`动画路径,设定`Geometry `派生类型几何图形的数据,例如`PathGeometry `、`LineGeometry `等,实现固定的路径动画效果 + +```xml +public class AnimationPath : Shape +``` + +# 属性 + +## Data 数据 + +动画路径需要显示的几何图形数据 + +```xml +M512 0C229.12 0 0 229.12 0 512c0 226.56 146.56 417.92 350.08 485.76 25.6 4.48 35.2-10.88 35.2-24.32 0-12.16-0.64-52.48-0.64-95.36-128.64 23.68-161.92-31.36-172.16-60.16-5.76-14.72-30.72-60.16-52.48-72.32-17.92-9.6-43.52-33.28-0.64-33.92 40.32-0.64 69.12 37.12 78.72 52.48 46.08 77.44 119.68 55.68 149.12 42.24 4.48-33.28 17.92-55.68 32.64-68.48-113.92-12.8-232.96-56.96-232.96-252.8 0-55.68 19.84-101.76 52.48-137.6-5.12-12.8-23.04-65.28 5.12-135.68 0 0 42.88-13.44 140.8 52.48 40.96-11.52 84.48-17.28 128-17.28 43.52 0 87.04 5.76 128 17.28 97.92-66.56 140.8-52.48 140.8-52.48 28.16 70.4 10.24 122.88 5.12 135.68 32.64 35.84 52.48 81.28 52.48 137.6 0 196.48-119.68 240-233.6 252.8 18.56 16 34.56 46.72 34.56 94.72 0 68.48-0.64 123.52-0.64 140.8 0 13.44 9.6 29.44 35.2 24.32A512.832 512.832 0 0 0 1024 512c0-282.88-229.12-512-512-512z +``` +案例: +```xml + + + +``` + +效果: + +![Animation-Default](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/AnimationPath-Default.gif) + +## PathLength 路径长度 + +设置路径动画,线性移动空白间隔长度,默认为0,设置属性为50,效果如下: + +![AnimationPath-PathLength](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/AnimationPath-PathLength.gif) + +## Duration 时间间隔 + +路径动画的执行时间间隔,此属性为必须设置项,否则动画路径效果无显示 + +## IsPlaying 是否正在播放动画 + +判定当前动画播放状态,常作为控件内部行为控制判定标识,可通过该属性进行路径动画的暂停控制 + +## RepeatBehavior 重复行为 + +设置动画重复行为,默认为`Forever`,可根据需要设置重复行为 + +## 继承至Shape常用属性 + +| 属性名称 | 用途 | +| --------------- | -------- | +| Stretch | 拉伸属性 | +| StrokeThickness | 边线宽度 | + +# 相关事件 + +## Completed + +非默认重复行为,当动画行为完成时,触发对应设置事件 \ No newline at end of file From 491ec94d68cd9e650b931af7172e33dc58b93617 Mon Sep 17 00:00:00 2001 From: guanguanchuangyu <3246907890@qq.com> Date: Sun, 1 Mar 2020 11:55:01 +0800 Subject: [PATCH 03/99] add doc of badge --- .../extend_controls/badge/index.md | 204 +++++++++++++++++- 1 file changed, 202 insertions(+), 2 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/badge/index.md b/doc/source/handycontrol/extend_controls/badge/index.md index ca12ad62..0925107e 100644 --- a/doc/source/handycontrol/extend_controls/badge/index.md +++ b/doc/source/handycontrol/extend_controls/badge/index.md @@ -1,5 +1,205 @@ --- -title: 建设中 +title: Badge 标记 --- -建设中 \ No newline at end of file +标记控件作为其他控件的特定状态内容标记,能够做到最小程度的侵入原有控件,可以看作是一种内容控件,内部`Content`就是对应需要显示标记的被修饰控件,继承关系如下: + +```c# +public class Badge : ContentControl +``` + +# 基础属性 + +| 属性名称 | 用途 | +| ----------- | ------------------------------------------------------------ | +| Text | 获取或设置标记显示内容 | +| Value | 获取或设置显示数值,支持数值动态变更 | +| Status | 获取或设置标记状态类型,Text(文本),Dot(圆点标记),Processing(动态标记)默认为文本显示 | +| Maximum | 获取或设置最大显示数值。数值显示时,最大显示数值 | +| BadgeMargin | 获取或设置标记相对于被修饰控件的外边距 | +| ShowBadge | 获取或设置是否显示标记,默认为True | + +`xaml`中,记得引入`handycontrol`的命名空间 + +```xml +xmlns:hc="https://handyorg.github.io/handycontrol" +``` + +## `Text`和`Value` + +可能看到属性解释,会比较疑惑,`Text`和`Value`在现实效果和数据填写时,是一样的,这有什么区别?在标记控件中,将文本和数值类型进行区分,数值类型能够进行动态的变更以及数据统计显示效果,当两者同时存在时,默认显示`Text`,由于标记的`Status`默认为文本 + +### 案例 + +```xml + + + + + + +``` + +![Badge-Attention01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Attention01.png) + + + + + From a53f495d7dbc834bfbcc6a3f0c497727b1e572a3 Mon Sep 17 00:00:00 2001 From: yxhq Date: Fri, 13 Mar 2020 21:27:42 +0800 Subject: [PATCH 04/99] =?UTF-8?q?NotifiIcon=E7=9A=84ContextMenu=20->=20Men?= =?UTF-8?q?uItem=20->=20Command=20=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/NotifyIconDemoCtl.xaml | 1 + .../Controls/Other/NotifyIcon.cs | 54 +++++++++++++++---- .../Extension/FrameworkElementExtension.cs | 9 +++- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml index 36c6aeac..40f5a071 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml @@ -41,6 +41,7 @@ + diff --git a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs index 6531ccf6..5dff7b65 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs @@ -11,6 +11,7 @@ using System.Windows.Media; using System.Windows.Threading; using HandyControl.Data; using HandyControl.Tools; +using HandyControl.Tools.Extension; using HandyControl.Tools.Interop; namespace HandyControl.Controls @@ -62,11 +63,13 @@ namespace HandyControl.Controls static NotifyIcon() { VisibilityProperty.OverrideMetadata(typeof(NotifyIcon), new PropertyMetadata(Visibility.Visible, OnVisibilityChanged)); + DataContextProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(DataContextPropertyChanged)); + ContextMenuProperty.OverrideMetadata(typeof(NotifyIcon), new FrameworkPropertyMetadata(ContextMenuPropertyChanged)); } private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var ctl = (NotifyIcon) d; + var ctl = (NotifyIcon)d; var v = (Visibility)e.NewValue; if (v == Visibility.Visible) @@ -77,11 +80,35 @@ namespace HandyControl.Controls } ctl.UpdateIcon(true); } - else if(ctl._iconCurrentHandle != IntPtr.Zero) + else if (ctl._iconCurrentHandle != IntPtr.Zero) { ctl.UpdateIcon(false); } } + private static void DataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + NotifyIcon owner = (NotifyIcon)d; + owner.OnDataContextPropertyChanged(e); + } + + private void OnDataContextPropertyChanged(DependencyPropertyChangedEventArgs e) + { + object newValue = e.NewValue; + object oldValue = e.OldValue; + UpdateDataContext(_contextContent, oldValue, newValue); + UpdateDataContext(ContextMenu, oldValue, newValue); + } + + private static void ContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + NotifyIcon owner = (NotifyIcon)d; + owner.OnContextMenuPropertyChanged(e); + } + + private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e) + { + UpdateDataContext((ContextMenu)e.NewValue, null, DataContext); + } public NotifyIcon() { @@ -228,7 +255,7 @@ namespace HandyControl.Controls public string Token { - get => (string) GetValue(TokenProperty); + get => (string)GetValue(TokenProperty); set => SetValue(TokenProperty, value); } @@ -237,7 +264,7 @@ namespace HandyControl.Controls public string Text { - get => (string) GetValue(TextProperty); + get => (string)GetValue(TextProperty); set => SetValue(TextProperty, value); } @@ -274,13 +301,13 @@ namespace HandyControl.Controls var ctl = (NotifyIcon)d; if (ctl._dispatcherTimerBlink != null) { - ctl._dispatcherTimerBlink.Interval = (TimeSpan) e.NewValue; + ctl._dispatcherTimerBlink.Interval = (TimeSpan)e.NewValue; } } public TimeSpan BlinkInterval { - get => (TimeSpan) GetValue(BlinkIntervalProperty); + get => (TimeSpan)GetValue(BlinkIntervalProperty); set => SetValue(BlinkIntervalProperty, value); } @@ -291,7 +318,7 @@ namespace HandyControl.Controls { var ctl = (NotifyIcon)d; if (ctl.Visibility != Visibility.Visible) return; - if ((bool) e.NewValue) + if ((bool)e.NewValue) { if (ctl._dispatcherTimerBlink == null) { @@ -465,7 +492,7 @@ namespace HandyControl.Controls InteropMethods.VirtualFreeEx(hProcess, address, 0, InteropValues.FreeType.Release); InteropMethods.CloseHandle(hProcess); } - return isFind; + return isFind; } private void OnIconChanged() @@ -674,7 +701,16 @@ namespace HandyControl.Controls { add => AddHandler(MouseDoubleClickEvent, value); remove => RemoveHandler(MouseDoubleClickEvent, value); - } + } + + private void UpdateDataContext(FrameworkElement target, object oldDataContextValue, object newDataContextValue) + { + if (target == null || target.IsDataContextDataBound()) return; + if (ReferenceEquals(this, target.DataContext) || Equals(oldDataContextValue, target.DataContext)) + { + target.DataContext = newDataContextValue ?? this; + } + } private void Dispose(bool disposing) { diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs index 8810122d..8028f5b8 100644 --- a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs +++ b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; namespace HandyControl.Tools.Extension { @@ -54,5 +55,11 @@ namespace HandyControl.Tools.Extension return 0; } + + public static bool IsDataContextDataBound(this FrameworkElement element) + { + if (element == null) throw new ArgumentNullException(nameof(element)); + return element.GetBindingExpression(FrameworkElement.DataContextProperty) != null; + } } } \ No newline at end of file From 0b031e8d0bc9a65af3e9248d2f34d3afef8dcfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E6=96=87=E5=8D=9A?= <964012840@qq.com> Date: Sat, 14 Mar 2020 11:53:31 +0800 Subject: [PATCH 05/99] Update Dialog.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加弹出对话框对所有带有装饰层的元素的支持。 --- .../Controls/Other/Dialog.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs b/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs index 7f2fc50a..aab70313 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs @@ -16,14 +16,14 @@ namespace HandyControl.Controls private Adorner _container; - private static readonly Dictionary WindowDic = new Dictionary(); + private static readonly Dictionary WindowDic = new Dictionary(); public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register( "IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox)); public bool IsClosed { - get => (bool) GetValue(IsClosedProperty); + get => (bool)GetValue(IsClosedProperty); internal set => SetValue(IsClosedProperty, value); } @@ -32,7 +32,7 @@ namespace HandyControl.Controls private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - if (d is System.Windows.Window window) + if (d is System.Windows.FrameworkElement window) { if (e.NewValue == null) { @@ -49,20 +49,20 @@ namespace HandyControl.Controls => element.SetValue(TokenProperty, value); public static string GetToken(DependencyObject element) - => (string) element.GetValue(TokenProperty); + => (string)element.GetValue(TokenProperty); public Dialog() { CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close())); } - public static void Register(string token, System.Windows.Window window) + public static void Register(string token, System.Windows.FrameworkElement window) { if (string.IsNullOrEmpty(token) || window == null) return; WindowDic[token] = window; } - public static void Unregister(string token, System.Windows.Window window) + public static void Unregister(string token, System.Windows.FrameworkElement window) { if (string.IsNullOrEmpty(token) || window == null) return; @@ -75,7 +75,7 @@ namespace HandyControl.Controls } } - public static void Unregister(System.Windows.Window window) + public static void Unregister(System.Windows.FrameworkElement window) { if (window == null) return; var first = WindowDic.FirstOrDefault(item => ReferenceEquals(window, item.Value)); @@ -105,7 +105,7 @@ namespace HandyControl.Controls Content = content }; - System.Windows.Window window; + System.Windows.FrameworkElement window; if (string.IsNullOrEmpty(token)) { @@ -154,7 +154,7 @@ namespace HandyControl.Controls } } - private void Close(System.Windows.Window window) + private void Close(System.Windows.FrameworkElement window) { if (window != null) { From 6ee123a34a8852033bc54c7b2f6ba53409b15c25 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 15 Mar 2020 22:31:48 +0800 Subject: [PATCH 06/99] add Magnifier for Screenshot --- .../Controls/Attach/WindowAttach.cs | 5 +- .../Controls/Screenshot/ScreenshotWindow.cs | 147 +++++++++++++++--- .../Controls/Window/Window.cs | 2 +- .../Themes/Styles/Screenshot.xaml | 23 ++- .../Tools/Extension/UIElementExtension.cs | 20 +-- 5 files changed, 153 insertions(+), 44 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs index dd6a8db5..848b2327 100644 --- a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs +++ b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs @@ -80,7 +80,10 @@ namespace HandyControl.Controls { if (d is System.Windows.Window window) { - if ((bool)e.NewValue) + var v = (bool) e.NewValue; + window.SetCurrentValue(System.Windows.Window.ShowInTaskbarProperty, v); + + if (v) { window.SourceInitialized -= Window_SourceInitialized; } diff --git a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs index 5e3bdb13..7b73fd0e 100644 --- a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs +++ b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using HandyControl.Data; using HandyControl.Tools; +using HandyControl.Tools.Extension; using HandyControl.Tools.Interop; namespace HandyControl.Controls @@ -17,13 +18,19 @@ namespace HandyControl.Controls [TemplatePart(Name = ElementMaskAreaRight, Type = typeof(FrameworkElement))] [TemplatePart(Name = ElementMaskAreaBottom, Type = typeof(FrameworkElement))] [TemplatePart(Name = ElementTargetArea, Type = typeof(InkCanvas))] - [TemplatePart(Name = ElementTextSize, Type = typeof(TextBlock))] + [TemplatePart(Name = ElementMagnifier, Type = typeof(FrameworkElement))] public class ScreenshotWindow : System.Windows.Window { #region fields private readonly Screenshot _screenshot; + private VisualBrush _visualPreview; + + private Size _viewboxSize; + + private BitmapSource _imageSource; + #region const private const int IntervalLength = 1; @@ -52,6 +59,8 @@ namespace HandyControl.Controls private readonly int[] _flagArr = new int[4]; + private bool _isOut; + private bool _canDrag; private bool _receiveMoveMsg = true; @@ -60,7 +69,7 @@ namespace HandyControl.Controls private Point _pointFixed; - private Point _pointFloating; + private InteropValues.POINT _pointFloating; private bool _saveScreenshot; @@ -82,7 +91,7 @@ namespace HandyControl.Controls internal FrameworkElement TargetArea { get; set; } - internal TextBlock TextSize { get; set; } + private FrameworkElement _magnifier; #endregion @@ -100,7 +109,7 @@ namespace HandyControl.Controls private const string ElementTargetArea = "PART_TargetArea"; - private const string ElementTextSize = "PART_TextSize"; + private const string ElementMagnifier = "PART_Magnifier"; #endregion @@ -124,6 +133,53 @@ namespace HandyControl.Controls internal set => SetValue(IsSelectingProperty, value); } + public static readonly DependencyProperty SizeProperty = DependencyProperty.Register( + "Size", typeof(Size), typeof(ScreenshotWindow), new PropertyMetadata(default(Size))); + + public Size Size + { + get => (Size) GetValue(SizeProperty); + internal set => SetValue(SizeProperty, value); + } + + public static readonly DependencyProperty SizeStrProperty = DependencyProperty.Register( + "SizeStr", typeof(string), typeof(ScreenshotWindow), new PropertyMetadata(default(string))); + + public string SizeStr + { + get => (string) GetValue(SizeStrProperty); + internal set => SetValue(SizeStrProperty, value); + } + + public static readonly DependencyProperty PixelColorProperty = DependencyProperty.Register( + "PixelColor", typeof(Color), typeof(ScreenshotWindow), new PropertyMetadata(default(Color))); + + public Color PixelColor + { + get => (Color) GetValue(PixelColorProperty); + internal set => SetValue(PixelColorProperty, value); + } + + public static readonly DependencyProperty PixelColorStrProperty = DependencyProperty.Register( + "PixelColorStr", typeof(string), typeof(ScreenshotWindow), new PropertyMetadata(default(string))); + + public string PixelColorStr + { + get => (string) GetValue(PixelColorStrProperty); + internal set => SetValue(PixelColorStrProperty, value); + } + + public static readonly DependencyPropertyKey PreviewBrushPropertyKey = DependencyProperty.RegisterReadOnly( + "PreviewBrush", typeof(Brush), typeof(ScreenshotWindow), new PropertyMetadata(default(Brush))); + + public static readonly DependencyProperty PreviewBrushProperty = PreviewBrushPropertyKey.DependencyProperty; + + public Brush PreviewBrush + { + get => (Brush) GetValue(PreviewBrushProperty); + set => SetValue(PreviewBrushProperty, value); + } + #endregion public ScreenshotWindow(Screenshot screenshot) @@ -149,7 +205,19 @@ namespace HandyControl.Controls MaskAreaRight = GetTemplateChild(ElementMaskAreaRight) as FrameworkElement; MaskAreaBottom = GetTemplateChild(ElementMaskAreaBottom) as FrameworkElement; TargetArea = GetTemplateChild(ElementTargetArea) as FrameworkElement; - TextSize = GetTemplateChild(ElementTextSize) as TextBlock; + _magnifier = GetTemplateChild(ElementMagnifier) as FrameworkElement; + + if (_magnifier != null) + { + _viewboxSize = new Size(29, 21); + } + + _visualPreview = new VisualBrush(Canvas) + { + ViewboxUnits = BrushMappingMode.Absolute + }; + SetValue(PreviewBrushPropertyKey, _visualPreview); + _magnifier.Show(); } protected override void OnPreviewKeyDown(KeyEventArgs e) @@ -190,6 +258,8 @@ namespace HandyControl.Controls protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) => _mousePointOld = e.GetPosition(this); + protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) => _magnifier.Collapse(); + protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e) { _saveScreenshot = true; @@ -210,6 +280,7 @@ namespace HandyControl.Controls if (IsDrawing) { + if (_isOut) return; var rect = _targetWindowRect; if (_canDrag) @@ -221,28 +292,37 @@ namespace HandyControl.Controls } else { + var magnifierPos = new InteropValues.POINT((int) newPoint.X, (int) newPoint.Y); + if (_flagArr[0] > 0) { _pointFloating.X += offsetX * _flagArr[0]; + magnifierPos.X = _pointFloating.X; } else if (_flagArr[2] > 0) { _pointFloating.X += offsetX * _flagArr[2]; + magnifierPos.X = _pointFloating.X - 1; } if (_flagArr[1] > 0) { _pointFloating.Y += offsetY * _flagArr[1]; + magnifierPos.Y = _pointFloating.Y; } else if (_flagArr[3] > 0) { _pointFloating.Y += offsetY * _flagArr[3]; + magnifierPos.Y = _pointFloating.Y - 1; } rect.Left = (int)Math.Min(_pointFixed.X, _pointFloating.X); rect.Top = (int)Math.Min(_pointFixed.Y, _pointFloating.Y); rect.Right = (int)Math.Max(_pointFixed.X, _pointFloating.X); rect.Bottom = (int)Math.Max(_pointFixed.Y, _pointFloating.Y); + + _magnifier.Show(); + MoveMagnifier(magnifierPos); } MoveTargetArea(rect); @@ -279,10 +359,17 @@ namespace HandyControl.Controls private void ScreenshotWindow_Loaded(object sender, RoutedEventArgs e) { - Canvas.Background = new ImageBrush(GetDesktopSnapshot()); + _imageSource = GetDesktopSnapshot(); + var image = new Image + { + Source = _imageSource + }; + RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.NearestNeighbor); + Canvas.Children.Add(image); StartHooks(); InteropMethods.GetCursorPos(out var point); - MoveElement2Point(point); + MoveElement(point); + MoveMagnifier(point); } private void UpdateStatus(Point point) @@ -295,6 +382,7 @@ namespace HandyControl.Controls var downAbs = Math.Abs(point.Y - _targetWindowRect.Height); _canDrag = false; + _isOut = false; _flagArr[0] = 0; _flagArr[1] = 0; _flagArr[2] = 0; @@ -309,7 +397,7 @@ namespace HandyControl.Controls // left cursor = Cursors.SizeWE; _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top); - _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Bottom); _flagArr[0] = 1; } else @@ -317,7 +405,7 @@ namespace HandyControl.Controls //left bottom cursor = Cursors.SizeNESW; _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top); - _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Bottom); _flagArr[0] = 1; _flagArr[3] = 1; } @@ -327,7 +415,7 @@ namespace HandyControl.Controls // left top cursor = Cursors.SizeNWSE; _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom); - _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Top); _flagArr[0] = 1; _flagArr[1] = 1; } @@ -348,6 +436,7 @@ namespace HandyControl.Controls { //out cursor = Cursors.Arrow; + _isOut = true; } } else @@ -355,7 +444,7 @@ namespace HandyControl.Controls //bottom cursor = Cursors.SizeNS; _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top); - _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Bottom); _flagArr[3] = 1; } } @@ -364,7 +453,7 @@ namespace HandyControl.Controls //top cursor = Cursors.SizeNS; _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom); - _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Top); _flagArr[1] = 1; } } @@ -377,7 +466,7 @@ namespace HandyControl.Controls //right cursor = Cursors.SizeWE; _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom); - _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Top); _flagArr[2] = 1; } else @@ -385,7 +474,7 @@ namespace HandyControl.Controls //right bottom cursor = Cursors.SizeNWSE; _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top); - _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Bottom); _flagArr[2] = 1; _flagArr[3] = 1; } @@ -395,7 +484,7 @@ namespace HandyControl.Controls // right top cursor = Cursors.SizeNESW; _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom); - _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top); + _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Top); _flagArr[1] = 1; _flagArr[2] = 1; } @@ -404,6 +493,7 @@ namespace HandyControl.Controls { //out cursor = Cursors.Arrow; + _isOut = true; } TargetArea.Cursor = cursor; @@ -426,33 +516,35 @@ namespace HandyControl.Controls switch (e.MessageType) { case MouseHookMessageType.MouseMove: - MoveElement2Point(e.Point); + MoveElement(e.Point); + MoveMagnifier(e.Point); break; case MouseHookMessageType.LeftButtonDown: _receiveMoveMsg = false; _mousePointOld = new Point(e.Point.X, e.Point.Y); InteropMethods.EnableWindow(_screenshotWindowHandle, true); break; + case MouseHookMessageType.RightButtonDown: + if (!IsDrawing) Close(); + break; case MouseHookMessageType.LeftButtonUp: StopHooks(); IsSelecting = false; IsDrawing = true; + _magnifier.Collapse(); break; } } private void SaveScreenshot() { - if (Canvas.Background is ImageBrush imageBrush && imageBrush.ImageSource is BitmapSource bitmapSource) - { - var cb = new CroppedBitmap(bitmapSource, new Int32Rect(_targetWindowRect.Left, _targetWindowRect.Top, _targetWindowRect.Width, _targetWindowRect.Height)); - _screenshot.OnSnapped(cb); - } + var cb = new CroppedBitmap(_imageSource, new Int32Rect(_targetWindowRect.Left, _targetWindowRect.Top, _targetWindowRect.Width, _targetWindowRect.Height)); + _screenshot.OnSnapped(cb); Close(); } - private ImageSource GetDesktopSnapshot() + private BitmapSource GetDesktopSnapshot() { _desktopWindowHandle = InteropMethods.GetDesktopWindow(); var hdcSrc = InteropMethods.GetWindowDC(_desktopWindowHandle); @@ -471,7 +563,7 @@ namespace HandyControl.Controls return Imaging.CreateBitmapSourceFromHBitmap(bitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } - private void MoveElement2Point(InteropValues.POINT point) + private void MoveElement(InteropValues.POINT point) { if (!_receiveMoveMsg) return; @@ -544,7 +636,8 @@ namespace HandyControl.Controls TargetArea.Margin = new Thickness(left, top, 0, 0); _targetWindowRect = new InteropValues.RECT(left, top, left + width, top + height); - TextSize.Text = $"{_targetWindowRect.Width} x {_targetWindowRect.Height}"; + Size = _targetWindowRect.Size; + SizeStr = $"{_targetWindowRect.Width} x {_targetWindowRect.Height}"; MoveMaskArea(); } @@ -566,5 +659,11 @@ namespace HandyControl.Controls MaskAreaBottom.Width = TargetArea.Width; MaskAreaBottom.Height = _desktopWindowRect.Height - TargetArea.Height - TargetArea.Margin.Top; } + + private void MoveMagnifier(InteropValues.POINT point) + { + _magnifier.Margin = new Thickness(point.X + 4, point.Y + 26, 0, 0); + _visualPreview.Viewbox = new Rect(new Point(point.X - _viewboxSize.Width / 2 + 0.5, point.Y - _viewboxSize.Height / 2 + 0.5), _viewboxSize); + } } } diff --git a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs index 5d190fb6..932e79c8 100644 --- a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs +++ b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs @@ -304,7 +304,7 @@ namespace HandyControl.Controls _tempNonClientAreaHeight = NonClientAreaHeight; NonClientAreaHeight += 8; } - else if (WindowState == WindowState.Normal) + else { BorderThickness = _actualBorderThickness; NonClientAreaHeight = _tempNonClientAreaHeight; diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml index 9b3a0bfd..27a4b5f6 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml @@ -88,10 +88,12 @@ - + + + @@ -112,7 +114,24 @@ - + + + + + + + + + + + + + + + + + + diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs index 81f22d93..7d242bec 100644 --- a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs +++ b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs @@ -9,37 +9,25 @@ namespace HandyControl.Tools.Extension /// 显示元素 /// /// - public static void Show(this UIElement element) - { - element.Visibility = Visibility.Visible; - } + public static void Show(this UIElement element) => element.Visibility = Visibility.Visible; /// /// 显示元素 /// /// /// - public static void Show(this UIElement element, bool show) - { - element.Visibility = show ? Visibility.Visible : Visibility.Collapsed; - } + public static void Show(this UIElement element, bool show) => element.Visibility = show ? Visibility.Visible : Visibility.Collapsed; /// /// 不现实元素,但保留空间 /// /// - public static void Hide(this UIElement element) - { - element.Visibility = Visibility.Hidden; - } + public static void Hide(this UIElement element) => element.Visibility = Visibility.Hidden; /// /// 不显示元素,且不保留空间 /// /// - public static void Collapse(this UIElement element) - { - element.Visibility = Visibility.Collapsed; - } + public static void Collapse(this UIElement element) => element.Visibility = Visibility.Collapsed; } } \ No newline at end of file From fb4e3d48b4fe8493158b1c804d640d869c9bd73f Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 15 Mar 2020 22:36:29 +0800 Subject: [PATCH 07/99] Update README.md --- README.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2faaf251..ff539909 100644 --- a/README.md +++ b/README.md @@ -27,32 +27,33 @@ ## Contributors - - - - - - - - - - + + + + + + + + + + ## Backers - - - - - - - - - - - - - + + + + + + + + + + + + + + ## Special thanks to From a4487021084cac02be7864a2e52292545fc6c467 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 16 Mar 2020 01:21:09 +0800 Subject: [PATCH 08/99] fixed #337 --- .../Controls/Cover/CoverFlow/CoverFlow.cs | 82 +++++++------------ .../Controls/Cover/CoverFlow/CoverFlowItem.cs | 23 ++---- 2 files changed, 35 insertions(+), 70 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs index 18427620..717f0731 100644 --- a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs +++ b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs @@ -4,9 +4,11 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Media.Media3D; using HandyControl.Data; +using HandyControl.Tools.Extension; namespace HandyControl.Controls { @@ -27,7 +29,7 @@ namespace HandyControl.Controls /// /// 最大显示数量的一半 /// - private const int MaxShowCountHalf = 7; + private const int MaxShowCountHalf = 3; /// /// 页码 @@ -55,7 +57,7 @@ namespace HandyControl.Controls private static void OnPageIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var ctl = (CoverFlow)d; - ctl.UpdateIndex((int)e.NewValue, (int)e.OldValue); + ctl.UpdateIndex((int)e.NewValue); } /// @@ -72,13 +74,15 @@ namespace HandyControl.Controls /// /// 当前在显示范围内的项 /// - private readonly Dictionary _itemShowList = new Dictionary(); + private readonly Dictionary _itemShowDic = new Dictionary(); /// /// 相机 /// private ProjectionCamera _camera; + private Point3DAnimation _point3DAnimation; + /// /// 3d画布 /// @@ -127,7 +131,7 @@ namespace HandyControl.Controls if (_viewport3D != null) { _viewport3D.Children.Clear(); - _itemShowList.Clear(); + _itemShowDic.Clear(); _viewport3D.MouseLeftButtonDown -= Viewport3D_MouseLeftButtonDown; } @@ -148,7 +152,9 @@ namespace HandyControl.Controls PageIndex = _jumpToIndex; _jumpToIndex = -1; } - _camera.Position = new Point3D(CoverFlowItem.Interval * PageIndex, _camera.Position.Y, _camera.Position.Z); + + _point3DAnimation = new Point3DAnimation(new Point3D(CoverFlowItem.Interval * PageIndex, _camera.Position.Y, _camera.Position.Z), new Duration(TimeSpan.FromMilliseconds(200))); + _camera.BeginAnimation(ProjectionCamera.PositionProperty, _point3DAnimation); } /// @@ -204,24 +210,17 @@ namespace HandyControl.Controls /// private void Remove(int pos) { - if (!_itemShowList.TryGetValue(pos, out var item)) return; + if (!_itemShowDic.TryGetValue(pos, out var item)) return; _visualParent.Children.Remove(item); - _itemShowList.Remove(pos); + _itemShowDic.Remove(pos); } - /// - /// 移动项到指定的位置 - /// - /// - /// - private void Move(int index, bool animated) => _itemShowList[index].Move(PageIndex, animated); - private void Viewport3D_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var result = (RayMeshGeometry3DHitTestResult)VisualTreeHelper.HitTest(_viewport3D, e.GetPosition(_viewport3D)); if (result != null) { - foreach (var item in _itemShowList.Values) + foreach (var item in _itemShowDic.Values) { if (item.HitTest(result.MeshHit)) { @@ -236,35 +235,25 @@ namespace HandyControl.Controls /// 更新项的位置 /// /// - /// - private void UpdateIndex(int newIndex, int oldIndex) + private void UpdateIndex(int newIndex) { - var animate = Math.Abs(newIndex - oldIndex) < MaxShowCountHalf; UpdateShowRange(); - if (newIndex > oldIndex) + _itemShowDic.Do(item => { - if (oldIndex < _firstShowIndex) + if (item.Value.Index < _firstShowIndex || item.Value.Index > _lastShowIndex) { - oldIndex = _firstShowIndex; + Remove(item.Value.Index); } - for (var i = oldIndex; i <= newIndex; i++) + else { - Move(i, animate); + item.Value.Move(PageIndex); } - } - else - { - if (oldIndex > _lastShowIndex) - { - oldIndex = _lastShowIndex; - } - for (var i = oldIndex; i >= newIndex; i--) - { - Move(i, animate); - } - } - _camera.Position = new Point3D(CoverFlowItem.Interval * newIndex, _camera.Position.Y, - _camera.Position.Z); + }); + + _point3DAnimation = new Point3DAnimation(new Point3D(CoverFlowItem.Interval * newIndex, _camera.Position.Y, + _camera.Position.Z), new Duration(TimeSpan.FromMilliseconds(200))); + + _camera.BeginAnimation(ProjectionCamera.PositionProperty, _point3DAnimation); } /// @@ -275,27 +264,12 @@ namespace HandyControl.Controls var newFirstShowIndex = Math.Max(PageIndex - MaxShowCountHalf, 0); var newLastShowIndex = Math.Min(PageIndex + MaxShowCountHalf, _contentDic.Count - 1); - if (_firstShowIndex < newFirstShowIndex) - { - for (var i = _firstShowIndex; i < newFirstShowIndex; i++) - { - Remove(i); - } - } - else if (newLastShowIndex < _lastShowIndex) - { - for (var i = newLastShowIndex; i < _lastShowIndex; i++) - { - Remove(i); - } - } - for (var i = newFirstShowIndex; i <= newLastShowIndex; i++) { - if (!_itemShowList.ContainsKey(i)) + if (!_itemShowDic.ContainsKey(i)) { var cover = CreateCoverFlowItem(i, _contentDic[i]); - _itemShowList[i] = cover; + _itemShowDic[i] = cover; _visualParent.Children.Add(cover); } } diff --git a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs index b678f343..485a17be 100644 --- a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs +++ b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs @@ -124,23 +124,14 @@ namespace HandyControl.Controls /// /// 移动 /// - internal void Move(int currentIndex, bool animated) + internal void Move(int currentIndex) { - if (animated || _rotation3D.HasAnimatedProperties) - { - _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty, - AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed)); - _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, - AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed)); - _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, - AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed)); - } - else - { - _rotation3D.Angle = GetAngleByPos(currentIndex); - _transform3D.OffsetX = GetXByPos(currentIndex); - _transform3D.OffsetZ = GetZByPos(currentIndex); - } + _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty, + AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed)); + _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty, + AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed)); + _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty, + AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed)); } /// From cba327d63a2b2f26380377498c9af1aa20d83fb4 Mon Sep 17 00:00:00 2001 From: guanguanchuangyu <3246907890@qq.com> Date: Sun, 22 Mar 2020 17:53:08 +0800 Subject: [PATCH 09/99] add doc of card --- .../extend_controls/card/index.md | 206 +++++++++++++++++- 1 file changed, 205 insertions(+), 1 deletion(-) diff --git a/doc/source/handycontrol/extend_controls/card/index.md b/doc/source/handycontrol/extend_controls/card/index.md index 877d2fd6..894d8dfd 100644 --- a/doc/source/handycontrol/extend_controls/card/index.md +++ b/doc/source/handycontrol/extend_controls/card/index.md @@ -1,3 +1,207 @@ --- -title: Card +title: Card 卡片 --- + +`Card`卡片作为同类型信息展示块,主要有内容头部以及尾部组成,常用于做集合类控件的子级模板使用,展示相同外观不同内容的卡片式风格数据,为`ContentControl`的派生类 + +```c# +public class Card : ContentControl +``` + +# 基础属性 + +| 属性 | 用途 | +| ---------------------- | ------------------------------ | +| Header | 卡片头部内容,用于显示同步文本 | +| HeaderTemplate | 卡片头部模板 | +| HeaderTemplateSelector | 卡片模板样式选择器 | +| HeaderStringFormat | 卡片头部模板内容显示格式 | +| Footer | 卡片尾部内容 | +| FooterTemplate | 卡片尾部模板 | +| FooterTemplateSelector | 卡片尾部样式选择器 | +| FooterStringFormat | 卡片尾部内容显示格式 | + +# 案例 + +## 单卡片使用 + +### `xaml`中使用 + +```xml + + + + + + + + + + + + + + + +``` + +### 效果 + +![Card-SampleCase](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Card-SampleCase.png) + +## 作为数据模板 + +### 数据类型 + +```c# + public class CardModel + { + public string Header { get; set; } + + public string Content { get; set; } + + public string Footer { get; set; } + } +``` + +### 视图实体 + +此实体并没有按照规范的`mvvm`方式进行设计,仅仅是作为普通数据源做展示使用 + +```c# + public class CardDemoViewModel + { + private IList _dataList; + public CardDemoViewModel() + { + DataList = GetCardDataList(); + } + + internal ObservableCollection GetCardDataList() + { + return new ObservableCollection + { + new CardModel + { + Header = "Atomic", + Content = "1.jpg", + Footer = "Stive Morgan" + }, + new CardModel + { + Header = "Zinderlong", + Content = "2.jpg", + Footer = "Zonderling" + }, + new CardModel + { + Header = "Busy Doin' Nothin'", + Content = "3.jpg", + Footer = "Ace Wilder" + }, + new CardModel + { + Header = "Wrong", + Content = "4.jpg", + Footer = "Blaxy Girls" + }, + new CardModel + { + Header = "The Lights", + Content = "5.jpg", + Footer = "Panda Eyes" + }, + new CardModel + { + Header = "EA7-50-Cent Disco", + Content = "6.jpg", + Footer = "еяхат музыка" + }, + new CardModel + { + Header = "Monsters", + Content = "7.jpg", + Footer = "Different Heaven" + }, + new CardModel + { + Header = "Gangsta Walk", + Content = "8.jpg", + Footer = "Illusionize" + }, + new CardModel + { + Header = "Won't Back Down", + Content = "9.jpg", + Footer = "Boehm" + }, + new CardModel + { + Header = "Katchi", + Content = "10.jpg", + Footer = "Ofenbach" + } + }; + } + public IList DataList { get => _dataList; set => _dataList = value; } + } +``` + +### `xaml`中的使用方式 + +`handycontrol`的命名空间和`DataContext`上下文需要自行引入 + +```xml +xmlns:hc="https://handyorg.github.io/handycontrol" +xmlns:data="CardModel所在命名空间" +xmlns:vm="CardDemoViewModel所在命名空间" +........ +``` + +```xml + + + + + + + +``` + +```xml + + + + + + + + + + + + + + + + + + + + + + + +``` + +### 效果 + +![Card-Case01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Card-Case01.png) \ No newline at end of file From 2d40b03334e65d337a7cedbf41af112bdf32ab8e Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 25 Mar 2020 23:14:55 +0800 Subject: [PATCH 10/99] add SimpleText --- src/HandyControl.sln | 2 + .../Controls/Text/OutlineText.cs | 37 +-- .../Controls/Text/SimpleText.cs | 248 ++++++++++++++++++ .../HandyControl_Shared.projitems | 1 + 4 files changed, 273 insertions(+), 15 deletions(-) create mode 100644 src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs diff --git a/src/HandyControl.sln b/src/HandyControl.sln index 1154962f..5040fb3e 100644 --- a/src/HandyControl.sln +++ b/src/HandyControl.sln @@ -34,7 +34,9 @@ Global Shared\HandyControl_Shared\HandyControl_Shared.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 4 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{9a7b52e6-94bb-4e7e-bb6a-7cf6761b79a7}*SharedItemsImports = 4 Shared\HandyControl_Shared\HandyControl_Shared.projitems*{aac11083-faca-405d-9197-5c1212d65656}*SharedItemsImports = 13 + Shared\HandyControl_Shared\HandyControl_Shared.projitems*{be4a567d-b6e0-413e-8f64-e1a53b4f9366}*SharedItemsImports = 5 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{c4694269-c9b8-45d5-87f8-d0088c532510}*SharedItemsImports = 13 + Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d7107690-8592-4f9f-9379-9b82c1c15d2a}*SharedItemsImports = 5 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d8ae88f8-c36b-4d10-a7f9-22ffcfba5231}*SharedItemsImports = 4 Shared\HandyControl_Shared\HandyControl_Shared.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 4 EndGlobalSection diff --git a/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs b/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs index 038480de..abc6a971 100644 --- a/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs +++ b/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs @@ -155,24 +155,31 @@ namespace HandyControl.Controls protected override void OnRender(DrawingContext drawingContext) { - EnsureGeometry(); - - drawingContext.DrawGeometry(Fill, null, _textGeometry); - - if (StrokePosition == StrokePosition.Outside) + if (StrokeThickness > 0) { - drawingContext.PushClip(_clipGeometry); + EnsureGeometry(); + + drawingContext.DrawGeometry(Fill, null, _textGeometry); + + if (StrokePosition == StrokePosition.Outside) + { + drawingContext.PushClip(_clipGeometry); + } + else if (StrokePosition == StrokePosition.Inside) + { + drawingContext.PushClip(_textGeometry); + } + + drawingContext.DrawGeometry(null, _pen, _textGeometry); + + if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside) + { + drawingContext.Pop(); + } } - else if (StrokePosition == StrokePosition.Inside) + else { - drawingContext.PushClip(_textGeometry); - } - - drawingContext.DrawGeometry(null, _pen, _textGeometry); - - if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside) - { - drawingContext.Pop(); + drawingContext.DrawText(_formattedText, new Point()); } } diff --git a/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs new file mode 100644 index 00000000..f8f873ba --- /dev/null +++ b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs @@ -0,0 +1,248 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.Windows; +using System.Windows.Documents; +using System.Windows.Media; +using HandyControl.Data; + +namespace HandyControl.Controls +{ + public class SimpleText : FrameworkElement + { + private Pen _pen; + + private FormattedText _formattedText; + + static SimpleText() + { + SnapsToDevicePixelsProperty.OverrideMetadata(typeof(SimpleText), new FrameworkPropertyMetadata(ValueBoxes.TrueBox)); + UseLayoutRoundingProperty.OverrideMetadata(typeof(SimpleText), new FrameworkPropertyMetadata(ValueBoxes.TrueBox)); + } + + public static readonly DependencyProperty StrokePositionProperty = DependencyProperty.Register( + "StrokePosition", typeof(StrokePosition), typeof(SimpleText), new PropertyMetadata(default(StrokePosition))); + + public StrokePosition StrokePosition + { + get => (StrokePosition)GetValue(StrokePositionProperty); + set => SetValue(StrokePositionProperty, value); + } + + public static readonly DependencyProperty TextProperty = DependencyProperty.Register( + "Text", typeof(string), typeof(SimpleText), new FrameworkPropertyMetadata( + string.Empty, + FrameworkPropertyMetadataOptions.AffectsMeasure | + FrameworkPropertyMetadataOptions.AffectsRender, OnFormattedTextInvalidated)); + + public string Text + { + get => (string)GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register( + "TextAlignment", typeof(TextAlignment), typeof(SimpleText), + new PropertyMetadata(default(TextAlignment), OnFormattedTextUpdated)); + + public TextAlignment TextAlignment + { + get => (TextAlignment)GetValue(TextAlignmentProperty); + set => SetValue(TextAlignmentProperty, value); + } + + public static readonly DependencyProperty TextTrimmingProperty = DependencyProperty.Register( + "TextTrimming", typeof(TextTrimming), typeof(SimpleText), + new PropertyMetadata(default(TextTrimming), OnFormattedTextInvalidated)); + + public TextTrimming TextTrimming + { + get => (TextTrimming)GetValue(TextTrimmingProperty); + set => SetValue(TextTrimmingProperty, value); + } + + public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register( + "TextWrapping", typeof(TextWrapping), typeof(SimpleText), + new PropertyMetadata(TextWrapping.NoWrap, OnFormattedTextInvalidated)); + + public TextWrapping TextWrapping + { + get => (TextWrapping)GetValue(TextWrappingProperty); + set => SetValue(TextWrappingProperty, value); + } + + public static readonly DependencyProperty FillProperty = DependencyProperty.Register( + "Fill", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated)); + + public Brush Fill + { + get => (Brush)GetValue(FillProperty); + set => SetValue(FillProperty, value); + } + + public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register( + "Stroke", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated)); + + public Brush Stroke + { + get => (Brush)GetValue(StrokeProperty); + set => SetValue(StrokeProperty, value); + } + + public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register( + "StrokeThickness", typeof(double), typeof(SimpleText), new PropertyMetadata(ValueBoxes.Double0Box, OnFormattedTextUpdated)); + + public double StrokeThickness + { + get => (double)GetValue(StrokeThicknessProperty); + set => SetValue(StrokeThicknessProperty, value); + } + + public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner( + typeof(SimpleText), + new FrameworkPropertyMetadata(OnFormattedTextUpdated)); + + public FontFamily FontFamily + { + get => (FontFamily)GetValue(FontFamilyProperty); + set => SetValue(FontFamilyProperty, value); + } + + public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner( + typeof(SimpleText), + new FrameworkPropertyMetadata(OnFormattedTextUpdated)); + + [TypeConverter(typeof(FontSizeConverter))] + public double FontSize + { + get => (double)GetValue(FontSizeProperty); + set => SetValue(FontSizeProperty, value); + } + + public static readonly DependencyProperty FontStretchProperty = TextElement.FontStretchProperty.AddOwner( + typeof(SimpleText), + new FrameworkPropertyMetadata(OnFormattedTextUpdated)); + + public FontStretch FontStretch + { + get => (FontStretch)GetValue(FontStretchProperty); + set => SetValue(FontStretchProperty, value); + } + + public static readonly DependencyProperty FontStyleProperty = TextElement.FontStyleProperty.AddOwner( + typeof(SimpleText), + new FrameworkPropertyMetadata(OnFormattedTextUpdated)); + + public FontStyle FontStyle + { + get => (FontStyle)GetValue(FontStyleProperty); + set => SetValue(FontStyleProperty, value); + } + + public static readonly DependencyProperty FontWeightProperty = TextElement.FontWeightProperty.AddOwner( + typeof(SimpleText), + new FrameworkPropertyMetadata(OnFormattedTextUpdated)); + + public FontWeight FontWeight + { + get => (FontWeight)GetValue(FontWeightProperty); + set => SetValue(FontWeightProperty, value); + } + + protected override void OnRender(DrawingContext drawingContext) => drawingContext.DrawText(_formattedText, new Point()); + + private void UpdatePen() + { + _pen = new Pen(Stroke, StrokeThickness); + + if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside) + { + _pen.Thickness = StrokeThickness * 2; + } + } + + private void EnsureFormattedText() + { + if (_formattedText != null || Text == null) + { + return; + } + +#if netle45 + _formattedText = new FormattedText( + Text, + CultureInfo.CurrentUICulture, + FlowDirection, + new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), + FontSize, Fill); +#else + var source = PresentationSource.FromVisual(this); + var dpi = 1.0; + if (source?.CompositionTarget != null) + { + dpi = 96.0 * source.CompositionTarget.TransformToDevice.M11 / 96.0; + } + _formattedText = new FormattedText( + Text, + CultureInfo.CurrentUICulture, + FlowDirection, + new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), + FontSize, Fill, dpi); +#endif + + UpdateFormattedText(); + } + + private void UpdateFormattedText() + { + if (_formattedText == null) + { + return; + } + + _formattedText.MaxLineCount = TextWrapping == TextWrapping.NoWrap ? 1 : int.MaxValue; + _formattedText.TextAlignment = TextAlignment; + _formattedText.Trimming = TextTrimming; + + _formattedText.SetFontSize(FontSize); + _formattedText.SetFontStyle(FontStyle); + _formattedText.SetFontWeight(FontWeight); + _formattedText.SetFontFamily(FontFamily); + _formattedText.SetFontStretch(FontStretch); + } + + private static void OnFormattedTextUpdated(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var outlinedTextBlock = (SimpleText)d; + outlinedTextBlock.UpdateFormattedText(); + + outlinedTextBlock.InvalidateMeasure(); + outlinedTextBlock.InvalidateVisual(); + } + + private static void OnFormattedTextInvalidated(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var outlinedTextBlock = (SimpleText)d; + outlinedTextBlock._formattedText = null; + + outlinedTextBlock.InvalidateMeasure(); + outlinedTextBlock.InvalidateVisual(); + } + + protected override Size MeasureOverride(Size availableSize) + { + EnsureFormattedText(); + + // constrain the formatted text according to the available size + // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions + // the Math.Max call is to ensure we don't hit zero, which will cause MaxTextHeight to throw + _formattedText.MaxTextWidth = Math.Min(3579139, availableSize.Width); + _formattedText.MaxTextHeight = Math.Max(0.0001d, availableSize.Height); + + UpdatePen(); + + // return the desired size + return new Size(_formattedText.Width, _formattedText.Height); + } + } +} \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index a78fba08..1ec85042 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -44,6 +44,7 @@ + From 008fa6689ed7c4b2d7539709b54f827ce487dcd4 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 26 Mar 2020 23:50:02 +0800 Subject: [PATCH 11/99] fixed a bug of TabControl --- src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs index c001fb30..c0aa5600 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs @@ -251,6 +251,8 @@ namespace HandyControl.Controls protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) { base.OnMouseRightButtonDown(e); + + if (VisualTreeHelper.HitTest(this, e.GetPosition(this)) == null) return; IsSelected = true; Focus(); } @@ -293,6 +295,7 @@ namespace HandyControl.Controls { base.OnMouseLeftButtonDown(e); + if (VisualTreeHelper.HitTest(this, e.GetPosition(this)) == null) return; var parent = TabControlParent; if (parent == null) return; From 31ee8e91f2f0faf77db8dd0108d4aa0e973c41df Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Fri, 27 Mar 2020 00:37:25 +0800 Subject: [PATCH 12/99] update SimpleText --- src/HandyControl.sln | 20 ------- .../Controls/Text/SimpleText.cs | 59 +++---------------- 2 files changed, 7 insertions(+), 72 deletions(-) diff --git a/src/HandyControl.sln b/src/HandyControl.sln index 5040fb3e..45fa85fc 100644 --- a/src/HandyControl.sln +++ b/src/HandyControl.sln @@ -106,57 +106,37 @@ Global {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Core31|Any CPU.ActiveCfg = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Core31|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net40|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net40|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net45|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net45|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net462|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net462|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net47|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net47|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net48|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net48|Any CPU.Build.0 = Debug-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core30|Any CPU.ActiveCfg = Release-Core30|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core30|Any CPU.Build.0 = Release-Core30|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core31|Any CPU.ActiveCfg = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core31|Any CPU.Build.0 = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net40|Any CPU.ActiveCfg = Release-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net40|Any CPU.Build.0 = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net45|Any CPU.ActiveCfg = Release-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net45|Any CPU.Build.0 = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net462|Any CPU.ActiveCfg = Release-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net462|Any CPU.Build.0 = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net47|Any CPU.ActiveCfg = Release-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net47|Any CPU.Build.0 = Release-Core31|Any CPU {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net48|Any CPU.ActiveCfg = Release-Core31|Any CPU - {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net48|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core30|Any CPU.ActiveCfg = Debug-Core30|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core30|Any CPU.Build.0 = Debug-Core30|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core31|Any CPU.ActiveCfg = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core31|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net40|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net40|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net45|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net45|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net462|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net462|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net47|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net47|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net48|Any CPU.ActiveCfg = Debug-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net48|Any CPU.Build.0 = Debug-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core30|Any CPU.ActiveCfg = Release-Core30|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core30|Any CPU.Build.0 = Release-Core30|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core31|Any CPU.ActiveCfg = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core31|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net40|Any CPU.ActiveCfg = Release-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net40|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net45|Any CPU.ActiveCfg = Release-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net45|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net462|Any CPU.ActiveCfg = Release-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net462|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net47|Any CPU.ActiveCfg = Release-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net47|Any CPU.Build.0 = Release-Core31|Any CPU {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net48|Any CPU.ActiveCfg = Release-Core31|Any CPU - {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net48|Any CPU.Build.0 = Release-Core31|Any CPU {32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Core30|Any CPU.ActiveCfg = Debug|Any CPU {32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Core31|Any CPU.ActiveCfg = Debug|Any CPU {32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Net40|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs index f8f873ba..84830748 100644 --- a/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs +++ b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs @@ -10,8 +10,6 @@ namespace HandyControl.Controls { public class SimpleText : FrameworkElement { - private Pen _pen; - private FormattedText _formattedText; static SimpleText() @@ -20,15 +18,6 @@ namespace HandyControl.Controls UseLayoutRoundingProperty.OverrideMetadata(typeof(SimpleText), new FrameworkPropertyMetadata(ValueBoxes.TrueBox)); } - public static readonly DependencyProperty StrokePositionProperty = DependencyProperty.Register( - "StrokePosition", typeof(StrokePosition), typeof(SimpleText), new PropertyMetadata(default(StrokePosition))); - - public StrokePosition StrokePosition - { - get => (StrokePosition)GetValue(StrokePositionProperty); - set => SetValue(StrokePositionProperty, value); - } - public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(SimpleText), new FrameworkPropertyMetadata( string.Empty, @@ -71,31 +60,13 @@ namespace HandyControl.Controls set => SetValue(TextWrappingProperty, value); } - public static readonly DependencyProperty FillProperty = DependencyProperty.Register( - "Fill", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated)); + public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register( + "Foreground", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated)); - public Brush Fill + public Brush Foreground { - get => (Brush)GetValue(FillProperty); - set => SetValue(FillProperty, value); - } - - public static readonly DependencyProperty StrokeProperty = DependencyProperty.Register( - "Stroke", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated)); - - public Brush Stroke - { - get => (Brush)GetValue(StrokeProperty); - set => SetValue(StrokeProperty, value); - } - - public static readonly DependencyProperty StrokeThicknessProperty = DependencyProperty.Register( - "StrokeThickness", typeof(double), typeof(SimpleText), new PropertyMetadata(ValueBoxes.Double0Box, OnFormattedTextUpdated)); - - public double StrokeThickness - { - get => (double)GetValue(StrokeThicknessProperty); - set => SetValue(StrokeThicknessProperty, value); + get => (Brush) GetValue(ForegroundProperty); + set => SetValue(ForegroundProperty, value); } public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner( @@ -151,16 +122,6 @@ namespace HandyControl.Controls protected override void OnRender(DrawingContext drawingContext) => drawingContext.DrawText(_formattedText, new Point()); - private void UpdatePen() - { - _pen = new Pen(Stroke, StrokeThickness); - - if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside) - { - _pen.Thickness = StrokeThickness * 2; - } - } - private void EnsureFormattedText() { if (_formattedText != null || Text == null) @@ -174,7 +135,7 @@ namespace HandyControl.Controls CultureInfo.CurrentUICulture, FlowDirection, new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), - FontSize, Fill); + FontSize, Foreground); #else var source = PresentationSource.FromVisual(this); var dpi = 1.0; @@ -187,7 +148,7 @@ namespace HandyControl.Controls CultureInfo.CurrentUICulture, FlowDirection, new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), - FontSize, Fill, dpi); + FontSize, Foreground, dpi); #endif UpdateFormattedText(); @@ -233,15 +194,9 @@ namespace HandyControl.Controls { EnsureFormattedText(); - // constrain the formatted text according to the available size - // the Math.Min call is important - without this constraint (which seems arbitrary, but is the maximum allowable text width), things blow up when availableSize is infinite in both directions - // the Math.Max call is to ensure we don't hit zero, which will cause MaxTextHeight to throw _formattedText.MaxTextWidth = Math.Min(3579139, availableSize.Width); _formattedText.MaxTextHeight = Math.Max(0.0001d, availableSize.Height); - UpdatePen(); - - // return the desired size return new Size(_formattedText.Width, _formattedText.Height); } } From b7222be265a47d817189e1c2178879b6c524944d Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 28 Mar 2020 14:27:13 +0800 Subject: [PATCH 13/99] update StepBar & readme --- README.md | 3 +- .../UserControl/Controls/StepBarDemoCtl.xaml | 2 +- .../Controls/StepBarDemoViewModel.cs | 12 ++ .../Controls/StepBar/StepBar.cs | 117 ++++++++++-------- 4 files changed, 81 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index ff539909..02b72924 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ [https://handyorg.github.io/handycontrol/](https://handyorg.github.io/handycontrol/) ### 赞助 -如果您觉得HandyControl还不错,并且刚好有些闲钱,那么可以选择以下两种方式来赞助: +如果您觉得HandyControl还不错,并且刚好有些闲钱,那么可以选择以下两种方式来赞助(记得入群联系我们呀~~): * [以HandyControl的名义为慈善事业做贡献](http://www.chinacharityfederation.org/ConfirmDonation/0.html?zhijie=3) @@ -54,6 +54,7 @@ + ## Special thanks to diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml index dbce1495..0c230a0b 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml @@ -18,7 +18,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs index 8c2032c1..49d03a53 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs @@ -16,6 +16,18 @@ namespace HandyControlDemo.ViewModel { public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList(); + private int _stepIndex; + + public int StepIndex + { + get => _stepIndex; +#if netle40 + set => Set(nameof(StepIndex), ref _stepIndex, value); +#else + set => Set(ref _stepIndex, value); +#endif + } + /// /// 下一步 /// diff --git a/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs b/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs index 4a085542..e4f7396c 100644 --- a/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs +++ b/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs @@ -18,6 +18,8 @@ namespace HandyControl.Controls { private ProgressBar _progressBarBack; + private int _oriStepIndex = -1; + #region Constants private const string ElementProgressBarBack = "PART_ProgressBarBack"; @@ -46,19 +48,14 @@ namespace HandyControl.Controls } } - if (StepIndex < count) + if (_oriStepIndex > 0) { - for (var i = 0; i < StepIndex; i++) - { - if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepBarItem) - { - stepBarItem.Status = StepStatus.Complete; - } - } - if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem item) - { - item.Status = StepStatus.UnderWay; - } + StepIndex = _oriStepIndex; + _oriStepIndex = -1; + } + else + { + OnStepIndexChanged(StepIndex); } } } @@ -85,12 +82,64 @@ namespace HandyControl.Controls } public static readonly DependencyProperty StepIndexProperty = DependencyProperty.Register( - "StepIndex", typeof(int), typeof(StepBar), new PropertyMetadata(ValueBoxes.Int0Box)); + "StepIndex", typeof(int), typeof(StepBar), new FrameworkPropertyMetadata(ValueBoxes.Int0Box, + FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnStepIndexChanged, CoerceStepIndex)); + + private static object CoerceStepIndex(DependencyObject d, object basevalue) + { + var ctl = (StepBar)d; + var stepIndex = (int) basevalue; + if (ctl.Items.Count == 0 && stepIndex > 0) + { + ctl._oriStepIndex = stepIndex; + return ValueBoxes.Int0Box; + } + + return stepIndex < 0 + ? ValueBoxes.Int0Box + : stepIndex >= ctl.Items.Count + ? ctl.Items.Count == 0 ? 0 : ctl.Items.Count - 1 + : basevalue; + } + + private static void OnStepIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var ctl = (StepBar) d; + ctl.OnStepIndexChanged((int)e.NewValue); + } + + private void OnStepIndexChanged(int stepIndex) + { + for (var i = 0; i < stepIndex; i++) + { + if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepItemFinished) + { + stepItemFinished.Status = StepStatus.Complete; + } + } + + for (var i = stepIndex + 1; i < Items.Count; i++) + { + if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepItemFinished) + { + stepItemFinished.Status = StepStatus.Waiting; + } + } + + if (ItemContainerGenerator.ContainerFromIndex(stepIndex) is StepBarItem stepItemSelected) + stepItemSelected.Status = StepStatus.UnderWay; + _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(stepIndex)); + + RaiseEvent(new FunctionEventArgs(StepChangedEvent, this) + { + Info = stepIndex + }); + } public int StepIndex { - get => (int)GetValue(StepIndexProperty); - protected set => SetValue(StepIndexProperty, value); + get => (int)GetValue(StepIndexProperty); + set => SetValue(StepIndexProperty, value); } public static readonly DependencyProperty DockProperty = DependencyProperty.Register( @@ -128,42 +177,8 @@ namespace HandyControl.Controls } } - public void Next() - { - StepIndex++; - if (StepIndex >= Items.Count) - { - StepIndex = Items.Count - 1; - return; - } - RaiseEvent(new FunctionEventArgs(StepChangedEvent, this) - { - Info = StepIndex - }); - if (ItemContainerGenerator.ContainerFromIndex(StepIndex - 1) is StepBarItem stepItemFinished) - stepItemFinished.Status = StepStatus.Complete; - if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected) - stepItemSelected.Status = StepStatus.UnderWay; - _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex)); - } + public void Next() => StepIndex++; - public void Prev() - { - StepIndex--; - if (StepIndex < 0) - { - StepIndex = 0; - return; - } - RaiseEvent(new FunctionEventArgs(StepChangedEvent, this) - { - Info = StepIndex - }); - if (ItemContainerGenerator.ContainerFromIndex(StepIndex + 1) is StepBarItem stepItemWaiting) - stepItemWaiting.Status = StepStatus.Waiting; - if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected) - stepItemSelected.Status = StepStatus.UnderWay; - _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex)); - } + public void Prev() => StepIndex--; } } \ No newline at end of file From aec26ea5bec407e99bff74c402fccd71200b510f Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 29 Mar 2020 00:54:44 +0800 Subject: [PATCH 14/99] optimized menu style --- .../Controls/Attach/MenuTopLineAttach.cs | 99 +++++++++++++++++++ .../HandyControl_Shared.projitems | 1 + .../Themes/Styles/Base/MenuBaseStyle.xaml | 5 +- .../Converter/TreeViewItemMarginConverter.cs | 1 - .../Tools/Helper/VisualHelper.cs | 25 ++--- 5 files changed, 116 insertions(+), 15 deletions(-) create mode 100644 src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs new file mode 100644 index 00000000..81be40a2 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs @@ -0,0 +1,99 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using HandyControl.Tools; +using HandyControl.Tools.Interop; + +namespace HandyControl.Controls +{ + public class MenuTopLineAttach + { + public static readonly DependencyProperty PopupProperty = DependencyProperty.RegisterAttached( + "Popup", typeof(Popup), typeof(MenuTopLineAttach), new PropertyMetadata(default(Popup), OnPopupChanged)); + + private static void OnPopupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var topLine = (FrameworkElement) d; + + if (e.NewValue is Popup popup) + { + if (popup.TemplatedParent is MenuItem menuItem) + { + SetTopLine(menuItem, topLine); + menuItem.Unloaded += MenuItem_Unloaded; + } + popup.Opened += Popup_Opened; + } + } + + private static void MenuItem_Unloaded(object sender, RoutedEventArgs e) + { + var menuItem = (FrameworkElement)sender; + menuItem.Unloaded -= MenuItem_Unloaded; + var topLine = GetTopLine(menuItem); + var popup = GetPopup(topLine); + if (popup != null) + { + popup.Opened -= Popup_Opened; + } + } + + private static void Popup_Opened(object sender, EventArgs e) + { + var popup = (Popup) sender; + if (popup.TemplatedParent is MenuItem menuItem) + { + var topLine = GetTopLine(menuItem); + if (topLine == null) return; + + topLine.HorizontalAlignment = HorizontalAlignment.Left; + topLine.Width = menuItem.ActualWidth; + topLine.Margin = new Thickness(); + + var positionLeftTop = menuItem.PointToScreen(new Point()); + var positionRightBottom = menuItem.PointToScreen(new Point(menuItem.ActualWidth, menuItem.ActualHeight)); + ScreenHelper.FindMonitorRectsFromPoint(InteropMethods.GetCursorPos(), out _, out var workAreaRect); + var panel = VisualHelper.GetParent(topLine); + + if (positionLeftTop.X < 0) + { + + topLine.Margin = new Thickness(positionLeftTop.X - panel.Margin.Left, 0, 0, 0); + } + else if (positionLeftTop.X + panel.ActualWidth > workAreaRect.Right) + { + var overflowWidth = positionRightBottom.X - workAreaRect.Right; + if (overflowWidth > 0) + { + topLine.Width -= overflowWidth + panel.Margin.Right; + } + topLine.HorizontalAlignment = HorizontalAlignment.Left; + topLine.Margin = new Thickness(positionLeftTop.X + panel.ActualWidth - workAreaRect.Right + panel.Margin.Right, 0, 0, 0); + } + + if (positionRightBottom.Y > workAreaRect.Bottom) + { + topLine.Width = 0; + topLine.HorizontalAlignment = HorizontalAlignment.Stretch; + topLine.Margin = new Thickness(); + } + } + } + + public static void SetPopup(DependencyObject element, Popup value) + => element.SetValue(PopupProperty, value); + + public static Popup GetPopup(DependencyObject element) + => (Popup) element.GetValue(PopupProperty); + + internal static readonly DependencyProperty TopLineProperty = DependencyProperty.RegisterAttached( + "TopLine", typeof(FrameworkElement), typeof(MenuTopLineAttach), new PropertyMetadata(default(FrameworkElement))); + + internal static void SetTopLine(DependencyObject element, FrameworkElement value) + => element.SetValue(TopLineProperty, value); + + internal static FrameworkElement GetTopLine(DependencyObject element) + => (FrameworkElement) element.GetValue(TopLineProperty); + } +} diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index 1ec85042..cf7a8042 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -17,6 +17,7 @@ + diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml index bd7b0652..4bc5ed76 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml @@ -3,6 +3,7 @@ xmlns:controls="clr-namespace:HandyControl.Controls"> + @@ -64,13 +65,13 @@ - + - + diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs index b8872602..a6bbd3e7 100644 --- a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs +++ b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs @@ -8,7 +8,6 @@ namespace HandyControl.Tools.Converter { public class TreeViewItemMarginConverter: IValueConverter { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var left = 0.0; diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs index b6351478..84a088e1 100644 --- a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs +++ b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs @@ -20,12 +20,10 @@ namespace HandyControl.Tools .FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0); } - internal static FrameworkElement GetImplementationRoot(DependencyObject d) - { - return 1 == VisualTreeHelper.GetChildrenCount(d) + internal static FrameworkElement GetImplementationRoot(DependencyObject d) => + 1 == VisualTreeHelper.GetChildrenCount(d) ? VisualTreeHelper.GetChild(d, 0) as FrameworkElement : null; - } public static T GetChild(DependencyObject d) where T : DependencyObject { @@ -42,16 +40,19 @@ namespace HandyControl.Tools return default; } - public static IntPtr GetHandle(this Visual visual) - { - return (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero; - } + public static T GetParent(DependencyObject d) where T : DependencyObject => + d switch + { + null => default, + T t => t, + Window _ => null, + _ => GetParent(VisualTreeHelper.GetParent(d)) + }; - internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback, - HitTestParameters parameters) - { + public static IntPtr GetHandle(this Visual visual) => (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero; + + internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback, HitTestParameters parameters) => VisualTreeHelper.HitTest(visual, ExcludeNonVisualElements, resultCallback, parameters); - } private static HitTestFilterBehavior ExcludeNonVisualElements(DependencyObject potentialHitTestTarget) { From efa05191dac9eb9c97e9adeca385a327f5180533 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 29 Mar 2020 20:02:42 +0800 Subject: [PATCH 15/99] completed the missing code --- src/Shared/HandyControlDemo_Shared/App.xaml.cs | 2 ++ .../Controls/Attach/MenuTopLineAttach.cs | 15 +++++++++++++-- .../Themes/Styles/Base/ContextMenuBaseStyle.xaml | 3 ++- .../Themes/Styles/Base/MenuBaseStyle.xaml | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs index 05d65336..1eb7fa4f 100644 --- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs +++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs @@ -71,6 +71,8 @@ namespace HandyControlDemo } ConfigHelper.Instance.SetSystemVersionInfo(CommonHelper.GetSystemVersionInfo()); + ConfigHelper.Instance.SetWindowDefaultStyle(); + ConfigHelper.Instance.SetNavigationWindowDefaultStyle(); ServicePointManager.SecurityProtocol = (SecurityProtocolType)(SslProtocols)0x00000C00; } diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs index 81be40a2..5d6cd18f 100644 --- a/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs +++ b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs @@ -21,8 +21,19 @@ namespace HandyControl.Controls if (popup.TemplatedParent is MenuItem menuItem) { SetTopLine(menuItem, topLine); - menuItem.Unloaded += MenuItem_Unloaded; - } + menuItem.Loaded += MenuItem_Loaded; + } + } + } + + private static void MenuItem_Loaded(object sender, RoutedEventArgs e) + { + var menuItem = (FrameworkElement)sender; + menuItem.Unloaded += MenuItem_Unloaded; + var topLine = GetTopLine(menuItem); + var popup = GetPopup(topLine); + if (popup != null) + { popup.Opened += Popup_Opened; } } diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml index 367c0b7f..85f1d0e6 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + @@ -11,7 +12,7 @@ - + diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml index 4bc5ed76..d9d3be29 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml @@ -167,7 +167,7 @@ - + @@ -185,7 +185,7 @@ - + From 95d847d72c89a3765334d3c3d2112903dd234bd2 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 29 Mar 2020 23:58:32 +0800 Subject: [PATCH 16/99] merge #339 --- src/HandyControl.sln | 2 + .../Data/MessageToken.cs | 2 + .../Data/MessageToken.tt | 3 +- .../Properties/Langs/Lang.Designer.cs | 9 +++ .../Properties/Langs/Lang.en.resx | 3 + .../Properties/Langs/Lang.fa.resx | 3 + .../Properties/Langs/Lang.fr.resx | 3 + .../Properties/Langs/Lang.ko-KR.resx | 3 + .../Properties/Langs/Lang.resx | 3 + .../UserControl/Controls/DialogDemoCtl.xaml | 27 +++++---- .../ViewModel/Controls/DialogDemoViewModel.cs | 15 +++-- .../Controls/Other/Dialog.cs | 56 +++++++++---------- 12 files changed, 86 insertions(+), 43 deletions(-) diff --git a/src/HandyControl.sln b/src/HandyControl.sln index 1154962f..5040fb3e 100644 --- a/src/HandyControl.sln +++ b/src/HandyControl.sln @@ -34,7 +34,9 @@ Global Shared\HandyControl_Shared\HandyControl_Shared.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 4 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{9a7b52e6-94bb-4e7e-bb6a-7cf6761b79a7}*SharedItemsImports = 4 Shared\HandyControl_Shared\HandyControl_Shared.projitems*{aac11083-faca-405d-9197-5c1212d65656}*SharedItemsImports = 13 + Shared\HandyControl_Shared\HandyControl_Shared.projitems*{be4a567d-b6e0-413e-8f64-e1a53b4f9366}*SharedItemsImports = 5 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{c4694269-c9b8-45d5-87f8-d0088c532510}*SharedItemsImports = 13 + Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d7107690-8592-4f9f-9379-9b82c1c15d2a}*SharedItemsImports = 5 Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d8ae88f8-c36b-4d10-a7f9-22ffcfba5231}*SharedItemsImports = 4 Shared\HandyControl_Shared\HandyControl_Shared.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 4 EndGlobalSection diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs index bcc0bcbd..456917df 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs +++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs @@ -46,5 +46,7 @@ public static readonly string NavigationWindow = nameof(NavigationWindow); + public static readonly string DialogContainer = nameof(DialogContainer); + } } \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt index 76cbb2b3..9c53e44f 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt +++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt @@ -25,7 +25,8 @@ var messageList = new List "QQGroupView", "GlowWindow", "NativeCommonWindow", - "NavigationWindow" + "NavigationWindow", + "DialogContainer" }; #> namespace HandyControlDemo.Data diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs index e3078682..5fcf9206 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs @@ -1725,6 +1725,15 @@ namespace HandyControlDemo.Properties.Langs { } } + /// + /// 查找类似 文本对话框(控件中) 的本地化字符串。 + /// + public static string TextDialogInControl { + get { + return ResourceManager.GetString("TextDialogInControl", resourceCulture); + } + } + /// /// 查找类似 文本对话框,带计时器 的本地化字符串。 /// diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx index 97bad55c..63f989ac 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx @@ -744,4 +744,7 @@ Screenshot + + TextDialog(In control) + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx index b1d3c4fe..e3bb5ced 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx @@ -744,4 +744,7 @@ Screenshot + + TextDialog(In control) + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx index 3c22a942..c24dda27 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx @@ -744,4 +744,7 @@ Screenshot + + TextDialog(In control) + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx index 88562ce8..70c29806 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx @@ -744,4 +744,7 @@ Screenshot + + TextDialog(In control) + \ 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 f4e63998..736038d0 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx @@ -744,4 +744,7 @@ 截图 + + 文本对话框(控件中) + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml index c8973990..7a2522b9 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml @@ -3,16 +3,23 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:data="clr-namespace:HandyControlDemo.Data" + hc:Dialog.Token="{x:Static data:MessageToken.DialogContainer}" Background="{DynamicResource RegionBrush}" - MinWidth="300" + MinWidth="500" DataContext="{Binding DialogDemo,Source={StaticResource Locator}}"> - - - - - - - -``` - -![Badge-Attention01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Attention01.png) - - - - - +![Badge-ErrorCorrection01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-ErrorCorrection01.png) \ No newline at end of file From da0ec024d58ea142abbe44a3963a3616a52d5cb5 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 1 Apr 2020 23:19:18 +0800 Subject: [PATCH 27/99] Revert "update Card doc" This reverts commit e1769e333f9948523e41debc1eb806fc552827c8. --- .../extend_controls/badge/index.md | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/badge/index.md b/doc/source/handycontrol/extend_controls/badge/index.md index fcf8bb57..0925107e 100644 --- a/doc/source/handycontrol/extend_controls/badge/index.md +++ b/doc/source/handycontrol/extend_controls/badge/index.md @@ -19,7 +19,7 @@ public class Badge : ContentControl | BadgeMargin | 获取或设置标记相对于被修饰控件的外边距 | | ShowBadge | 获取或设置是否显示标记,默认为True | -`xaml`中,记得引入`handycontrol`的命名空间。 +`xaml`中,记得引入`handycontrol`的命名空间 ```xml xmlns:hc="https://handyorg.github.io/handycontrol" @@ -27,7 +27,7 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ## `Text`和`Value` -可能看到属性解释,会比较疑惑,`Text`和`Value`在效果和数值上是一样的,这有什么区别?在标记控件中,将文本和数值类型进行区分,数值类型能够进行动态的变更以及数据统计显示效果,当两者同时存在时,默认显示`Text`。 +可能看到属性解释,会比较疑惑,`Text`和`Value`在现实效果和数据填写时,是一样的,这有什么区别?在标记控件中,将文本和数值类型进行区分,数值类型能够进行动态的变更以及数据统计显示效果,当两者同时存在时,默认显示`Text`,由于标记的`Status`默认为文本 ### 案例 @@ -148,7 +148,7 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ![Badge-Styles](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Styles.png) -# FAQ +# 常见问题 ## 坐标偏移问题[版本 小于等于 2.4] @@ -182,4 +182,24 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ``` -![Badge-ErrorCorrection01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-ErrorCorrection01.png) \ No newline at end of file +![Badge-ErrorCorrection01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-ErrorCorrection01.png) + +## 标记适用范围 + +标记派生至`ContentControl`,不支持多子集,仅仅能够包含一个子集,支持`ContentControl`支持的所有控件作为被标记控件 + +```xml + + + + + + +``` + +![Badge-Attention01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Attention01.png) + + + + + From 0b0ddc7db1c3d6cbc70dfaefb6c44a9976ebc833 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 1 Apr 2020 23:20:01 +0800 Subject: [PATCH 28/99] update Badge doc --- .../extend_controls/badge/index.md | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/badge/index.md b/doc/source/handycontrol/extend_controls/badge/index.md index 0925107e..fcf8bb57 100644 --- a/doc/source/handycontrol/extend_controls/badge/index.md +++ b/doc/source/handycontrol/extend_controls/badge/index.md @@ -19,7 +19,7 @@ public class Badge : ContentControl | BadgeMargin | 获取或设置标记相对于被修饰控件的外边距 | | ShowBadge | 获取或设置是否显示标记,默认为True | -`xaml`中,记得引入`handycontrol`的命名空间 +`xaml`中,记得引入`handycontrol`的命名空间。 ```xml xmlns:hc="https://handyorg.github.io/handycontrol" @@ -27,7 +27,7 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ## `Text`和`Value` -可能看到属性解释,会比较疑惑,`Text`和`Value`在现实效果和数据填写时,是一样的,这有什么区别?在标记控件中,将文本和数值类型进行区分,数值类型能够进行动态的变更以及数据统计显示效果,当两者同时存在时,默认显示`Text`,由于标记的`Status`默认为文本 +可能看到属性解释,会比较疑惑,`Text`和`Value`在效果和数值上是一样的,这有什么区别?在标记控件中,将文本和数值类型进行区分,数值类型能够进行动态的变更以及数据统计显示效果,当两者同时存在时,默认显示`Text`。 ### 案例 @@ -148,7 +148,7 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ![Badge-Styles](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Styles.png) -# 常见问题 +# FAQ ## 坐标偏移问题[版本 小于等于 2.4] @@ -182,24 +182,4 @@ xmlns:hc="https://handyorg.github.io/handycontrol" ``` -![Badge-ErrorCorrection01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-ErrorCorrection01.png) - -## 标记适用范围 - -标记派生至`ContentControl`,不支持多子集,仅仅能够包含一个子集,支持`ContentControl`支持的所有控件作为被标记控件 - -```xml - - - - - - -``` - -![Badge-Attention01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-Attention01.png) - - - - - +![Badge-ErrorCorrection01](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Badge-ErrorCorrection01.png) \ No newline at end of file From 4fe502de778527e99998bcd12b600d0102dabbfa Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 1 Apr 2020 23:20:11 +0800 Subject: [PATCH 29/99] update Card doc --- doc/source/handycontrol/extend_controls/card/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/handycontrol/extend_controls/card/index.md b/doc/source/handycontrol/extend_controls/card/index.md index 894d8dfd..98a172fb 100644 --- a/doc/source/handycontrol/extend_controls/card/index.md +++ b/doc/source/handycontrol/extend_controls/card/index.md @@ -2,7 +2,7 @@ title: Card 卡片 --- -`Card`卡片作为同类型信息展示块,主要有内容头部以及尾部组成,常用于做集合类控件的子级模板使用,展示相同外观不同内容的卡片式风格数据,为`ContentControl`的派生类 +用于卡片化展示数据,为`ContentControl`的派生类 ```c# public class Card : ContentControl From e16f3d4998ff0e85071fe293e5e8146ca3354d6f Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 2 Apr 2020 00:04:15 +0800 Subject: [PATCH 30/99] Update ComboBoxBaseStyle.xaml --- .../Themes/Styles/Base/ComboBoxBaseStyle.xaml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Core_GE30/HandyControl_Core_GE30/Themes/Styles/Base/ComboBoxBaseStyle.xaml b/src/Core_GE30/HandyControl_Core_GE30/Themes/Styles/Base/ComboBoxBaseStyle.xaml index f57cf567..c12c3416 100644 --- a/src/Core_GE30/HandyControl_Core_GE30/Themes/Styles/Base/ComboBoxBaseStyle.xaml +++ b/src/Core_GE30/HandyControl_Core_GE30/Themes/Styles/Base/ComboBoxBaseStyle.xaml @@ -86,7 +86,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -216,7 +216,7 @@ - + @@ -294,7 +294,7 @@ - + @@ -360,7 +360,7 @@ - + @@ -424,7 +424,7 @@ - + @@ -597,7 +597,7 @@ - + @@ -701,7 +701,7 @@ - + @@ -808,7 +808,7 @@ - + @@ -932,7 +932,7 @@ - + @@ -1071,7 +1071,7 @@ - + @@ -1192,7 +1192,7 @@ - + @@ -1348,4 +1348,4 @@ - \ No newline at end of file + From 8d328dbc4bb724e1fba01a8708e6af28554b02a4 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 2 Apr 2020 22:05:51 +0800 Subject: [PATCH 31/99] Update README.md --- README.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b9245ba3..820f3c14 100644 --- a/README.md +++ b/README.md @@ -27,16 +27,19 @@ ## Contributors - - - - - - - - - - +ghost1372 +DingpingZhang +M0n7y5 +guanguanchuangyu +yanchao891012 +noctwolf +xianyun666 +afunc233 +DinoChan +MrZhangYuan +JinhuaChen-OMEC +seedtyx +KleinPan ## Backers From 9113a624ea3e2b38243270cd3850617d6f9ddfa1 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 2 Apr 2020 22:22:02 +0800 Subject: [PATCH 32/99] update doc --- .../extend_controls/growl/index.md | 19 +++++++++++++++++++ doc/source/handycontrol/tnx/index.md | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/growl/index.md b/doc/source/handycontrol/extend_controls/growl/index.md index 744b2956..b69e2b79 100644 --- a/doc/source/handycontrol/extend_controls/growl/index.md +++ b/doc/source/handycontrol/extend_controls/growl/index.md @@ -95,26 +95,45 @@ title: Growl 信息通知 | Success(string) | 显示一则成功通知 | | Success(string, string) | 使用指定的消息标记显示一则成功通知 | | Success(GrowlInfo) | 使用完整的消息初始化模型显示一则成功通知 | +| SuccessGlobal(string) | 显示一则全局成功通知 | +| SuccessGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局成功通知 | | Info(string) | 显示一则消息通知 | | Info(string, string) | 使用指定的消息标记显示一则消息通知 | | Info(GrowlInfo) | 使用完整的消息初始化模型显示一则消息通知 | +| InfoGlobal(string) | 显示一则全局消息通知 | +| InfoGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局消息通知 | | Warning(string) | 显示一则警告通知 | | Warning(string, string) | 使用指定的消息标记显示一则警告通知 | | Warning(GrowlInfo) | 使用完整的消息初始化模型显示一则警告通知 | +| WarningGlobal(string) | 显示一则全局警告通知 | +| WarningGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局警告通知 | | Error(string) | 显示一则错误通知 | | Error(string, string) | 使用指定的消息标记显示一则错误通知 | | Error(GrowlInfo) | 使用完整的消息初始化模型显示一则错误通知 | +| ErrorGlobal(string) | 显示一则全局错误通知 | +| ErrorGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局错误通知 | | Fatal(string) | 显示一则严重通知 | | Fatal(string, string) | 使用指定的消息标记显示一则严重通知 | | Fatal(GrowlInfo) | 使用完整的消息初始化模型显示一则严重通知 | +| FatalGlobal(string) | 显示一则全局严重通知 | +| FatalGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局严重通知 | | Ask(string, Func) | 显示一则询问通知 | | Ask(string, Func, string) | 使用指定的消息标记显示一则询问通知 | | Ask(GrowlInfo) | 使用完整的消息初始化模型显示一则询问通知 | +| AskGlobal(string, Func) | 显示一则全局询问通知 | +| AskGlobal(GrowlInfo) | 使用完整的消息初始化模型显示一则全局询问通知 | | Register(string, Panel) | 为指定的容器注册消息标记 | | Unregister(string, Panel) | 为指定的容器取消消息标记的注册 | | Unregister(Panel) | 如果该容器注册了消息标记则取消注册 | +| Unregister(string) | 如果该消息标记有对应的容器则取消注册 | | Clear( ) | 清空当前使用的消息容器中的消息 | | Clear(string) | 清空含有指定消息标记的消息容器中的消息 | +| Clear(Panel) | 清空指定容器中的消息 | +| ClearGlobal( ) | 清空全局容器中的消息 | + +# 注意 + +`Error` 和 `Fatal`模式不会自动关闭。 # FAQ diff --git a/doc/source/handycontrol/tnx/index.md b/doc/source/handycontrol/tnx/index.md index ca232716..8b5c9cc4 100644 --- a/doc/source/handycontrol/tnx/index.md +++ b/doc/source/handycontrol/tnx/index.md @@ -4,12 +4,12 @@ title: 鸣谢 # 感谢以下Coder提供代码贡献 -

ghost1372Dingping ZhangM0n7y5guanguanchuangyuyanchao891012noctwolfxianyun666afunc233DinoChanMrZhangYuan

+

ghost1372Dingping ZhangM0n7y5guanguanchuangyuyanchao891012noctwolfxianyun666afunc233DinoChanMrZhangYuanYC946586wihalostartewho5653325

# 感谢以下组织机构提供开源许可 -

JetBrains

+

Visual Studio Community 2019JetBrains

# 感谢以下捐赠者 -

bigorange190014632791IUpdatablemapleweisunshang-hlyangkang326zmrbakAFei19911012wayne2006towerDLHBluceBosenMrZhangYuanYC946586

\ No newline at end of file +

bigorange190014632791IUpdatablemapleweisunshang-hlyangkang326zmrbakAFei19911012wayne2006towerDLHBluceBosenMrZhangYuanYC946586wihalostartewho5653325

\ No newline at end of file From aead17d5b78fe1ef6b7bc7ff15f9dced55c8cf8a Mon Sep 17 00:00:00 2001 From: DinoChan Date: Fri, 3 Apr 2020 15:55:21 +0800 Subject: [PATCH 33/99] update passwordbox document --- doc/source/handycontrol/extend_controls/passwordBox/index.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/source/handycontrol/extend_controls/passwordBox/index.md b/doc/source/handycontrol/extend_controls/passwordBox/index.md index ea751e04..90231b22 100644 --- a/doc/source/handycontrol/extend_controls/passwordBox/index.md +++ b/doc/source/handycontrol/extend_controls/passwordBox/index.md @@ -20,11 +20,6 @@ public class PasswordBox : Control, IDataInput var passwordBox = new PasswordBox(); ``` -生成的PasswordBox如下图所示: - -![PasswordBox](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/PasswordBox_1.png) - - # 输入密码 From e5307d0b4cf4878921dc539978dd36b5c1a795d0 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 4 Apr 2020 00:09:49 +0800 Subject: [PATCH 34/99] update pr/338 --- .../Controls/Other/NotifyIcon.cs | 34 ++++++++----------- .../Extension/FrameworkElementExtension.cs | 9 +---- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs index 5dff7b65..592f3313 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs @@ -6,12 +6,12 @@ using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; using HandyControl.Data; using HandyControl.Tools; -using HandyControl.Tools.Extension; using HandyControl.Tools.Interop; namespace HandyControl.Controls @@ -85,30 +85,24 @@ namespace HandyControl.Controls ctl.UpdateIcon(false); } } - private static void DataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - NotifyIcon owner = (NotifyIcon)d; - owner.OnDataContextPropertyChanged(e); - } + + private static void DataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => + ((NotifyIcon) d).OnDataContextPropertyChanged(e); private void OnDataContextPropertyChanged(DependencyPropertyChangedEventArgs e) { - object newValue = e.NewValue; - object oldValue = e.OldValue; - UpdateDataContext(_contextContent, oldValue, newValue); - UpdateDataContext(ContextMenu, oldValue, newValue); + UpdateDataContext(_contextContent, e.OldValue, e.NewValue); + UpdateDataContext(ContextMenu, e.OldValue, e.NewValue); } private static void ContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - NotifyIcon owner = (NotifyIcon)d; - owner.OnContextMenuPropertyChanged(e); + var ctl = (NotifyIcon)d; + ctl.OnContextMenuPropertyChanged(e); } - private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e) - { - UpdateDataContext((ContextMenu)e.NewValue, null, DataContext); - } + private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e) => + UpdateDataContext((ContextMenu) e.NewValue, null, DataContext); public NotifyIcon() { @@ -703,12 +697,12 @@ namespace HandyControl.Controls remove => RemoveHandler(MouseDoubleClickEvent, value); } - private void UpdateDataContext(FrameworkElement target, object oldDataContextValue, object newDataContextValue) + private void UpdateDataContext(FrameworkElement target, object oldValue, object newValue) { - if (target == null || target.IsDataContextDataBound()) return; - if (ReferenceEquals(this, target.DataContext) || Equals(oldDataContextValue, target.DataContext)) + if (target == null || BindingOperations.GetBindingExpression(target, DataContextProperty) != null) return; + if (ReferenceEquals(this, target.DataContext) || Equals(oldValue, target.DataContext)) { - target.DataContext = newDataContextValue ?? this; + target.DataContext = newValue ?? this; } } diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs index 8028f5b8..8810122d 100644 --- a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs +++ b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs @@ -1,5 +1,4 @@ -using System; -using System.Windows; +using System.Windows; namespace HandyControl.Tools.Extension { @@ -55,11 +54,5 @@ namespace HandyControl.Tools.Extension return 0; } - - public static bool IsDataContextDataBound(this FrameworkElement element) - { - if (element == null) throw new ArgumentNullException(nameof(element)); - return element.GetBindingExpression(FrameworkElement.DataContextProperty) != null; - } } } \ No newline at end of file From 501a6376893fa8c6cf78ab011d82fe5d3e543bc3 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 4 Apr 2020 15:06:47 +0800 Subject: [PATCH 35/99] merged pr/347 --- .../handycontrol/extend_controls/blurWindow/index.md | 5 ----- .../handycontrol/extend_controls/clock/index.md | 11 ++--------- doc/source/handycontrol/extend_controls/index.md | 4 ++-- .../handycontrol/extend_controls/passwordBox/index.md | 9 +++------ .../handycontrol/extend_controls/radioGroup/index.md | 5 ----- .../handycontrol/extend_controls/textBox/index.md | 8 +------- doc/themes/next/_config.yml | 4 +--- 7 files changed, 9 insertions(+), 37 deletions(-) delete mode 100644 doc/source/handycontrol/extend_controls/blurWindow/index.md delete mode 100644 doc/source/handycontrol/extend_controls/radioGroup/index.md diff --git a/doc/source/handycontrol/extend_controls/blurWindow/index.md b/doc/source/handycontrol/extend_controls/blurWindow/index.md deleted file mode 100644 index ca12ad62..00000000 --- a/doc/source/handycontrol/extend_controls/blurWindow/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: 建设中 ---- - -建设中 \ No newline at end of file diff --git a/doc/source/handycontrol/extend_controls/clock/index.md b/doc/source/handycontrol/extend_controls/clock/index.md index e27b7d54..89fc1253 100644 --- a/doc/source/handycontrol/extend_controls/clock/index.md +++ b/doc/source/handycontrol/extend_controls/clock/index.md @@ -1,5 +1,5 @@ --- -title: Clock +title: Clock 时钟 --- Clock 控件展示一个虚拟的时钟,允许用户在这个时钟上选择时间。 @@ -29,9 +29,7 @@ var clock = new Clock(); ![Clock](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/Clock_1.png) - - -# 选择s时间 +# 选择时间 可以通过点击左边的时钟,或者点击右边的时分秒列表选择时间。也可以在XAML钟或代码中这样设置日期。 @@ -43,11 +41,6 @@ var clock = new Clock(); clock.SelectedTime = DateTime.Now; ``` - - - - - # 属性 | 属性 | 描述 | diff --git a/doc/source/handycontrol/extend_controls/index.md b/doc/source/handycontrol/extend_controls/index.md index ca12ad62..772e7310 100644 --- a/doc/source/handycontrol/extend_controls/index.md +++ b/doc/source/handycontrol/extend_controls/index.md @@ -1,5 +1,5 @@ --- -title: 建设中 +title: 扩展控件 --- -建设中 \ No newline at end of file +HandyControl目前包含70余款扩展控件,正逐步增加。 \ No newline at end of file diff --git a/doc/source/handycontrol/extend_controls/passwordBox/index.md b/doc/source/handycontrol/extend_controls/passwordBox/index.md index 90231b22..3eeb5705 100644 --- a/doc/source/handycontrol/extend_controls/passwordBox/index.md +++ b/doc/source/handycontrol/extend_controls/passwordBox/index.md @@ -1,5 +1,5 @@ --- -title: PasswordBox +title: PasswordBox 密码框 --- 表示用于输入和处理密码的控件。 @@ -20,7 +20,6 @@ public class PasswordBox : Control, IDataInput var passwordBox = new PasswordBox(); ``` - # 输入密码 可以通过文本框输入密码,也可以在XAML钟或代码中这样设置日期。 @@ -37,7 +36,9 @@ passwordBox.Password = "123456"; PasswordBox控件可以主动显示已输入的密码。将`ShowEyeButton`设置为`true`,PasswordBox将显示一个“眼睛”的按钮,点击这个按钮即可显示已输入的密码。 +``` XML +``` ![PasswordBox](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/extend_controls/PasswordBox_2.gif) @@ -51,9 +52,6 @@ PasswordBox控件可以主动显示已输入的密码。将`ShowEyeButton`设置 hc:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr2}" ``` - - - # 属性 | 属性 | 描述 | @@ -77,4 +75,3 @@ PasswordBox控件可以主动显示已输入的密码。将`ShowEyeButton`设置 | Paste() | 用剪贴板中的内容替换 PasswordBox 中的当前选定内容。 | | SelectAll() | 选择 PasswordBox 中的全部内容。 | | VerifyData() | 验证数据。 | - diff --git a/doc/source/handycontrol/extend_controls/radioGroup/index.md b/doc/source/handycontrol/extend_controls/radioGroup/index.md deleted file mode 100644 index ca12ad62..00000000 --- a/doc/source/handycontrol/extend_controls/radioGroup/index.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: 建设中 ---- - -建设中 \ No newline at end of file diff --git a/doc/source/handycontrol/extend_controls/textBox/index.md b/doc/source/handycontrol/extend_controls/textBox/index.md index ff30f18d..2e98b20c 100644 --- a/doc/source/handycontrol/extend_controls/textBox/index.md +++ b/doc/source/handycontrol/extend_controls/textBox/index.md @@ -1,5 +1,5 @@ --- -title: TextBox +title: TextBox 文本框 --- 表示一个控件,该控件可用于显示或编辑无格式文本。 @@ -18,9 +18,6 @@ public class TextBox : System.Windows.Controls.TextBox, IDataInput var textBox = new TextBox(); ``` - - - # 输入文本 此示例演示如何使用 Text 属性设置 TextBox 控件的初始文本内容: @@ -50,9 +47,6 @@ textBox.Text = "这是内容"; hc:InfoElement.Title="{x:Static langs:Lang.TitleDemoStr2}" ``` - - - # 属性 | 属性 | 描述 | diff --git a/doc/themes/next/_config.yml b/doc/themes/next/_config.yml index 6e310349..c29078e3 100644 --- a/doc/themes/next/_config.yml +++ b/doc/themes/next/_config.yml @@ -231,8 +231,7 @@ menu: default: /extend_controls/ || AnimationPath 动画路径: /animationPath/ || Badge 标记: /badge/ || - ButtonGroup : /buttonGroup/ || - BlurWindow 背景模糊窗口: /blurWindow/ || + ButtonGroup 按钮组: /buttonGroup/ || CalendarWithClock 带有时钟的日历: /calendarWithClock/ || Card 卡片: /card/ || Carousel 轮播: /carousel/ || @@ -276,7 +275,6 @@ menu: PreviewSlider 预览滑块: /previewSlider/ || ProgressButton 进度按钮: /progressButton/ || RangeSlider 范围滑块: /rangeSlider/ || - RadioGroup 单选按钮组: /radioGroup/ || Rate 评分: /rate/ || RelativePanel 相对布局: /relativePanel/ || RunningBlock 滚动块: /runningBlock/ || From 31e962f594e53fc59178efdcc8e5a444d67d5f92 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sat, 4 Apr 2020 19:05:14 +0800 Subject: [PATCH 36/99] fixed #346 --- .../Controls/Image/ImageViewer.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs index a531d8d6..ba9678de 100644 --- a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs +++ b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs @@ -8,6 +8,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using System.Windows.Threading; using HandyControl.Data; using HandyControl.Interactivity; using HandyControl.Properties.Langs; @@ -157,6 +158,8 @@ namespace HandyControl.Controls ///
private bool _showBorderBottom; + private DispatcherTimer _dispatcher; + #endregion Data #region ctor @@ -444,6 +447,18 @@ namespace HandyControl.Controls { if (ImageSource == null || !IsLoaded) return; + if (ImageSource.IsDownloading) + { + _dispatcher = new DispatcherTimer(DispatcherPriority.ApplicationIdle) + { + Interval = TimeSpan.FromSeconds(1) + }; + _dispatcher.Tick += Dispatcher_Tick; + _dispatcher.Start(); + + return; + } + double width; double height; @@ -495,6 +510,25 @@ namespace HandyControl.Controls InitBorderSmall(); } + private void Dispatcher_Tick(object sender, EventArgs e) + { + if (ImageSource == null || !IsLoaded) + { + _dispatcher.Stop(); + _dispatcher.Tick -= Dispatcher_Tick; + _dispatcher = null; + return; + } + + if (!ImageSource.IsDownloading) + { + _dispatcher.Stop(); + _dispatcher.Tick -= Dispatcher_Tick; + _dispatcher = null; + Init(); + } + } + private void ButtonActual_OnClick(object sender, RoutedEventArgs e) { var scaleAnimation = AnimationHelper.CreateAnimation(1); From 0b666d7fa1e42eb802872cb16502b7efa9b82803 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 5 Apr 2020 21:34:04 +0800 Subject: [PATCH 37/99] fixed #350 --- .../HandyControl_Shared/Themes/Styles/TabControl.xaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml index 73da8568..f2b62cd6 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml @@ -31,13 +31,6 @@ - - - - - - - From 91f68b5d8fb15d4fe6c8803013fad1835d60cf09 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 5 Apr 2020 23:07:20 +0800 Subject: [PATCH 38/99] fixed #352 --- .../Controls/TabControl/TabControl.cs | 14 ++------------ .../Controls/TabControl/TabItem.cs | 5 +++-- .../Controls/TabControl/TabPanel.cs | 10 +++++++--- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs index d656468f..e5d1fb8c 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabControl.cs @@ -232,15 +232,6 @@ namespace HandyControl.Controls return; } - if (IsAnimationEnabled) - { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); - } - else - { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); - } - if (e.Action == NotifyCollectionChangedAction.Add) { for (var i = 0; i < Items.Count; i++) @@ -252,7 +243,6 @@ namespace HandyControl.Controls } _headerBorder?.InvalidateMeasure(); - IsInternalAction = false; } @@ -361,11 +351,11 @@ namespace HandyControl.Controls list.Insert(0, actualItem); if (IsAnimationEnabled) { - HeaderPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, new Duration(TimeSpan.FromMilliseconds(200))); + HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(200))); } else { - HeaderPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); + HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(0))); } HeaderPanel.ForceUpdate = true; HeaderPanel.Measure(new Size(HeaderPanel.DesiredSize.Width, ActualHeight)); diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs index c0aa5600..ca35a03c 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs @@ -280,7 +280,7 @@ namespace HandyControl.Controls RaiseEvent(argsClosing); if (argsClosing.Cancel) return; - TabPanel.SetCurrentValue(TabPanel.FluidMoveDurationProperty, parent.IsAnimationEnabled + TabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, parent.IsAnimationEnabled ? new Duration(TimeSpan.FromMilliseconds(200)) : new Duration(TimeSpan.FromMilliseconds(1))); @@ -302,7 +302,7 @@ namespace HandyControl.Controls if (parent.IsDraggable && !ItemIsDragging && !_isDragging) { parent.UpdateScroll(); - TabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0)); + TabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromSeconds(0))); _mouseDownOffsetX = RenderTransform.Value.OffsetX; _scrollHorizontalOffset = parent.GetHorizontalOffset(); var mx = TranslatePoint(new Point(), parent).X + _scrollHorizontalOffset; @@ -407,6 +407,7 @@ namespace HandyControl.Controls list.Remove(item); parent.IsInternalAction = true; list.Insert(index, item); + _tabPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(0))); TabPanel.CanUpdate = true; TabPanel.ForceUpdate = true; TabPanel.Measure(new Size(TabPanel.DesiredSize.Width, ActualHeight)); diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs index ec7c5bd5..f1c26ace 100644 --- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs +++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabPanel.cs @@ -22,11 +22,15 @@ namespace HandyControl.Controls ///
internal Dictionary ItemDic = new Dictionary(); + public static readonly DependencyPropertyKey FluidMoveDurationPropertyKey = + DependencyProperty.RegisterReadOnly("FluidMoveDuration", typeof(Duration), typeof(TabPanel), + new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(0)))); + /// /// 流式行为持续时间 /// - public static readonly DependencyProperty FluidMoveDurationProperty = DependencyProperty.Register( - "FluidMoveDuration", typeof(Duration), typeof(TabPanel), new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(200)))); + public static readonly DependencyProperty FluidMoveDurationProperty = + FluidMoveDurationPropertyKey.DependencyProperty; /// /// 流式行为持续时间 @@ -96,7 +100,7 @@ namespace HandyControl.Controls protected override Size MeasureOverride(Size constraint) { - if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate) return _oldSize; + if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate && !IsTabFillEnabled) return _oldSize; constraint.Height = TabItemHeight; _itemCount = InternalChildren.Count; From cbff2e3f71c8f0a0da33129d57e5afd741aebb55 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 5 Apr 2020 23:27:06 +0800 Subject: [PATCH 39/99] Update TabControl.xaml --- src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml index f2b62cd6..4b32eadd 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml @@ -45,7 +45,7 @@ - + @@ -66,6 +66,9 @@ + + + From ca081b47d4bb1ef6298e2c07a40dc30cfea4a5ab Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 6 Apr 2020 01:14:16 +0800 Subject: [PATCH 40/99] update action --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++++++++ .github/workflows/nuget.yml | 16 ------------ 2 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/nuget.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7e49d47b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Nuget + +on: + push: + branches: + - master + + pull_request: + branches: + - master + +jobs: + build: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@master + + - name: Setup Nuget.exe + uses: nuget/setup-nuget@master + + - name: Restore Nuget packages + run: nuget restore src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@master + + - name: Setup .NET Core + uses: actions/setup-dotnet@master + + - name: Build Net_40 + run: msbuild src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj -p:Configuration=Release + + - name: Build Net_45 + run: msbuild src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj -p:Configuration=Release-Net45 + + - name: Build Net_462 + run: msbuild src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj -p:Configuration=Release-Net462 + + - name: Build Net_47 + run: msbuild src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj -p:Configuration=Release-Net47 + + - name: Build Net_48 + run: msbuild src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj -p:Configuration=Release-Net48 + + - name: Build Core_30 + run: dotnet build src/Core_GE30/HandyControl_Core_GE30/HandyControl_Core_GE30.csproj --configuration Release-Core30 + + - name: Build Core_31 + run: dotnet build src/Core_GE30/HandyControl_Core_GE30/HandyControl_Core_GE30.csproj --configuration Release-Core31 diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml deleted file mode 100644 index 8495d6ec..00000000 --- a/.github/workflows/nuget.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Nuget - -on: - push: - branches: [ master ] - -jobs: - build: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@2.0. - - name: Build the Docker image - run: docker build -f Dockerfile -t HandyOrg/hcbuild . - - name: Run the Docker image - run: docker run --rm HandyOrg/hcbuild --version From be63f71d7cb5871763c6f1e0876e83471676be58 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 6 Apr 2020 01:21:53 +0800 Subject: [PATCH 41/99] update readme --- .github/workflows/build.yml | 6 +----- README.md | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e49d47b..ed17c3ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,9 @@ -name: Nuget +name: build on: push: branches: - master - - pull_request: - branches: - - master jobs: build: diff --git a/README.md b/README.md index 820f3c14..140f71f4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![logo](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/icon.png) -![dotnet-version](https://img.shields.io/badge/.net-%3E%3D4.0-blue.svg) ![csharp-version](https://img.shields.io/badge/C%23-8.0-blue.svg) ![IDE-version](https://img.shields.io/badge/IDE-vs2019-blue.svg) [![nuget-version](https://img.shields.io/nuget/v/HandyControl.svg)](https://www.nuget.org/packages/HandyControl) [![build-status](https://ci.appveyor.com/api/projects/status/github/handyorg/handycontrol?svg=true)](https://ci.appveyor.com/project/handyorg/handycontrol) [![Join the chat at https://gitter.im/HandyControl/Lobby](https://badges.gitter.im/HandyControl/Lobby.svg)](https://gitter.im/HandyControl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![wiki](https://img.shields.io/badge/wiki-Complete-brightgreen.svg)](https://github.com/ghost1372/HandyControl/wiki) [![Nuget](https://img.shields.io/nuget/dt/handycontrol)](https://www.nuget.org/packages/HandyControl) +![dotnet-version](https://img.shields.io/badge/.net-%3E%3D4.0-blue.svg) ![csharp-version](https://img.shields.io/badge/C%23-8.0-blue.svg) ![IDE-version](https://img.shields.io/badge/IDE-vs2019-blue.svg) [![nuget-version](https://img.shields.io/nuget/v/HandyControl.svg)](https://www.nuget.org/packages/HandyControl) [![build-status](https://ci.appveyor.com/api/projects/status/github/handyorg/handycontrol?svg=true)](https://ci.appveyor.com/project/handyorg/handycontrol) ![Nuget](https://github.com/HandyOrg/HandyControl/workflows/Nuget/badge.svg) [![Join the chat at https://gitter.im/HandyControl/Lobby](https://badges.gitter.im/HandyControl/Lobby.svg)](https://gitter.im/HandyControl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![wiki](https://img.shields.io/badge/wiki-Complete-brightgreen.svg)](https://github.com/ghost1372/HandyControl/wiki) [![Nuget](https://img.shields.io/nuget/dt/handycontrol)](https://www.nuget.org/packages/HandyControl) # Welcome to HandyControl From 6ef79d6e789dab8650026b4e0b022b792ec9b0d9 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Mon, 6 Apr 2020 01:23:46 +0800 Subject: [PATCH 42/99] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 140f71f4..8016f8a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![logo](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/icon.png) -![dotnet-version](https://img.shields.io/badge/.net-%3E%3D4.0-blue.svg) ![csharp-version](https://img.shields.io/badge/C%23-8.0-blue.svg) ![IDE-version](https://img.shields.io/badge/IDE-vs2019-blue.svg) [![nuget-version](https://img.shields.io/nuget/v/HandyControl.svg)](https://www.nuget.org/packages/HandyControl) [![build-status](https://ci.appveyor.com/api/projects/status/github/handyorg/handycontrol?svg=true)](https://ci.appveyor.com/project/handyorg/handycontrol) ![Nuget](https://github.com/HandyOrg/HandyControl/workflows/Nuget/badge.svg) [![Join the chat at https://gitter.im/HandyControl/Lobby](https://badges.gitter.im/HandyControl/Lobby.svg)](https://gitter.im/HandyControl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![wiki](https://img.shields.io/badge/wiki-Complete-brightgreen.svg)](https://github.com/ghost1372/HandyControl/wiki) [![Nuget](https://img.shields.io/nuget/dt/handycontrol)](https://www.nuget.org/packages/HandyControl) +![dotnet-version](https://img.shields.io/badge/.net-%3E%3D4.0-blue.svg) ![csharp-version](https://img.shields.io/badge/C%23-8.0-blue.svg) ![IDE-version](https://img.shields.io/badge/IDE-vs2019-blue.svg) [![nuget-version](https://img.shields.io/nuget/v/HandyControl.svg)](https://www.nuget.org/packages/HandyControl) [![appveyor-build-status](https://ci.appveyor.com/api/projects/status/github/handyorg/handycontrol?svg=true)](https://ci.appveyor.com/project/handyorg/handycontrol) ![Github-build-status](https://github.com/HandyOrg/HandyControl/workflows/build/badge.svg) [![Join the chat at https://gitter.im/HandyControl/Lobby](https://badges.gitter.im/HandyControl/Lobby.svg)](https://gitter.im/HandyControl/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![wiki](https://img.shields.io/badge/wiki-Complete-brightgreen.svg)](https://github.com/ghost1372/HandyControl/wiki) [![Nuget](https://img.shields.io/nuget/dt/handycontrol)](https://www.nuget.org/packages/HandyControl) # Welcome to HandyControl From b6068f04327dc38dd3a555f0f63c20e4e409c87d Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 7 Apr 2020 23:34:09 +0800 Subject: [PATCH 43/99] fixed #358 --- src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml index 4b32eadd..b6c10e4d 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/TabControl.xaml @@ -157,7 +157,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Basic/Avatar.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Basic/Avatar.xaml.cs deleted file mode 100644 index 88727b94..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Basic/Avatar.xaml.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Diagnostics; -using System.Windows; -using System.Windows.Media.Imaging; - - -namespace HandyControlDemo.UserControl -{ - public partial class Avatar - { - public Avatar() - { - InitializeComponent(); - } - - public static readonly DependencyProperty SourceProperty = DependencyProperty.Register( - "Source", typeof(BitmapFrame), typeof(Avatar), new PropertyMetadata(default(BitmapFrame))); - - public BitmapFrame Source - { - get => (BitmapFrame) GetValue(SourceProperty); - set => SetValue(SourceProperty, value); - } - - public static readonly DependencyProperty UserNameProperty = DependencyProperty.Register( - "UserName", typeof(string), typeof(Avatar), new PropertyMetadata(default(string))); - - public string UserName - { - get => (string) GetValue(UserNameProperty); - set => SetValue(UserNameProperty, value); - } - - public static readonly DependencyProperty LinkProperty = DependencyProperty.Register( - "Link", typeof(string), typeof(Avatar), new PropertyMetadata(default(string))); - - public string Link - { - get => (string) GetValue(LinkProperty); - set => SetValue(LinkProperty, value); - } - - private void ButtonAvatar_OnClick(object sender, RoutedEventArgs e) => Process.Start(Link); - } -} \ No newline at end of file diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml deleted file mode 100644 index c4531f33..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml.cs deleted file mode 100644 index 0b63c95e..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/AnimationPathDemoCtl.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace HandyControlDemo.UserControl -{ - public partial class AnimationPathDemoCtl - { - public AnimationPathDemoCtl() - { - InitializeComponent(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml deleted file mode 100644 index c4b46bae..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml.cs deleted file mode 100644 index 51545d68..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CarouselDemoCtl.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace HandyControlDemo.UserControl -{ - public partial class CarouselDemoCtl - { - public CarouselDemoCtl() - { - InitializeComponent(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CirclePanelDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CirclePanelDemoCtl.xaml deleted file mode 100644 index 0fe47f40..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Controls/CirclePanelDemoCtl.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/NoUserContent.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/NoUserContent.xaml.cs deleted file mode 100644 index f765a014..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/NoUserContent.xaml.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Diagnostics; -using System.Reflection; -using System.Windows; -using System.Windows.Controls; -using GalaSoft.MvvmLight.Messaging; -using HandyControl.Controls; -using HandyControl.Data; -using HandyControlDemo.Data; -using HandyControlDemo.Tools; -using HandyControlDemo.Window; - - -namespace HandyControlDemo.UserControl -{ - public partial class NoUserContent - { - public NoUserContent() - { - InitializeComponent(); - } - - private void ButtonLangs_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is Button button && button.Tag is string tag) - { - PopupConfig.IsOpen = false; - if (tag.Equals(GlobalData.Config.Lang)) return; - Growl.Ask(Properties.Langs.Lang.ChangeLangAsk, b => - { - if (!b) return true; - GlobalData.Config.Lang = tag; - GlobalData.Save(); - Process.Start(Assembly.GetExecutingAssembly().Location); - Environment.Exit(0); - return true; - }); - } - } - - private void ButtonConfig_OnClick(object sender, RoutedEventArgs e) => PopupConfig.IsOpen = true; - - private void ButtonSkins_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is Button button && button.Tag is SkinType tag) - { - PopupConfig.IsOpen = false; - if (tag.Equals(GlobalData.Config.Skin)) return; - GlobalData.Config.Skin = tag; - GlobalData.Save(); - ((App)Application.Current).UpdateSkin(tag); - } - } - - private void MenuItemLinks_OnClick(object sender, RoutedEventArgs e) - { - if (e.OriginalSource is MenuItem menuItem && menuItem.Tag is string tag) - { - Process.Start(tag); - } - } - - private void MenuItemQQGroup_OnClick(object sender, RoutedEventArgs e) - { - Messenger.Default.Send(null, MessageToken.ClearLeftSelected); - Messenger.Default.Send(true, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.QQGroupView}"), MessageToken.LoadShowContent); - } - - private void MenuItemContributors_OnClick(object sender, RoutedEventArgs e) - { - Messenger.Default.Send(null, MessageToken.ClearLeftSelected); - Messenger.Default.Send(true, MessageToken.FullSwitch); - Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.ContributorsView}"), MessageToken.LoadShowContent); - } - - private void MenuAbout_OnClick(object sender, RoutedEventArgs e) - { - new AboutWindow - { - Owner = Application.Current.MainWindow - }.ShowDialog(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml deleted file mode 100644 index eec1d7f3..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml.cs deleted file mode 100644 index 8cce5d16..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Main/QQGroupView.xaml.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace HandyControlDemo.UserControl -{ - public partial class QQGroupView - { - public QQGroupView() - { - InitializeComponent(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml deleted file mode 100644 index 1f964c5e..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml.cs deleted file mode 100644 index 101e7a91..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BorderDemoCtl.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace HandyControlDemo.UserControl -{ - public partial class BorderDemoCtl - { - public BorderDemoCtl() - { - InitializeComponent(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml deleted file mode 100644 index b1bd9fa9..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - - - diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml.cs b/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml.cs deleted file mode 100644 index 2b757c25..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/BrushDemoCtl.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace HandyControlDemo.UserControl -{ - public partial class BrushDemoCtl - { - public BrushDemoCtl() - { - InitializeComponent(); - } - } -} diff --git a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/ButtonDemoCtl.xaml b/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/ButtonDemoCtl.xaml deleted file mode 100644 index dd61990e..00000000 --- a/src/Net_35/HandyControlDemo_Net_35/UserControl/Styles/ButtonDemoCtl.xaml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - -