Exemplo n.º 1
0
        void IActiveTaskDialog.UpdateMainIcon(VistaTaskDialogIcon icon)
        {
            options.MainIcon = icon;

            RaisePropertyChangedEvent("MainIconType");
            RaisePropertyChangedEvent("MainIcon");
        }
Exemplo n.º 2
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(VistaTaskDialogIcon 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)
     VistaUnsafeNativeMethods.SendMessage(
         this.handle,
         (uint)VistaUnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_UPDATE_ICON,
         (IntPtr)VistaUnsafeNativeMethods.TASKDIALOG_ICON_ELEMENTS.TDIE_ICON_FOOTER,
         (IntPtr)icon);
 }
Exemplo n.º 3
0
        private TaskDialogResult showTaskDialog(string title, string mainIns, string Content, string[] buttons, string footer = "",
                                                VistaTaskDialogIcon mainIcon = VistaTaskDialogIcon.Information, VistaTaskDialogIcon footerIcon = VistaTaskDialogIcon.Information)
        {
            TaskDialogOptions config = new TaskDialogOptions();

            config.Owner           = this;
            config.Title           = title;
            config.MainInstruction = mainIns;
            config.Content         = Content;
            //config.ExpandedInfo = "Any expanded content text for the " +
            //                  "task dialog is shown here and the text " +
            //                  "will automatically wrap as needed.";
            //config.VerificationText = "Don't show me this message again";
            config.CustomButtons = buttons;  //new string[] { "&Save", "Do&n't save", "&Cancel" };
            config.MainIcon      = mainIcon; // VistaTaskDialogIcon.Shield;
            if (footer != "")
            {
                config.FooterText = footer;
                config.FooterIcon = footerIcon;
            }


            return(TaskDialog.Show(config));
        }
Exemplo n.º 4
0
        private System.Windows.Media.ImageSource ConvertIconToImageSource(VistaTaskDialogIcon icon, bool isLarge)
        {
            System.Windows.Media.ImageSource iconSource = null;
            System.Drawing.Icon sysIcon = null;
            System.Drawing.Bitmap altBmp = null;

            try
            {
                switch (icon)
                {
                    default:
                    case VistaTaskDialogIcon.None:
                        break;
                    case VistaTaskDialogIcon.Information:
                        sysIcon = System.Drawing.SystemIcons.Information;
                        break;
                    case VistaTaskDialogIcon.Warning:
                        sysIcon = System.Drawing.SystemIcons.Warning;
                        break;
                    case VistaTaskDialogIcon.Error:
                        sysIcon = System.Drawing.SystemIcons.Error;
                        break;
                    case VistaTaskDialogIcon.Shield:
                        if (isLarge)
                        {
                            altBmp = Properties.Resources.shield_32;
                        }
                        else
                        {
                            altBmp = Properties.Resources.shield_16;
                        }
                        break;
                }

                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
            {
                if (sysIcon != null)
                    sysIcon.Dispose();
                if (altBmp != null)
                    altBmp.Dispose();
            }

            return iconSource;
        }
Exemplo n.º 5
0
        private System.Windows.Media.ImageSource ConvertIconToImageSource(VistaTaskDialogIcon icon, Icon customIcon, bool isLarge)
        {
            System.Windows.Media.ImageSource iconSource = null;
            System.Drawing.Icon   sysIcon = null;
            System.Drawing.Bitmap altBmp  = null;

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

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

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

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

                case VistaTaskDialogIcon.Shield:
                    if (isLarge)
                    {
                        altBmp = Properties.Resources.shield_32;
                    }
                    else
                    {
                        altBmp = Properties.Resources.shield_16;
                    }
                    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);
        }
Exemplo n.º 6
0
        void IActiveTaskDialog.UpdateFooterIcon(VistaTaskDialogIcon icon)
        {
            options.FooterIcon = icon;

            RaisePropertyChangedEvent("FooterIcon");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="messageText">
        /// A <see cref="T:System.String"/> that specifies the text to display.
        /// </param>
        /// <param name="caption">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:TaskDialogInterop.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="icon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// icon to display.
        /// </param>
        /// <returns>
        /// A <see cref="T:TaskDialogInterop.TaskDialogSimpleResult"/> value that
        /// specifies which button is clicked by the user.
        /// </returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string messageText, string caption, TaskDialogCommonButtons buttons, VistaTaskDialogIcon icon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            options.Owner = owner;
            options.Title = caption;
            options.Content = messageText;
            options.CommonButtons = buttons;
            options.MainIcon = icon;

            return Show(options).Result;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="messageText">
        /// A <see cref="T:System.String"/> that specifies the text to display.
        /// </param>
        /// <param name="caption">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:TaskDialogInterop.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="icon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// icon to display.
        /// </param>
        /// <returns>
        /// A <see cref="T:TaskDialogInterop.TaskDialogSimpleResult"/> value that
        /// specifies which button is clicked by the user.
        /// </returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string messageText, string caption, TaskDialogCommonButtons buttons, VistaTaskDialogIcon icon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            options.Owner         = owner;
            options.Title         = caption;
            options.Content       = messageText;
            options.CommonButtons = buttons;
            options.MainIcon      = icon;

            return(Show(options).Result);
        }
		private System.Windows.Media.ImageSource ConvertIconToImageSource(VistaTaskDialogIcon icon, bool isLarge)
		{
			System.Windows.Media.ImageSource iconSource = null;
			System.Drawing.Icon sysIcon = null;
			System.Drawing.Bitmap altBmp = null;

			try
			{
				switch (icon)
				{
					default:
					case VistaTaskDialogIcon.None:
						break;
					case VistaTaskDialogIcon.Information:
						sysIcon = System.Drawing.SystemIcons.Information;
						break;
					case VistaTaskDialogIcon.Warning:
						sysIcon = System.Drawing.SystemIcons.Warning;
						break;
					case VistaTaskDialogIcon.Error:
						sysIcon = System.Drawing.SystemIcons.Error;
						break;
					case VistaTaskDialogIcon.Shield:
						if (isLarge)
						{
						    altBmp = new Bitmap(AssemblyHelper.GetEmbeddedResource("IExtendFramework.Controls.AdvancedMessageBox.Resources.shield-32.png"));
						}
						else
						{
						    altBmp = new Bitmap(AssemblyHelper.GetEmbeddedResource("IExtendFramework.Controls.AdvancedMessageBox.Resources.shield-16.png"));
						}
						break;
				}

				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
			{
				if (sysIcon != null)
					sysIcon.Dispose();
				if (altBmp != null)
					altBmp.Dispose();
			}

			return iconSource;
		}
Exemplo n.º 10
0
        private static void ShowSimpleBox(String mainInstruction, String text, String caption, VistaTaskDialogIcon icon)
        {
            TaskDialogOptions options = new TaskDialogOptions()
            {
                MainIcon        = icon,
                MainInstruction = mainInstruction,
                Content         = text,
                Title           = caption
            };

            TaskDialog.Show(options);
        }
Exemplo n.º 11
0
        void IActiveTaskDialog.UpdateFooterIcon(VistaTaskDialogIcon icon)
        {
            options.FooterIcon = icon;

            RaisePropertyChangedEvent("FooterIcon");
        }
Exemplo n.º 12
0
        void IActiveTaskDialog.UpdateMainIcon(VistaTaskDialogIcon icon)
        {
            options.MainIcon = icon;

            RaisePropertyChangedEvent("MainIconType");
            RaisePropertyChangedEvent("MainIcon");
        }
Exemplo n.º 13
0
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="title">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="mainInstruction">
        /// A <see cref="T:System.String"/> that specifies the main text to display.
        /// </param>
        /// <param name="content">
        /// A <see cref="T:System.String"/> that specifies the body text to display.
        /// </param>
        /// <param name="expandedInfo">
        /// A <see cref="T:System.String"/> that specifies the expanded text to display when toggled.
        /// </param>
        /// <param name="verificationText">
        /// A <see cref="T:System.String"/> that specifies the text to display next to a checkbox.
        /// </param>
        /// <param name="footerText">
        /// A <see cref="T:System.String"/> that specifies the footer text to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:TaskDialogInterop.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="mainIcon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// main icon to display.
        /// </param>
        /// <param name="footerIcon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// footer icon to display.
        /// </param>
        /// <returns></returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string title, string mainInstruction, string content, string expandedInfo, string verificationText, string footerText, TaskDialogCommonButtons buttons, VistaTaskDialogIcon mainIcon, VistaTaskDialogIcon footerIcon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            if (owner != null)
            {
                options.Owner = owner;
            }
            if (!String.IsNullOrEmpty(title))
            {
                options.Title = title;
            }
            if (!String.IsNullOrEmpty(mainInstruction))
            {
                options.MainInstruction = mainInstruction;
            }
            if (!String.IsNullOrEmpty(content))
            {
                options.Content = content;
            }
            if (!String.IsNullOrEmpty(expandedInfo))
            {
                options.ExpandedInfo = expandedInfo;
            }
            if (!String.IsNullOrEmpty(verificationText))
            {
                options.VerificationText = verificationText;
            }
            if (!String.IsNullOrEmpty(footerText))
            {
                options.FooterText = footerText;
            }
            options.CommonButtons = buttons;
            options.MainIcon      = mainIcon;
            options.FooterIcon    = footerIcon;

            return(Show(options).Result);
        }
Exemplo n.º 14
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 = VistaTaskDialogIcon.None;
     this.customMainIcon = null;
     this.footerIcon = VistaTaskDialogIcon.None;
     this.customFooterIcon = null;
     this.buttons = new VistaTaskDialogButton[0];
     this.radioButtons = new VistaTaskDialogButton[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;
 }
Exemplo n.º 15
0
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="title">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="mainInstruction">
        /// A <see cref="T:System.String"/> that specifies the main text to display.
        /// </param>
        /// <param name="content">
        /// A <see cref="T:System.String"/> that specifies the body text to display.
        /// </param>
        /// <param name="expandedInfo">
        /// A <see cref="T:System.String"/> that specifies the expanded text to display when toggled.
        /// </param>
        /// <param name="verificationText">
        /// A <see cref="T:System.String"/> that specifies the text to display next to a checkbox.
        /// </param>
        /// <param name="footerText">
        /// A <see cref="T:System.String"/> that specifies the footer text to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:TaskDialogInterop.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="mainIcon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// main icon to display.
        /// </param>
        /// <param name="footerIcon">
        /// A <see cref="T:TaskDialogInterop.VistaTaskDialogIcon"/> that specifies the
        /// footer icon to display.
        /// </param>
        /// <returns></returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string title, string mainInstruction, string content, string expandedInfo, string verificationText, string footerText, TaskDialogCommonButtons buttons, VistaTaskDialogIcon mainIcon, VistaTaskDialogIcon footerIcon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            if (owner != null)
                options.Owner = owner;
            if (!String.IsNullOrEmpty(title))
                options.Title = title;
            if (!String.IsNullOrEmpty(mainInstruction))
                options.MainInstruction = mainInstruction;
            if (!String.IsNullOrEmpty(content))
                options.Content = content;
            if (!String.IsNullOrEmpty(expandedInfo))
                options.ExpandedInfo = expandedInfo;
            if (!String.IsNullOrEmpty(verificationText))
                options.VerificationText = verificationText;
            if (!String.IsNullOrEmpty(footerText))
                options.FooterText = footerText;
            options.CommonButtons = buttons;
            options.MainIcon = mainIcon;
            options.FooterIcon = footerIcon;

            return Show(options).Result;
        }
Exemplo n.º 16
0
 /// <summary>
 /// Updates the main instruction 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 UpdateMainIcon(VistaTaskDialogIcon 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)
     VistaUnsafeNativeMethods.SendMessage(
         this.handle,
         (uint)VistaUnsafeNativeMethods.TASKDIALOG_MESSAGES.TDM_UPDATE_ICON,
         (IntPtr)VistaUnsafeNativeMethods.TASKDIALOG_ICON_ELEMENTS.TDIE_ICON_MAIN,
         (IntPtr)icon);
 }
Exemplo n.º 17
0
        private System.Windows.Media.ImageSource ConvertIconToImageSource(VistaTaskDialogIcon icon, bool isLarge)
        {
            System.Windows.Media.ImageSource iconSource = null;
            System.Drawing.Icon   sysIcon = null;
            System.Drawing.Bitmap altBmp  = null;

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

                case VistaTaskDialogIcon.Information:
                    sysIcon = System.Drawing.SystemIcons.Information;
                    break;

                case VistaTaskDialogIcon.Warning:
                    sysIcon = System.Drawing.SystemIcons.Warning;
                    break;

                case VistaTaskDialogIcon.Error:
                    sysIcon = System.Drawing.SystemIcons.Error;
                    break;

                case VistaTaskDialogIcon.Shield:
                    if (isLarge)
                    {
                        altBmp = new Bitmap(AssemblyHelper.GetEmbeddedResource("IExtendFramework.Controls.AdvancedMessageBox.Resources.shield-32.png"));
                    }
                    else
                    {
                        altBmp = new Bitmap(AssemblyHelper.GetEmbeddedResource("IExtendFramework.Controls.AdvancedMessageBox.Resources.shield-16.png"));
                    }
                    break;
                }

                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
            {
                if (sysIcon != null)
                {
                    sysIcon.Dispose();
                }
                if (altBmp != null)
                {
                    altBmp.Dispose();
                }
            }

            return(iconSource);
        }