-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormCreateTargetList.cs
213 lines (193 loc) · 8.2 KB
/
FormCreateTargetList.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
202
203
204
205
206
207
208
209
210
211
212
213
// --------------------------------------------------------------------------------
// VariScan module
//
// Description:
//
// Environment: Windows 10 executable, 32 and 64 bit
//
// Usage: TBD
//
// Author: (REM) Rick McAlister, [email protected]
//
// Edit Log: Rev 1.0 Initial Version
//
// Date Who Vers Description
// ----------- --- ----- -------------------------------------------------------
//
// ---------------------------------------------------------------------------------
//
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
namespace VariScan
{
public partial class FormCreateTargetList : Form
{
public string[] zeroBasedFilters;
public FormCreateTargetList()
{
InitializeComponent();
//fill Collection list
CollectionListBox.Items.Clear();
foreach (var c in CollectionManagement.ListCollections())
CollectionListBox.Items.Add(c);
return;
}
private void InitializeCollection()
{
Configuration cfg = new Configuration();
this.Text = "Collection: " + cfg.TargetListPath;
if (File.Exists(cfg.TargetListPath))
{
//file exists so populate window accordingly
TargetXList tList = new TargetXList();
List<TargetXList.TargetXDescriptor> tXList = tList.GetTargetXList();
TargetListDropDown.Items.Clear();
foreach (TargetXList.TargetXDescriptor tX in tXList)
TargetListDropDown.Items.Add(tX.Name);
if (TargetListDropDown.Items.Count > 0)
TargetListDropDown.Text = TargetListDropDown.Items[0].ToString();
//Load Filter assignments
ColorIndexing colorIndex = new ColorIndexing();
FilterListBox.Items.Clear();
zeroBasedFilters = colorIndex.GetSessionFilters().ToArray();
//Add to list box
if (zeroBasedFilters != null)
FilterListBox.Items.AddRange(zeroBasedFilters);
for (int i = 0; i < FilterListBox.Items.Count; i++)
FilterListBox.SetItemChecked(i, true);
}
else //Load filters from TSX
{
TargetListDropDown.Items.Clear();
FilterListBox.Items.Clear();
zeroBasedFilters = Filters.FilterNameSet();
//Add to list box
if (zeroBasedFilters != null)
FilterListBox.Items.AddRange(zeroBasedFilters);
}
Utility.ButtonGreen(DoneButton);
}
private void CreateAAVSOTargetList_Button(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://filtergraph.com/aavso/default/index");
CompileButton.Text = "Cancel";
}
private void ImportCSVButton_Click(object sender, EventArgs e)
{
Utility.ButtonRed(ImportCSVButton);
DialogResult odr = OpenTargetTextFileDialog.ShowDialog();
if (odr == DialogResult.OK)
{
string textFileName = OpenTargetTextFileDialog.FileName;
Configuration cfg = new Configuration();
TargetXList.CreateXListFromCSV(textFileName, cfg.TargetListPath);
}
Utility.ButtonGreen(ImportCSVButton);
return;
}
private void CompileButton_Click(object sender, EventArgs e)
{
//Save configurations to filehttps://www.mcafee.com/content/dam/ngm/retention/2022/AR-Scammer/Online-security.png
ColorIndexing clist = new ColorIndexing();
List<Filters.ActiveFilter> afList = new List<Filters.ActiveFilter>();
for (int i = 0; i < FilterListBox.CheckedItems.Count; i++)
{
afList.Add(new Filters.ActiveFilter()
{
FilterName = FilterListBox.CheckedItems[i].ToString(),
FilterIndex = (int)Filters.LookUpFilterIndex(FilterListBox.CheckedItems[i].ToString())
});
}
clist.SaveActiveFilters(afList);
}
private void AddTargetButton_Click(object sender, EventArgs e)
{
//Add contents of target list field to target list
//Read in from field
string newTgtName = TargetListDropDown.Text;
//Look up target from TSX and get Ra and Dec
double ra; double dec;
try { (ra, dec) = TSX_Resources.FindTarget(newTgtName); }
catch
{
MessageBox.Show("Look up of target failed");
return;
}
//remove target, if already present, to prevent duplicates
TargetXList.DeleteFromTargetXList(newTgtName);
//Add new target
TargetXList.AddToTargetXList(newTgtName, ra, dec, DateTime.Now);
//Repopulate
TargetXList tList = new TargetXList();
List<TargetXList.TargetXDescriptor> tXList = tList.GetTargetXList();
TargetListDropDown.Items.Clear();
foreach (TargetXList.TargetXDescriptor tX in tXList)
TargetListDropDown.Items.Add(tX.Name);
if (TargetListDropDown.Items.Count > 0)
TargetListDropDown.Text = TargetListDropDown.Items[0].ToString();
}
private void FinishedButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void DeleteTargetButton_Click(object sender, EventArgs e)
{
//Read in from field
string newTgtName = TargetListDropDown.Text;
//remove target
TargetXList.DeleteFromTargetXList(newTgtName);
//Repopulate
TargetXList tList = new TargetXList();
List<TargetXList.TargetXDescriptor> tXList = tList.GetTargetXList();
TargetListDropDown.Items.Clear();
foreach (TargetXList.TargetXDescriptor tX in tXList)
TargetListDropDown.Items.Add(tX.Name);
if (TargetListDropDown.Items.Count > 0)
TargetListDropDown.Text = TargetListDropDown.Items[0].ToString();
else
TargetListDropDown.Text = "";
}
private void CollectionListBox_SelectedIndexChanged(object sender, EventArgs e)
{
string tgtListPath = CollectionManagement.OpenCollection(CollectionListBox.SelectedItem.ToString());
InitializeCollection();
return;
}
private void AddNewButton_Click(object sender, EventArgs e)
{
Utility.ButtonRed(AddNewButton);
Configuration cfg = new Configuration();
//Add new folder for Collection
DialogResult dr = MessageBox.Show("Camera and Filter Wheel must be powered on and able to connect.", "Check Image Train", MessageBoxButtons.OKCancel);
if ((dr == DialogResult.OK) && (AddCollectionTextBox.Text.Length > 0))
{
string choice = AddCollectionTextBox.Text;
CollectionManagement.CreateCollection(choice);
CollectionManagement.OpenCollection(choice);
}
if (!File.Exists(cfg.TargetListPath))
{
InitializeCollection();
}
Utility.ButtonGreen(AddNewButton);
return;
}
private void AddCollectionTextBox_TextChanged(object sender, EventArgs e)
{
}
//private void PrimaryFilterBox_SelectedIndexChanged(object sender, EventArgs e)
//{
// PrimaryFilterZBBox.Text = Filters.LookUpFilterIndex(PrimaryFilterBox.Text).ToString() ?? "N/A";
//}
//private void DifferentialFilterZBBox_TextChanged(object sender, EventArgs e)
//{
// DifferentialFilterZBBox.Text = Filters.LookUpFilterIndex(DifferentialFilterBox.Text).ToString() ?? "N/A";
//}
//private void OtherFilterZBBox_TextChanged(object sender, EventArgs e)
//{
// OtherFilterZBBox.Text = Filters.LookUpFilterIndex(OtherFilterBox.Text).ToString() ?? "N/A";
//}
}
}