void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "TraceStates")
            {
                switch (Model.TraceStates)
                {
                case TraceStates.Running:
                    Running.Begin(cTraceState, true);
                    Starting.Stop(cTraceState);
                    Stopping.Stop(cTraceState);

                    break;

                case TraceStates.Starting:
                    Starting.Begin(cTraceState, true);
                    Stopping.Stop(cTraceState);
                    Running.Stop(cTraceState);

                    break;

                case TraceStates.Stopping:
                    Stopping.Begin(cTraceState, true);
                    Running.Stop(cTraceState);
                    Starting.Stop(cTraceState);
                    break;

                case TraceStates.Stopped:
                default:
                    Starting.Stop(cTraceState);
                    Stopping.Stop(cTraceState);
                    Running.Stop(cTraceState);
                    break;
                }
            }
        }
示例#2
0
        private void RunningControl_Click(object sender, RoutedEventArgs e)
        {
            if (Arthur.App.Current.Option.RemainingMinutes <= 0)
            {
                MessageBox.Show("软件已经过期,无法操作!");
                return;
            }

            var btn = (ProcButton)sender;

            if (btn.Name == "start")
            {
                if (TimerExec.IsRunning)
                {
                    Current.App.ErrorMsg = "系统已经在运行,请勿重复启动!";
                    return;
                }

                if (Current.App.RunStatus == RunStatus.异常)
                {
                    Current.App.ErrorMsg = "请先复位!";
                    return;
                }

                var result = Running.Start();
                if (result.IsSucceed)
                {
                    Logging.AddEvent("点击【启动】", Arthur.App.Model.EventType.信息);
                }
                else
                {
                    Running.ShowErrorMsg(result.Msg);
                }
            }
            else if (btn.Name == "stop")
            {
                if (!TimerExec.IsRunning)
                {
                    Current.App.ErrorMsg = "系统没有在运行,操作无效!";
                    return;
                }

                var result = Running.Stop();
                if (result.IsSucceed)
                {
                    Logging.AddEvent("点击【停止】", Arthur.App.Model.EventType.信息);
                }
                else
                {
                    Running.ShowErrorMsg(result.Msg);
                }
            }
            else if (btn.Name == "reset")
            {
                if (Current.App.RunStatus == RunStatus.运行)
                {
                    Current.App.ErrorMsg = "系统正在运行,复位无效,请停止运行后再执行复位操作!";
                    return;
                }

                var result = Running.Reset();
                if (result.IsSucceed)
                {
                    Logging.AddEvent("点击【复位】", Arthur.App.Model.EventType.信息);
                }
                else
                {
                    Running.ShowErrorMsg(result.Msg);
                }
            }
        }