Ejemplo n.º 1
0
        private KBusyIndicator CreateOverlay(string text, bool showProgress)
        {
            try
            {
                SuspendLayout();

                // Create a new busy indicator and layouyt
                KBusyIndicator overlay = new KBusyIndicator();
                overlay.ShowProgress = showProgress;
                overlay.Text         = text;

                // Remove the existing controls; the overlay must be first to be rendered on top,
                // and there's no insert function.
                // Also disable the controls on the fly
                List <Control> existing = new List <Control>();
                while (Controls.Count > 0)
                {
                    existing.Add(Controls[0]);
                    Controls[0].Enabled = false;
                    Controls.RemoveAt(0);
                }

                // Add the busy overlay
                Controls.Add(overlay);

                // Re-add the existing controls
                Controls.AddRange(existing.ToArray());

                return(overlay);
            }
            finally
            {
                ResumeLayout();
            }
        }
Ejemplo n.º 2
0
 private void HideCompleteOverlay()
 {
     if (_completeOverlay != null)
     {
         RemoveOverlay(_completeOverlay);
         _completeOverlay = null;
     }
 }
Ejemplo n.º 3
0
        private void RemoveOverlay(KBusyIndicator overlay)
        {
            Controls.Remove(overlay);

            // And enable the controls
            foreach (Control control in Controls)
            {
                control.Enabled = true;
            }

            // Excute any actions
            foreach (Action action in _doneActions)
            {
                action();
            }
            _doneActions.Clear();
        }
Ejemplo n.º 4
0
        public void ShowCompletion(string text)
        {
            // Show the overlay
            _completeOverlay = CreateOverlay(text, false);

            _completeOverlay.MouseMove += _completeOverlay_MouseMove;

            // Add a timer to hide
            var timer = new System.Windows.Forms.Timer();

            timer.Interval = 5000; // TODO: make a property for this
            timer.Tick    += (o, args) =>
            {
                timer.Stop();
                HideCompleteOverlay();
            };
            timer.Start();
        }