Simply3DScan
SimpleScanMainForm.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq;
3 using System.Threading;
4 using System.Windows.Forms;
6 using Configuration;
7 using SharedObjects;
8 using Syncfusion.Windows.Forms;
9 using Syncfusion.Windows.Forms.Gauge;
10 using Syncfusion.Windows.Forms.Tools;
11 using Translator;
12 
13 namespace Simple3DScan.UI
14 {
18  public sealed partial class SimpleScanMainForm : Office2007Form
19  {
20  private readonly Information configuration = Singleton<Config>.Instance.Information;
21 
26  [Log]
27  [LogException]
28  public SimpleScanMainForm(ArduinoCommands arduinoCommands)
29  {
30  if (this.DesignMode)
31  return;
32 
33  this.InitializeComponent();
34  this.scanControlMain.Init(arduinoCommands);
35  this.manualControl.Init(arduinoCommands);
36  this.Text = $"SimpleScan3D {Program.Version}";
37  this.scanControlMain.StartScanning += this.ScanControlMainOnStartScanning;
38  this.scanControlMain.StopScanning += this.ScanControlMainOnStopScanning;
39 
40  this.TranslateTexts();
41 
42  //SkinManager.SetVisualStyle(this, VisualTheme.Office2007Black);
43  }
44 
45  [LogException]
46  private void TranslateTexts()
47  {
48  this.Translate<Label>();
50  this.Translate<ButtonAdv>();
52  this.Translate<Button>();
53  this.Translate<TabPageAdv>();
54  this.Translate<CheckBox>();
55 
56  foreach (RadialGauge childControl in this.Descendants<RadialGauge>())
57  childControl.GaugeLabel = Singleton<Translate>.Instance.GetString(childControl.GaugeLabel, this.configuration.Language);
58  }
59 
60  [LogException]
61  private void Translate<T>() where T : Control
62  {
63  foreach (T childControl in this.Descendants<T>().Where(childControl => !String.IsNullOrEmpty(childControl.Text)))
64  childControl.Text = Singleton<Translate>.Instance.GetString(childControl.Text, this.configuration.Language);
65  }
66 
67  [LogException]
68  private void ScanControlMainOnStartScanning()
69  {
70  for (int i = 0; i < this.tabControlMain.TabPages.Count; i++)
71  {
72  if (this.tabControlMain.TabPages[i] != this.tabPageScan)
73  this.tabControlMain.TabPages[i].TabVisible = false;
74  }
75  }
76 
77  [LogException]
78  private void ScanControlMainOnStopScanning()
79  {
80  for (int i = 0; i < this.tabControlMain.TabPages.Count; i++)
81  {
82  if (this.tabControlMain.TabPages[i] != this.tabPageScan)
83  this.tabControlMain.TabPages[i].TabVisible = true;
84  }
85  }
86 
92  private void tabControlMain_SelectedIndexChanged(object sender, EventArgs e)
93  {
94  switch (this.tabControlMain.SelectedTab.Name)
95  {
96  case "tabPageScan":
97  this.manualControl.Stop();
98  this.configurationControl1.Stop();
99  Thread.Sleep(400);
100  this.scanControlMain.Start();
101  break;
102  case "tabPageControl":
103  this.scanControlMain.Stop();
104  this.configurationControl1.Stop();
105  Thread.Sleep(400);
106  this.manualControl.Start();
107  break;
108  case "tabPageConfiguration":
109  this.scanControlMain.Stop();
110  this.manualControl.Stop();
111  Thread.Sleep(400);
112  this.configurationControl1.Start();
113  break;
114  }
115  }
116  }
117 }
Class for detecting an arduino and sending commands to it
Class holding the configuration information
Definition: Information.cs:8
SimpleScanMainForm(ArduinoCommands arduinoCommands)
Initializes a new instance of the SimpleScanMainForm class.
Class for creating a singleton for a generic class
Definition: Singleton.cs:9
static T Instance
Gets the instance.
Definition: Singleton.cs:27