-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddUserWindow.xaml.cs
86 lines (74 loc) · 2.4 KB
/
AddUserWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Desktop01
{
/// <summary>
/// Interaction logic for AddUserWindow.xaml
/// </summary>
public partial class AddUserWindow : Window
{
public AddUserWindow(AddUserVM vm)
{
InitializeComponent();
DataContext = vm;
vm.CloseAction = () => Close();
}
private void btnResize_Click(object sender, RoutedEventArgs e)
{
if (this.WindowState == WindowState.Normal)
this.WindowState = WindowState.Maximized;
else this.WindowState = WindowState.Normal;
}
private void btnMinimize_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private bool isDragging = false;
private Point dragOffset;
public AddUserWindow()
{
InitializeComponent();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
isDragging = true;
dragOffset = e.GetPosition(this);
this.CaptureMouse();
}
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
Point currentPosition = e.GetPosition(this);
double left = currentPosition.X - dragOffset.X + this.Left;
double top = currentPosition.Y - dragOffset.Y + this.Top;
this.Left = left;
this.Top = top;
}
}
private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
isDragging = false;
this.ReleaseMouseCapture();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
double screenWidth = SystemParameters.PrimaryScreenWidth;
double windowHeight = ActualHeight;
double windowTop = (SystemParameters.PrimaryScreenHeight - windowHeight) / 2;
Left = screenWidth - ActualWidth;
Top = windowTop;
}
}
}