-
Notifications
You must be signed in to change notification settings - Fork 2
/
PlaneWaveTools.cs
201 lines (172 loc) · 6.87 KB
/
PlaneWaveTools.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#region "copyright"
/*
Copyright (c) 2024 Dale Ghent <[email protected]>
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/
*/
#endregion "copyright"
using CommunityToolkit.Mvvm.Input;
using DaleGhent.NINA.PlaneWaveTools.Utility;
using NINA.Core.Utility;
using NINA.Plugin;
using NINA.Plugin.Interfaces;
using NINA.Profile.Interfaces;
using System;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace DaleGhent.NINA.PlaneWaveTools {
[Export(typeof(IPluginManifest))]
public partial class PlaneWaveTools : PluginBase, ISettings, INotifyPropertyChanged {
[ImportingConstructor]
public PlaneWaveTools() {
if (Properties.Settings.Default.UpgradeSettings) {
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpgradeSettings = false;
CoreUtil.SaveSettings(Properties.Settings.Default);
}
if (string.IsNullOrEmpty(Pwi3ClientId) || string.IsNullOrWhiteSpace(Pwi3ClientId)) {
Pwi3ClientId = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8);
}
}
public string Pwi3ExePath {
get => Properties.Settings.Default.Pwi3ExePath;
set {
Properties.Settings.Default.Pwi3ExePath = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string Pwi3IpAddress {
get => Properties.Settings.Default.Pwi3IpAddress;
set {
Properties.Settings.Default.Pwi3IpAddress = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public ushort Pwi3Port {
get => Properties.Settings.Default.Pwi3Port;
set {
Properties.Settings.Default.Pwi3Port = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string Pwi3ClientId {
get => Properties.Settings.Default.Pwi3ClientId;
set {
Properties.Settings.Default.Pwi3ClientId = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string Pwi4ExePath {
get => Properties.Settings.Default.Pwi4ExePath;
set {
Properties.Settings.Default.Pwi4ExePath = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string Pwi4IpAddress {
get => Properties.Settings.Default.Pwi4IpAddress;
set {
Properties.Settings.Default.Pwi4IpAddress = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public ushort Pwi4Port {
get => Properties.Settings.Default.Pwi4Port;
set {
Properties.Settings.Default.Pwi4Port = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string PwscExePath {
get => Properties.Settings.Default.PwscExePath;
set {
Properties.Settings.Default.PwscExePath = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public string PwscIpAddress {
get => Properties.Settings.Default.PwscIpAddress;
set {
Properties.Settings.Default.PwscIpAddress = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public ushort PwscPort {
get => Properties.Settings.Default.PwscPort;
set {
Properties.Settings.Default.PwscPort = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public int DeltaTDefaultPrimaryPowerLevel {
get => Properties.Settings.Default.DeltaTDefaultPrimaryPowerLevel;
set {
Properties.Settings.Default.DeltaTDefaultPrimaryPowerLevel = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
public int DeltaTDefaultSecondaryPowerLevel {
get => Properties.Settings.Default.DeltaTDefaultSecondaryPowerLevel;
set {
Properties.Settings.Default.DeltaTDefaultSecondaryPowerLevel = value;
CoreUtil.SaveSettings(Properties.Settings.Default);
RaisePropertyChanged();
}
}
[RelayCommand]
private void OpenPwi3ExePathDialog(object obj) {
Microsoft.Win32.OpenFileDialog dialog = new() {
FileName = string.Empty,
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
Filter = "Any Program|*.exe"
};
if (dialog.ShowDialog() == true) {
Pwi3ExePath = dialog.FileName;
}
}
[RelayCommand]
private void OpenPwi4ExePathDialog(object obj) {
Microsoft.Win32.OpenFileDialog dialog = new() {
FileName = string.Empty,
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
Filter = "Any Program|*.exe"
};
if (dialog.ShowDialog() == true) {
Pwi4ExePath = dialog.FileName;
}
}
[RelayCommand]
private void OpenPwscExePathDialog(object obj) {
Microsoft.Win32.OpenFileDialog dialog = new() {
FileName = string.Empty,
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
Filter = "Any Program|*.exe"
};
if (dialog.ShowDialog() == true) {
PwscExePath = dialog.FileName;
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override Task Teardown() {
Pwi4StatusChecker.Shutdown();
return base.Teardown();
}
}
}