Skip to content

Commit d47790f

Browse files
committed
update in issues.
1 parent 7f7ef80 commit d47790f

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

SoftwareHelper/Helpers/Win32Api.cs

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Windows.Input;
88
using System.Windows.Interop;
99
using System.Windows.Media;
10+
using System.Windows.Media.Animation;
1011
using System.Windows.Media.Imaging;
1112

1213
namespace SoftwareHelper.Helpers
@@ -239,6 +240,9 @@ public static void RegisterDesktop(EmbedDeasktopView window = null)
239240
var source = PresentationSource.FromVisual(_window);
240241
var dpiX = source.CompositionTarget.TransformToDevice.M11;
241242
var dpiY = source.CompositionTarget.TransformToDevice.M22;
243+
244+
if (_window.ActualWidth < 90)
245+
_window.Width = 90;
242246
_window.Width = _window.ActualWidth * dpiX;
243247
_window.Height = _window.ActualHeight * dpiY;
244248

SoftwareHelper/Views/EmbedDeasktopView.xaml.cs

+38-15
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ public partial class EmbedDeasktopView : Window
2424
private Point anchorPoint;
2525
private readonly KeyboardHook _hook;
2626
private readonly List<Key> keys = new List<Key>();
27+
private MainVM mainVM;
2728

2829
public EmbedDeasktopView()
2930
{
3031
InitializeComponent();
32+
mainVM = DataContext as MainVM;
3133
desktopWorkingArea = SystemParameters.WorkArea;
3234
Loaded += EmbedDeasktopView_Loaded;
3335
Closing += EmbedDeasktopView_Closing;
@@ -38,13 +40,14 @@ public EmbedDeasktopView()
3840

3941
private void OnHookKeyUp(object sender, HookEventArgs e)
4042
{
43+
if (!mainVM.IsEmbedded) return;
4144
SetKeyUp(e.Key);
42-
Thread.Sleep(300);
4345
KeyDownPanel.Visibility = Visibility.Collapsed;
4446
}
4547

4648
private void OnHookKeyDown(object sender, HookEventArgs e)
4749
{
50+
if (!mainVM.IsEmbedded) return;
4851
SetKeyDown(e.Key);
4952
if (IsKeyDown(Key.PrintScreen))
5053
{
@@ -191,11 +194,19 @@ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
191194
#endregion
192195
public void ExitEmbedded()
193196
{
194-
Width = 110;
197+
if(ToggleButtonMini.IsChecked == true)
198+
Width = 30;
199+
else
200+
Width = 120;
195201
Height = desktopWorkingArea.Height / 2;
196202
Left = desktopWorkingArea.Width - Width;
197203
Top = desktopWorkingArea.Height / 2 - (Height / 2);
198204
}
205+
public void OepnEmbedded()
206+
{
207+
if (mainVM.IsEmbedded) return;
208+
209+
}
199210
#region 窗体动画
200211
private void ToggleButtonMini_Checked(object sender, RoutedEventArgs e)
201212
{
@@ -210,24 +221,30 @@ private void ToggleButtonMini_Checked(object sender, RoutedEventArgs e)
210221
var heightAnimation = new DoubleAnimation
211222
{
212223
Name = "heightMini",
224+
From = desktopWorkingArea.Height / 2,
213225
To = 60,
214226
Duration = new Duration(TimeSpan.FromSeconds(0.5)),
215-
EasingFunction = easeFunction
227+
EasingFunction = easeFunction,
228+
};
229+
heightAnimation.Completed += delegate
230+
{
231+
BeginAnimation(HeightProperty, null);
216232
};
217233
var widthAnimation = new DoubleAnimation
218234
{
219235
Name = "widthMini",
236+
From = 120,
220237
To = 30,
221238
Duration = new Duration(TimeSpan.FromSeconds(0.51)),
222-
EasingFunction = easeFunction
239+
EasingFunction = easeFunction,
223240
};
224241
widthAnimation.Completed += delegate
225242
{
226-
this.Left = desktopWorkingArea.Width - this.Width;
243+
Left = desktopWorkingArea.Width - this.Width;
244+
BeginAnimation(WidthProperty, null);
227245
};
228-
229-
this.BeginAnimation(HeightProperty, heightAnimation);
230-
this.BeginAnimation(WidthProperty, widthAnimation);
246+
BeginAnimation(HeightProperty, heightAnimation);
247+
BeginAnimation(WidthProperty, widthAnimation);
231248
}
232249
catch (Exception ex)
233250
{
@@ -248,23 +265,30 @@ private void UnToggleButtonMini_Checked(object sender, RoutedEventArgs e)
248265
};
249266
var widthAnimation = new DoubleAnimation
250267
{
268+
From = 30,
251269
To = 120,
252270
Duration = new Duration(TimeSpan.FromSeconds(0.01)),
253-
EasingFunction = easeFunction
271+
EasingFunction = easeFunction,
254272
};
255273
widthAnimation.Completed += delegate
256274
{
257-
this.Left = desktopWorkingArea.Width - this.Width;
275+
Left = desktopWorkingArea.Width - this.Width;
276+
BeginAnimation(WidthProperty, null);
258277
};
259278

260279
var heightAnimation = new DoubleAnimation
261280
{
281+
From = 60,
262282
To = desktopWorkingArea.Height / 2,
263283
Duration = new Duration(TimeSpan.FromSeconds(0.5)),
264-
EasingFunction = easeFunction
284+
EasingFunction = easeFunction,
285+
};
286+
heightAnimation.Completed += delegate
287+
{
288+
BeginAnimation(HeightProperty, null);
265289
};
266-
this.BeginAnimation(WidthProperty, widthAnimation);
267-
this.BeginAnimation(HeightProperty, heightAnimation);
290+
BeginAnimation(WidthProperty, widthAnimation);
291+
BeginAnimation(HeightProperty, heightAnimation);
268292
}
269293
catch (Exception ex)
270294
{
@@ -278,8 +302,7 @@ private void UnToggleButtonMini_Checked(object sender, RoutedEventArgs e)
278302

279303
private void myNotifyIcon_TrayLeftMouseUp(object sender, RoutedEventArgs e)
280304
{
281-
var vm = DataContext as MainVM;
282-
if (vm == null && vm.IsEmbedded) return;
305+
if (mainVM.IsEmbedded) return;
283306
Show();
284307
Activate();
285308
Focus();

0 commit comments

Comments
 (0)