-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindowCustomize.cs
76 lines (68 loc) · 2.33 KB
/
WindowCustomize.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace DotNetPad
{
public partial class MainWindow : Window
{
private void TopBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// This is all it takes to make the top of the window draggable
DragMove();
}
// Display the system menu when you right-click the app icon
private void AppIcon_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
var offset = Application.Current.MainWindow.BorderThickness;
SystemCommands.ShowSystemMenu(this, new Point((Left + offset.Left) + 24, (Top + offset.Top) + 24));
}
private void MinimizeButton_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void MaximizeButton_Click(object sender, RoutedEventArgs e)
{
if (this.WindowState == WindowState.Maximized)
{
this.WindowState = WindowState.Normal;
}
else
{
// Make sure the maximized window doesn't cover the taskbar first
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
this.WindowState = WindowState.Maximized;
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Window_StateChanged(object sender, EventArgs e)
{
switch (WindowState)
{
case WindowState.Normal:
MaximizeButton.Content = "\xE922";
break;
case WindowState.Maximized:
MaximizeButton.Content = "\xE923";
break;
default:
break;
}
}
private void CloseButton_MouseEnter(object sender, MouseEventArgs e)
{
CloseButton.Background = Brushes.Red;
}
private void CloseButton_MouseLeave(object sender, MouseEventArgs e)
{
CloseButton.Background = Brushes.Transparent;
}
}
}