ScreenPosition for RadDesktopAlertManager depending on current screen

4 posts, 0 answers
  1. Valentin
    Valentin avatar
    73 posts
    Member since:
    Mar 2016

    Posted 15 Sep Link to this post

    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.

  2. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 16 Sep Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Valentin
    Valentin avatar
    73 posts
    Member since:
    Mar 2016

    Posted 19 Sep in reply to Nasko Link to this post

    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 !

     

  5. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 19 Sep Link to this post

    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.
Back to Top