示例#1
0
        private void HandleProtocolStatusChanged(object sender, ProtocolStatusChangeEventArgs e)
        {
            string Titel ;
            string Sendor  = UserControlProtocolParameters.Name;
            string Message = e.NewStatus + ">" + e.Message;

            //((MainForm)this.ParentForm).Notify(new Logging.LoggingEntery(this

            bool buttonStopEnabled ;
            bool buttonStartEnabled ;
            bool buttonPauseEnabled ;
            System.Drawing.Color ProtocolBackColor;

            switch (e.NewStatus)
            {
                case (Protocol.Statuses.Stoping):
                    buttonStopEnabled  = false;
                    buttonStartEnabled =false;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.White;
                    break;
                case (Protocol.Statuses.Pausing):
                    buttonStopEnabled  = true;
                    buttonStartEnabled =false;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.White;
                    break;
                case (Protocol.Statuses.Starting):
                    buttonStopEnabled  = true;
                    buttonStartEnabled =false;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.White;
                    break;
                case (Protocol.Statuses.Stopped):
                    buttonStopEnabled  = false;
                    buttonStartEnabled =true;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.Red;
                    break;
                case (Protocol.Statuses.Started):
                    buttonStopEnabled  = true;
                    buttonStartEnabled =false;
                    buttonPauseEnabled=true ;
                    ProtocolBackColor = System.Drawing.Color.LightGreen;
                    break;
                case (Protocol.Statuses.Paused):
                    buttonStopEnabled  = true;
                    buttonStartEnabled =true;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.Yellow;
                    break;
                case (Protocol.Statuses.Error):
                    buttonStopEnabled  = false;
                    buttonStartEnabled =true;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.DarkRed;
                    // notify
                    Titel = string.Format("Error in {0} ({1})",this.labelProtocolType.Text,this.labelProtocolName.Text);
                    Message = string.Format("Error in {0} ({1}\n {2})",this.labelProtocolType.Text,this.labelProtocolName.Text,e.Message);
                    Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","ProtocolUserControl",Titel,Message,LoggingEntery.EnteryTypes.Error));
                    break;
                case (Protocol.Statuses.FatalError):
                    buttonStopEnabled  = false;
                    buttonStartEnabled =true;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.Black;
                    // notify
                    Titel = string.Format("Error in {0} ({1})",this.labelProtocolType.Text,this.labelProtocolName.Text);
                    Message = string.Format("Error in {0} ({1}\n {2})",this.labelProtocolType.Text,this.labelProtocolName.Text,e.Message);
                    Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","ProtocolUserControl",Titel,Message,LoggingEntery.EnteryTypes.Critical));
                    break;
                case (Protocol.Statuses.RuntimeError):
                    buttonStopEnabled  = true;
                    buttonStartEnabled =false;
                    buttonPauseEnabled=false ;
                    ProtocolBackColor = System.Drawing.Color.Yellow;
                    Titel = string.Format("Run time error {0} ({1})",this.labelProtocolType.Text,this.labelProtocolName.Text);
                    Message = string.Format("Run time error in {0} ({1}\n {2})",this.labelProtocolType.Text,this.labelProtocolName.Text,e.Message);
                    Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","ProtocolUserControl",Titel,Message,LoggingEntery.EnteryTypes.Critical));

                    break;
                default:
                    buttonStopEnabled  = true;
                    buttonStartEnabled =true;
                    buttonPauseEnabled=true ;
                    ProtocolBackColor = System.Drawing.Color.White;
                    break;
            }

            string Title	= string.Format("{0}:{1}>{2}",this.Name, e.NewStatus ,e.Message);
            Log.LogEntery(new LoggingEntery("OctoTipPlus Appilcation","ProtocolUserControl",Title,LoggingEntery.EnteryTypes.Debug));

            if			(this.ParentForm !=null)
            {
                MethodInvoker buttonStopaction = delegate
                {
                    buttonStop.Enabled=buttonStopEnabled;
                };
                buttonStop.BeginInvoke(buttonStopaction);

                MethodInvoker buttonStartaction = delegate
                {
                    buttonStart.Enabled=buttonStartEnabled;
                };
                buttonStart.BeginInvoke(buttonStartaction);

                MethodInvoker buttonPauseaction = delegate
                {
                    buttonPause.Enabled=buttonPauseEnabled;
                };
                buttonPause.BeginInvoke(buttonPauseaction);

                MethodInvoker UserControlaction = delegate
                {
                    this.BackColor=ProtocolBackColor;
                };
                this.BeginInvoke(UserControlaction);
            }

            ((MainForm)this.ParentForm).RefreshProtocolUserControls();
        }
示例#2
0
 private void OnStatusChanged(ProtocolStatusChangeEventArgs e)
 {
     EventHandler<ProtocolStatusChangeEventArgs> handler = StatusChanged;
     if (handler != null)
     {
         handler(this, e);
     }
 }