/// <summary> /// Handle the case when form is being shown, either reopened or newly opened. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Shown(object sender, EventArgs e) { if (ZAMsettings.Settings.AutoStart) { m_zpMonitorService.StartMonitor(); } else { // Bring up the options dialog tsmiOptions.PerformClick(); } // Set control statuses OnCollectionStatusChanged(); m_logger.LogInformation("MainForm Shown"); }
private void btnStart_Click(object sender, EventArgs e) { int targetHr = 0; int targetPower = 0; bool debugMode = cbMonitorOthers.Checked; if (rbFindByMetrics.Checked) { if (!Int32.TryParse(tbTargetHeartrate.Text, out targetHr) || targetHr == 0) { tbTargetHeartrate.Text = "0"; targetHr = 0; } if (!Int32.TryParse(tbTargetPower.Text, out targetPower) || targetPower == 0) { tbTargetPower.Text = "0"; targetPower = 0; } } try { m_zpMonitorService.StartMonitor(debugMode, targetHr, targetPower); OnMonitorStatusChanged(); } catch (ArgumentException ex) { MessageBox.Show($"{ex.Message}.\r\r1) Run command IpConfig /all at a windows CMD prompt to find your network.\r2) Update the ZwiftPacketMonitor:Network key in appsettings.json", "ZwiftPacketMonitor Not Started", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show("Exception occurred: " + ex.ToString(), "ZwiftPacketMonitor Not Started", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }