-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow1.xaml.cs
225 lines (205 loc) · 10.6 KB
/
Window1.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
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
214
215
216
217
218
219
220
221
222
223
224
225
//Shahar Seifer 2020
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Interactivity;
using System.Threading.Tasks;
using System.IO;
namespace ClusterAlign
{
public class Window1 : Window
{
public static string loadAttentionFile = "";
public static string loadfidFile = "";
public static int AttentionNumMarkedfids;
public static bool isArbAngle = false;
private TextBox TtextInputPath;
private Button btnBrowsePath;
private Button btnloadAttention;
private Button btnloadfid;
private TextBox txtuseAttention;
private TextBox txtMarkedfids;
private NumericUpDown NumMarkedfids;
private Button btnRun;
private TextBox TDatafile;
private TextBox TTiltFile;
private ComboBox CombxisRotation;
private NumericUpDown NumClusterSize;
private NumericUpDown NumNcluster;
private NumericUpDown Numfidsize;
private NumericUpDown NumNfidmax;
private NumericUpDown Numncenter;
private NumericUpDown NumNminimumTracked;
private ComboBox CombForceFill;
private ComboBox Combcoswindow;
private NumericUpDown NumPreAlignmentTol;
private ComboBox Combfiducialbright;
private NumericUpDown NumTolFidCenter;
private NumericUpDown NumTolFidSize;
private CheckBox reconstruct;
private CheckBox normalali;
private NumericUpDown ArbAngle;
public Window1()
{
this.InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
TtextInputPath = this.FindControl<TextBox>("textInputPath");
btnBrowsePath = this.FindControl<Button>("btnBrowsePath");
btnloadAttention = this.FindControl<Button>("loadAttention");
btnloadfid = this.FindControl<Button>("loadfid");
txtuseAttention = this.FindControl<TextBox>("useAttention");
NumMarkedfids = this.FindControl<NumericUpDown>("NumMarkedfids");
txtMarkedfids = this.FindControl<TextBox>("Markedfids"); ;
TDatafile = this.FindControl<TextBox>("Datafile");
TTiltFile = this.FindControl<TextBox>("TiltFile");
CombxisRotation = this.FindControl<ComboBox>("xisRotation");
NumClusterSize = this.FindControl<NumericUpDown>("ClusterSize");
NumNcluster = this.FindControl<NumericUpDown>("Ncluster");
Numfidsize = this.FindControl<NumericUpDown>("fidsize");
NumNfidmax = this.FindControl<NumericUpDown>("NFidMax");
Numncenter = this.FindControl<NumericUpDown>("ncenter");
NumNminimumTracked = this.FindControl<NumericUpDown>("NminimumTracked");
CombForceFill = this.FindControl<ComboBox>("ForceFill");
Combcoswindow = this.FindControl<ComboBox>("coswindow");
NumPreAlignmentTol = this.FindControl<NumericUpDown>("PreAlignmentTol");
Combfiducialbright = this.FindControl<ComboBox>("fiducialbright");
NumTolFidCenter = this.FindControl<NumericUpDown>("TolFidCenter");
NumTolFidSize = this.FindControl<NumericUpDown>("TolFidSize");
reconstruct = this.FindControl<CheckBox>("reconstruct");
normalali = this.FindControl<CheckBox>("normal_ali");
ArbAngle = this.FindControl<NumericUpDown>("Random_angle");
TtextInputPath.Text = ClusterAlign.Settings4ClusterAlign2.Default.Path;
TDatafile.Text= ClusterAlign.Settings4ClusterAlign2.Default.DataFileName;
TTiltFile.Text= ClusterAlign.Settings4ClusterAlign2.Default.TiltFileName;
ArbAngle.Value = ClusterAlign.Settings4ClusterAlign2.Default.ArbAngle;
isArbAngle = ClusterAlign.Settings4ClusterAlign2.Default.isArbAngle;
if (isArbAngle)
{
CombxisRotation.SelectedIndex = 2;
ArbAngle.IsVisible = true;
}
else
{
CombxisRotation.SelectedIndex = (ClusterAlign.Settings4ClusterAlign2.Default.xisRotation ? 1 : 0);
ArbAngle.IsVisible = false;
}
NumClusterSize.Value = ClusterAlign.Settings4ClusterAlign2.Default.cluster_size;
NumNcluster.Value = ClusterAlign.Settings4ClusterAlign2.Default.Ncluster;
Numfidsize.Value = ClusterAlign.Settings4ClusterAlign2.Default.fidsize;
NumNfidmax.Value = ClusterAlign.Settings4ClusterAlign2.Default.NfidMax;
Numncenter.Value = ClusterAlign.Settings4ClusterAlign2.Default.ncenter;
NumNminimumTracked.Value = ClusterAlign.Settings4ClusterAlign2.Default.N_minimum_tracked_fiducials;
CombForceFill.SelectedIndex = (ClusterAlign.Settings4ClusterAlign2.Default.ForceFill ? 1 : 0);
Combcoswindow.SelectedIndex = (ClusterAlign.Settings4ClusterAlign2.Default.coswindow ? 1 : 0);
NumPreAlignmentTol.Value = ClusterAlign.Settings4ClusterAlign2.Default.PreAlignmentTol;
NumTolFidSize.Value = ClusterAlign.Settings4ClusterAlign2.Default.TolFidSize;
NumTolFidCenter.Value = ClusterAlign.Settings4ClusterAlign2.Default.TolFidCenter;
Combfiducialbright.SelectedIndex = (ClusterAlign.Settings4ClusterAlign2.Default.fiducials_bright ? 1 : 0);
txtuseAttention.Text ="Optional tif stack: N/A";
txtMarkedfids.IsVisible = false;
NumMarkedfids.Value = 0;
NumMarkedfids.IsVisible = false;
reconstruct.IsChecked= ClusterAlign.Settings4ClusterAlign2.Default.add_reconst;
normalali.IsChecked = ClusterAlign.Settings4ClusterAlign2.Default.export_normalali;
CombxisRotation.SelectionChanged += (sender, e) => Rot_SelectionChanged();
btnRun = this.FindControl<Button>("btnRun");
btnBrowsePath.Click += async (sender, e) => await GetPath();
btnloadAttention.Click += async (sender, e) => await GetAttentionFile();
btnloadfid.Click += async (sender, e) => await GetfidFile();
btnRun.Click += BtnRun_Click;
}
private void BtnRun_Click(object sender, RoutedEventArgs e)
{
AttentionNumMarkedfids = (int)NumMarkedfids.Value;
ClusterAlign.Settings4ClusterAlign2.Default.Path= TtextInputPath.Text;
ClusterAlign.Settings4ClusterAlign2.Default.DataFileName= TDatafile.Text;
ClusterAlign.Settings4ClusterAlign2.Default.TiltFileName= TTiltFile.Text;
ClusterAlign.Settings4ClusterAlign2.Default.xisRotation = (CombxisRotation.SelectedIndex==1 ? true : false);
ClusterAlign.Settings4ClusterAlign2.Default.cluster_size= (int)NumClusterSize.Value;
ClusterAlign.Settings4ClusterAlign2.Default.Ncluster= (int)NumNcluster.Value;
ClusterAlign.Settings4ClusterAlign2.Default.NfidMax =(int)NumNfidmax.Value;
ClusterAlign.Settings4ClusterAlign2.Default.fidsize= (float)Numfidsize.Value;
ClusterAlign.Settings4ClusterAlign2.Default.ncenter= (int)Numncenter.Value;
ClusterAlign.Settings4ClusterAlign2.Default.N_minimum_tracked_fiducials= (int)NumNminimumTracked.Value;
ClusterAlign.Settings4ClusterAlign2.Default.ForceFill = (CombForceFill.SelectedIndex==1 ? true : false);
ClusterAlign.Settings4ClusterAlign2.Default.coswindow = (Combcoswindow.SelectedIndex==1 ? true : false);
ClusterAlign.Settings4ClusterAlign2.Default.PreAlignmentTol = NumPreAlignmentTol.Value;
ClusterAlign.Settings4ClusterAlign2.Default.fiducials_bright = (Combfiducialbright.SelectedIndex==1 ? true : false);
ClusterAlign.Settings4ClusterAlign2.Default.TolFidSize = (int)NumTolFidSize.Value;
ClusterAlign.Settings4ClusterAlign2.Default.TolFidCenter = (int)NumTolFidCenter.Value;
ClusterAlign.Settings4ClusterAlign2.Default.add_reconst = (bool)reconstruct.IsChecked;
ClusterAlign.Settings4ClusterAlign2.Default.export_normalali= (bool)normalali.IsChecked;
ClusterAlign.Settings4ClusterAlign2.Default.isArbAngle= isArbAngle;
ClusterAlign.Settings4ClusterAlign2.Default.ArbAngle = (uint)ArbAngle.Value;
ClusterAlign.Settings4ClusterAlign2.Default.Save();
ClusterAlign.App.Hidewin();
Program.MyMain();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
//private void DataFileButtonClick(object sender, RoutedEventArgs e)
//{
// GetPath();
//}
private async Task GetPath()
{
//var dlg = new OpenFolderDialog();
var dlg = new OpenFileDialog();
string text = TtextInputPath.Text;
if (text.Length > 0)
{
dlg.Directory = TtextInputPath.Text;
}
var result = await dlg.ShowAsync(this);
if (!string.IsNullOrWhiteSpace(result[0]))
{
TtextInputPath.Text = Path.GetDirectoryName(@result[0]);
TDatafile.Text=Path.GetFileName(@result[0]);
TTiltFile.Text= Path.GetFileNameWithoutExtension(@result[0])+".rawtlt";
}
}
private void Rot_SelectionChanged()
{
isArbAngle = (CombxisRotation.SelectedIndex == 2 ? true : false); //Angle=
if (isArbAngle)
{
ArbAngle.IsVisible = true;
}
else
{
ArbAngle.IsVisible = false;
}
}
private async Task GetAttentionFile()
{
var dlg = new OpenFileDialog();
dlg.Title="Choose tif stack file in which important fiducials are painted over with color 0 paintbrush";
var result = await dlg.ShowAsync(this);
if (!string.IsNullOrWhiteSpace(result[0]))
{
loadAttentionFile = result[0];
txtuseAttention.Text = "Optional tif stack: loaded";
txtMarkedfids.IsVisible = true;
//NumMarkedfids.IsVisible = true;
}
}
private async Task GetfidFile()
{
var dlg = new OpenFileDialog();
dlg.Title = "Choose *.fid.txt file with partial table of fiducials";
var result = await dlg.ShowAsync(this);
if (!string.IsNullOrWhiteSpace(result[0]))
{
loadfidFile = result[0];
}
}
//private void DataFilePointerEnter(object sender, PointerEventArgs e)
//{
// //do something when pointer enters
// }
}
}