/// <summary> /// Displays a <see cref="CustomColorDialog"/> in front of the specified WPF <see /// cref="WpfWindow"/> and with the specified WPF color initially selected.</summary> /// <param name="owner"> /// A WPF <see cref="WpfWindow"/> indicating the parent window of the dialog.</param> /// <param name="color"><para> /// The initially selected <see cref="WpfColor"/>. <see cref="WpfColors.Transparent"/> /// translates to <see cref="WpfColors.Black"/>. /// </para><para> /// On return, contains the current color selection if the dialog was dismissed by clicking /// <b>OK</b>; otherwise unchanged.</para></param> /// <returns> /// <c>true</c> if the <see cref="CustomColorDialog"/> was dismissed with a <see /// cref="DialogResult"/> of <see cref="DialogResult.OK"/>; otherwise, <c>false</c>. /// </returns> /// <remarks><para> /// If the <see cref="CustomColorDialog"/> was dismissed by clicking <b>OK</b>, <b>Show</b> /// stores the current color selection in the <paramref name="color"/> argument. /// </para><para> /// The current set of <see cref="ColorDialog.CustomColors"/> is stored in the static <see /// cref="CustomColorSet"/> property so that it can be restored when the next instance of /// the <b>CustomColorDialog</b> class is created.</para></remarks> public static bool Show(WpfWindow owner, ref WpfColor color) { using (CustomColorDialog dialog = new CustomColorDialog(color.ToGdiColor())) { DialogResult result = dialog.ShowDialog(new HwndWrapper(owner)); // retrieve selected and custom colors on OK if (result == DialogResult.OK) { color = dialog.Color.ToWpfColor(); CustomColorDialog.CustomColorSet = dialog.CustomColors; } return(result == DialogResult.OK); } }
/// <overloads> /// Displays a <see cref="CustomColorDialog"/> in front of the specified window and with the /// specified color initially selected.</overloads> /// <summary> /// Displays a <see cref="CustomColorDialog"/> in front of the specified Windows Forms <see /// cref="IWin32Window"/> and with the specified GDI+ color initially selected.</summary> /// <param name="owner"> /// A Windows Forms <see cref="IWin32Window"/> instance indicating the parent window of the /// dialog.</param> /// <param name="color"><para> /// The initially selected <see cref="Color"/>. <see cref="Color.Transparent"/> translates /// to <see cref="Color.Black"/>. /// </para><para> /// On return, contains the current color selection if the dialog was dismissed by clicking /// <b>OK</b>; otherwise unchanged.</para></param> /// <returns> /// A <see cref="DialogResult"/> value indicating how the <see cref="CustomColorDialog"/> /// was dismissed.</returns> /// <remarks><para> /// If the <see cref="CustomColorDialog"/> was dismissed by clicking <b>OK</b>, <b>Show</b> /// stores the current color selection in the <paramref name="color"/> argument. /// </para><para> /// The current set of <see cref="ColorDialog.CustomColors"/> is stored in the static <see /// cref="CustomColorSet"/> property so that it can be restored when the next instance of /// the <b>CustomColorDialog</b> class is created.</para></remarks> public static DialogResult Show(IWin32Window owner, ref Color color) { using (CustomColorDialog dialog = new CustomColorDialog(color)) { DialogResult result = dialog.ShowDialog(owner); // retrieve selected and custom colors on OK if (result == DialogResult.OK) { color = dialog.Color; CustomColorDialog.CustomColorSet = dialog.CustomColors; } return(result); } }