Example #1
0
        /// <summary>
        /// Gets the bar for the given item.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private FloatingOperationDialogBar GetBarForItem(IOperationItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // find the bar with the given item...
            FloatingOperationDialogBar bar = null;

            foreach (FloatingOperationDialogBar scanBar in this.panelBars.Controls)
            {
                if (scanBar.Item == item)
                {
                    bar = scanBar;
                    break;
                }
            }

            // not found... create one...
            if (bar == null)
            {
                bar = this.AddBar(item);
            }

            // return...
            return(bar);
        }
Example #2
0
        /// <summary>
        /// Updates the view.
        /// </summary>
        public void RefreshView()
        {
            if (this.InvokeRequired)
            {
                RefreshViewDelegate d = new RefreshViewDelegate(this.RefreshView);
                this.Invoke(d);
                return;
            }

            // set...
            IOperationItem item = this.CurrentItem;

            if (item != null)
            {
                // get the bar to display status information in...
                FloatingOperationDialogBar bar = this.GetBarForItem(item);
                if (bar != null)
                {
                    bar.RefreshView();
                }
            }
            else
            {
                if (this.IsDefaultBarVisible)
                {
                    this.DefaultBar.Status = this.Caption;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Adds a bar to the view.
        /// </summary>
        /// <returns></returns>
        private FloatingOperationDialogBar AddBar(IOperationItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // invoke?
            if (this.InvokeRequired)
            {
                // flip...
                AddBarDelegate d = new AddBarDelegate(this.AddBar);
                return((FloatingOperationDialogBar)this.Invoke(d, new object[] { item }));
            }

            // layout...
            this.panelBars.SuspendLayout();
            try
            {
                // clear...
                if (this.IsDefaultBarVisible)
                {
                    this.panelBars.Controls.Clear();
                }

                // create...
                FloatingOperationDialogBar bar = new FloatingOperationDialogBar(item);
                bar.Dock = DockStyle.Top;
                this.panelBars.Controls.Add(bar);

                // listen...
                item.Finished += new EventHandler(item_Finished);

                // set...
                _currentItem = item;

                // return...
                return(bar);
            }
            finally
            {
                this.panelBars.ResumeLayout();
            }
        }
Example #4
0
 private void timerSample_Tick(object sender, System.EventArgs e)
 {
     try
     {
         if (this.CurrentItem != null)
         {
             FloatingOperationDialogBar bar = this.GetBarForItem(this.CurrentItem);
             if (bar != null)
             {
                 bar.RefreshView();
             }
         }
     }
     catch (Exception ex)
     {
         this.timerSample.Enabled = false;
         Alert.ShowWarning(this, "Failed to update operation bar.", ex);
     }
 }
Example #5
0
        /// <summary>
        /// Removes the bar from the view.
        /// </summary>
        /// <param name="item"></param>
        private void RemoveBar(IOperationItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // invoke...
            if (this.InvokeRequired)
            {
                // flip...
                RemoveBarDelegate d = new RemoveBarDelegate(this.RemoveBar);
                this.Invoke(d, new object[] { item });
                return;
            }

            // layout...
            this.panelBars.SuspendLayout();
            try
            {
                // fins...
                FloatingOperationDialogBar bar = this.GetBarForItem(item);
                if (bar != null)
                {
                    // unsub...
                    item.Finished -= new EventHandler(item_Finished);

                    // remove...
                    this.panelBars.Controls.Remove(bar);

                    // count?
                    if (this.panelBars.Controls.Count == 0)
                    {
                        ShowDefaultBar();
                    }
                }
            }
            finally
            {
                this.panelBars.ResumeLayout();
            }
        }