RadWindow.Alert - sound?

7 posts, 0 answers
  1. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 23 Jan 2014 Link to this post

    I'm replacing some calls to MessageBox.Show() with calls to RadWindow.Alert so that the message dialogs match the theme of my application.  However, I noticed that the Alert dialog doesn't play any sort of system sound like MessageBox.Show.  Digging through the docs and the forum, I don't see any mention of this.  I'd definitely think the pre-defined dialogs should have some built-in system sound support., right?

    Input appreciated.

    Jeff
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 24 Jan 2014 Link to this post

    Hi Jeff,

    You can easily add sound to RadWindow.Alert dialog by using Opened event handler:
    private MediaPlayer player;
     
    private void RadButton_Click(object sender, RoutedEventArgs e)
    {
     
        var dialogParams = new DialogParameters();
        dialogParams.Opened = Opened;
        dialogParams.Closed = AlertClosed;
        dialogParams.Content = "Content";
        RadWindow.Alert(dialogParams);
    }
     
    private void AlertClosed(object sender, WindowClosedEventArgs e)
    {
        this.player.Stop();
    }
     
    private void Opened(object sender, EventArgs e)
    {
        this.PlaySound();
    }
     
    private void PlaySound()
    {
        Uri uri = new Uri("../../MyWave.wav", UriKind.RelativeOrAbsolute);
        if (this.player == null)
        {
            this.player = new MediaPlayer();
            this.player.Open(uri);
        }
     
        this.player.Play();
    }

    The idea of code above is to play the wave when RadWindow.Alert is opened and stop it when the alert is closed.

    Hope this helps.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 24 Jan 2014 Link to this post

    Thanks for the sample code.  While it (or something similar) may very well be the best solution to my problem, I want to make sure I was clear about the issue.

    As mentioned above, I'm replacing MessageBox.Show() calls with RadWindow.Alert() calls in order to get proper themeing.  However, I immediately noticed that when a RadWindow.Alert is opened (in place of an Error or Warning style MessageBox), that it's "silent".  That is, it doesn't play the standard Windows sounds normally associated with the various MessageBox styles.

    That strikes me as odd as I presume replacing MessageBox.Show calls is a typical use-case for RadWindow.Alert, right?  I assumed that I had somehow missed some built-in mechanism to play standard system sounds via RadWindow.Alert, but maybe that's not the case?

    Based on the above, is the sample code still my best route?  If so, I guess I'll just need to wrap this all up into a reusable component to better mimic a typical MessageBox.

    Assuming there is no "built-in" support for playing standard system sounds, might you consider that for a future enhancement, as it seems like a natural fit.

    Thanks,

    Jeff

  5. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 24 Jan 2014 Link to this post

    So, with some additional research, it looks like I can do what I want using something like this:

    RadWindow.Alert(new DialogParameters()
    {
        Content = new System.Windows.Controls.TextBlock {
            Text = ex.Message, Width = 250, TextWrapping = TextWrapping.Wrap },
        Header = "Update Error",
        Opened = (alertDialog, eventArgs) => System.Media.SystemSounds.Exclamation.Play()
    });

    That'll work, but it would be nice if some of the default dialogs had built-in system sound support.

    Thanks,

    Jeff
  6. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 27 Jan 2014 Link to this post

    Hi Jeff,

    Thank you for your valuable feedback. You can add this feature request in our feedback portal and if there is customer demand, we'll consider adding it to our Alert dialog.

    Hope this helps.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  7. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 27 Jan 2014 in reply to Rosen Vladimirov Link to this post

    As requested, this enhancement has been requested on the feed back portal.  That suggestion can be seen here:

    http://feedback.telerik.com/Project/143/Feedback/Details/101789-add-system-sound-support-to-radwindow-alert-and-radwindow-confirm

    Jeff
  8. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 27 Jan 2014 Link to this post

    Hi Jeff,

    Thank you very much for the fast response. We have reviewed it and it has been approved as a possible future improvement of our controls. If there is enough customer demand, we'll consider implementing this functionality.

    Regards,
    Rosen Vladimirov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready