Ejemplo n.º 1
0
        private static Result InternalShow(IntPtr parent, string title, string instruction, string content, TaskDialogButton commonButtons, TaskDialogIcon icon)
        {
            int dlgValue;

            try {
                //Get handle for parent window if none specified (behave like MessageBox)
                if (parent == IntPtr.Zero)
                    parent = Native.Windows.GetActiveWindow();

                if (NativeMethods.TaskDialog(parent, IntPtr.Zero, title, instruction, content, (int)commonButtons, new IntPtr((long)icon), out dlgValue) != 0)
                    throw new Exception(String.Format(Resources.ExceptionMessages.NativeCallFailure, "TaskDialog"));
            }
            catch (EntryPointNotFoundException ex) {
                throw new Exception(Resources.ExceptionMessages.CommonControlEntryPointNotFound, ex);
            }
            catch (Exception ex) {
                throw new Exception(Resources.ExceptionMessages.TaskDialogFailure, ex);
            }

            //Convert int value to common dialog result
            if (dlgValue > 0 && dlgValue <= 8)
                return (Result)dlgValue;
            else
                return Result.None;
        }
Ejemplo n.º 2
0
        private static bool Prompt(IWin32Window window, string service, string action, string content, TaskDialogIcon icon)
        {
            DialogResult result = DialogResult.No;

            if (OSVersion.HasTaskDialogs)
            {
                TaskDialog td = new TaskDialog();

                td.WindowTitle = "Process Hacker";
                td.MainInstruction = "Do you want to " + action + " " + service + "?";
                td.MainIcon = icon;
                td.Content = content;

                td.Buttons = new TaskDialogButton[]
                {
                    new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)),
                    new TaskDialogButton((int)DialogResult.No, "Cancel")
                };
                td.DefaultButton = (int)DialogResult.No;

                result = (DialogResult)td.Show(window);
            }
            else
            {
                result = MessageBox.Show("Are you sure you want to " + action + " " + service + "?",
                    "Process Hacker", MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
            }

            return result == DialogResult.Yes;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialog"/> class.
 /// </summary>
 /// <param name="caption">The caption.</param>
 /// <param name="instructionHeading">The instruction heading.</param>
 /// <param name="instructionText">The instruction text.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <param name="instructionIcon">The instruction icon.</param>
 /// <param name="buttonsDisabledDelay">The buttons disabled delay.</param>
 public TaskDialog(String caption, String instructionHeading, String instructionText, TaskDialogButton buttons, TaskDialogResult defaultButton, TaskDialogIcon instructionIcon, Int32 buttonsDisabledDelay = 0)
 {
     _caption                  = caption;
     _instructionHeading       = instructionHeading;
     _instructionText          = instructionText;
     _buttons                  = buttons;
     _defaultButton            = defaultButton;
     _instructionIcon          = instructionIcon;
     this.ButtonsDisabledDelay = buttonsDisabledDelay;
 }
Ejemplo n.º 4
0
        /// <summary>Initializes a new Task Dialog instance with an instruction, a title, some content text, a specific button and an icon.</summary>
        /// <param name="instruction">The main instruction to display.</param>
        /// <param name="title">The title of the Task Dialog.</param>
        /// <param name="content">The content text that will be displayes below the main instruction.</param>
        /// <param name="commonButtons">Specifies one or more buttons to be displayed on the bottom of the dialog, instead of the default OK button.</param>
        /// <param name="icon">The icon to display.</param>
        public TaskDialog(string instruction, string title, string content, TaskDialogButton commonButtons, TaskDialogIcon icon)
        {
            Init();

            Title         = title;
            Instruction   = instruction;
            Content       = content;
            CommonButtons = commonButtons;
            CommonIcon    = icon;
        }
Ejemplo n.º 5
0
 public static void ShowDialog(this ITaskDialog taskDialog, TaskDialogIcon taskDialogIcon, IWin32Window owner,
                               string text, string caption = null)
 {
     taskDialog.ShowDialog(owner,
                           new TaskDialogPage
     {
         Icon    = taskDialogIcon,
         Caption = caption,
         Text    = text
     });
 }
Ejemplo n.º 6
0
 public static void ShowDialog(this ITaskDialog taskDialog, TaskDialogIcon taskDialogIcon, IntPtr hwndOwner,
                               string text, string caption = null)
 {
     taskDialog.ShowDialog(hwndOwner,
                           new TaskDialogPage
     {
         Icon    = taskDialogIcon,
         Caption = caption,
         Text    = text
     });
 }
Ejemplo n.º 7
0
        //shows a message box using the given parameters
        public void ShowMessageBox(string dialogName, string id, string message, TaskDialogIcon icon, TaskDialogCommonButtons buttons)
        {
            //give an error message if we do not
            TaskDialog td = new TaskDialog(dialogName);

            td.Id            = id;
            td.MainIcon      = icon;
            td.CommonButtons = buttons;
            td.MainContent   = message;
            td.Show();
        }
Ejemplo n.º 8
0
 public static TaskDialog CreateDialog(string title, string subtitle, TaskDialogIcon mainIcon)
 {
     return(new TaskDialog
     {
         CanBeMinimized = false,
         MainIcon = mainIcon,
         MainInstruction = title,
         Content = subtitle,
         PositionRelativeToWindow = true,
         WindowTitle = "Convert All to MP3"
     });
 }
Ejemplo n.º 9
0
        public static TaskDialog Create(
            string windowtitle,
            string maintext,
            TaskDialogIcon mainicon)
        {
            TaskDialog td = new TaskDialog(windowtitle);

            td.MainInstruction = maintext;
            td.MainIcon        = mainicon;

            return(td);
        }
Ejemplo n.º 10
0
        public static void ShowTaskDialog(string content, TaskDialogIcon icon)
        {
            TaskDialog dialog = new TaskDialog()
            {
                Content     = content,
                MainIcon    = icon,
                WindowTitle = "Discord Statistics"
            };

            dialog.Buttons.Add(new TaskDialogButton(ButtonType.Ok));
            dialog.ShowDialog();
        }
Ejemplo n.º 11
0
 private void ShowMessageTaskDialog(TaskDialogIcon icon, string title, string message, string details, IntPtr?owner)
 {
     using (var dialog = GetTaskDialog())
     {
         dialog.WindowTitle         = title;
         dialog.MainIcon            = icon;
         dialog.Content             = message;
         dialog.ExpandedInformation = details;
         dialog.ExpandFooterArea    = true;
         dialog.Buttons.Add(new TaskDialogButton(ButtonType.Ok));
         dialog.ShowDialog(GetOwnerHandle(owner));
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialog"/> class.
 /// </summary>
 /// <param name="caption">The caption.</param>
 /// <param name="instructionHeading">The instruction heading.</param>
 /// <param name="instructionText">The instruction text.</param>
 /// <param name="additionalDetailsText">The additional details text.</param>
 /// <param name="footerText">The footer text.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <param name="instructionIcon">The instruction icon.</param>
 /// <param name="footerIcon">The footer icon.</param>
 /// <param name="buttonsDisabledDelay">The buttons disabled delay.</param>
 public TaskDialog(String caption, String instructionHeading, String instructionText, String additionalDetailsText, String footerText, TaskDialogButton buttons, TaskDialogResult defaultButton, TaskDialogIcon instructionIcon, TaskDialogIcon footerIcon, Int32 buttonsDisabledDelay = 0)
 {
     _caption                  = caption;
     _instructionHeading       = instructionHeading;
     _instructionText          = instructionText;
     _additionalDetailsText    = additionalDetailsText;
     _footerText               = footerText;
     _buttons                  = buttons;
     _defaultButton            = defaultButton;
     _instructionIcon          = instructionIcon;
     _footerIcon               = footerIcon;
     this.ButtonsDisabledDelay = buttonsDisabledDelay;
 }
Ejemplo n.º 13
0
        public static TaskDialogResult MessageBox(string message, string content, TaskDialogIcon icon,
                                                  TaskDialogCommonButtonFlags commonButtons, params string [] buttons)
        {
            TaskDialogButton [] tdButtons = buttons != null?TaskDialogButton.Cast(buttons) : null;

            TaskDialog taskDialog = new TaskDialog
            {
                Title           = StringTable.SharedStrings ["daram_renamer"],
                MainInstruction = message,
                Content         = content,
                MainIcon        = icon,
                CommonButtons   = commonButtons,
                Buttons         = tdButtons,
            };

            return(taskDialog.Show());
        }
Ejemplo n.º 14
0
        public static TaskDialogResult ShowTaskDialog(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;
            if (NativeMethods.TaskDialog(IntPtr.Zero, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
                throw new InvalidOperationException("Error occurred calling TaskDialog.");

            switch (p)
            {
                case 1: return TaskDialogResult.Ok;
                case 2: return TaskDialogResult.Cancel;
                case 4: return TaskDialogResult.Retry;
                case 6: return TaskDialogResult.Yes;
                case 7: return TaskDialogResult.No;
                case 8: return TaskDialogResult.Close;
                default: return TaskDialogResult.None;
            }
        }
Ejemplo n.º 15
0
 public static void Show(Window owner, string title, string instruction, string content, string verbose,
     string footer, TaskDialogIcon icon)
 {
     using (var dialog = new TaskDialog())
     {
         dialog.Width = 240;
         dialog.WindowTitle = title;
         dialog.MainInstruction = instruction;
         dialog.Content = content;
         dialog.ExpandedInformation = verbose;
         dialog.Footer = footer;
         dialog.FooterIcon = icon;
         dialog.EnableHyperlinks = true;
         var okButton = new TaskDialogButton(ButtonType.Ok);
         dialog.Buttons.Add(okButton);
         dialog.HyperlinkClicked += (sender, args) => { Process.Start(args.Href); };
         dialog.ShowDialog(owner);
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// More comprehensive wrapper function.
        /// </summary>
        public static TaskDialogResult TaskDialog(
            Window ParentWindow,
            string strTitle,
            string strMainInstruction,
            string strContent,
            TaskDialogButtons eButtons,
            TaskDialogIcon eIcon)
        {
            int    iDialogResult = 0;
            IntPtr hwnd          = new WindowInteropHelper(ParentWindow).Handle;

            HRESULT hResult = TaskDialog(hwnd, IntPtr.Zero, strTitle, strMainInstruction, strContent, eButtons, eIcon, ref iDialogResult);

            if ((int)hResult < 0)             // >= 0 means HRESULT success
            {
                throw new COMException("TaskDialog() failed.", (int)hResult);
            }
            return((TaskDialogResult)iDialogResult);
        }
Ejemplo n.º 17
0
 public static void Show(Window owner, string title, string instruction, string content, string verbose,
                         string footer, TaskDialogIcon icon)
 {
     using (var dialog = new TaskDialog())
     {
         dialog.Width               = 240;
         dialog.WindowTitle         = title;
         dialog.MainInstruction     = instruction;
         dialog.Content             = content;
         dialog.ExpandedInformation = verbose;
         dialog.Footer              = footer;
         dialog.FooterIcon          = icon;
         dialog.EnableHyperlinks    = true;
         var okButton = new TaskDialogButton(ButtonType.Ok);
         dialog.Buttons.Add(okButton);
         dialog.HyperlinkClicked += (sender, args) => { Process.Start(args.Href); };
         dialog.ShowDialog(owner);
     }
 }
Ejemplo n.º 18
0
        private static MessageBoxImage ConvertTaskDialogIcon(TaskDialogIcon icon)
        {
            switch (icon)
            {
            case TaskDialogIcon.Error:
                return(MessageBoxImage.Error);

            case TaskDialogIcon.Information:
                return(MessageBoxImage.Information);

            case TaskDialogIcon.Shield:
                return(MessageBoxImage.Question);

            case TaskDialogIcon.Warning:
                return(MessageBoxImage.Warning);

            default:
                return(MessageBoxImage.None);
            }
        }
Ejemplo n.º 19
0
        public Window1()
        {
            InitializeComponent();

            TitleText   = "Task Dialog Options";
            Header      = "The Header text for the message box.";
            ContentText = "The Content text for the message box. This text will automatically wrap and is selectable";
            Detail      = "The Detail text for the message box. This text will automatically wrap and is selectable";
            Footer      = "The Footer text for the message box.";
            Button1Text = "Button1";
            Button2Text = "Button2";
            Button3Text = "Button3";

            _sound            = TaskDialogSound.Beep;
            _headerBackground = Brushes.White;
            _headerForeground = Brushes.Navy;
            _headerIcon       = TaskDialogIcon.Information;
            _footerIcon       = TaskDialogIcon.Shield;
            _button           = TaskDialogButton.Ok;
        }
Ejemplo n.º 20
0
        static IntPtr IconToID(TaskDialogIcon icon)
        {
            switch (icon)
            {
            case TaskDialogIcon.None:
                return(IntPtr.Zero);

            case TaskDialogIcon.Warning:
                return(NativeMethods.TD_WARNING_ICON);

            case TaskDialogIcon.Error:
                return(NativeMethods.TD_ERROR_ICON);

            case TaskDialogIcon.Information:
                return(NativeMethods.TD_INFORMATION_ICON);

            case TaskDialogIcon.Shield:
                return(NativeMethods.TD_SHIELD_ICON);
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 21
0
            public static NiTaskDialogIcon DecodeIcon(TaskDialogIcon value)
            {
                switch (value)
                {
                case TaskDialogIcon.None:
                    return(NiTaskDialogIcon.None);

                case TaskDialogIcon.Warning:
                    return(NiTaskDialogIcon.Warning);

                case TaskDialogIcon.Error:
                    return(NiTaskDialogIcon.Error);

                case TaskDialogIcon.Information:
                    return(NiTaskDialogIcon.Information);

                case TaskDialogIcon.Shield:
                    return(NiTaskDialogIcon.Shield);

                default:
                    throw new ArgumentOutOfRangeException("value");
                }
            }
Ejemplo n.º 22
0
        private static NativeMethods.TASKDIALOG_ICON GetIconResource(TaskDialogIcon icon)
        {
            switch (icon)
            {
            case TaskDialogIcon.None:
                return(0);

            case TaskDialogIcon.Error:
                return(NativeMethods.TASKDIALOG_ICON.TD_ERROR_ICON);

            case TaskDialogIcon.Warning:
                return(NativeMethods.TASKDIALOG_ICON.TD_WARNING_ICON);

            case TaskDialogIcon.Information:
                return(NativeMethods.TASKDIALOG_ICON.TD_INFORMATION_ICON);

            case TaskDialogIcon.Shield:
                return(NativeMethods.TASKDIALOG_ICON.TD_SHIELD_ICON);

            default:
                throw new ArgumentException("Invalid TaskDialogIcon value", "icon");
            }
        }
Ejemplo n.º 23
0
        private static TaskDialogIcon GetIcon(string icon, TaskDialogIcon defaultIcon)
        {
            if (icon != null)
            {
                switch (icon)
                {
                case "info":
                case "information":
                    return(TaskDialogIcon.Information);

                case "warn":
                case "warning":
                    return(TaskDialogIcon.Warning);

                case "error":
                    return(TaskDialogIcon.Error);

                case "none":
                    return(TaskDialogIcon.None);
                }
            }

            return(defaultIcon);
        }
 protected void SetFooterIcon(TaskDialogIcon footerIcon)
 {
     this.TaskDialogInternal.SetFooterIcon(footerIcon);
 }
Ejemplo n.º 25
0
        private static TaskDialogResult ShowCore(DependencyObject owner, string header, string content, string title,
            TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks,
            params TaskDialogButtonData[] buttons)
        {
            var taskDialog = new TaskDialog
            {
                Owner = owner,
                Title = title,
                Header = header,
                Content = content,
                MainIcon = TaskDialogIconConverter.ConvertFrom(icon)
            };

            foreach (TaskDialogButtonData buttonData in TaskDialogButtonData.FromStandardButtons(standardButtons))
            {
                taskDialog.Buttons.Add(buttonData);
            }

            if (useCommandLinks)
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.CommandLinks.Add(buttonData);
                }
            }
            else
            {
                foreach (TaskDialogButtonData buttonData in buttons)
                {
                    taskDialog.Buttons.Add(buttonData);
                }
            }

            taskDialog.Show();

            return taskDialog.Result;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/>.
        /// </summary>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <param name="icon">A <see cref="TaskDialogIcon"/> value that specifies the icon to
        /// display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult Show(String instruction, String content, String title,
			                                TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            // Initialize task dialog instance
            TaskDialog taskDialog = new TaskDialog();
            taskDialog.Title = title;
            taskDialog.Instruction = instruction;
            taskDialog.Content = content;
            taskDialog.CommonButtons = buttons;
            taskDialog.DefaultIcon = icon;

            // Show instance and return result
            return taskDialog.Show();
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Resets the Task Dialog to the state when first constructed, all properties set to their default value.
 /// </summary>
 public void Reset( )
 {
     this.windowTitle = null;
     this.mainInstruction = null;
     this.content = null;
     this.commonButtons = 0;
     this.mainIcon = TaskDialogIcon.None;
     this.customMainIcon = null;
     this.footerIcon = TaskDialogIcon.None;
     this.customFooterIcon = null;
     this.buttons = new TaskDialogButton[0];
     this.radioButtons = new TaskDialogButton[0];
     this.flags = 0;
     this.defaultButton = 0;
     this.defaultRadioButton = 0;
     this.verificationText = null;
     this.expandedInformation = null;
     this.expandedControlText = null;
     this.collapsedControlText = null;
     this.footer = null;
     this.callback = null;
     this.callbackData = null;
     this.width = 0;
 }
Ejemplo n.º 28
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return(ShowInternal(IntPtr.Zero, text, instruction, caption, buttons, icon));
 }
        System.Windows.Media.ImageSource ConvertIconToImageSource(TaskDialogIcon icon, Icon customIcon, bool isLarge)
        {
            System.Windows.Media.ImageSource iconSource = null;
            Icon   sysIcon = null;
            Bitmap altBmp  = null;

            try
            {
                switch (icon)
                {
                default:
                case TaskDialogIcon.None:
                    break;

                case TaskDialogIcon.Information:
                    sysIcon = SystemIcons.Information;
                    break;

                case TaskDialogIcon.Warning:
                    sysIcon = SystemIcons.Warning;
                    break;

                case TaskDialogIcon.Error:
                    sysIcon = SystemIcons.Error;
                    break;

                case TaskDialogIcon.Question:
                    sysIcon = SystemIcons.Question;
                    break;
                }

                // Custom Icons always take priority
                if (customIcon != null)
                {
                    iconSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                        customIcon.Handle,
                        System.Windows.Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                }
                else if (sysIcon != null)
                {
                    iconSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                        sysIcon.Handle,
                        System.Windows.Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                }
                else if (altBmp != null)
                {
                    iconSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                        altBmp.GetHbitmap(),
                        IntPtr.Zero,
                        System.Windows.Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
                }
            }
            finally
            {
                // Not responsible for disposing of custom icons

                if (sysIcon != null)
                {
                    sysIcon.Dispose();
                }
                if (altBmp != null)
                {
                    altBmp.Dispose();
                }
            }

            return(iconSource);
        }
Ejemplo n.º 30
0
        public static TaskDialogResult Show(IntPtr hwndOwner, string content, string instruction = null, string caption = null,
            TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
        {
            TaskDialog dialog = new TaskDialog()
            {
                Content = content,
                MainInstruction = instruction,
                Title = caption,
                CommonButtons = buttons,
                MainIcon = icon
            };
            dialog.Show(hwndOwner);

            return dialog.ResultCommonButtonID;
        }
Ejemplo n.º 31
0
 static extern TaskDialogResult TaskDialog(IntPtr hWndParent, IntPtr hInstance, String title, String mainInstruction, String content, TaskDialogButtons buttons, TaskDialogIcon icon);
Ejemplo n.º 32
0
 /// <summary>
 /// Displays a task dialog in front of the specified window and with the specified title, intruction, content, title, buttons and icon..
 /// </summary>
 /// <param name="owner">A window that will own the modal dialog box.</param>
 /// <param name="windowTitle">The text to display in the title bar of the task dialog.</param>
 /// <param name="mainInstruction">The instruction to display in the task dialog.</param>
 /// <param name="content">The text to display in the task dialog.</param>
 /// <param name="commonButtons">One of the TaskDialogCommonButtons values that specifies which buttons to display in the task dialog.</param>
 /// <param name="icon">One of the TaskDialogIcon values that specifies which icon to display in the task dialog.</param>
 /// <returns>One of the TaskDialogResult values.</returns>
 public static TaskDialogResult Show(Window owner, string windowTitle, string mainInstruction, string content, TaskDialogCommonButtons commonButtons, TaskDialogIcon icon)
 {
     TaskDialogWindow td = new TaskDialogWindow(null, true) { Owner = owner, WindowTitle = windowTitle, MainIcon = icon, MainInstruction = mainInstruction, ContentText = content, CommonButtons = commonButtons };
     td.DefaultButton = TaskDialogHelpers.GetFirstButton(commonButtons);
     td.UseCommandLinks = true;
     td.ShowDialog();
     return (TaskDialogResult)td.Tag;
 }
Ejemplo n.º 33
0
        private static TaskDialogResult ShowInternal(IntPtr owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;

            if (_TaskDialog(owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
                throw new InvalidOperationException("Something weird has happened.");

            switch (p)
            {
                case 1:
                    return TaskDialogResult.OK;
                case 2:
                    return TaskDialogResult.Cancel;
                case 4:
                    return TaskDialogResult.Retry;
                case 6:
                    return TaskDialogResult.Yes;
                case 7:
                    return TaskDialogResult.No;
                case 8:
                    return TaskDialogResult.Close;
                default:
                    return TaskDialogResult.None;
            }
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Displays a task dialog with the specified title, intruction, content, title, buttons and icon.
 /// </summary>
 /// <param name="windowTitle">The text to display in the title bar of the task dialog.</param>
 /// <param name="mainInstruction">The instruction to display in the task dialog.</param>
 /// <param name="content">The text to display in the task dialog.</param>
 /// <param name="commonButtons">One of the TaskDialogCommonButtons values that specifies which buttons to display in the task dialog.</param>
 /// <param name="icon">One of the TaskDialogIcon values that specifies which icon to display in the task dialog.</param>
 /// <returns>One of the TaskDialogResult values.</returns>
 public static TaskDialogResult Show(string windowTitle, string mainInstruction, string content, TaskDialogCommonButtons commonButtons, TaskDialogIcon icon)
 {
     return Show(DefaultOwnerWindow, windowTitle, mainInstruction, content, commonButtons, icon);
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Displays a task dialog in front of the specified window and with specified text, title, buttons, icon, and default button.
 /// </summary>
 /// <param name="owner">A window that will own the modal dialog box.</param>
 /// <param name="text">The text to display in the task dialog.</param>
 /// <param name="title">The text to display in the title bar of the task dialog.</param>
 /// <param name="buttons">One of the TaskDialogCommonButtons values that specifies which buttons to display in the task dialog.</param>
 /// <param name="icon">One of the TaskDialogIcon values that specifies which icon to display in the task dialog.</param>
 /// <param name="defaultButton">TaskDialogResult value that specifies the default button for the task dialog.</param>
 /// <returns>One of the TaskDialogResult values.</returns>
 public static TaskDialogResult Show(Window owner, string text, string title, TaskDialogCommonButtons buttons, TaskDialogIcon icon, TaskDialogResult defaultButton)
 {
     TaskDialogWindow td = new TaskDialogWindow(null, false)
     {
         Owner = owner,
         WindowTitle = title,
         MainIcon = icon,
         ContentText = text,
         CommonButtons = buttons,
         DefaultButton = defaultButton,
     };
     td.ShowDialog();
     return (TaskDialogResult)td.Tag;
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Displays a task dialog in front of the specified window and with the specified text, title, buttons, and icon.
 /// </summary>
 /// <param name="owner">A window that will own the modal dialog box.</param>
 /// <param name="text">The text to display in the task dialog.</param>
 /// <param name="title">The text to display in the title bar of the task dialog.</param>
 /// <param name="buttons">One of the TaskDialogCommonButtons values that specifies which buttons to display in the task dialog.</param>
 /// <param name="icon">One of the TaskDialogIcon values that specifies which icon to display in the task dialog.</param>
 /// <returns>One of the TaskDialogResult values.</returns>
 public static TaskDialogResult Show(Window owner, string text, string title, TaskDialogCommonButtons buttons, TaskDialogIcon icon)
 {
     return Show(owner, text, title, buttons, icon, TaskDialogHelpers.GetFirstButton(buttons));
 }
Ejemplo n.º 37
0
 public static TaskDialogResult Show(DependencyObject owner, string header, string content, string title,
     TaskDialogButtons standardButtons, TaskDialogIcon icon, bool useCommandLinks,
     params TaskDialogButtonData[] buttons)
 {
     return ShowCore(owner, header, content, title, standardButtons, icon, useCommandLinks, buttons);
 }
Ejemplo n.º 38
0
 public static TaskDialogResult Show(TaskDialog owner, string content, string instruction = null, string caption = null,
     TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
     => Show(GetWindowHandle((IWin32Window)owner), content, instruction, caption, buttons, icon);
Ejemplo n.º 39
0
        private static bool Prompt(IWin32Window window, string service, string action, string content, TaskDialogIcon icon)
        {
            DialogResult result = DialogResult.No;

            if (OSVersion.HasTaskDialogs)
            {
                TaskDialog td = new TaskDialog();

                td.WindowTitle     = "Process Hacker";
                td.MainInstruction = "Do you want to " + action + " " + service + "?";
                td.MainIcon        = icon;
                td.Content         = content;

                td.Buttons = new TaskDialogButton[]
                {
                    new TaskDialogButton((int)DialogResult.Yes, char.ToUpper(action[0]) + action.Substring(1)),
                    new TaskDialogButton((int)DialogResult.No, "Cancel")
                };
                td.DefaultButton = (int)DialogResult.No;

                result = (DialogResult)td.Show(window);
            }
            else
            {
                result = MessageBox.Show("Are you sure you want to " + action + " " + service + "?",
                                         "Process Hacker", MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);
            }

            return(result == DialogResult.Yes);
        }
Ejemplo n.º 40
0
        /// <summary>Initializes a new Task Dialog instance with an instruction, a title, some content text, a specific button and an icon.</summary>
        /// <param name="instruction">The main instruction to display.</param>
        /// <param name="title">The title of the Task Dialog.</param>
        /// <param name="content">The content text that will be displayes below the main instruction.</param>
        /// <param name="commonButtons">Specifies one or more buttons to be displayed on the bottom of the dialog, instead of the default OK button.</param>
        /// <param name="icon">The icon to display.</param>
        public TaskDialog(string instruction, string title, string content, TaskDialogButton commonButtons, TaskDialogIcon icon)
        {
            Init();

            Title = title;
            Instruction = instruction;
            Content = content;
            CommonButtons = commonButtons;
            CommonIcon = icon;
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Displays a task dialog with specified text, title, buttons, icon, and default button.
 /// </summary>
 /// <param name="text">The text to display in the task dialog.</param>
 /// <param name="title">The text to display in the title bar of the task dialog.</param>
 /// <param name="buttons">One of the TaskDialogCommonButtons values that specifies which buttons to display in the task dialog.</param>
 /// <param name="icon">One of the TaskDialogIcon values that specifies which icon to display in the task dialog.</param>
 /// <param name="defaultButton">TaskDialogResult value that specifies the default button for the task dialog.</param>
 /// <returns>One of the TaskDialogResult values.</returns>
 public static TaskDialogResult Show(string text, string title, TaskDialogCommonButtons buttons, TaskDialogIcon icon, TaskDialogResult defaultButton)
 {
     return Show(DefaultOwnerWindow, text, title, buttons, icon, defaultButton);
 }
Ejemplo n.º 42
0
 public static TaskDialogResult Show(string content, string instruction = null, string caption = null,
     TaskDialogButtons buttons = TaskDialogButtons.OK, TaskDialogIcon icon = 0)
      => Show(IntPtr.Zero, content, instruction, caption, buttons, icon);
Ejemplo n.º 43
0
        /// <summary>
        /// Method to actually show the task dialog.
        /// </summary>
        /// <param name="text">The text to display.</param>
        /// <param name="instruction">The instructions to display.</param>
        /// <param name="caption">The caption for the task dialog.</param>
        /// <param name="buttons">Any <see cref="TaskDialogButtons"/> to display.</param>
        /// <param name="icon">The <see cref="TaskDialogIcon"/> to display.</param>
        /// <returns>The <see cref="TaskDialogResult"/> from the task dialog.</returns>
        private TaskDialogResult ShowInternal(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int result;

            if (externalTaskDialog(_owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out result) != 0)
                throw new InvalidOperationException("ShowInternal");

            switch (result)
            {
                case 1: return TaskDialogResult.OK;
                case 2: return TaskDialogResult.Cancel;
                case 4: return TaskDialogResult.Retry;
                case 6: return TaskDialogResult.Yes;
                case 7: return TaskDialogResult.No;
                case 8: return TaskDialogResult.Close;
                default: return TaskDialogResult.None;
            }
        }
Ejemplo n.º 44
0
 public static NiTaskDialogIcon DecodeIcon(TaskDialogIcon value)
 {
     switch (value)
     {
         case TaskDialogIcon.None:
             return NiTaskDialogIcon.None;
         case TaskDialogIcon.Warning:
             return NiTaskDialogIcon.Warning;
         case TaskDialogIcon.Error:
             return NiTaskDialogIcon.Error;
         case TaskDialogIcon.Information:
             return NiTaskDialogIcon.Information;
         case TaskDialogIcon.Shield:
             return NiTaskDialogIcon.Shield;
         default:
             throw new ArgumentOutOfRangeException("value");
     }
 }
        void IActiveTaskDialog.UpdateFooterIcon(TaskDialogIcon icon)
        {
            _Options.FooterIcon = icon;

            RaisePropertyChanged("FooterIcon");
        }
 /// <summary>
 ///     Converts a <see cref="TaskDialogIcon" /> to an <see cref="ImageSource" />.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public static ImageSource ConvertFrom(TaskDialogIcon value)
 {
     // ReSharper disable AssignNullToNotNullAttribute
     return (ImageSource)(new TaskDialogIconConverter().ConvertFrom(null, null, value));
     // ReSharper restore AssignNullToNotNullAttribute
 }
Ejemplo n.º 47
0
 public static extern TaskDialogResult TaskDialog(IntPtr hwndParent, IntPtr hInstance,
                                                  string title, string mainInstruction, string content,
                                                  TaskDialogButtons buttons, TaskDialogIcon icon);
Ejemplo n.º 48
0
        /// <summary>
        /// Displays a <see cref="TaskDialog"/> in front of the specified window.
        /// </summary>
        /// <param name="owner">A <see cref="Window"/> that represents the owner window of the
        /// task dialog.</param>
        /// <param name="instruction">A <see cref="String"/> that specifies the instruction text
        /// to display.</param>
        /// <param name="content">A <see cref="String"/> that specifies the content text to
        /// display.</param>
        /// <param name="title">A <see cref="String"/> that specifies the title bar text of the
        /// task dialog.</param>
        /// <param name="buttons">A <see cref="TaskDialogButtons"/> value that specifies which
        /// buttons to display.</param>
        /// <param name="icon">A <see cref="TaskDialogIcon"/> value that specifies the icon to
        /// display.</param>
        /// <returns>A <see cref="TaskDialogResult"/> value that specifies which common button
        /// was selected by the user.</returns>
        public static TaskDialogResult ShowModal(Window owner, String instruction, String content,
			                                     String title, TaskDialogButtons buttons,
			                                     TaskDialogIcon icon)
        {
            // Validate arguments
            if (owner == null) {
                throw new ArgumentNullException("owner");
            }

            // Initialize task dialog instance
            TaskDialog taskDialog = new TaskDialog();
            taskDialog.Title = title;
            taskDialog.Instruction = instruction;
            taskDialog.Content = content;
            taskDialog.CommonButtons = buttons;
            taskDialog.DefaultIcon = icon;

            // Show instance and return result
            return taskDialog.ShowModal(owner);
        }
 protected void SetMainIcon(TaskDialogIcon mainIcon)
 {
     this.TaskDialogInternal.SetMainIcon(mainIcon);
 }
Ejemplo n.º 50
0
 private void SetupIcon(TaskDialogIcon icon, System.Drawing.Icon customIcon, NativeMethods.TaskDialogFlags flag)
 {
     SetFlag(flag, false);
     if( icon == TaskDialogIcon.Custom )
     {
         if( customIcon != null )
         {
             SetFlag(flag, true);
             if( flag == NativeMethods.TaskDialogFlags.UseHIconMain )
                 _config.hMainIcon = customIcon.Handle;
             else
                 _config.hFooterIcon = customIcon.Handle;
         }
     }
     else
     {
         if( flag == NativeMethods.TaskDialogFlags.UseHIconMain )
             _config.hMainIcon = new IntPtr((int)icon);
         else
             _config.hFooterIcon = new IntPtr((int)icon);
     }
 }
Ejemplo n.º 51
0
 public void UpdateMainIcon(TaskDialogIcon icon)
 {
     UnsafeNativeMethods.SendMessage(
         this.handle,
         (uint)UnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_UPDATE_ICON,
         (IntPtr)UnsafeNativeMethods.TASKDIALOG_ICON_ELEMENTS.TDIE_ICON_MAIN,
         (IntPtr)icon);
 }
Ejemplo n.º 52
0
 /// <summary>Displays a task dialog that has a message, a title, an instruction, one or more buttons and an icon.</summary>
 /// <param name="instruction">The text to display.</param>
 /// <param name="title">The title bar caption of the dialog.</param>
 /// <param name="instruction">The instruction shown below the main text.</param>
 /// <param name="buttons">Value that specifies which button or buttons to display.</param>
 /// <param name="icon">The icon to display.</param>
 public static Result Show(string instruction, string title, string content, TaskDialogButton buttons, TaskDialogIcon icon)
 {
     return(InternalShow(IntPtr.Zero, title, instruction, content, buttons, icon));
 }
Ejemplo n.º 53
0
 /// <summary>Displays a task dialog that has a message, a title, an instruction, one or more buttons and an icon.</summary>
 /// <param name="title">The title bar caption of the dialog.</param>
 /// <param name="instruction">The instruction shown below the main text.</param>
 /// <param name="buttons">Value that specifies which button or buttons to display.</param>
 /// <param name="icon">The icon to display.</param>
 public static Result Show(string instruction, string title, string content, TaskDialogButton buttons, TaskDialogIcon icon)
 {
     return InternalShow(IntPtr.Zero, title, instruction, content, buttons, icon);
 }
Ejemplo n.º 54
0
        private static Result InternalShow(IntPtr parent, string title, string instruction, string content, TaskDialogButton commonButtons, TaskDialogIcon icon)
        {
            int dlgValue;

            try {
                //Get handle for parent window if none specified (behave like MessageBox)
                if (parent == IntPtr.Zero)
                {
                    parent = Native.Windows.GetActiveWindow();
                }

                if (NativeMethods.TaskDialog(parent, IntPtr.Zero, title, instruction, content, (int)commonButtons, new IntPtr((long)icon), out dlgValue) != 0)
                {
                    throw new Exception(String.Format(Resources.ExceptionMessages.NativeCallFailure, "TaskDialog"));
                }
            }
            catch (EntryPointNotFoundException ex) {
                throw new Exception(Resources.ExceptionMessages.CommonControlEntryPointNotFound, ex);
            }
            catch (Exception ex) {
                throw new Exception(Resources.ExceptionMessages.TaskDialogFailure, ex);
            }

            //Convert int value to common dialog result
            if (dlgValue > 0 && dlgValue <= 8)
            {
                return((Result)dlgValue);
            }
            else
            {
                return(Result.None);
            }
        }
Ejemplo n.º 55
0
 /// <summary>
 /// Updates the footer icon. Note the type (standard via enum or
 /// custom via Icon type) must be used when upating the icon.
 /// </summary>
 /// <param name="icon">Task Dialog standard icon.</param>
 public void UpdateFooterIcon(TaskDialogIcon icon)
 {
     // TDM_UPDATE_ICON = WM_USER+116  // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
     UnsafeNativeMethods.SendMessage(
         this.handle,
         (uint)UnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_UPDATE_ICON,
         (IntPtr)UnsafeNativeMethods.TASKDIALOG_ICON_ELEMENTS.TDIE_ICON_FOOTER,
         (IntPtr)icon);
 }
Ejemplo n.º 56
0
        private static TaskDialogResult ShowInternal(IntPtr owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            int p;

            if (_TaskDialog(owner, IntPtr.Zero, caption, instruction, text, (int)buttons, new IntPtr((int)icon), out p) != 0)
            {
                throw new InvalidOperationException("Something weird has happened.");
            }

            switch (p)
            {
            case 1:
                return(TaskDialogResult.OK);

            case 2:
                return(TaskDialogResult.Cancel);

            case 4:
                return(TaskDialogResult.Retry);

            case 6:
                return(TaskDialogResult.Yes);

            case 7:
                return(TaskDialogResult.No);

            case 8:
                return(TaskDialogResult.Close);

            default:
                return(TaskDialogResult.None);
            }
        }
Ejemplo n.º 57
0
        static TaskDialogResult ShowInternal(Window window, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            IntPtr windowHandle = IntPtr.Zero;

            if (window != null)
            {
                WindowInteropHelper win = new WindowInteropHelper(window);
                windowHandle = win.Handle;
            }

            return TaskDialog(windowHandle, IntPtr.Zero, caption, instruction, text, buttons, icon);
        }
Ejemplo n.º 58
0
 public static TaskDialogResult Show(IWin32Window owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return(ShowInternal(owner.Handle, text, instruction, caption, buttons, icon));
 }
Ejemplo n.º 59
0
 public static TaskDialogResult Show(string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return ShowInternal(null, text, instruction, caption, buttons, icon);
 }
Ejemplo n.º 60
0
 public static TaskDialogResult Show(Window owner, string text, string instruction, string caption, TaskDialogButtons buttons, TaskDialogIcon icon)
 {
     return ShowInternal(new WindowInteropHelper(owner).Handle, text, instruction, caption, buttons, icon);
 }