Exemplo n.º 1
0
 public void Fire(ODEventArgs e)
 {
     if (e.Tag is ProgressBarHelper)
     {
         ProgressBarHelper progBarHelper = (ProgressBarHelper)e.Tag;
         if (progBarHelper.ProgressStyle == ProgBarStyle.NoneSpecified)
         {
             progBarHelper.ProgressStyle = _progBarStyle;
         }
     }
     _event.FireEvent(e);
 }
Exemplo n.º 2
0
 public void ODEvent_Fired(ODEventArgs e)
 {
     try {
         //We don't know what thread will cause a progress status change, so invoke this method as a delegate if necessary.
         if (this.InvokeRequired)
         {
             this.Invoke((Action) delegate() { ODEvent_Fired(e); });
             return;
         }
         //If Tag on the ODEvent is null then there is nothing to for this event handler to do.
         if (e.Tag == null)
         {
             return;
         }
         //Check to see if an ODEventType was set otherwise check the ODEventName to make sure this is an event that this instance cares to process.
         if (_odEventType != ODEventType.Undefined)
         {
             //Always use ODEventType if one was explicitly set regardless of what _odEventName is set to.
             if (_odEventType != e.EventType)
             {
                 return;
             }
         }
         ProgressBarHelper progHelper = new ProgressBarHelper("");
         bool   hasProgHelper         = false;
         string status = "";
         if (e.Tag.GetType() == typeof(string))
         {
             status = ((string)e.Tag);
         }
         else if (e.Tag.GetType() == typeof(ProgressBarHelper))
         {
             progHelper    = (ProgressBarHelper)e.Tag;
             status        = progHelper.LabelValue;
             hasProgHelper = true;
         }
         else                  //Unsupported type passed in.
         {
             return;
         }
         UpdateProgress(status, progHelper, hasProgHelper);
     }
     catch (Exception ex) {
         ex.DoNothing();                //It's just progress...
     }
 }
Exemplo n.º 3
0
 public sealed override void UpdateProgress(string status, ProgressBarHelper progHelper, bool hasProgHelper)
 {
     if (Visible && _hasHistory && !progressBar.Visible)
     {
         //Once the progress bar is hidden when history is showing, we never want to process another event.
         return;
     }
     labelMsg.Text = status;
     if (hasProgHelper)
     {
         if (progHelper.BlockMax != 0)
         {
             progressBar.Maximum = progHelper.BlockMax;
         }
         if (progHelper.BlockValue != 0)
         {
             progressBar.Value = progHelper.BlockValue;
         }
         if (progHelper.ProgressStyle == ProgBarStyle.Marquee)
         {
             progressBar.Style = ProgressBarStyle.Marquee;
         }
         else if (progHelper.ProgressStyle == ProgBarStyle.Blocks)
         {
             progressBar.Style = ProgressBarStyle.Blocks;
         }
         else if (progHelper.ProgressStyle == ProgBarStyle.Continuous)
         {
             progressBar.Style = ProgressBarStyle.Continuous;
         }
     }
     if (_hasHistory)
     {
         if (_dateTimeLastEvent == DateTime.MinValue)
         {
             textHistoryMsg.AppendText(status.PadRight(60));
             _dateTimeLastEvent = DateTime.Now;
         }
         else
         {
             textHistoryMsg.AppendText(GetElapsedTime(_dateTimeLastEvent, DateTime.Now) + "\r\n" + status.PadRight(60));
             _dateTimeLastEvent = DateTime.Now;
         }
     }
 }
        public sealed override void UpdateProgress(string status, ProgressBarHelper progHelper, bool hasProgHelper)
        {
            if (hasProgHelper)
            {
                switch (progHelper.ProgressBarEventType)
                {
                case ProgBarEventType.BringToFront:
                    this.TopMost = true;
                    this.TopMost = false;
                    break;

                case ProgBarEventType.Header:
                    this.Text = status;
                    break;

                case ProgBarEventType.ProgressLog:
                    label4.Text = status;
                    break;

                case ProgBarEventType.TextMsg:
                    status = status.Trim();                          //Get rid of leading and trailing new lines.
                    textMsg.AppendText((string.IsNullOrWhiteSpace(textMsg.Text) ? "" : "\r\n") + status.PadRight(60));
                    break;

                case ProgBarEventType.WarningOff:
                case ProgBarEventType.AllowResume:
                    labelWarning.Visible = false;
                    butPause.Enabled     = true;
                    if (_isPaused)
                    {
                        butPause.Text = "Resume";
                    }
                    else
                    {
                        butPause.Text = "Pause";                              //setting down below wasn't always working when this event type was passed in.
                    }
                    break;

                case ProgBarEventType.Done:
                    butCancel.Visible = true;                           //can sometimes be set to invisible with HideButtons. Show if previously invisible.
                    butCancel.Text    = "Close";
                    butPause.Enabled  = false;
                    _isDone           = true;
                    break;

                case ProgBarEventType.HideButtons:                        //hide pause and cancel. Call Done when "close button" should appear.
                    butPause.Visible  = false;
                    butCancel.Visible = false;
                    break;

                case ProgBarEventType.ProgressBar:
                default:
                    if (!_listProgressBars.Exists(x => x.TagString.ToLower() == progHelper.TagString.ToLower()))                           //if not already added
                    {
                        ODProgressBar progBar = AddNewProgressBar(progHelper.LabelValue, progHelper.LabelTop, progHelper.PercentValue, progHelper.BlockValue,
                                                                  progHelper.BlockMax, progHelper.TagString, progHelper.ProgressStyle, progHelper.MarqueeSpeed, progHelper.IsValHidden, progHelper.IsTopHidden,
                                                                  progHelper.IsPercentHidden);
                        if (progBar == null)
                        {
                            break;
                        }
                        _listProgressBars.Add(progBar);
                    }
                    else
                    {
                        ODProgressBar odBar = _listProgressBars.Find(x => x.TagString.ToLower() == progHelper.TagString.ToLower());
                        UpdateProgressBar(odBar, progHelper);
                    }
                    break;
                }
            }
        }
 private void UpdateProgressBar(ODProgressBar progBar, ProgressBarHelper progHelper)
 {
     progBar.ODProgUpdate(progHelper.LabelValue, progHelper.LabelTop, progHelper.PercentValue, progHelper.BlockValue, progHelper.BlockMax,
                          progHelper.TagString, progHelper.ProgressStyle, progHelper.MarqueeSpeed, progHelper.IsValHidden, progHelper.IsTopHidden, progHelper.IsPercentHidden);
 }
Exemplo n.º 6
0
 ///<summary>Extending classes are required to implement this method.
 ///This class was originally an abstract class which made this fact apparent but Visual Studio's designer doesn't play nicely.</summary>
 public virtual void UpdateProgress(string status, ProgressBarHelper progHelper, bool hasProgHelper)
 {
     throw new NotImplementedException();            //STOP!  It is up to extending methods to implement this.  Go away.
 }