-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClientWindow.xaml.cs
More file actions
160 lines (146 loc) · 5.51 KB
/
ClientWindow.xaml.cs
File metadata and controls
160 lines (146 loc) · 5.51 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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;
using EdGo.EdgoClient;
using Microsoft.Win32;
namespace EdGo
{
/// <summary>
/// Логика взаимодействия для ClientWindow.xaml
/// </summary>
public partial class ClientWindow : Window
{
RegistryKey AutoStartRK;
Client client = Client.instance;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
public ClientWindow()
{
InitializeComponent();
getSettings();
showButtons();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
folderBrowserDialog1.ShowNewFolderButton = false;
}
private void showButtons()
{
if (client.isTested)
{
buttonTest.IsEnabled = false;
buttonOk.IsEnabled = true;
}
else if (client.canTest)
{
buttonTest.IsEnabled = true;
buttonOk.IsEnabled = false;
}
else if (!client.canTest && !client.isTested)
{
buttonTest.IsEnabled = false;
buttonOk.IsEnabled = false;
}
}
private void getSettings()
{
inputURL.Text = client.url;
inputUserID.Text = client.userId;
inputUserKey.Text = client.userKey;
AutoStartRK = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (AutoStartRK.GetValue(System.Windows.Forms.Application.ProductName) == null)
{
AutoStartChk.IsChecked = false;
} else
{
AutoStartChk.IsChecked = true;
}
chkScreenshotUpload.IsChecked = Properties.Settings.Default.ScreenshotUpload;
chkScreenshotConvert.IsChecked = Properties.Settings.Default.ScreenshotConvert;
if (Properties.Settings.Default.ScreenshotPath.Equals("default", StringComparison.OrdinalIgnoreCase) || (Properties.Settings.Default.ScreenshotPath == null))
{
ScreenshotsPath.Text = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures) + "\\Frontier Developments\\Elite Dangerous\\";
}
else
{
ScreenshotsPath.Text = Properties.Settings.Default.ScreenshotPath;
}
StartMinimizedChk.IsChecked = Properties.Settings.Default.StartMinimized;
StartProcChk.IsChecked = Properties.Settings.Default.AutoStartProc;
}
private void inputs_KeyUp(object sender, KeyEventArgs e)
{
client.url = inputURL.Text;
client.userId = inputUserID.Text;
client.userKey = inputUserKey.Text;
client.isTested = false;
showButtons();
}
private void buttonTest_Click(object sender, RoutedEventArgs e)
{
this.IsEnabled = false;
if (client.httpTest())
{
MessageBox.Show("Test OK", "Testing connection", MessageBoxButton.OK);
} else
{
MessageBox.Show("Test FAILED!", "Testing connection", MessageBoxButton.OK);
}
this.IsEnabled = true;
showButtons();
}
private void buttonOk_Click(object sender, RoutedEventArgs e)
{
string startPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs)
+ @"\C3S Development\edgo-client\edgo-client.appref-ms";
if (AutoStartChk.IsChecked == true)
{
AutoStartRK.SetValue(System.Windows.Forms.Application.ProductName, startPath/* System.Windows.Forms.Application.ExecutablePath.ToString()*/);
} else
{
if (AutoStartRK.GetValue(System.Windows.Forms.Application.ProductName) != null) AutoStartRK.DeleteValue(System.Windows.Forms.Application.ProductName);
}
Properties.Settings.Default.StartMinimized = (StartMinimizedChk.IsChecked == true);
Properties.Settings.Default.AutoStartProc = (StartProcChk.IsChecked == true);
Properties.Settings.Default.ScreenshotConvert = (chkScreenshotConvert.IsChecked == true);
Properties.Settings.Default.ScreenshotUpload = (chkScreenshotUpload.IsChecked == true);
Properties.Settings.Default.ScreenshotPath = ScreenshotsPath.Text;
client.saveDefault();
this.Hide();
AppDispatcher.instance.hideClientSettings();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//BrightIdeasSoftware.ObjectListView
e.Cancel = true;
this.Hide();
client.retunDefault();
AppDispatcher.instance.hideClientSettings();
}
private void ResetScreenshotPath_Click(object sender, RoutedEventArgs e)
{
ScreenshotsPath.Text = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures) + "\\Frontier Developments\\Elite Dangerous\\";
}
private void buttonCancel_Click(object sender, RoutedEventArgs e)
{
this.Hide();
client.retunDefault();
AppDispatcher.instance.hideClientSettings();
}
private void SelectScreenshotPath_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.DialogResult result = folderBrowserDialog1.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
ScreenshotsPath.Text = folderBrowserDialog1.SelectedPath;
}
}
}
}