/
HCSAnalyzer2.cs
439 lines (338 loc) · 21.1 KB
/
HCSAnalyzer2.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
using HCSAnalyzer.Classes;
using HCSAnalyzer.Classes.Base_Classes.DataStructures;
using HCSAnalyzer.Classes.Base_Classes.Viewers;
using HCSAnalyzer.Classes.General_Types;
using HCSAnalyzer.GUI.FormsForGraphsDisplay.Generic;
using HCSPlugin;
using LibPlateAnalysis;
//using Microsoft.Office.Interop.PowerPoint;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
//using Microsoft.Office.Core;
namespace HCSAnalyzer
{
public partial class HCSAnalyzer : Form
{
private void testPPTToolStripMenuItem_Click(object sender, EventArgs e)
{
//Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
//Microsoft.Office.Interop.PowerPoint.Slides slides;
//Microsoft.Office.Interop.PowerPoint._Slide slide;
//Microsoft.Office.Interop.PowerPoint.TextRange objText;
//// Create the Presentation File
//Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);
//Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
//// Create new Slide
//slides = pptPresentation.Slides;
//slide = slides.AddSlide(1, customLayout);
//// Add title
//objText = slide.Shapes[1].TextFrame.TextRange;
//objText.Text = "FPPT.com";
//objText.Font.Name = "Arial";
//objText.Font.Size = 32;
//objText = slide.Shapes[2].TextFrame.TextRange;
//objText.Text = "Content goes here\nYou can add text\nItem 3";
//slide.NotesPage.Shapes[2].TextFrame.TextRange.Text = "This demo is created by FPPT using C# - Download free templates from http://FPPT.com";
//pptPresentation.SaveAs(@"c:\temp\fppt.pptx", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
////pptPresentation.Close();
////pptApplication.Quit();
}
#region Plugins Management
private void HCSAnalyzer_Shown(object sender, EventArgs e)
{
BuildPluginMenu();
}
private void BuildPluginMenu()
{
List<PluginDescriptor> paList = null;
try
{
paList = PluginDescriptor.GetList(Application.StartupPath + @"\Plugins");
}
catch (DirectoryNotFoundException e)
{
Directory.CreateDirectory("Plugins");
paList = PluginDescriptor.GetList(Application.StartupPath + @"\Plugins");
//MessageBox.Show("Error: " + e.Message, "Plugin's directory not Found" + "\n No Plugin will be loaded", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
ToolStripMenuItem currentMenu = null;
foreach (PluginDescriptor pluginDescriptor in paList)
{
currentMenu = pluginsToolStripMenuItem;
string[] subMenu = pluginDescriptor.MenuPath.Split('|');
if (pluginDescriptor.MenuPath.Length != 0)
{
foreach (string sm in subMenu)
{
string menuName = sm.Trim();
//if submenu exist , get in
if (currentMenu.DropDownItems.ContainsKey(menuName))
{
currentMenu = (ToolStripMenuItem)currentMenu.DropDownItems[menuName];
}
else//if not, create it first.
{
ToolStripMenuItem tsmMenu = new ToolStripMenuItem(menuName);
currentMenu.DropDownItems.Add(tsmMenu);
tsmMenu.Name = menuName;
currentMenu = tsmMenu;
}
}
}
ToolStripMenuItem tsmiName =
new ToolStripMenuItem(pluginDescriptor.Name + @" - " + pluginDescriptor.Author);
currentMenu.DropDownItems.Add(tsmiName);
tsmiName.Tag = pluginDescriptor;
tsmiName.Name = pluginDescriptor.Name;
currentMenu = tsmiName;
currentMenu.Click += new EventHandler(toolMenuItem_Click);
}
}
private void toolMenuItem_Click(object sender, EventArgs e)
{
try
{
ToolStripMenuItem s = (ToolStripMenuItem)sender;
PluginDescriptor p = (PluginDescriptor)s.Tag;
Plugin.CurrentScreen = cGlobalInfo.CurrentScreening;
p.Instanciate();
}
catch (PluginException ex)
{
MessageBox.Show(ex.Message, "Plugin information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
#endregion
private void SwitchVizuMode(object sender, EventArgs e)
{
GlobalInfo.SwitchVisuMode();
}
#region DRC management
private void convertDRCToWellToolStripMenuItem1_Click(object sender, EventArgs e)
{
System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, the current screening will be entirely updated ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (ResWin == System.Windows.Forms.DialogResult.No) return;
//foreach (cDescriptorsType DescType in CompleteScreening.ListDescriptors)
//{
// CompleteScreening.ListDescriptors.RemoveDescUnSafe(DescType, CompleteScreening);
//}
if (cGlobalInfo.CurrentScreening != null) cGlobalInfo.CurrentScreening.Close3DView();
// CompleteScreening.ListDescriptors.RemoveDesc(CompleteScreening.ListDescriptors[IntToTransfer], CompleteScreening);
cScreening MergedScreening = new cScreening("Merged Screen");
MergedScreening.PanelForPlate = this.panelForPlate;
MergedScreening.Rows = cGlobalInfo.CurrentScreening.Rows;
MergedScreening.Columns = cGlobalInfo.CurrentScreening.Columns;
MergedScreening.ListPlatesAvailable = new cListPlates(null);
// create the descriptor
MergedScreening.ListDescriptors.Clean();
int Idesc = 0;
List<cDescriptorType> ListDescType = new List<cDescriptorType>();
for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
{
if (!cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive()) continue;
cDescriptorType DescEC50 = new cDescriptorType("EC50_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1);
ListDescType.Add(DescEC50);
MergedScreening.ListDescriptors.AddNew(DescEC50);
cDescriptorType DescTop = new cDescriptorType("Top_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1);
ListDescType.Add(DescTop);
MergedScreening.ListDescriptors.AddNew(DescTop);
cDescriptorType DescBottom = new cDescriptorType("Bottom_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1);
ListDescType.Add(DescBottom);
MergedScreening.ListDescriptors.AddNew(DescBottom);
cDescriptorType DescSlope = new cDescriptorType("Slope_" + cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName(), true, 1);
ListDescType.Add(DescSlope);
MergedScreening.ListDescriptors.AddNew(DescSlope);
Idesc++;
}
MergedScreening.ListDescriptors.CurrentSelectedDescriptorIdx = 0;
foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable)
{
cPlate NewPlate = new cPlate(CurrentPlate.GetName() + " Merged", MergedScreening);
// check if the plate exist already
MergedScreening.AddPlate(NewPlate);
foreach (cDRC_Region CurrentRegion in CurrentPlate.ListDRCRegions)
{
cListSignature LDesc = new cListSignature();
Idesc = 0;
int IDESCBase = 0;
for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
{
if (!cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive()) continue;
cDRC CurrentDRC = CurrentRegion.GetDRC(cGlobalInfo.CurrentScreening.ListDescriptors[IDESCBase++]);
cSignature Desc_EC50 = new cSignature(CurrentDRC.EC50, ListDescType[Idesc++], cGlobalInfo.CurrentScreening);
LDesc.Add(Desc_EC50);
cSignature Desc_Top = new cSignature(CurrentDRC.Top, ListDescType[Idesc++], cGlobalInfo.CurrentScreening);
LDesc.Add(Desc_Top);
cSignature Desc_Bottom = new cSignature(CurrentDRC.Bottom, ListDescType[Idesc++], cGlobalInfo.CurrentScreening);
LDesc.Add(Desc_Bottom);
cSignature Desc_Slope = new cSignature(CurrentDRC.Slope, ListDescType[Idesc++], cGlobalInfo.CurrentScreening);
LDesc.Add(Desc_Slope);
}
cWell NewWell = new cWell(LDesc, CurrentRegion.PosXMin + 1, CurrentRegion.PosYMin + 1, MergedScreening, NewPlate);
NewWell.ListProperties.UpdateValueByName("Compound Name", "DRC [" + CurrentRegion.PosXMin + ":" + CurrentRegion.PosYMin + "]");
NewPlate.AddWell(NewWell);
}
}
// PanelList[0].CurrentScreening.ListPlatesActive.Clear();
// PanelList[0].CurrentScreening.GlobalInfo.WindowHCSAnalyzer.RefreshInfoScreeningRichBox();
MergedScreening.ListPlatesActive = new cListPlates();
for (int i = 0; i < MergedScreening.ListPlatesAvailable.Count; i++)
{
MergedScreening.ListPlatesActive.Add(MergedScreening.ListPlatesAvailable[i]);
// MergedScreening.GlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Add(PanelList[0].CurrentScreening.ListPlatesActive[i].Name);
}
//PanelList[0].CurrentScreening.CurrentDisplayPlateIdx = 0;
//PanelList[0].CurrentScreening.GlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.SelectedIndex = 0;
//PanelList[0].CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(PanelList[0].CurrentScreening.ListDescriptors.CurrentSelectedDescriptor, false);
cGlobalInfo.CurrentScreening.ListDescriptors = MergedScreening.ListDescriptors;
cGlobalInfo.CurrentScreening.ListPlatesAvailable = MergedScreening.ListPlatesAvailable;
cGlobalInfo.CurrentScreening.ListPlatesActive = MergedScreening.ListPlatesActive;
cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate();
for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++)
cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax();
cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true);
}
//private void displayDRCToolStripMenuItem1_Click(object sender, EventArgs e)
//{
// if (cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListDRCRegions == null) return;
// int h = 0;
// FormToDisplayDRC WindowforDRCsDisplay = new FormToDisplayDRC();
// foreach (cDRC_Region TmpRegion in cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListDRCRegions)
// {
// int cpt = 0;
// List<cDRC> ListDRC = new List<cDRC>();
// for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
// {
// if (cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive())
// {
// cDRC CurrentDRC = new cDRC(TmpRegion, cGlobalInfo.CurrentScreening.ListDescriptors[i]);
// ListDRC.Add(CurrentDRC);
// cpt++;
// }
// }
// cDRCDisplay DRCDisplay = new cDRCDisplay(ListDRC, GlobalInfo);
// if (DRCDisplay.CurrentChart.Series.Count == 0) continue;
// DRCDisplay.CurrentChart.Location = new Point((DRCDisplay.CurrentChart.Width + 50) * 0, (DRCDisplay.CurrentChart.Height + 10 + DRCDisplay.CurrentRichTextBox.Height) * h++);
// DRCDisplay.CurrentRichTextBox.Location = new Point(DRCDisplay.CurrentChart.Location.X, DRCDisplay.CurrentChart.Location.Y + DRCDisplay.CurrentChart.Height + 5);
// WindowforDRCsDisplay.LChart.Add(DRCDisplay.CurrentChart);
// WindowforDRCsDisplay.LRichTextBox.Add(DRCDisplay.CurrentRichTextBox);
// }
// WindowforDRCsDisplay.panelForDRC.Controls.AddRange(WindowforDRCsDisplay.LChart.ToArray());
// WindowforDRCsDisplay.panelForDRC.Controls.AddRange(WindowforDRCsDisplay.LRichTextBox.ToArray());
// WindowforDRCsDisplay.Show();
//}
//private void displayRespondingDRCToolStripMenuItem1_Click(object sender, EventArgs e)
//{
// if (cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListDRCRegions == null) return;
// FormForDRCSelection WindowSelectionDRC = new FormForDRCSelection();
// if (WindowSelectionDRC.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
// if (WindowSelectionDRC.checkBoxMOAClassification.Checked == false)
// {
// int h = 0;
// FormToDisplayDRC WindowforDRCsDisplay = new FormToDisplayDRC();
// foreach (cDRC_Region TmpRegion in cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListDRCRegions)
// {
// int cpt = 0;
// List<cDRC> ListDRC = new List<cDRC>();
// for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
// {
// if (cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive())
// {
// cDRC CurrentDRC = new cDRC(TmpRegion, cGlobalInfo.CurrentScreening.ListDescriptors[i]);
// if (CurrentDRC.IsResponding(WindowSelectionDRC) == 1)
// {
// ListDRC.Add(CurrentDRC);
// cpt++;
// }
// }
// }
// cDRCDisplay DRCDisplay = new cDRCDisplay(ListDRC, GlobalInfo);
// if (DRCDisplay.CurrentChart.Series.Count == 0) continue;
// DRCDisplay.CurrentChart.Location = new Point((DRCDisplay.CurrentChart.Width + 50) * 0, (DRCDisplay.CurrentChart.Height + 10 + DRCDisplay.CurrentRichTextBox.Height) * h++);
// DRCDisplay.CurrentRichTextBox.Location = new Point(DRCDisplay.CurrentChart.Location.X, DRCDisplay.CurrentChart.Location.Y + DRCDisplay.CurrentChart.Height + 5);
// WindowforDRCsDisplay.LChart.Add(DRCDisplay.CurrentChart);
// WindowforDRCsDisplay.LRichTextBox.Add(DRCDisplay.CurrentRichTextBox);
// }
// WindowforDRCsDisplay.panelForDRC.Controls.AddRange(WindowforDRCsDisplay.LChart.ToArray());
// WindowforDRCsDisplay.panelForDRC.Controls.AddRange(WindowforDRCsDisplay.LRichTextBox.ToArray());
// WindowforDRCsDisplay.Show();
// return;
// }
// System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, the current screening will be entirely updated ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
// if (ResWin == System.Windows.Forms.DialogResult.No) return;
// foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
// {
// foreach (cDRC_Region TmpRegion in CurrentPlate.ListDRCRegions)
// {
// //int cpt = 0;
// //List<cDRC> ListDRC = new List<cDRC>();
// //for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++)
// //{
// // if (CompleteScreening.ListDescriptors[i].IsActive())
// // {
// // cDRC CurrentDRC = new cDRC(TmpRegion, CompleteScreening.ListDescriptors[i]);
// // if (CurrentDRC.IsResponding(WindowSelectionDRC))
// // {
// // ListDRC.Add(CurrentDRC);
// // cpt++;
// // }
// // }
// //}
// List<int> ResDescActive = TmpRegion.GetListRespondingDescritpors(CurrentScreening, WindowSelectionDRC);
// for (int j = 0; j < TmpRegion.NumReplicate; j++)
// for (int i = 0; i < TmpRegion.NumConcentrations; i++)
// {
// cWell CurrentWell = TmpRegion.GetListWells()[j][i];
// if (CurrentWell == null) continue;
// for (int IdxDesc = 0; IdxDesc < ResDescActive.Count; IdxDesc++)
// {
// if (ResDescActive[IdxDesc] == -1) continue;
// //CurrentWell.ListDescriptors[IdxDesc].HistoValues = new double[1];
// CurrentWell.ListSignatures[IdxDesc].SetHistoValues((double)ResDescActive[IdxDesc]);
// if ((i == 0) && (j == 0))
// CurrentWell.SetClass(0);
// else
// CurrentWell.SetAsNoneSelected();
// //[0] = ResDescActive[IdxDesc];
// CurrentWell.ListSignatures[IdxDesc].UpDateDescriptorStatistics();
// }
// }
// }
// CurrentPlate.UpDataMinMax();
// }
//}
#endregion
#region Distributions
private void distributionsModeToolStripMenuItem_Click(object sender, EventArgs e)
{
GlobalInfo.SwitchDistributionMode();
}
private void displayReferenceToolStripMenuItem_Click(object sender, EventArgs e)
{
if (cGlobalInfo.CurrentScreening.Reference == null)
{
MessageBox.Show("No reference curve generated. Switch to Distribution mode.\n", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
FormForDisplay TMPWin = new FormForDisplay();
cExtendedList ListValues = cGlobalInfo.CurrentScreening.Reference.GetValues(cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx);
ListValues.Name = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
cPanelHisto PanelHisto = new cPanelHisto(ListValues, eGraphType.HISTOGRAM, eOrientation.HORIZONTAL);
// cDisplayHisto CpdToDisplayHisto = new cDisplayHisto();
TMPWin.Controls.Add(PanelHisto.WindowForPanelHisto.panelForGraphContainer);
//TMPWin.panel.Controls.Add(CpdToDisplayHisto);
TMPWin.ShowDialog();
// cWindowToDisplayHisto NewWindow = new cWindowToDisplayHisto(CompleteScreening,CompleteScreening.Reference.GetValues(CompleteScreening.ListDescriptors.CurrentSelectedDescriptor));
// NewWindow.Show();
// NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
// cWindowToDisplayScatter NewWindow = new cWindowToDisplayScatter();
// NewWindow.chartForSimpleForm.Controls.Add(CompleteScreening.Reference.GetChart(CompleteScreening.ListDescriptors.CurrentSelectedDescriptor));
// NewWindow.Show();
//cDisplayGraph DispGraph = new cDisplayGraph(CompleteScreening.Reference[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].ToArray(),
// CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " - Reference distribution.");
}
#endregion
}
}