示例#1
0
        private void BnColourClick(object sender, RoutedEventArgs e)
        {
            // ColorPickerDialog comes from ColorPicker.dll, which comes from the Microsoft stable.
            // I know that CodeProject has some colour picker dialogs available, but I choose the
            // plain vanilla one from Microsoft, since our focus in this code is on providing a
            // vignette effect, and not a fancy colour dialog application.
            var cPicker = new ColorPickerDialog
                              {
                                  WindowStartupLocation = WindowStartupLocation.Manual,
                                  Top = Top + 200,
                                  Left = Width,
                                  Height = 169,
                                  ResizeMode = ResizeMode.NoResize,
                                  StartingColor = _borderColor,
                                  Owner = this
                              };
            // I deliberately set the height to be this, so as not to show the Opacity and other
            // colour text boxes in the dialog. I currently don't have the facility to change the
            // opacity of the image, and therefore I don't want users to change the opacity, and hence
            // report a bug saying that "opacity is not working". So, I don't show the opacity button at all
            // and further, I don't allow this colour picker dialog to be resized.

            if (cPicker.ShowDialog() != true) return;

            _borderColor = cPicker.SelectedColor;
            bnColour.Background = new SolidColorBrush(_borderColor);

            ApplyEffect();
        }
        private SolidColorBrush ChooseColor(String color)
        {
            ColorPickerDialog colorPicker = new ColorPickerDialog();
            colorPicker.Height = 425;
            Color actCol;
            try {
                actCol = (Color)ColorConverter.ConvertFromString(color);
            } catch {
                actCol = (Color)ColorConverter.ConvertFromString("#ffffffff");
            }
            colorPicker.StartingColor = actCol;

            bool? result = colorPicker.ShowDialog();

            if (result != null && (bool)result == true) {
                return new SolidColorBrush(colorPicker.SelectedColor);
            } else {
                return new SolidColorBrush(actCol);
            }
        }
        /// <summary>
        /// Selects the color of the font.
        /// </summary>
        private void SelectFontColor()
        {
            var cPicker = new ColorPickerDialog
                              {
                                  StartingColor = SelectedCategory.FontColor.ToColor()
                              };

            bool? dialogResult = cPicker.ShowDialog();
            if (dialogResult != null && (bool)dialogResult)
            {
                SelectedCategory.FontColor = cPicker.SelectedColor.ToString();
            }
        }
示例#4
0
 private void pageLoaded(object sender, RoutedEventArgs e)
 {
     w       = new ColorPickerDialog();
     w.Owner = Application.Current.MainWindow;
 }
示例#5
0
 void btnColorPicker_Click(object sender, RoutedEventArgs e)
 {
     ColorPickerDialog cp = new ColorPickerDialog();
     cp.Owner = this;
     cp.Left = Left + Width / 2 - cp.Width / 2;
     cp.Top = Top + Height / 2 - cp.Height / 2;
     if (cp.ShowDialog() == true)
     {
         txtCategoryColor.Text = cp.SelectedColor.ToString();
     }
 }
示例#6
0
        private SolidColorBrush SelectColor(MyEdit edit, TextRange range)
        {
            SolidColorBrush currentBrush = Brushes.Black;
            SolidColorBrush newBrush = null;
            if (range.GetPropertyValue(ForegroundProperty) != DependencyProperty.UnsetValue)
            {
                currentBrush = (SolidColorBrush)range.GetPropertyValue(ForegroundProperty);
            }

            ColorPickerDialog colorPicker = new ColorPickerDialog();
            colorPicker.Owner = this;

            colorPicker.cPicker.SelectedColor = currentBrush.Color;
            if (colorPicker.ShowDialog() == true)
            {
                newBrush = new SolidColorBrush(colorPicker.cPicker.SelectedColor);
                if (edit != null)
                {
                    edit.ApplyUndoAwarePropertyValue(range, ForegroundProperty, newBrush);
                }
                else
                {

                    ApplyUndoEnabledPropertyValue(OutlinerTree.SelectedItem, ForegroundProperty, newBrush);
                }
            }

            UpdateFontSettings(range);
            return newBrush;
        }
示例#7
0
        private SolidColorBrush SelectColor(BaseStyle activeStyle)
        {
            SolidColorBrush currentBrush = activeStyle.Foreground;
            if (currentBrush == null)
                currentBrush = DefaultForegroundBrush;

            SolidColorBrush newBrush = null;

            ColorPickerDialog colorPicker = new ColorPickerDialog();
            colorPicker.Owner = this;

            colorPicker.cPicker.SelectedColor = currentBrush.Color;
            if (colorPicker.ShowDialog() == true)
                newBrush = new SolidColorBrush(colorPicker.cPicker.SelectedColor);

            return newBrush;
        }
示例#8
0
        private bool PickColor(ref Color selectedColor)
        {
            ColorPickerDialog colorPicker = new ColorPickerDialog();
            colorPicker.Owner = this;

            colorPicker.cPicker.SelectedColor = selectedColor;
            if (colorPicker.ShowDialog() == true)
            {
                selectedColor = colorPicker.cPicker.SelectedColor;
                return true;
            }

            return false;
        }