Beispiel #1
0
        void viewSpecificTimerScene_Click(object sender, EventArgs e)
        {
            // Date time variable
            DateTime dateTime = DateTime.Now;

            // Get the current scene pipe info
            PipeInfo currentPipeInfo = IApp.theApp.DataDriven.CurrentData;
            if (currentPipeInfo != null)
            {
                dateTime = currentPipeInfo.Time;
            }

            // Pop up the Specify timer dialog
            using (SpecifyTime form = new SpecifyTime())
            {
                form.InitialDateTime = dateTime;
                if (DialogResult.OK == form.ShowDialog())
                {
                    dateTime = form.SelectedDateTime;

                    // Update the scene
                    IHistoryDataQuery dataQuery = IApp.theApp.HistoryTimeDataQuery;

                    if (dataQuery != null && dataQuery.IsConnected)
                    {
                        try
                        {
                            PipeInfo pipeInfo = IApp.theApp.HistoryTimeDataQuery.GetPipeRecord(dateTime, true);
                            if (pipeInfo == null)
                            {
                                MessageBox.Show(Resources.IDS_NODATA_TO_TIME, this.Text);
                                return;
                            }

                            // Use the latest time
                            dateTime = pipeInfo.Time;

                            // Drive Pipe Index
                            if (pipeInfo.PipeId < toolStripComboBoxPipes.Items.Count)
                            {
                                toolStripComboBoxPipes.SelectedIndex = pipeInfo.PipeId;
                            }

                            // Update the track bar value
                            try
                            {
                                // How to get a track bar value by the date time
                                IProgress2DateTimeMapper dateTimeMapper = m_pipeProgressController.GetMapper(pipeInfo.PipeId);
                                if (dateTimeMapper != null)
                                {
                                    int iTrackBarValue = (int)dateTimeMapper.GetPosition(dateTime);
                                    trackBarAnimation.Value = iTrackBarValue;

                                    CReplayMode replayMode = IApp.theApp.ObserverModeManager.ActiveModeInstance as CReplayMode;
                                    replayMode.ReplayAnimationEngine.AnimationProgress = iTrackBarValue;
                                }
                            }
                            catch(Exception ex)
                            {
                                string errMsg = ex.Message + "\n" + ex.StackTrace;
                                vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg);
                            }

                            // Drive Model
                            DriveModel(pipeInfo);

                            // Update Animation Text
                            UpdateAnimationLabelTextByPipeInfo(pipeInfo);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(Resources.IDS_NODATA_TO_TIME, this.Text);
                            string errMsg = ex.Message + "\n" + ex.StackTrace;
                            vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg);
                            return;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void setFirstPipeGPSSwitchTime_Click(object sender, EventArgs e)
        {
            DriveModelOptions option = ApplicationOptions.Instance().DriveModelOptions;

            // Get the last switch if it set before
            DateTime t = DateTime.Now;
            if (option.IsFirstPipeGPSSwitcheTimeSet())
            {
                t = option.FirstPipeGPSSwitchTime;
            }

            // Pop up the Specify timer dialog
            using (SpecifyTime form = new SpecifyTime())
            {
                form.InitialDateTime = t;
                if (DialogResult.OK == form.ShowDialog())
                {
                    option.FirstPipeGPSSwitchTime = form.SelectedDateTime;
                    IApp.theApp.RenderScene();
                }
            }
        }