Ejemplo n.º 1
0
        /// <summary>
        /// Sends a pop-up dialog notification.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        /// <param name="request">The request.</param>
        /// <param name="blinkColor">Light stack colors that should blink until this popup is dismissed.</param>
        /// <param name="buttonNames">The custom button names.</param>
        /// <returns></returns>
        public static string PopUp(string title, string message, string request, LightStackColor blinkColor, params string[] buttonNames)
        {
            string customClickedName = "";

            Form activeForm = Form.ActiveForm;

            if (activeForm == null && Application.OpenForms.Count > 0)
            {
                activeForm = Application.OpenForms[Application.OpenForms.Count - 1];
            }

            int notifyCount = 0;

            foreach (Form f in Application.OpenForms)
            {
                if (f is NotifyForm)
                {
                    notifyCount++;
                }
            }

            UIUtility.Invoke(activeForm, () =>
            {
                using (NotifyForm notify = new NotifyForm(title, message, request, buttonNames))
                {
                    if (notifyCount > 0)
                    {
                        notify.StartPosition = FormStartPosition.Manual;
                        Rectangle bounds     = Screen.PrimaryScreen.Bounds;
                        Point center         = new Point((bounds.Width - notify.Width) / 2, (bounds.Height - notify.Height) / 2);
                        notify.Location      = new Point(center.X + (50 * notifyCount), center.Y + (50 * notifyCount));
                    }

                    LightStackColor prevColor = LightStackColor.Off;
                    bool lightTowerSet        = false;

                    try
                    {
                        if (LightTower != null && blinkColor != LightStackColor.Off)
                        {
                            prevColor = LightTower.GetBlink();
                            LightTower.Off(LightStackColor.All);
                            LightTower.Blink(blinkColor);
                            lightTowerSet = true;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        notify.ShowDialog();
                        customClickedName = notify.ClickedCustomName;

                        if (lightTowerSet)
                        {
                            LightTower.Off(LightStackColor.All);
                            LightTower.Blink(prevColor);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            });

            return(customClickedName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends an error pop-up dialog notification. The border and title will be in red.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        /// <param name="details">The error details.</param>
        /// <param name="blinkColor">Light stack colors that should blink until this popup is dismissed.</param>
        public static void PopUpError(string title, string message, LightStackColor blinkColor, string details = "")
        {
            Form activeForm = Form.ActiveForm;

            if (activeForm == null && Application.OpenForms.Count > 0)
            {
                activeForm = Application.OpenForms[Application.OpenForms.Count - 1];
            }

            int notifyCount = 0;

            foreach (Form f in Application.OpenForms)
            {
                if (f is NotifyForm)
                {
                    notifyCount++;
                }
            }

            UIUtility.Invoke(activeForm, () =>
            {
                using (NotifyForm notify = new NotifyForm(title, message, "", "Details", "Copy", "OK"))
                {
                    notify.BackColor        = Color.OrangeRed;
                    notify.CustomButtonText = details;
                    notify.FormClosing     += notify_FormClosing;

                    if (notifyCount > 0)
                    {
                        notify.StartPosition = FormStartPosition.Manual;
                        Rectangle bounds     = Screen.PrimaryScreen.Bounds;
                        Point center         = new Point((bounds.Width - notify.Width) / 2, (bounds.Height - notify.Height) / 2);
                        notify.Location      = new Point(center.X + (50 * notifyCount), center.Y + (50 * notifyCount));
                    }

                    LightStackColor prevColor = LightStackColor.Off;
                    bool lightTowerSet        = false;

                    try
                    {
                        if (LightTower != null && blinkColor != LightStackColor.Off)
                        {
                            prevColor = LightTower.GetBlink();
                            LightTower.Off(LightStackColor.All);
                            LightTower.Blink(blinkColor);
                            lightTowerSet = true;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        notify.ShowDialog();

                        if (lightTowerSet)
                        {
                            LightTower.Off(LightStackColor.All);
                            LightTower.Blink(prevColor);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            });
        }
Ejemplo n.º 3
0
        private void UpdateStep()
        {
            if (Steps.Count == 0)
            {
                return;
            }

            UIUtility.Invoke(this, () =>
            {
                if (CurrentStep != null)
                {
                    this.Message = CurrentStep.Instructions;
                }

                this.ClearActions();

                if (CurrentStep != Steps.Last())
                {
                    this.CloseText = "Cancel";
                }

                if (CurrentStep.Actions.Count <= 1)
                {
                    if (CurrentStep.Actions.Count == 0)
                    {
                        if (CurrentStep != Steps.Last())
                        {
                            this.AddAction("Next", null);
                        }
                        else
                        {
                            this.CloseText = "Done";
                        }
                    }
                    else
                    {
                        Tuple <string, Action> actionAndName = CurrentStep.Actions[0];

                        if (actionAndName.Item2 == null && CurrentStep == Steps.Last())
                        {
                            this.CloseText = "Done";
                        }
                        else
                        {
                            string actionText = "Next";

                            if (!String.IsNullOrEmpty(actionAndName.Item1))
                            {
                                actionText = actionAndName.Item1;
                            }
                            if (CurrentStep == Steps.Last())
                            {
                                actionText = "OK";
                            }

                            this.AddAction(actionText, () => ActionAndProgress(actionAndName.Item2));
                        }
                    }
                }
                else
                {
                    foreach (Tuple <string, Action> actionAndName in CurrentStep.Actions)
                    {
                        string actionText = "Next";

                        if (!String.IsNullOrEmpty(actionAndName.Item1))
                        {
                            actionText = actionAndName.Item1;
                        }

                        this.AddAction(actionText, () => ActionAndProgress(actionAndName.Item2));
                    }
                }
            });
        }