This is a migrated thread and some comments may be shown as answers.

ScreenPosition for RadDesktopAlertManager depending on current screen

4 Answers 395 Views
DesktopAlert
This is a migrated thread and some comments may be shown as answers.
Valentin
Top achievements
Rank 1
Iron
Iron
Valentin asked on 15 Sep 2016, 12:51 PM

Hello Télérik,

 

I'm using a RadDesktopAlert in my software.

The declaration :

private void CreateNotification(string header, string content, int dureeEnMillisecondes, int tailleEnPx)
        {
            var alert = new RadDesktopAlert();
            alert.Header = header;
            alert.Content = content;
            alert.Opacity = 0.7;
            alert.ShowDuration = dureeEnMillisecondes;
            alert.Height = tailleEnPx;
            alert.ShowCloseButton = false;
 
            //Point pointDeDepart = new Point(0, 20);
            RadDesktopAlertManager manager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight);//pointDeDepart);
              
            manager.ShowAlert(alert);
        }

- Me, and my clients, using 2 or more screens to work. 

- For the moment, i'm using AlertScreenPosition.BottomRight and the notification was displayed in the bottom-right of the main screen (where is the windows task bar), even if the screen software is on a other screen.

 

I want to know if is it possible to display the notification on the current screen (where is the software, or where is the mouse) ?

 

Thank you very much, I hope be understadable.

4 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 16 Sep 2016, 06:16 AM
Hi Valentin,

With the current implementation the Alert is shown on the main display by default. However using one of the overloads of the RadDesktopAlertManager you could pass an offset parameter that would help you to show the Alert on the desired place - you would need to manually calculate the needed offset right before creating the DesktopAlertManager. Please, check the the following example from our online XAML SDK Repository that demonstrates how to achieve something similar using calculated offset:
https://github.com/telerik/xaml-sdk/tree/master/DesktopAlert/DesktopAlertWithScreenPositionOffset

We also have an item logged as a feature in our Feedback portal about providing such built-in functionality. You could vote for the item and track its status here:
http://feedback.telerik.com/Project/143/Feedback/Details/174589-desktopalert-provide-built-in-functionality-to-show-the-alert-on-the-current-dis

Hope this helps.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Valentin
Top achievements
Rank 1
Iron
Iron
answered on 19 Sep 2016, 09:30 AM

Hello Nasko,

 

Thank you for you answer.

I found the solution with a part of your code. First, I'm using GetWindowRectangle(), adapted for my environment. I have a UserControl in a RadWindow and so I should to get the UserControl parent :

private System.Drawing.Rectangle GetWindowRectangle()
        {
            WndVisu wndParent = InterfaceCpp.WndVisualisationGraphique;

 

            System.Drawing.Rectangle windowRectangle = new System.Drawing.Rectangle((int)wndParent.Left,
                     (int)wndParent.Top,
                     (int)this.ActualWidth
(int)this.ActualHeight);

 

            return windowRectangle;
        }

 

Next, I get the area where my window is. With this area (Rectangle), I get the current (and used) screen. With it, I create a new Point and apply the difference with the Main Windows Screen and the current screen WorkingArea to display the notification.

private void CreateNotification(string header, string content, int dureeEnMillisecondes, int tailleEnPx)
        {
            System.Drawing.Rectangle r = GetWindowRectangle(); //Récupère la zone en cours
            System.Windows.Forms.Screen currentScreen = System.Windows.Forms.Screen.FromRectangle(r); //Récupère l'écran en fonction de la zone en cours
             
            var alert = new RadDesktopAlert();
            alert.Header = header;
            alert.Content = content;
            alert.Opacity = 0.7;
            alert.ShowDuration = dureeEnMillisecondes;
            alert.Height = tailleEnPx;
            alert.ShowCloseButton = false;
 
            Point pointDeDepart = new Point(currentScreen.WorkingArea.X, currentScreen.WorkingArea.Y);
            RadDesktopAlertManager manager = new RadDesktopAlertManager(AlertScreenPosition.BottomRight, pointDeDepart);
              
            manager.ShowAlert(alert);
        }

 

So, my notification is showing on the current screen.

 

NB : In order to get the expected result, the user should have the same screen sizes, else, there is a little offset, depending on the differents screen sizes.

 

Thank you !

 

0
Nasko
Telerik team
answered on 19 Sep 2016, 10:10 AM
Hello Valentin,

I am glad to here you were able to achieve the desired by you behavior and now everything is working as expected for you. Thank you also for sharing your approach with the community.

If you have any additional questions or concerns regarding Telerik controls, please do not hesitate to contact us.

Regards,
Nasko
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
1
Leonid
Top achievements
Rank 2
answered on 18 Jan 2018, 02:48 PM

My solution is to use Application.Current.MainWindow

manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(Application.Current.MainWindow.Left,0));

Tags
DesktopAlert
Asked by
Valentin
Top achievements
Rank 1
Iron
Iron
Answers by
Nasko
Telerik team
Valentin
Top achievements
Rank 1
Iron
Iron
Leonid
Top achievements
Rank 2
Share this question
or