Skip to content

Commit d5af82f

Browse files
committed
update in issues.
1 parent d47790f commit d5af82f

File tree

4 files changed

+52
-64
lines changed

4 files changed

+52
-64
lines changed

SoftwareHelper/Helpers/Win32Api.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ public static void RegisterDesktop(EmbedDeasktopView window = null)
241241
var dpiX = source.CompositionTarget.TransformToDevice.M11;
242242
var dpiY = source.CompositionTarget.TransformToDevice.M22;
243243

244-
if (_window.ActualWidth < 90)
245-
_window.Width = 90;
244+
_window.Width = 90;
246245
_window.Width = _window.ActualWidth * dpiX;
247246
_window.Height = _window.ActualHeight * dpiY;
248247

SoftwareHelper/Views/EmbedDeasktopView.xaml.cs

+48-59
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Windows.Media.Animation;
1212
using SoftwareHelper.Helpers;
1313
using SoftwareHelper.ViewModels;
14+
using WPFDevelopers.Controls;
1415

1516
namespace SoftwareHelper.Views
1617
{
@@ -19,12 +20,12 @@ namespace SoftwareHelper.Views
1920
/// </summary>
2021
public partial class EmbedDeasktopView : Window
2122
{
22-
private bool inDrag;
23-
private readonly Rect desktopWorkingArea;
24-
private Point anchorPoint;
2523
private readonly KeyboardHook _hook;
24+
private readonly Rect desktopWorkingArea;
2625
private readonly List<Key> keys = new List<Key>();
27-
private MainVM mainVM;
26+
private Point anchorPoint;
27+
private bool inDrag;
28+
private readonly MainVM mainVM;
2829

2930
public EmbedDeasktopView()
3031
{
@@ -51,7 +52,7 @@ private void OnHookKeyDown(object sender, HookEventArgs e)
5152
SetKeyDown(e.Key);
5253
if (IsKeyDown(Key.PrintScreen))
5354
{
54-
var screenCut = new WPFDevelopers.Controls.ScreenCut();
55+
var screenCut = new ScreenCut();
5556
screenCut.ShowDialog();
5657
}
5758
else
@@ -152,7 +153,33 @@ private void MenuItem_Click(object sender, RoutedEventArgs e)
152153
myNotifyIcon.Dispose();
153154
Environment.Exit(0);
154155
}
156+
157+
public void ExitEmbedded()
158+
{
159+
if (ToggleButtonMini.IsChecked == true)
160+
Width = 30;
161+
else
162+
Width = 120;
163+
Height = desktopWorkingArea.Height / 2;
164+
Left = desktopWorkingArea.Width - Width;
165+
Top = desktopWorkingArea.Height / 2 - Height / 2;
166+
}
167+
168+
public void OepnEmbedded()
169+
{
170+
if (mainVM.IsEmbedded) return;
171+
}
172+
173+
private void myNotifyIcon_TrayLeftMouseUp(object sender, RoutedEventArgs e)
174+
{
175+
if (mainVM.IsEmbedded) return;
176+
Show();
177+
Activate();
178+
Focus();
179+
}
180+
155181
#region 移动窗体
182+
156183
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
157184
{
158185
anchorPoint = e.GetPosition(this);
@@ -165,16 +192,9 @@ protected override void OnMouseMove(MouseEventArgs e)
165192
{
166193
try
167194
{
168-
if (!inDrag) return;
195+
if (!inDrag && e.LeftButton != MouseButtonState.Pressed) return;
169196
var currentPoint = e.GetPosition(this);
170-
var y = this.Top + currentPoint.Y - anchorPoint.Y;
171-
Win32Api.RECT rect;
172-
Win32Api.GetWindowRect(new WindowInteropHelper(this).Handle, out rect);
173-
var w = rect.right - rect.left;
174-
var h = rect.bottom - rect.top;
175-
int x = Convert.ToInt32(PrimaryScreen.DESKTOP.Width - w);
176-
Win32Api.MoveWindow(new WindowInteropHelper(this).Handle, x, (int)y, w, h, 1);
177-
197+
Top = Top + (currentPoint.Y - anchorPoint.Y);
178198
}
179199
catch (Exception ex)
180200
{
@@ -191,31 +211,18 @@ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
191211
e.Handled = true;
192212
}
193213
}
214+
194215
#endregion
195-
public void ExitEmbedded()
196-
{
197-
if(ToggleButtonMini.IsChecked == true)
198-
Width = 30;
199-
else
200-
Width = 120;
201-
Height = desktopWorkingArea.Height / 2;
202-
Left = desktopWorkingArea.Width - Width;
203-
Top = desktopWorkingArea.Height / 2 - (Height / 2);
204-
}
205-
public void OepnEmbedded()
206-
{
207-
if (mainVM.IsEmbedded) return;
208216

209-
}
210217
#region 窗体动画
218+
211219
private void ToggleButtonMini_Checked(object sender, RoutedEventArgs e)
212220
{
213-
214221
try
215222
{
216-
EasingFunctionBase easeFunction = new CubicEase()
223+
EasingFunctionBase easeFunction = new CubicEase
217224
{
218-
EasingMode = EasingMode.EaseOut,
225+
EasingMode = EasingMode.EaseOut
219226
};
220227

221228
var heightAnimation = new DoubleAnimation
@@ -224,23 +231,20 @@ private void ToggleButtonMini_Checked(object sender, RoutedEventArgs e)
224231
From = desktopWorkingArea.Height / 2,
225232
To = 60,
226233
Duration = new Duration(TimeSpan.FromSeconds(0.5)),
227-
EasingFunction = easeFunction,
228-
};
229-
heightAnimation.Completed += delegate
230-
{
231-
BeginAnimation(HeightProperty, null);
234+
EasingFunction = easeFunction
232235
};
236+
heightAnimation.Completed += delegate { BeginAnimation(HeightProperty, null); };
233237
var widthAnimation = new DoubleAnimation
234238
{
235239
Name = "widthMini",
236240
From = 120,
237241
To = 30,
238242
Duration = new Duration(TimeSpan.FromSeconds(0.51)),
239-
EasingFunction = easeFunction,
243+
EasingFunction = easeFunction
240244
};
241245
widthAnimation.Completed += delegate
242246
{
243-
Left = desktopWorkingArea.Width - this.Width;
247+
Left = desktopWorkingArea.Width - Width;
244248
BeginAnimation(WidthProperty, null);
245249
};
246250
BeginAnimation(HeightProperty, heightAnimation);
@@ -253,26 +257,24 @@ private void ToggleButtonMini_Checked(object sender, RoutedEventArgs e)
253257
}
254258

255259

256-
257260
private void UnToggleButtonMini_Checked(object sender, RoutedEventArgs e)
258261
{
259-
260262
try
261263
{
262-
var easeFunction = new CubicEase()
264+
var easeFunction = new CubicEase
263265
{
264-
EasingMode = EasingMode.EaseIn,
266+
EasingMode = EasingMode.EaseIn
265267
};
266268
var widthAnimation = new DoubleAnimation
267269
{
268270
From = 30,
269271
To = 120,
270272
Duration = new Duration(TimeSpan.FromSeconds(0.01)),
271-
EasingFunction = easeFunction,
273+
EasingFunction = easeFunction
272274
};
273275
widthAnimation.Completed += delegate
274276
{
275-
Left = desktopWorkingArea.Width - this.Width;
277+
Left = desktopWorkingArea.Width - Width;
276278
BeginAnimation(WidthProperty, null);
277279
};
278280

@@ -281,31 +283,18 @@ private void UnToggleButtonMini_Checked(object sender, RoutedEventArgs e)
281283
From = 60,
282284
To = desktopWorkingArea.Height / 2,
283285
Duration = new Duration(TimeSpan.FromSeconds(0.5)),
284-
EasingFunction = easeFunction,
285-
};
286-
heightAnimation.Completed += delegate
287-
{
288-
BeginAnimation(HeightProperty, null);
286+
EasingFunction = easeFunction
289287
};
288+
heightAnimation.Completed += delegate { BeginAnimation(HeightProperty, null); };
290289
BeginAnimation(WidthProperty, widthAnimation);
291290
BeginAnimation(HeightProperty, heightAnimation);
292291
}
293292
catch (Exception ex)
294293
{
295294
Log.Error($"MainView.UnToggleButtonMini_Checked{ex.Message}");
296295
}
297-
298296
}
299297

300-
301298
#endregion
302-
303-
private void myNotifyIcon_TrayLeftMouseUp(object sender, RoutedEventArgs e)
304-
{
305-
if (mainVM.IsEmbedded) return;
306-
Show();
307-
Activate();
308-
Focus();
309-
}
310299
}
311300
}

SoftwareHelper/Views/StartView.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
<Rectangle x:Name="freeRect" Fill="{StaticResource freeMachineImageBrush}"
2929
Height="48" Width="128" Canvas.Left="186" Canvas.Top="20"/>
3030
<TextBlock x:Name="tbMsg" FontSize="20" Canvas.Left="10" />
31-
<TextBlock x:Name="tb1" Text="8866" FontSize="20" Canvas.Left="200" Canvas.Top="120" Width="1262"/>
31+
<TextBlock x:Name="tb1" Text="8866 微信公众号:WPF开发者" FontSize="20" Canvas.Left="100" Canvas.Top="120" Width="1262"/>
3232
<TextBlock x:Name="tb2" Text="2333哈哈哈哈" FontSize="20" Canvas.Left="800" Canvas.Top="80" Width="1262"/>
33-
<TextBlock x:Name="tb3" Text="66666 再接再厉" FontSize="20" Canvas.Left="450" Canvas.Top="160" Width="1262"/>
33+
<TextBlock x:Name="tb3" Text="66666 再接再厉" FontSize="20" Canvas.Left="450" Canvas.Top="160" Width="1262"/>
3434
<!-- Canvas.Left="122"-->
3535
</Canvas>
3636
</Window>

SoftwareHelper/Views/StartView.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public StartView()
3333
background2.Fill = backgroundBrush;
3434
if (background2.Fill.CanFreeze)
3535
background2.Fill.Freeze();
36-
Start();
3736
Loaded += StartView_Loaded;
3837
}
3938

4039
private void StartView_Loaded(object sender, RoutedEventArgs e)
4140
{
41+
Start();
4242
var bw = new BackgroundWorker();
4343
bw.DoWork += delegate
4444
{

0 commit comments

Comments
 (0)