Esempio n. 1
0
        public static bool ShowDialog(out Color color, ColorPickerDialogOptions flags = ColorPickerDialogOptions.None, string customPaletteName = null)
        {
            var instance = new ColorPickerWindow();

            color = instance.ColorPicker.Color;

            if ((flags & ColorPickerDialogOptions.SimpleView) == ColorPickerDialogOptions.SimpleView)
            {
                instance.ToggleSimpleAdvancedView();
            }

            if ((flags & ColorPickerDialogOptions.LoadCustomPalette) == ColorPickerDialogOptions.LoadCustomPalette)
            {
                if (!String.IsNullOrEmpty(customPaletteName))
                {
                    instance.ColorPicker.LoadCustomPalette(customPaletteName);
                    instance.FilenameTextBox.Text = customPaletteName;
                }
                else
                {
                    instance.ColorPicker.LoadDefaultCustomPalette();
                }
            }

            var result = instance.ShowDialog();

            if (result.HasValue && result.Value)
            {
                color = instance.ColorPicker.Color;
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public static bool ShowDialog(out Color color, ColorPickerDialogOptions flags = ColorPickerDialogOptions.None, string customPaletteName = null, Color?startColor = null, ColorPickerControl.ColorPickerChangeHandler customPreviewEventHandler = null)
        {
            var instance = new ColorPickerWindow();

            color = instance.ColorPicker.Color;

            if ((flags & ColorPickerDialogOptions.SimpleView) == ColorPickerDialogOptions.SimpleView)
            {
                instance.ToggleSimpleAdvancedView();
            }

            if ((flags & ColorPickerDialogOptions.LoadCustomPalette) == ColorPickerDialogOptions.LoadCustomPalette)
            {
                if (!String.IsNullOrEmpty(customPaletteName))
                {
                    instance.ColorPicker.LoadCustomPalette(customPaletteName);
                    instance.FilenameTextBox.Text = customPaletteName;
                }
                else
                {
                    instance.ColorPicker.LoadDefaultCustomPalette();
                }
            }

            if (startColor.HasValue)
            {
                instance.ColorPicker.SetColor(startColor.Value);
            }
            else
            {
                instance.ColorPicker.SetColor(Colors.White);
            }

            if (customPreviewEventHandler != null)
            {
                instance.ColorPicker.OnPickColor += customPreviewEventHandler;
            }

            var result = instance.ShowDialog();

            if (result.HasValue && result.Value)
            {
                color = instance.ColorPicker.Color;
                return(true);
            }

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

            var instance = new ColorPickerWindow();

            if (initialColor.HasValue)
            {
                instance.ColorPicker.SetColor(initialColor.Value);
            }
            color = instance.ColorPicker.Color;

            if ((flags & ColorPickerDialogOptions.SimpleView) == ColorPickerDialogOptions.SimpleView)
            {
                instance.ToggleSimpleAdvancedView();
            }

            if (ColorPickerSettings.UsingCustomPalette)
            {
                instance.ColorPicker.LoadDefaultCustomPalette();
            }

            if (customPreviewEventHandler != null)
            {
                instance.ColorPicker.OnPickColor += customPreviewEventHandler;
            }

            var result = instance.ShowDialog();

            if (result.HasValue && result.Value)
            {
                color = instance.ColorPicker.Color;
                return(true);
            }

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

            var instance = new ColorPickerWindow();

            instance.ColorPicker.Color = currentColor; //This should set the value, but it doesn't. Why?

            color = currentColor;

            if ((flags & ColorPickerDialogOptions.SimpleView) == ColorPickerDialogOptions.SimpleView)
            {
                instance.ToggleSimpleAdvancedView();
            }

            if (ColorPickerSettings.UsingCustomPalette)
            {
            }

            if (customPreviewEventHandler != null)
            {
                instance.ColorPicker.OnPickColor += customPreviewEventHandler;
            }

            var result = instance.ShowDialog();

            if (result.HasValue && result.Value)
            {
                color = instance.ColorPicker.Color;
                return(true);
            }

            return(false);
        }