-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
117 lines (103 loc) · 3.24 KB
/
MainWindow.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.ComponentModel;
namespace MSB_SERVER
{
public partial class MainWindow
{
private App serverApplication;
private bool WINDOW_STATE_MAXIMIZED;
public MainWindow()
{
serverApplication = (App) Application.Current;
Closing += OnWindowClosing;
InitializeComponent();
InitializeTitleBar();
}
private void InitializeTitleBar()
{
WINDOW_STATE_MAXIMIZED = false;
titleBar.MouseDown += OnTitleBarMouseDown;
titleMainIcon.Source = new BitmapImage(new Uri(@"/MSB_SERVER;component/Resources/icon.png", UriKind.Relative));
titleMinIcon.Source = new BitmapImage(new Uri(@"/MSB_SERVER;component/Resources/title_min.png", UriKind.Relative));
titleMaxIcon.Source = new BitmapImage(new Uri(@"/MSB_SERVER;component/Resources/title_max.png", UriKind.Relative));
titleEndIcon.Source = new BitmapImage(new Uri(@"/MSB_SERVER;component/Resources/title_end.png", UriKind.Relative));
titleMinIcon.MouseLeftButtonUp += OnTitleMinClickedM;
titleMaxIcon.MouseLeftButtonUp += OnTitleMaxClickedM;
titleEndIcon.MouseLeftButtonUp += OnTitleEndClickedM;
}
private void OnTitleMinClicked(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void OnTitleMinClickedM(object sender, MouseEventArgs e)
{
OnTitleMinClicked(sender, new RoutedEventArgs());
}
private void OnTitleMaxClicked(object sender, RoutedEventArgs e)
{
if (WINDOW_STATE_MAXIMIZED)
{
WindowState = WindowState.Normal;
WINDOW_STATE_MAXIMIZED = false;
} else
{
WindowState = WindowState.Maximized;
WINDOW_STATE_MAXIMIZED = true;
}
}
private void OnTitleMaxClickedM(object sender, MouseEventArgs e)
{
OnTitleMaxClicked(sender, new RoutedEventArgs());
}
private void OnTitleEndClicked(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void OnTitleEndClickedM(object sender, MouseEventArgs e)
{
OnTitleEndClicked(sender, new RoutedEventArgs());
}
private void OnTitleBarMouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void OnServerButtonClicked(object sender, RoutedEventArgs e)
{
string SERVER_IP = "localhost";
int SERVER_PORT = 9993;
try
{
if (mainEditorIP.GetLineText(0) != null && mainEditorIP.GetLineText(0).Trim().Length != 0)
{
SERVER_IP = mainEditorIP.GetLineText(0).Trim();
}
SERVER_PORT = int.Parse(mainEditorPort.GetLineText(0).Trim());
} catch { }
serverApplication.graphicalManager.OnUserServerButton(SERVER_IP, SERVER_PORT);
}
private void OnCommandKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
{
string inputCommand = mainEditorCommand.GetLineText(0).Trim();
if (!string.IsNullOrEmpty(inputCommand))
{
serverApplication.commandManager.ApplyCommand(inputCommand);
mainEditorCommand.Clear();
}
}
}
private void OnWindowClosing(object sender, CancelEventArgs e)
{
try
{
serverApplication.networkManager.ServerStop();
}
catch { }
Application.Current.Shutdown();
}
}
}