From e500eed7e97936240cb4c7b14db51a9e88e014ee Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Thu, 10 Jun 2021 20:45:44 +0800
Subject: [PATCH 1/5] update Contributors
---
README-cn.md | 3 ++-
README.md | 3 ++-
.../HandyControlDemo_Shared/Properties/Langs/LangProvider.tt | 4 ++--
.../HandyControl_Shared/Properties/Langs/LangProvider.tt | 2 +-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/README-cn.md b/README-cn.md
index 0926910c2..2c285712d 100644
--- a/README-cn.md
+++ b/README-cn.md
@@ -53,7 +53,7 @@ HandyControl 项目已加入 [dotNET China](https://gitee.com/dotnetchina) 组
| | 西江月群 | 定风波群 |
|-|:-:|:-:|
-| 群号码 | [![qq-group](https://img.shields.io/badge/qq-714704041-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=a571e5553c9d41e49c4f22f3a8b2865451497a795ff281fedf3285def247efc1) | [![qq-group](https://img.shields.io/badge/qq-858784803-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=5c18622a0f6ee07a6f33afa8cdb85b1f72ea50e878271dfcec919c76b55afee7) | 微信群 |
+| 群号码 | [![qq-group](https://img.shields.io/badge/qq-714704041-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=a571e5553c9d41e49c4f22f3a8b2865451497a795ff281fedf3285def247efc1) | [![qq-group](https://img.shields.io/badge/qq-858784803-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=5c18622a0f6ee07a6f33afa8cdb85b1f72ea50e878271dfcec919c76b55afee7) |
| 二维码 | ![qq-group](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/qq_group_1.png) | ![qq-group](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/qq_group_2.png) |
* 为我们购买防脱洗发水 (支付宝扫码)
@@ -87,6 +87,7 @@ HandyControl 项目已加入 [dotNET China](https://gitee.com/dotnetchina) 组
+
## 赞助者
diff --git a/README.md b/README.md
index 68cdfd9e9..76c78cf61 100644
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@
| | 西江月群 | 定风波群 |
|-|:-:|:-:|
-| 群号码 | [![qq-group](https://img.shields.io/badge/qq-714704041-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=a571e5553c9d41e49c4f22f3a8b2865451497a795ff281fedf3285def247efc1) | [![qq-group](https://img.shields.io/badge/qq-858784803-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=5c18622a0f6ee07a6f33afa8cdb85b1f72ea50e878271dfcec919c76b55afee7) | 微信群 |
+| 群号码 | [![qq-group](https://img.shields.io/badge/qq-714704041-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=a571e5553c9d41e49c4f22f3a8b2865451497a795ff281fedf3285def247efc1) | [![qq-group](https://img.shields.io/badge/qq-858784803-red.svg)](//shang.qq.com/wpa/qunwpa?idkey=5c18622a0f6ee07a6f33afa8cdb85b1f72ea50e878271dfcec919c76b55afee7) |
| 二维码 | ![qq-group](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/qq_group_1.png) | ![qq-group](https://gitee.com/handyorg/HandyOrgResource/raw/master/HandyControl/Resources/qq_group_2.png) |
* 为我们购买防脱洗发水 (支付宝扫码)
@@ -81,6 +81,7 @@
+
## Backers
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.tt b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.tt
index ae2907dab..9e0077bbd 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.tt
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.tt
@@ -27,7 +27,7 @@ namespace HandyControlDemo.Properties.Langs
{
public class LangProvider : INotifyPropertyChanged
{
- internal static LangProvider Instance => ResourceHelper.GetResource("DemoLangs");
+ internal static LangProvider Instance { get; } = ResourceHelper.GetResource("DemoLangs");
private static string CultureInfoStr;
@@ -81,4 +81,4 @@ namespace HandyControlDemo.Properties.Langs
<#}#>
}
-}
\ No newline at end of file
+}
diff --git a/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.tt b/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.tt
index 292cd060f..0fb8beb28 100644
--- a/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.tt
+++ b/src/Shared/HandyControl_Shared/Properties/Langs/LangProvider.tt
@@ -27,7 +27,7 @@ namespace HandyControl.Properties.Langs
{
public class LangProvider : INotifyPropertyChanged
{
- internal static LangProvider Instance => ResourceHelper.GetResourceInternal("Langs");
+ internal static LangProvider Instance { get; } = ResourceHelper.GetResourceInternal("Langs");
private static string CultureInfoStr;
From e55d481eeefc277f143e5be5f9674085f747512e Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Tue, 15 Jun 2021 21:57:45 +0800
Subject: [PATCH 2/5] fixed #856
---
.../HandyControl_Shared/Controls/Attach/DataGridAttach.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
index 2f5ca9ba9..80b39cb2e 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
@@ -278,7 +278,7 @@ private static void OnShowRowNumberChanged(DependencyObject target, DependencyPr
private static void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
{
if (sender is not ItemContainerGenerator generator) return;
- UpdateItems(generator, e.ItemCount);
+ UpdateItems(generator, generator.Items.Count);
}
private static void UpdateItems(ItemContainerGenerator generator, int itemsCount, bool show = true)
From 75923b16b0c98034e8087aa07873c05777af1e5a Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Tue, 15 Jun 2021 22:12:07 +0800
Subject: [PATCH 3/5] fixed build error
---
.../Controls/Attach/DataGridAttach.cs | 45 +++++++++----------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
index 80b39cb2e..2feb13e7e 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/DataGridAttach.cs
@@ -264,44 +264,39 @@ private static void OnShowRowNumberChanged(DependencyObject target, DependencyPr
if (show)
{
dataGrid.LoadingRow += DataGrid_LoadingRow;
- dataGrid.ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged;
+ dataGrid.ItemContainerGenerator.ItemsChanged += ItemContainerGeneratorItemsChanged;
}
else
{
dataGrid.LoadingRow -= DataGrid_LoadingRow;
- dataGrid.ItemContainerGenerator.ItemsChanged -= ItemContainerGenerator_ItemsChanged;
+ dataGrid.ItemContainerGenerator.ItemsChanged -= ItemContainerGeneratorItemsChanged;
}
- UpdateItems(dataGrid.ItemContainerGenerator, dataGrid.Items.Count, show);
- }
-
- private static void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
- {
- if (sender is not ItemContainerGenerator generator) return;
- UpdateItems(generator, generator.Items.Count);
- }
-
- private static void UpdateItems(ItemContainerGenerator generator, int itemsCount, bool show = true)
- {
- if (show)
+ void ItemContainerGeneratorItemsChanged(object sender, ItemsChangedEventArgs e)
{
- for (var i = 0; i < itemsCount; i++)
+ var generator = dataGrid.ItemContainerGenerator;
+ var itemsCount = dataGrid.Items.Count;
+
+ if (show)
{
- var row = (DataGridRow) generator.ContainerFromIndex(i);
- if (row != null)
+ for (var i = 0; i < itemsCount; i++)
{
- row.Header = (i + 1).ToString();
+ var row = (DataGridRow) generator.ContainerFromIndex(i);
+ if (row != null)
+ {
+ row.Header = (i + 1).ToString();
+ }
}
}
- }
- else
- {
- for (var i = 0; i < itemsCount; i++)
+ else
{
- var row = (DataGridRow) generator.ContainerFromIndex(i);
- if (row != null)
+ for (var i = 0; i < itemsCount; i++)
{
- row.Header = null;
+ var row = (DataGridRow) generator.ContainerFromIndex(i);
+ if (row != null)
+ {
+ row.Header = null;
+ }
}
}
}
From e86f101103863f263e8753dad17d463a615f7083 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Tue, 15 Jun 2021 22:32:33 +0800
Subject: [PATCH 4/5] minor modify TextBlockAttach
I'm not sure this is a good solution
---
.../HandyControl_Shared/Controls/Attach/TextBlockAttach.cs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs
index 9ec37a0dd..3e5236db9 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/TextBlockAttach.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using HandyControl.Data;
@@ -46,7 +47,9 @@ private static void UpdateTooltip(TextBlock textBlock)
textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var width = textBlock.DesiredSize.Width - textBlock.Margin.Left - textBlock.Margin.Right;
- if (textBlock.RenderSize.Width > width || textBlock.ActualWidth < width || CalcTextWidth(textBlock) > width)
+ // the code Math.Abs(CalcTextWidth(textBlock) - width) > 1 is not elegant end even bugly,
+ // while it does solve the problem of Tooltip failure in some cases
+ if (textBlock.RenderSize.Width > width || textBlock.ActualWidth < width || Math.Abs(CalcTextWidth(textBlock) - width) > 1)
{
ToolTipService.SetToolTip(textBlock, textBlock.Text);
}
From 6ce9130b0797810e7a550508d51bf3f55e18f6dc Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Tue, 15 Jun 2021 23:12:24 +0800
Subject: [PATCH 5/5] fixed #777
---
.../Controls/Image/ImageViewer.cs | 20 ++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
index 57cddcc39..ed9f59dc0 100644
--- a/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
@@ -160,6 +160,8 @@ public class ImageViewer : Control
private DispatcherTimer _dispatcher;
+ private bool _isLoaded;
+
#endregion Data
#region ctor
@@ -174,7 +176,11 @@ public ImageViewer()
CommandBindings.Add(new CommandBinding(ControlCommands.RotateLeft, ButtonRotateLeft_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.RotateRight, ButtonRotateRight_OnClick));
- Loaded += (s, e) => Init();
+ Loaded += (s, e) =>
+ {
+ _isLoaded = true;
+ Init();
+ };
}
///
@@ -445,7 +451,7 @@ private static void OnImageScaleChanged(DependencyObject d, DependencyPropertyCh
///
private void Init()
{
- if (ImageSource == null || !IsLoaded) return;
+ if (ImageSource == null || !_isLoaded) return;
if (ImageSource.IsDownloading)
{
@@ -464,13 +470,13 @@ private void Init()
if (!_isOblique)
{
- width = ImageSource.Width;
- height = ImageSource.Height;
+ width = ImageSource.PixelWidth;
+ height = ImageSource.PixelHeight;
}
else
{
- width = ImageSource.Height;
- height = ImageSource.Width;
+ width = ImageSource.PixelHeight;
+ height = ImageSource.PixelWidth;
}
ImageWidth = width;
@@ -514,7 +520,7 @@ private void Dispatcher_Tick(object sender, EventArgs e)
{
if (_dispatcher == null) return;
- if (ImageSource == null || !IsLoaded)
+ if (ImageSource == null || !_isLoaded)
{
_dispatcher.Stop();
_dispatcher.Tick -= Dispatcher_Tick;