Esempio n. 1
0
        /// <summary>
        ///     Show a dialog that simulates a UAC Dialog prompt,
        ///     the Content property is a Usercontrol
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UAC2_Click(object sender, RoutedEventArgs e)
        {
            TaskDialog dialog = new TaskDialog();

            dialog.MaxWidth = 440;
            dialog.TopMost  = InteropWindowZOrder.TopMost;
            dialog.TaskDialogWindow.Title = "User Account Control";
            dialog.HeaderIcon             = TaskDialogIcon.Warning;
            dialog.SystemSound            = TaskDialogSound.Exclamation;
            // set custom button captions
            dialog.TaskDialogButton = TaskDialogButton.Custom;
            dialog.Button1Text      = "_Continue";
            dialog.Button2Text      = "C_ancel";
            dialog.DefaultResult    = TaskDialogResult.Button2;
            dialog.IsButton2Cancel  = true;
            // header properties
            dialog.Header           = "A program needs your permission to continue.";
            dialog.HeaderBackground = Brushes.DarkGray;
            dialog.HeaderForeground = Brushes.White;

            // for the body, use a custom Usercontrol to display an image with the text
            Uac uac = new Uac(dialog.TaskDialogWindow);

            uac.buttonAllow.Visibility  = Visibility.Collapsed;
            uac.buttonCancel.Visibility = Visibility.Collapsed;
            dialog.Content = uac;
            dialog.Detail  = @"C:\Program Files\Some program.exe";
            dialog.Footer  = "User Account Control helps stop unauthorised changes to your computer";

            dialog.Show();
        }
Esempio n. 2
0
        /// <summary>
        ///     Show a dialog that simulates a UAC Dialog prompt,
        ///     the Content property is a Usercontrol that has two TaskDialogCommandButtons
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UAC1_Click(object sender, RoutedEventArgs e)
        {
            TaskDialog dialog = new TaskDialog();

            dialog.MaxWidth = 480;
            dialog.TaskDialogWindow.Title = "User Account Control";
            dialog.TaskDialogWindow.IsCloseButtonEnabled = false; // disables the close button on the window (defaults to enabled)
            dialog.SystemSound = TaskDialogSound.Exclamation;     // play a system sound

            dialog.Header           = "An Unidentified program wants access to your computer";
            dialog.HeaderIcon       = TaskDialogIcon.Warning;
            dialog.HeaderBackground = Brushes.Gold;
            dialog.HeaderForeground = Brushes.Black;

            // add a usercontrol that has two command buttons on it, pass in the TaskDialogWindow to the usercontrol so that it can close the dialog window
            Uac uac1 = new Uac(dialog.TaskDialogWindow);

            dialog.Content = uac1;

            // for the body,use a custom Usercontrol to display an image with the text
            dialog.Detail = @"C:\Program Files\Some program.exe";
            dialog.Footer = "User Account Control helps stop unauthorised changes to your computer";

            dialog.Show();
        }