private void FormProximityOD_Load(object sender, EventArgs e) { ODException.SwallowAnyException(() => { GetSettings(); }); #region Check ProximityOD Process Process[] processes = Process.GetProcessesByName("ProximityOD"); for (int p = 0; p < processes.Length; p++) { if (Process.GetCurrentProcess().Id == processes[p].Id) { continue; } //another process was found MessageBox.Show(this, "ProximityOD is already running.", "ProximityOD"); Application.Exit(); return; } #endregion #region Database Connection try { #if DEBUG new DataConnection().SetDb("localhost", "customers", "root", "", "", "", DatabaseType.MySql); #else new DataConnection().SetDb("10.10.1.200", "customers", "root", "", "", "", DatabaseType.MySql); #endif } catch (Exception ex) { MessageBox.Show("This tool is not designed for general use.\r\n\r\n" + ex.Message); return; } #endregion _sensor = new ODSonicSensor(); _sensor.ProximityChanged += Sensor_ProximityChanged; _sensor.RangeChanged += Sensor_RangeChanged; _timerStopWebCamSnapshotPref = new Timer() { Interval = 60000 }; _timerStopWebCamSnapshotPref.Tick += TimerStopWebCamSnapshotPref_Tick; _timerStopWebCamSnapshotPref.Start(); _timerDatabase = new Timer() { Interval = 1600 }; _timerDatabase.Tick += TimerDatabase_Tick; _timerDatabase.Start(); _acquisitionTimer = new Timer() { Interval = 2500 }; _acquisitionTimer.Tick += acquisitionTimer_Tick; _releaseTimer = new Timer() { Interval = 1500 }; _releaseTimer.Tick += releaseTimer_Tick; textProximityDev.Text = "Away"; notifyIcon.Visible = false; textProximityDev.BackColor = Color.FromArgb(255, 200, 200); //light red textProximitySoft.Text = "Away"; textProximitySoft.BackColor = Color.FromArgb(255, 200, 200); //light red textTriggerSoft.Text = _rangeOverride.ToString() + "\""; checkSetup_CheckedChanged(this, new EventArgs()); //resizes form. this.WindowState = FormWindowState.Normal; }
private void FormProximityOD_Load(object sender, EventArgs e) { #region Check ProximityOD Process if (!ODBuild.IsDebug()) { Process[] processes = Process.GetProcessesByName("ProximityOD"); for (int p = 0; p < processes.Length; p++) { if (Process.GetCurrentProcess().Id == processes[p].Id) { continue; } //another process was found MessageBox.Show(this, "ProximityOD is already running.", "ProximityOD"); Application.Exit(); return; } } #endregion ODException.SwallowAnyException(() => { GetSettings(); }); #region Database Connection //Preserve old behavior by first connecting to customers database (hard coded). //This will be overridden by site specific connection settings later (see TryDatabaseConnectionSettings() and DataAction.RunCustomers()). try { if (ODBuild.IsDebug()) { new DataConnection().SetDb("localhost", "customers_192", "root", "", "", "", DatabaseType.MySql); } else { new DataConnection().SetDb("10.10.1.200", "customers", "root", "", "", "", DatabaseType.MySql); } } catch (Exception ex) { labelError.Visible = true; MessageBox.Show("This tool is not designed for general use.\r\n\r\n" + ex.Message); return; } #endregion _sensor = new ODSonicSensor(); _sensor.ProximityChanged += Sensor_ProximityChanged; _sensor.RangeChanged += Sensor_RangeChanged; _timerStopWebCamSnapshotPref = new Timer() { Interval = 60000 }; _timerStopWebCamSnapshotPref.Tick += TimerStopWebCamSnapshotPref_Tick; _timerStopWebCamSnapshotPref.Start(); _timerDatabase = new Timer() { Interval = 1600 }; _timerDatabase.Tick += TimerDatabase_Tick; _timerDatabase.Start(); _acquisitionTimer = new Timer() { Interval = 2500 }; _acquisitionTimer.Tick += acquisitionTimer_Tick; _releaseTimer = new Timer() { Interval = 1500 }; _releaseTimer.Tick += releaseTimer_Tick; textProximityDev.Text = "Away"; notifyIcon.Visible = false; textProximityDev.BackColor = Color.FromArgb(255, 200, 200); //light red textProximitySoft.Text = "Away"; textProximitySoft.BackColor = Color.FromArgb(255, 200, 200); //light red textTriggerSoft.Text = _rangeOverride.ToString() + "\""; }