From 08ae754ea34678222260a1a5eedb3ed3deb69faf Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Mon, 2 Mar 2020 23:27:22 +0800
Subject: [PATCH 1/8] add ManualObservableCollection
---
.../Controls/NotifyIconDemoCtl.xaml | 34 ++--
.../UserControl/Controls/SideMenuDemoCtl.xaml | 12 +-
.../UserControl/Main/LeftMainContent.xaml | 12 +-
.../ManualObservableCollection!1.cs | 191 ++++++++++++++++++
.../HandyControl_Shared.projitems | 1 +
5 files changed, 218 insertions(+), 32 deletions(-)
create mode 100644 src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml
index 173073e2..36c6aeac 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml
@@ -3,8 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:hc="https://handyorg.github.io/handycontrol"
- xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
- xmlns:command="http://www.galasoft.ch/mvvmlight"
xmlns:data="clr-namespace:HandyControlDemo.Data"
DataContext="{Binding NotifyIconDemo,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
@@ -47,14 +45,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -68,14 +66,14 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml
index 2b2ae21d..2672b5a2 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml
@@ -2,18 +2,16 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
- xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
- xmlns:command="http://www.galasoft.ch/mvvmlight"
DataContext="{Binding SideMenuDemo,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
index 909f10d9..775e9bc3 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
@@ -1,6 +1,4 @@
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs b/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs
new file mode 100644
index 00000000..39abfc7e
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Collections/ManualObservableCollection!1.cs
@@ -0,0 +1,191 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+
+namespace HandyControl.Collections
+{
+ [Serializable]
+ public class ManualObservableCollection : Collection, INotifyCollectionChanged, INotifyPropertyChanged
+ {
+ private SimpleMonitor _monitor = new SimpleMonitor();
+
+ private const string CountString = "Count";
+
+ private const string IndexerName = "Item[]";
+
+ private bool _canNotify = true;
+
+ public bool CanNotify
+ {
+ get => _canNotify;
+ set
+ {
+ _canNotify = value;
+
+ if (value)
+ {
+ if (_oldCount != Count)
+ {
+ OnPropertyChanged(CountString);
+ }
+
+ OnPropertyChanged(IndexerName);
+ OnCollectionReset();
+ }
+ else
+ {
+ _oldCount = Count;
+ }
+ }
+ }
+
+ private int _oldCount;
+
+ public event NotifyCollectionChangedEventHandler CollectionChanged;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public ManualObservableCollection()
+ {
+
+ }
+
+ // ReSharper disable once AssignNullToNotNullAttribute
+ public ManualObservableCollection(List list) : base(list != null ? new List(list.Count) : list) => CopyFrom(list);
+
+ public ManualObservableCollection(IEnumerable collection)
+ {
+ if (collection == null) throw new ArgumentNullException(nameof(collection));
+ CopyFrom(collection);
+ }
+
+ private void CopyFrom(IEnumerable collection)
+ {
+ var items = Items;
+ if (collection != null)
+ {
+ using var enumerator = collection.GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ items.Add(enumerator.Current);
+ }
+ }
+ }
+
+ public void Move(int oldIndex, int newIndex) => MoveItem(oldIndex, newIndex);
+
+ protected override void ClearItems()
+ {
+ CheckReentrancy();
+ base.ClearItems();
+ OnPropertyChanged(CountString);
+ OnPropertyChanged(IndexerName);
+ OnCollectionReset();
+ }
+
+ protected override void RemoveItem(int index)
+ {
+ CheckReentrancy();
+ var removedItem = this[index];
+
+ base.RemoveItem(index);
+
+ OnPropertyChanged(CountString);
+ OnPropertyChanged(IndexerName);
+ OnCollectionChanged(NotifyCollectionChangedAction.Remove, removedItem, index);
+ }
+
+ protected override void InsertItem(int index, T item)
+ {
+ CheckReentrancy();
+ base.InsertItem(index, item);
+
+ OnPropertyChanged(CountString);
+ OnPropertyChanged(IndexerName);
+ OnCollectionChanged(NotifyCollectionChangedAction.Add, item, index);
+ }
+
+ protected override void SetItem(int index, T item)
+ {
+ CheckReentrancy();
+ var originalItem = this[index];
+ base.SetItem(index, item);
+
+ OnPropertyChanged(IndexerName);
+ OnCollectionChanged(NotifyCollectionChangedAction.Replace, originalItem, item, index);
+ }
+
+ protected virtual void MoveItem(int oldIndex, int newIndex)
+ {
+ CheckReentrancy();
+
+ var removedItem = this[oldIndex];
+
+ base.RemoveItem(oldIndex);
+ base.InsertItem(newIndex, removedItem);
+
+ OnPropertyChanged(IndexerName);
+ OnCollectionChanged(NotifyCollectionChangedAction.Move, removedItem, newIndex, oldIndex);
+ }
+
+ protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
+ {
+ if (!CanNotify || PropertyChanged == null) return;
+
+ PropertyChanged.Invoke(this, e);
+ }
+
+ protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
+ {
+ if (!CanNotify || CollectionChanged == null) return;
+
+ using (BlockReentrancy())
+ {
+ // ReSharper disable once PossibleNullReferenceException
+ CollectionChanged(this, e);
+ }
+ }
+
+ protected IDisposable BlockReentrancy()
+ {
+ _monitor.Enter();
+ return _monitor;
+ }
+
+ protected void CheckReentrancy()
+ {
+ if (_monitor.Busy && CollectionChanged != null && CollectionChanged.GetInvocationList().Length > 1)
+ {
+ throw new InvalidOperationException("ObservableCollectionReentrancyNotAllowed");
+ }
+ }
+
+ private void OnPropertyChanged(string propertyName) =>
+ OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
+
+ private void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index) =>
+ OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item, index));
+
+ private void OnCollectionChanged(NotifyCollectionChangedAction action, object item, int index, int oldIndex) =>
+ OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, item, index, oldIndex));
+
+ private void OnCollectionChanged(NotifyCollectionChangedAction action, object oldItem, object newItem, int index) =>
+ OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, newItem, oldItem, index));
+
+ private void OnCollectionReset() =>
+ OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
+
+ private class SimpleMonitor : IDisposable
+ {
+ public void Enter() => ++_busyCount;
+
+ public void Dispose() => --_busyCount;
+
+ public bool Busy => _busyCount > 0;
+
+ private int _busyCount;
+ }
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index 8e5bce5f..1bad34b4 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -9,6 +9,7 @@
HandyControl
+
From 46b1297aa7d911ce56207b8d1fcb19c6df5d4f2f Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Fri, 6 Mar 2020 14:36:12 +0800
Subject: [PATCH 2/8] add Screenshot
---
.../HandyControlDemo_Shared/App.xaml.cs | 1 -
.../UserControl/Controls/PoptipDemoCtl.xaml | 6 +-
.../Controls/Attach/TipElement.cs | 6 +-
.../Controls/ColorPicker/ColorDropper.cs | 2 +-
.../Controls/Other/Poptip.cs | 46 +-
.../Controls/Screenshot/Screenshot.cs | 16 +
.../Controls/Screenshot/ScreenshotWindow.cs | 572 ++++++++++++++++++
.../Data/Args/MouseHookEventArgs.cs | 2 +-
.../Data/Enum/PlacementType.cs | 66 ++
.../Data/Enum/TipPlacement.cs | 2 +-
.../HandyControl_Shared/Data/ResourceToken.cs | 4 +-
.../HandyControl_Shared.projitems | 22 +-
.../{ => Behavior}/Behavior!1.cs | 0
.../Interactivity/{ => Behavior}/Behavior.cs | 0
.../{ => Behavior}/BehaviorCollection.cs | 0
.../{ => Behavior}/FluidMoveBehavior.cs | 0
.../{ => Behavior}/FluidMoveBehaviorBase.cs | 0
.../MouseDragElementBehavior.cs | 0
.../MouseDragElementBehaviorEx.cs | 0
.../Themes/Styles/Screenshot.xaml | 125 ++++
.../Themes/Styles/Style.xaml | 1 +
.../Tools/GlobalShortcut.cs | 19 +-
.../Tools/Helper/WindowHelper.cs | 1 -
.../Tools/Hook/ClipboardHook.cs | 31 +-
.../Tools/Hook/KeyboardHook.cs | 35 +-
.../Tools/Hook/MouseHook.cs | 37 +-
.../Tools/Interop/InteropMethods.cs | 18 +-
.../Tools/Interop/InteropValues.cs | 11 +-
28 files changed, 923 insertions(+), 100 deletions(-)
create mode 100644 src/Shared/HandyControl_Shared/Controls/Screenshot/Screenshot.cs
create mode 100644 src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
create mode 100644 src/Shared/HandyControl_Shared/Data/Enum/PlacementType.cs
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/Behavior!1.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/Behavior.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/BehaviorCollection.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/FluidMoveBehavior.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/FluidMoveBehaviorBase.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/MouseDragElementBehavior.cs (100%)
rename src/Shared/HandyControl_Shared/Interactivity/{ => Behavior}/MouseDragElementBehaviorEx.cs (100%)
create mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
index 6cc43843..05d65336 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
@@ -7,7 +7,6 @@ using System.Runtime;
using System.Security.Authentication;
using System.Threading;
using System.Windows;
-using System.Windows.Media.Animation;
using HandyControl.Data;
using HandyControl.Tools;
using HandyControlDemo.Data;
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
index 43d45e3e..30891034 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
@@ -36,12 +36,12 @@
diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
index 50bbc0a2..0efba4ca 100644
--- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
+++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
@@ -547,6 +547,9 @@
Resources\Img\cloud.png
+
+ Resources\Img\LeftMainContent\WindowScreenshot_16x.png
+
diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
index abe74897..0dae1c8d 100644
--- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
+++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
@@ -610,6 +610,9 @@
Resources\Img\cloud.png
+
+ Resources\Img\LeftMainContent\WindowScreenshot_16x.png
+
diff --git a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
index db149ee9..d307144e 100644
--- a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
+++ b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
@@ -317,6 +317,9 @@
UserControl\Controls\RunningBlockDemoCtl.xaml
+
+ UserControl\Controls\ScreenshotDemoCtl.xaml
+
UserControl\Controls\ScrollViewerDemoCtl.xaml
@@ -713,6 +716,10 @@
UserControl\Controls\RunningBlockDemoCtl.xaml.cs
RunningBlockDemoCtl.xaml
+
+ UserControl\Controls\ScreenshotDemoCtl.xaml.cs
+ ScreenshotDemoCtl.xaml
+
UserControl\Controls\ScrollViewerDemoCtl.xaml.cs
ScrollViewerDemoCtl.xaml
diff --git a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json
index c849557e..69a6b1da 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json
+++ b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json
@@ -98,6 +98,7 @@
[ "Sprite", "SpriteDemoCtl", "HandyControl", "" ],
[ "Notification", "NotificationDemoCtl", "Procedure_16x", "" ],
[ "Dialog", "DialogDemoCtl", "Dialog_16x", "" ],
+ [ "Screenshot", "ScreenshotDemoCtl", "WindowScreenshot_16x", "1" ],
[ "Window", "WindowDemoCtl", "WindowsForm_16x", "1" ]
]
},
@@ -106,7 +107,7 @@
"demoItemList": [
[ "HatchBrushGenerator", "HatchBrushGeneratorDemoCtl", "DataGenerator_16x", "" ],
[ "Morphing Animation", "GeometryAnimationDemoCtl", "Animation_16x", "" ],
- [ "Effects", "EffectsDemoCtl", "Effects_16x", "1" ]
+ [ "Effects", "EffectsDemoCtl", "Effects_16x", "" ]
]
}
]
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
index ef1f20e3..9bb9f927 100644
--- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
+++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
@@ -190,6 +190,9 @@
RunningBlockDemoCtl.xaml
+
+ ScreenshotDemoCtl.xaml
+
ScrollViewerDemoCtl.xaml
@@ -684,6 +687,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
index bd30d1fd..e3078682 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
@@ -1176,15 +1176,6 @@ namespace HandyControlDemo.Properties.Langs {
}
}
- ///
- /// 查找类似 概览 的本地化字符串。
- ///
- public static string Overview {
- get {
- return ResourceManager.GetString("Overview", resourceCulture);
- }
- }
-
///
/// 查找类似 页码条 的本地化字符串。
///
@@ -1491,6 +1482,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 截图 的本地化字符串。
+ ///
+ public static string Screenshot {
+ get {
+ return ResourceManager.GetString("Screenshot", resourceCulture);
+ }
+ }
+
///
/// 查找类似 滚动视图 的本地化字符串。
///
@@ -1608,6 +1608,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 开始截图 的本地化字符串。
+ ///
+ public static string StartScreenshot {
+ get {
+ return ResourceManager.GetString("StartScreenshot", resourceCulture);
+ }
+ }
+
///
/// 查找类似 保持打开 的本地化字符串。
///
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
index 24edac67..97bad55c 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
@@ -738,4 +738,10 @@
Practical demos
+
+ Start screenshot
+
+
+ Screenshot
+
\ 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 73fd70c6..b1d3c4fe 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
@@ -738,4 +738,10 @@
Practical demos
+
+ Start screenshot
+
+
+ Screenshot
+
\ 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 c8051c46..3c22a942 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
@@ -738,4 +738,10 @@
Practical demos
+
+ Start screenshot
+
+
+ Screenshot
+
\ 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 9715066f..88562ce8 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx
@@ -738,4 +738,10 @@
Practical demos
+
+ Start screenshot
+
+
+ Screenshot
+
\ 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 a64229fb..f4e63998 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
@@ -738,4 +738,10 @@
实用例子
+
+ 开始截图
+
+
+ 截图
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/WindowScreenshot_16x.png b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/WindowScreenshot_16x.png
new file mode 100644
index 0000000000000000000000000000000000000000..45e78d9f63fd79f1c7e9350a758b47cd7c64cb29
GIT binary patch
literal 207
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMpkSk?
zi(^Pd+}Vi-IS(iZumlHXZI~a?W~-7LF@w|c+w6jV(RYPKC%qFNw%imfeaQ6TPp9CL
zDf?2w4&GenktTX2>i72(x`vG%YZzwbd1=-t%+-|Q-g0J*n`gEYW=YHNGZfPOqo@?+l=07(8A5T-G@yGywoC
C^h`eh
literal 0
HcmV?d00001
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml
new file mode 100644
index 00000000..85767c53
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs
new file mode 100644
index 00000000..7f237020
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using HandyControl.Controls;
+using HandyControl.Data;
+
+namespace HandyControlDemo.UserControl
+{
+ public partial class ScreenshotDemoCtl : IDisposable
+ {
+ public ScreenshotDemoCtl()
+ {
+ InitializeComponent();
+ Screenshot.Snapped += Screenshot_Snapped;
+ }
+
+ private void Screenshot_Snapped(object sender, FunctionEventArgs e)
+ {
+ new HandyControl.Controls.Window
+ {
+ Content = new Image
+ {
+ Source = e.Info,
+ Stretch = Stretch.None
+ },
+ WindowStartupLocation = WindowStartupLocation.CenterScreen
+ }.ShowDialog();
+ }
+
+ public void Dispose() => Screenshot.Snapped -= Screenshot_Snapped;
+ }
+}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml
index e016d2fe..e4bacd27 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml
@@ -3,7 +3,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
x:Class="HandyControlDemo.UserControl.MainContent">
-
+
diff --git a/src/Shared/HandyControl_Shared/Controls/Screenshot/Screenshot.cs b/src/Shared/HandyControl_Shared/Controls/Screenshot/Screenshot.cs
index ba219ac4..887db21f 100644
--- a/src/Shared/HandyControl_Shared/Controls/Screenshot/Screenshot.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Screenshot/Screenshot.cs
@@ -1,16 +1,15 @@
using System;
using System.Windows.Media;
+using HandyControl.Data;
namespace HandyControl.Controls
{
public class Screenshot
{
- public event EventHandler Snapped;
-
- public ImageSource Source { get; set; }
+ public static event EventHandler> Snapped;
public void Start() => new ScreenshotWindow(this).Show();
- internal void OnSnapped() => Snapped?.Invoke(this, EventArgs.Empty);
+ internal void OnSnapped(ImageSource source) => Snapped?.Invoke(this, new FunctionEventArgs(source));
}
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
index 27d665c5..9af41e93 100644
--- a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
@@ -26,8 +26,6 @@ namespace HandyControl.Controls
#region const
- private const int RectMinLength = 14;
-
private const int IntervalLength = 1;
private const int IntervalBigLength = 10;
@@ -60,6 +58,8 @@ namespace HandyControl.Controls
private Point _mousePointOld;
+ private bool _saveScreenshot;
+
#endregion
#endregion
@@ -177,7 +177,8 @@ namespace HandyControl.Controls
}
break;
case Key.Enter:
- SaveScreenshot();
+ _saveScreenshot = true;
+ Close();
break;
}
}
@@ -185,7 +186,11 @@ namespace HandyControl.Controls
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) => _mousePointOld = e.GetPosition(this);
- protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e) => SaveScreenshot();
+ protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
+ {
+ _saveScreenshot = true;
+ Close();
+ }
protected override void OnPreviewMouseMove(MouseEventArgs e)
{
@@ -282,6 +287,11 @@ namespace HandyControl.Controls
private void ScreenshotWindow_Closed(object sender, EventArgs e)
{
+ if (_saveScreenshot)
+ {
+ SaveScreenshot();
+ }
+
StopHooks();
IsDrawing = false;
@@ -442,10 +452,9 @@ namespace HandyControl.Controls
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.Source = cb;
+ _screenshot.OnSnapped(cb);
}
- _screenshot.OnSnapped();
Close();
}
@@ -488,7 +497,21 @@ namespace HandyControl.Controls
}
}
- private void RegularRect(ref InteropValues.RECT rect)
+ private static InteropValues.RECT MoveRect(InteropValues.RECT rect, int leftFlag = 0, int topFlag = 0, int rightFlag = 0, int bottomFlag = 0)
+ {
+ var moveLength = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)
+ ? IntervalBigLength
+ : IntervalLength;
+
+ rect.Left += leftFlag * moveLength;
+ rect.Top += topFlag * moveLength;
+ rect.Right += rightFlag * moveLength;
+ rect.Bottom += bottomFlag * moveLength;
+
+ return rect;
+ }
+
+ private void MoveTargetArea(InteropValues.RECT rect)
{
if (rect.Left < 0)
{
@@ -516,25 +539,6 @@ namespace HandyControl.Controls
rect.Left = Math.Max(0, rect.Left);
rect.Top = Math.Max(0, rect.Top);
- }
-
- private static InteropValues.RECT MoveRect(InteropValues.RECT rect, int leftFlag = 0, int topFlag = 0, int rightFlag = 0, int bottomFlag = 0)
- {
- var moveLength = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)
- ? IntervalBigLength
- : IntervalLength;
-
- rect.Left += leftFlag * moveLength;
- rect.Top += topFlag * moveLength;
- rect.Right += rightFlag * moveLength;
- rect.Bottom += bottomFlag * moveLength;
-
- return rect;
- }
-
- private void MoveTargetArea(InteropValues.RECT rect)
- {
- RegularRect(ref rect);
var width = rect.Width;
var height = rect.Height;
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index 726a31f5..a78fba08 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -61,6 +61,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs b/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
index 07c58353..770de7f2 100644
--- a/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
+++ b/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
@@ -161,5 +161,10 @@ namespace HandyControl.Interactivity
/// 关闭窗口
///
public static CloseWindowCommand CloseWindow { get; } = new CloseWindowCommand();
+
+ ///
+ /// 开始截图
+ ///
+ public static StartScreenshotCommand StartScreenshot { get; } = new StartScreenshotCommand();
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Interactivity/Commands/ScreenshotCommand.cs b/src/Shared/HandyControl_Shared/Interactivity/Commands/ScreenshotCommand.cs
new file mode 100644
index 00000000..cefef4f4
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Interactivity/Commands/ScreenshotCommand.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Windows.Input;
+using HandyControl.Controls;
+
+namespace HandyControl.Interactivity
+{
+ public class StartScreenshotCommand : ICommand
+ {
+ public bool CanExecute(object parameter) => true;
+
+ public void Execute(object parameter) => new Screenshot().Start();
+
+ public event EventHandler CanExecuteChanged;
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Interactivity/Commands/StartScreenshotCommand.cs b/src/Shared/HandyControl_Shared/Interactivity/Commands/StartScreenshotCommand.cs
new file mode 100644
index 00000000..cefef4f4
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Interactivity/Commands/StartScreenshotCommand.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Windows.Input;
+using HandyControl.Controls;
+
+namespace HandyControl.Interactivity
+{
+ public class StartScreenshotCommand : ICommand
+ {
+ public bool CanExecute(object parameter) => true;
+
+ public void Execute(object parameter) => new Screenshot().Start();
+
+ public event EventHandler CanExecuteChanged;
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
index b9682b70..23f73766 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
@@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Windows;
using System.Windows.Interop;
+using HandyControl.Tools.Extension;
using HandyControl.Tools.Interop;
namespace HandyControl.Tools
From 8124dedce2fbf736007c47134f9b9c8029d9de4c Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Sat, 7 Mar 2020 23:46:16 +0800
Subject: [PATCH 4/8] update readme
---
README.md | 8 +-
.../Controls/Screenshot/ScreenshotWindow.cs | 110 +++++++++---------
2 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/README.md b/README.md
index 271efa13..2faaf251 100644
--- a/README.md
+++ b/README.md
@@ -98,6 +98,10 @@ Step 4:enjoy coding
## Latest examples
+### Screenshot
+
+
+
### GooeyEffect

@@ -114,6 +118,8 @@ Step 4:enjoy coding

+## History publication
+
### Effects

@@ -122,8 +128,6 @@ Step 4:enjoy coding

-## History publication
-
### Drawer

diff --git a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
index 9af41e93..5e3bdb13 100644
--- a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
@@ -58,6 +58,10 @@ namespace HandyControl.Controls
private Point _mousePointOld;
+ private Point _pointFixed;
+
+ private Point _pointFloating;
+
private bool _saveScreenshot;
#endregion
@@ -203,10 +207,11 @@ namespace HandyControl.Controls
var newPoint = Mouse.GetPosition(this);
var offsetX = (int)(newPoint.X - _mousePointOld.X);
var offsetY = (int)(newPoint.Y - _mousePointOld.Y);
- var rect = _targetWindowRect;
-
+
if (IsDrawing)
{
+ var rect = _targetWindowRect;
+
if (_canDrag)
{
rect.Left += offsetX;
@@ -216,72 +221,45 @@ namespace HandyControl.Controls
}
else
{
- var leftAddend = offsetX * _flagArr[0];
- var topAddend = offsetY * _flagArr[1];
- var rightAddend = offsetX * _flagArr[2];
- var bottomAddend = offsetY * _flagArr[3];
-
- rect.Left += leftAddend;
- rect.Top += topAddend;
- rect.Right += rightAddend;
- rect.Bottom += bottomAddend;
-
- if (rect.Width < 0)
+ if (_flagArr[0] > 0)
{
- if (_flagArr[0] > 0)
- {
- _flagArr[0] = 0;
- _flagArr[2] = 1;
- rect.Left -= leftAddend;
- rightAddend = offsetX * _flagArr[2];
- rect.Right += rightAddend;
- }
- else if (_flagArr[2] > 0)
- {
- _flagArr[0] = 1;
- _flagArr[2] = 0;
- rect.Right -= rightAddend;
- leftAddend = offsetX * _flagArr[0];
- rect.Left += leftAddend;
- }
+ _pointFloating.X += offsetX * _flagArr[0];
+ }
+ else if (_flagArr[2] > 0)
+ {
+ _pointFloating.X += offsetX * _flagArr[2];
}
- if (rect.Height < 0)
+ if (_flagArr[1] > 0)
{
- if (_flagArr[1] > 0)
- {
- _flagArr[1] = 0;
- _flagArr[3] = 1;
- rect.Top -= topAddend;
- bottomAddend = offsetY * _flagArr[3];
- rect.Bottom += bottomAddend;
- }
- else if (_flagArr[3] > 0)
- {
- _flagArr[1] = 1;
- _flagArr[3] = 0;
- rect.Bottom -= bottomAddend;
- topAddend = offsetY * _flagArr[1];
- rect.Top += topAddend;
- }
+ _pointFloating.Y += offsetY * _flagArr[1];
}
+ else if (_flagArr[3] > 0)
+ {
+ _pointFloating.Y += offsetY * _flagArr[3];
+ }
+
+ 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);
}
MoveTargetArea(rect);
_mousePointOld = newPoint;
}
- else
+ else if (IsSelecting)
{
- if (!IsSelecting && offsetX > 0 && offsetY > 0)
- {
- rect = new InteropValues.RECT((int)_mousePointOld.X, (int)_mousePointOld.Y, 0, 0);
- IsSelecting = true;
- }
+ var minX = (int)Math.Min(_mousePointOld.X, newPoint.X);
+ var maxX = (int)Math.Max(_mousePointOld.X, newPoint.X);
+ var minY = (int)Math.Min(_mousePointOld.Y, newPoint.Y);
+ var maxY = (int)Math.Max(_mousePointOld.Y, newPoint.Y);
- if (IsSelecting)
- {
- MoveTargetArea(new InteropValues.RECT(rect.Left, rect.Top, rect.Left + offsetX, rect.Top + offsetY));
- }
+ MoveTargetArea(new InteropValues.RECT(minX, minY, maxX, maxY));
+ }
+ else if (!IsSelecting && offsetX > 0 && offsetY > 0)
+ {
+ IsSelecting = true;
}
}
@@ -313,8 +291,8 @@ namespace HandyControl.Controls
var leftAbs = Math.Abs(point.X);
var topAbs = Math.Abs(point.Y);
- var rightAbs = Math.Abs(point.X - TargetArea.Width);
- var downAbs = Math.Abs(point.Y - TargetArea.Height);
+ var rightAbs = Math.Abs(point.X - _targetWindowRect.Width);
+ var downAbs = Math.Abs(point.Y - _targetWindowRect.Height);
_canDrag = false;
_flagArr[0] = 0;
@@ -330,12 +308,16 @@ namespace HandyControl.Controls
{
// left
cursor = Cursors.SizeWE;
+ _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
+ _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
_flagArr[0] = 1;
}
else
{
//left bottom
cursor = Cursors.SizeNESW;
+ _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
+ _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
_flagArr[0] = 1;
_flagArr[3] = 1;
}
@@ -344,6 +326,8 @@ namespace HandyControl.Controls
{
// left top
cursor = Cursors.SizeNWSE;
+ _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
+ _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
_flagArr[0] = 1;
_flagArr[1] = 1;
}
@@ -370,6 +354,8 @@ namespace HandyControl.Controls
{
//bottom
cursor = Cursors.SizeNS;
+ _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
+ _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
_flagArr[3] = 1;
}
}
@@ -377,6 +363,8 @@ namespace HandyControl.Controls
{
//top
cursor = Cursors.SizeNS;
+ _pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
+ _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
_flagArr[1] = 1;
}
}
@@ -388,12 +376,16 @@ namespace HandyControl.Controls
{
//right
cursor = Cursors.SizeWE;
+ _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
+ _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
_flagArr[2] = 1;
}
else
{
//right bottom
cursor = Cursors.SizeNWSE;
+ _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
+ _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
_flagArr[2] = 1;
_flagArr[3] = 1;
}
@@ -402,6 +394,8 @@ namespace HandyControl.Controls
{
// right top
cursor = Cursors.SizeNESW;
+ _pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
+ _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
_flagArr[1] = 1;
_flagArr[2] = 1;
}
From 768c8e4f690d283e176e3ab6493ca19efdbf1620 Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Mon, 9 Mar 2020 17:59:50 +0800
Subject: [PATCH 5/8] fixed #333
---
src/Shared/HandyControl_Shared/Controls/Window/Window.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
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 6/8] 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 7/8] 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 8/8] 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));
}
///