Ejemplo n.º 1
0
        public BorderControl()
        {
            InitializeComponent();

            _vm         = new BorderControlViewModel();
            DataContext = _vm;

            _vm.ColorPickCommand = new RelayCommand(o =>
            {
                ColorPickerControl.ColorPickerChangeHandler previewHandler =
                    selectedColor => RaiseEvent(new ColorSelectedEvent(TintSelectedEvent, selectedColor));

                Color color;
                bool ok = SettingsManager.LiveColorPreview
                    ? ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.SelectColor, previewHandler)
                    : ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.SelectColor);

                if (ok)
                {
                    _vm.SelectColor = color;
                }

                RaiseEvent(new ColorSelectedEvent(TintSelectedEvent, _vm.SelectColor));
            });
        }
        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();

            instance.ColorPicker.SetColor(initialColor ?? Colors.White);
            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, ColorPickerControl.ColorPickerChangeHandler customPreviewEventHandler = null)
        {
            var instance = new ColorPickerWindow();

            color = instance.ColorPicker.Color;

            instance.Width = instance.WidthMax;

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

            var result = instance.ShowDialog();

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

            return(false);
        }
Ejemplo n.º 4
0
        public static bool ShowDialog(out Color color, ColorPickerDialogOptions flags = ColorPickerDialogOptions.None, string customPaletteName = 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 (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);
        }
Ejemplo n.º 6
0
        public SpecialControl()
        {
            InitializeComponent();
            _vm         = new SpecialControlViewModel();
            DataContext = _vm;

            _vm.ColorPickCommand = new RelayCommand(o =>
            {
                ColorPickerControl.ColorPickerChangeHandler previewHandler =
                    selectedColor => RaiseEvent(new ColorSelectedEvent(TextManipulationChangedEvent, selectedColor));

                Color color;
                bool ok = SettingsManager.LiveColorPreview
                    ? ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.TextColor, previewHandler)
                    : ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.TextColor);

                if (ok)
                {
                    _vm.TextColor = color;
                }

                RaiseEvent(new ColorSelectedEvent(TextManipulationChangedEvent, _vm.TextColor));
            });

            _vm.BackdropColorPickCommand = new RelayCommand(o =>
            {
                ColorPickerControl.ColorPickerChangeHandler previewHandler =
                    selectedColor => RaiseEvent(new ColorSelectedEvent(BackdropColorChangedEvent, selectedColor));

                Color color;
                bool ok = SettingsManager.LiveColorPreview
                    ? ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.BackdropColor, previewHandler)
                    : ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.BackdropColor);

                if (ok)
                {
                    _vm.BackdropColor = color;
                }

                RaiseEvent(new ColorSelectedEvent(BackdropColorChangedEvent, _vm.BackdropColor));
            });

            _vm.SpecialFilterColorPickCommand = new RelayCommand(o =>
            {
                ColorPickerControl.ColorPickerChangeHandler previewHandler =
                    selectedColor => RaiseEvent(new ColorSelectedEvent(SpecialFilterColorChangedEvent, selectedColor));

                Color color;
                bool ok = SettingsManager.LiveColorPreview
                    ? ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.SpecialFilterColor, previewHandler)
                    : ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.None, null, _vm.SpecialFilterColor);

                if (ok)
                {
                    _vm.SpecialFilterColor = color;
                }

                RaiseEvent(new ColorSelectedEvent(SpecialFilterColorChangedEvent, _vm.SpecialFilterColor));
            });

            _vm.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(_vm.RotationAngle))
                {
                    if (int.TryParse(_vm.RotationAngle, out int rotationAngle))
                    {
                        RaiseEvent(new RotationChangedEvent(RotationChangedEvent, rotationAngle));
                    }
                }
                if (args.PropertyName == nameof(_vm.TextManipulationShowBorder) ||
                    args.PropertyName == nameof(_vm.TextManipulationShowText) ||
                    args.PropertyName == nameof(_vm.TextRotationAngle) ||
                    args.PropertyName == nameof(_vm.TextContent))
                {
                    int.TryParse(_vm.TextRotationAngle, out int textRotationAngle);

                    var textChangedEvent = new TextManipulationEvent(
                        TextManipulationChangedEvent,
                        _vm.TextManipulationShowBorder,
                        _vm.TextManipulationShowText,
                        _vm.TextContent,
                        textRotationAngle
                        );
                    RaiseEvent(textChangedEvent);
                }
            };
            _vm.ManualZoomImage = new RelayCommand(o =>
            {
                RaiseEvent(new ButtonZoomEvent(ButtonZoomEvent, int.Parse(o.ToString()), Events.ButtonZoomEvent.Target.Image));
            });
            _vm.ManualZoomText = new RelayCommand(o =>
            {
                RaiseEvent(new ButtonZoomEvent(ButtonZoomEvent, int.Parse(o.ToString()), Events.ButtonZoomEvent.Target.Text));
            });
        }