private void tsbLaps_Click(object sender, EventArgs e) { MainView.SendToBack(); SplitsView.SendToBack(); LapView.BringToFront(); LapView.Dock = DockStyle.Fill; }
/// <summary> /// On initial load, the desired collection durations are load from configuration. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { // for handling UI events m_dispatcher = Dispatcher.CurrentDispatcher; // Determine window position if (ZAMsettings.Settings.WindowPositionX > 0 && ZAMsettings.Settings.WindowPositionY > 0) { this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Location = new System.Drawing.Point(ZAMsettings.Settings.WindowPositionX, ZAMsettings.Settings.WindowPositionY); } // Set the environment based on the current user SetupCurrentUser(); // Make sure the analysis control is shown SplitsView.SendToBack(); LapView.SendToBack(); MainView.BringToFront(); MainView.Dock = DockStyle.Fill; SplitsView.Dock = DockStyle.Fill; LapView.Dock = DockStyle.Fill; SplitsView.SplitGoalCompletedEvent += SplitCompletedEventHandler; SplitsView.SplitCompletedEvent += SplitCompletedEventHandler; LapView.LapCompletedEvent += LapCompletedEventHandler; var form = new SplashScreen(); DialogResult result = form.ShowDialog(this); Logger.LogInformation("MainForm_Load"); }
/// <summary> /// Stops the data collectors and sets menu item enabled statuses accordingly. /// </summary> private void Collection_OnStop() { if (m_isStarted) { if (m_cancellationTokenSource == null) { MainView.StopCollection(); SplitsView.StopCollection(); LapView.StopCollection(); runTimer.Enabled = false; } else { // Cancel the waiting thread m_cancellationTokenSource.Cancel(); } m_isStarted = false; OnCollectionStatusChanged(); if (m_cancellationTokenSource == null) { var form = new RideRecap(MainView.RideRecap); form.Show(this); } } Logger.LogInformation($"Collection_OnStop"); }
/// <summary> /// Load and initialize the moving average collection wrapper collection based upon the current menu item checked settings. /// /// This is called on form load and also when menu items change. /// </summary> private void LoadMovingAverageCollection() { MainView.RefreshListViews(true); SplitsView.ClearListView(); LapView.ClearListView(); // Remove all moving average collectors and ListView items MainView.ClearViewerItems(); // Loop through the menu items within the Collect menu. // If an item is checked, we want to create a collector for it. // The collector duration is determined by a match between the menu item's tag and the DurationType Enum. // Up to 3 items can be shown. // The label on the UI gets the same text as the menu item. foreach (ToolStripItem mi in tsmiAnalyze.DropDownItems) { ToolStripMenuItem tsmi = mi as ToolStripMenuItem; if (tsmi == null) { continue; } if (tsmi.Checked) { if (MainView.CountViewerItems < 3) { DurationType result; if (Enum.TryParse <DurationType>(tsmi.Tag.ToString(), true, out result)) { MainView.AddViewerItem(result, tsmi.Text); } else { throw new ApplicationException($"Bug: The menuitem tag {tsmi.Tag} for menuitem {tsmi.Text} did not match any DurationType Enums."); } } else { tsmi.Checked = false; } } } }
/// <summary> /// Starts the data collectors and sets menu item enabled statuses accordingly. /// </summary> private async void Collection_OnStart() { if (!m_isStarted) { m_isStarted = true; // update all the menu items accordingly OnCollectionStatusChanged(); // view analysis window tsbAnalysis.PerformClick(); if (m_startWithEventTimer) { m_cancellationTokenSource = new CancellationTokenSource(); // Start a thread to wait for the PlayerState.Time to become non-zero. // This can be cancelled by selecting Stop from the menu. await WaitForRiderStartAsync(m_cancellationTokenSource.Token); bool cancelled = m_cancellationTokenSource.IsCancellationRequested; m_cancellationTokenSource = null; if (cancelled) { Logger.LogInformation($"Collection_OnStart - Cancelled"); return; } } MainView.StartCollection(); SplitsView.StartCollection(); LapView.StartCollection(); m_collectionStart = DateTime.Now; runTimer.Enabled = true; m_splitsViewDisplayTime = null; Logger.LogInformation($"Collection_OnStart"); } }
private void OnCollectionStatusChanged() { if (m_isStarted) { // Clear any values on the screen MainView.RefreshListViews(true); SplitsView.ClearListView(); LapView.ClearListView(); tsmiStop.Enabled = true; tsmiStart.Enabled = false; tsmi10min.Enabled = false; tsmi1min.Enabled = false; tsmi20min.Enabled = false; tsmi30min.Enabled = false; tsmi30sec.Enabled = false; tsmi5min.Enabled = false; tsmi5sec.Enabled = false; tsmi6min.Enabled = false; tsmi60min.Enabled = false; tsmi90min.Enabled = false; tsmiTimer.Enabled = false; tsmiOptions.Enabled = false; tsmiAdvanced.Enabled = false; } else { tsmiStop.Enabled = false; tsmiStart.Enabled = true; tsmi10min.Enabled = true; tsmi1min.Enabled = true; tsmi20min.Enabled = true; tsmi30min.Enabled = true; tsmi30sec.Enabled = true; tsmi5min.Enabled = true; tsmi5sec.Enabled = true; tsmi6min.Enabled = true; tsmi60min.Enabled = true; tsmi90min.Enabled = true; tsmiTimer.Enabled = true; tsmiOptions.Enabled = true; tsmiAdvanced.Enabled = true; tsmiSetupTimer.Enabled = true; tsmiStopTimer.Enabled = false; // set Timer menu sub-items if (countdownTimer.Enabled) { // Clear any values on the screen MainView.RefreshListViews(true); SplitsView.ClearListView(); LapView.ClearListView(); tsmiSetupTimer.Enabled = false; tsmiStopTimer.Enabled = true; tsmiStart.Enabled = false; tsmiOptions.Enabled = false; tsmiAdvanced.Enabled = false; } if (ZAMsettings.ZPMonitorService.IsStarted) { tsslStatus.Text = "Select Analyze->Start to begin"; } else { tsslStatus.Text = "ZPM Service Not Running"; } } }