Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
248
Dispaly style for DesktopAlert
posted

I am using a desktop alert in my MDI form. And there are sequence of alerts(could be one ore more then one as this is database driven) which shows on the right hand bottom of my screen.

What i want is whenever there are more then one alerts then instead of showing them in Tiled way, they should pop-up one after the another, i.e. after i close the first alert, then it should show the next alert and so on and if not closed then then first one should close as mentioned in autoclose and then the 2nd appears.

How to achieve this?

Thanks

Amit Govil

  • 6158
    Suggested Answer
    Offline posted

    Hello Amit,

    I don't believe the UltraDesktopAlert has this functionality built in, but it shouldn't be too difficult to implement an alert "queue" to achieve this desired behavior.

            List<string> alertQueue = new List<string>();
            string alertKey = "ALERTKEY";
    
            private void ShowAlert(string alertString)
            {
                // if the UltraDesktopAlert is open, queue the new alert
                if (this.ultraDesktopAlert1.IsOpen(this.alertKey))
                {
                    this.alertQueue.Add(alertString);
                    return;
                }
    
                // show the new alert
                UltraDesktopAlertShowWindowInfo windowInfo = new UltraDesktopAlertShowWindowInfo(alertString, alertString);
                windowInfo.Key = this.alertKey;
                this.ultraDesktopAlert1.Show(windowInfo);
            }
            private void ultraDesktopAlert1_DesktopAlertClosed(object sender, DesktopAlertClosedEventArgs e)
            {
                // if any alerts are queued, take the first one off the queue and display it.
                if (this.alertQueue.Count > 0)
                {
                    string alertString = this.alertQueue[0];
                    this.alertQueue.RemoveAt(0);
                    this.BeginInvoke((Action)delegate()
                    {
                        this.ShowAlert(alertString);
                    });
                }
            }
    

     

    You would call the ShowAlert() method in your code whenever a new alert should be displayed. The DesktopAlertClosed event handler will handle popping any queued alerts off of the queue and display them. I've attached the project if you want to see the whole sample.

    Let me know if you need any further details.

    Thanks,

    Chris

    WindowsFormsApplication1.zip