예제 #1
0
        /// <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();
            SplitsView.Dock = DockStyle.Fill;
            MainView.BringToFront();
            MainView.Dock = DockStyle.Fill;

            SplitsView.SplitGoalCompletedEvent += SplitCompletedEventHandler;
            SplitsView.SplitCompletedEvent     += SplitCompletedEventHandler;

            var          form   = new SplashScreen();
            DialogResult result = form.ShowDialog(this);

            Logger.LogInformation("MainForm_Load");
        }
예제 #2
0
 private void tsbSplits_Click(object sender, EventArgs e)
 {
     MainView.SendToBack();
     //MainView.Dock = DockStyle.None;
     SplitsView.BringToFront();
     SplitsView.Dock = DockStyle.Fill;
 }
예제 #3
0
        /// <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();

                    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");
        }
예제 #4
0
 private void tsbAnalysis_Click(object sender, EventArgs e)
 {
     SplitsView.SendToBack();
     LapView.SendToBack();
     MainView.BringToFront();
     MainView.Dock = DockStyle.Fill;
 }
예제 #5
0
        /// <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;
                    }
                }
            }
        }
예제 #6
0
        /// <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");
            }
        }
예제 #7
0
        private void OnCollectionStatusChanged()
        {
            if (m_isStarted)
            {
                // Clear any values on the screen
                MainView.RefreshListViews(true);
                SplitsView.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;

                // set Timer menu sub-items
                if (countdownTimer.Enabled)
                {
                    // Clear any values on the screen
                    MainView.RefreshListViews(true);
                    SplitsView.ClearListView();

                    tsmiSetupTimer.Enabled = false;
                    tsmiStopTimer.Enabled  = true;
                }
                else
                {
                    tsmiSetupTimer.Enabled = true;
                    tsmiStopTimer.Enabled  = false;
                }

                if (ZAMsettings.ZPMonitorService.IsStarted)
                {
                    tsslStatus.Text = "Select Analyze->Start to begin";
                }
                else
                {
                    tsslStatus.Text = "ZPM Service Not Running";
                }
            }
        }