Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT - add seedColor parameter to ShowDialog #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ColorPickerWPF/ColorPickRow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ColorPickRow()
private void PickColorButton_OnClick(object sender, RoutedEventArgs e)
{
Color color;
if (ColorPickerWindow.ShowDialog(out color, Options))
if (ColorPickerWindow.ShowDialog(out color, seedColor: Color, flags: Options))
{
SetColor(color);
OnPick?.Invoke(this, EventArgs.Empty);
Expand Down
3 changes: 2 additions & 1 deletion src/ColorPickerWPF/ColorPickerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ public ColorPickerWindow()
InitializeComponent();
}

public static bool ShowDialog(out Color color, ColorPickerDialogOptions flags = ColorPickerDialogOptions.None, ColorPickerControl.ColorPickerChangeHandler customPreviewEventHandler = null)
public static bool ShowDialog(out Color color, Color? seedColor = null, ColorPickerDialogOptions flags = ColorPickerDialogOptions.None, ColorPickerControl.ColorPickerChangeHandler customPreviewEventHandler = null)
{
if ((flags & ColorPickerDialogOptions.LoadCustomPalette) == ColorPickerDialogOptions.LoadCustomPalette)
{
ColorPickerSettings.UsingCustomPalette = true;
}

var instance = new ColorPickerWindow();
instance.ColorPicker.SetColor(seedColor ?? Colors.White);
color = instance.ColorPicker.Color;

if ((flags & ColorPickerDialogOptions.SimpleView) == ColorPickerDialogOptions.SimpleView)
Expand Down