示例#1
0
        public DialogResult ShowDialog(IWin32Window owner)
        {
            DialogResult res = DialogResult.Cancel;

            using (ColorPicker frm = new ColorPicker(_mode, _fader))
            {
                frm.Color = ColorModels.XYZ.FromRGB(_color);
                res       = frm.ShowDialog(owner);
                if (res == DialogResult.OK)
                {
                    _color = frm.Color.ToRGB();
                    _mode  = frm.SecondaryMode;
                    _fader = frm.PrimaryFader;
                }
            }
            return(res);
        }
        // edits the selected color in the 'edit' control
        private void editSelectedColor()
        {
            if (edit.Gradient == null || edit.FocusSelection)
            {
                return;
            }
            ColorPoint pt = edit.Selection as ColorPoint;

            if (pt == null)
            {
                return;
            }
            using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
                frm.LockValue_V = LockColorEditorHSV_Value;
                frm.Color       = _xyz;
                if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    pt.Color             = _xyz = frm.Color;
                    lblColorSelect.Color = _xyz.ToRGB().ToArgb();
                    _mode  = frm.SecondaryMode;
                    _fader = frm.PrimaryFader;
                }
            }
        }
示例#3
0
        // edits the selected color in the 'edit' control
        private void editSelectedPoints()
        {
            if (edit.Gradient == null || edit.FocusSelection)
                return;

            if (DiscreteColors) {
                List<Color> selectedColors = new List<Color>();
                foreach (ColorGradient.Point point in edit.Selection) {
                    ColorPoint pt = point as ColorPoint;
                    if (pt == null)
                        continue;
                    selectedColors.Add(pt.Color.ToRGB().ToArgb());
                }

                using (DiscreteColorPicker picker = new DiscreteColorPicker()) {
                    picker.ValidColors = ValidDiscreteColors;
                    picker.SelectedColors = selectedColors;
                    if (picker.ShowDialog() == DialogResult.OK) {
                        if (picker.SelectedColors.Count() == 0) {
                            DeleteColor();
                        }
                        else if (picker.SelectedColors.Count() == selectedColors.Count) {
                            int i = 0;
                            foreach (Color selectedColor in picker.SelectedColors) {
                                ColorPoint pt = edit.Selection[i] as ColorPoint;
                                pt.Color = XYZ.FromRGB(selectedColor);
                            }
                        }
                        else {
                            double position = edit.Selection.First().Position;

                            foreach (ColorGradient.Point point in edit.Selection) {
                                edit.Gradient.Colors.Remove(point as ColorPoint);
                            }

                            foreach (Color selectedColor in picker.SelectedColors) {
                                ColorPoint newPoint = new ColorPoint(selectedColor, position);
                                edit.Gradient.Colors.Add(newPoint);
                            }
                        }
                    }
                }
            }
            else {
                if (edit.Selection.Count > 1)
                    MessageBox.Show("Non-discrete color gradient, >1 selected point. oops! please report it.");
                ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint;
                if (pt == null)
                    return;
                using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
                    frm.LockValue_V = LockColorEditorHSV_Value;
                    frm.Color = _xyz;
                    if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) {
                        pt.Color = _xyz = frm.Color;
                        lblColorSelect.Color = _xyz.ToRGB().ToArgb();
                        _mode = frm.SecondaryMode;
                        _fader = frm.PrimaryFader;
                    }
                }
            }
        }
示例#4
0
        private void ShowColorPicker()
        {
            //Logging.Debug("Enter color picker");
            var value = GetColorGradientValue();

            if (value == null)
            {
                return;
            }
            var selectedIndex = SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }
            var           handle            = _points[selectedIndex];
            var           colorPointIndexes = (List <int>)handle.Tag;
            ColorGradient holdValue;

            if (IsDiscrete)
            {
                holdValue = new ColorGradient(value);
                List <Color>      selectedColors = new List <Color>();
                List <ColorPoint> colorPoints    = new List <ColorPoint>();
                foreach (int index in colorPointIndexes)
                {
                    ColorPoint pt = holdValue.Colors[index];
                    if (pt == null)
                    {
                        continue;
                    }
                    colorPoints.Add(pt);
                    selectedColors.Add(pt.Color.ToRGB().ToArgb());
                }

                using (DiscreteColorPicker picker = new DiscreteColorPicker())
                {
                    picker.ValidColors    = ValidColors;
                    picker.SelectedColors = selectedColors;
                    if (picker.ShowDialog() == DialogResult.OK)
                    {
                        if (!picker.SelectedColors.Any())
                        {
                            DeletePoint();
                        }
                        else
                        {
                            double position = colorPoints.First().Position;
                            foreach (var colorPoint in colorPoints)
                            {
                                holdValue.Colors.Remove(colorPoint);
                            }

                            foreach (Color selectedColor in picker.SelectedColors)
                            {
                                ColorPoint newPoint = new ColorPoint(selectedColor, position);
                                holdValue.Colors.Add(newPoint);
                            }
                            SetColorGradientValue(holdValue);
                        }
                    }
                }
            }
            else
            {
                if (colorPointIndexes.Count > 1)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false);
                    messageBox.ShowDialog();
                }

                holdValue = new ColorGradient(value);
                ColorPoint pt = holdValue.Colors[colorPointIndexes.FirstOrDefault()];
                if (pt == null)
                {
                    return;
                }
                using (ColorPicker frm = new ColorPicker(_mode, _fader))
                {
                    frm.LockValue_V = false;
                    frm.Color       = pt.Color;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        pt.Color = frm.Color;
                        _mode    = frm.SecondaryMode;
                        _fader   = frm.PrimaryFader;
                        SetColorGradientValue(holdValue);
                    }
                }
            }
            //Logging.Debug("Exit normally color picker");
        }
 // edits the selected color in the 'edit' control
 private void editSelectedColor()
 {
     if (edit.Gradient == null || edit.FocusSelection)
         return;
     ColorPoint pt = edit.Selection as ColorPoint;
     if (pt == null)
         return;
     using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
         frm.LockValue_V = LockColorEditorHSV_Value;
         frm.Color = _xyz;
         if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) {
             pt.Color = _xyz = frm.Color;
             lblColorSelect.Color = _xyz.ToRGB().ToArgb();
             _mode = frm.SecondaryMode;
             _fader = frm.PrimaryFader;
         }
     }
 }
示例#6
0
        // edits the selected color in the 'edit' control
        private void editSelectedPoints()
        {
            if (edit.Gradient == null || edit.FocusSelection)
            {
                return;
            }

            if (DiscreteColors)
            {
                List <Color> selectedColors = new List <Color>();
                foreach (ColorGradient.Point point in edit.Selection)
                {
                    ColorPoint pt = point as ColorPoint;
                    if (pt == null)
                    {
                        continue;
                    }
                    selectedColors.Add(pt.Color.ToRGB().ToArgb());
                }

                using (DiscreteColorPicker picker = new DiscreteColorPicker()) {
                    picker.ValidColors    = ValidDiscreteColors;
                    picker.SelectedColors = selectedColors;
                    if (picker.ShowDialog() == DialogResult.OK)
                    {
                        if (picker.SelectedColors.Count() == 0)
                        {
                            DeleteColor();
                        }
                        else if (picker.SelectedColors.Count() == selectedColors.Count)
                        {
                            int i = 0;
                            foreach (Color selectedColor in picker.SelectedColors)
                            {
                                ColorPoint pt = edit.Selection[i] as ColorPoint;
                                pt.Color = XYZ.FromRGB(selectedColor);
                            }
                        }
                        else
                        {
                            double position = edit.Selection.First().Position;

                            foreach (ColorGradient.Point point in edit.Selection)
                            {
                                edit.Gradient.Colors.Remove(point as ColorPoint);
                            }

                            foreach (Color selectedColor in picker.SelectedColors)
                            {
                                ColorPoint newPoint = new ColorPoint(selectedColor, position);
                                edit.Gradient.Colors.Add(newPoint);
                            }
                        }
                    }
                }
            }
            else
            {
                if (edit.Selection.Count > 1)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false);
                    messageBox.ShowDialog();
                }
                ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint;
                if (pt == null)
                {
                    return;
                }
                using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
                    frm.LockValue_V = LockColorEditorHSV_Value;
                    frm.Color       = _xyz;
                    if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
                    {
                        pt.Color             = _xyz = frm.Color;
                        lblColorSelect.Color = _xyz.ToRGB().ToArgb();
                        _mode  = frm.SecondaryMode;
                        _fader = frm.PrimaryFader;
                    }
                }
            }
        }
        // edits the selected color in the 'edit' control
        private void editSelectedPoints()
        {
            if (edit.Gradient == null || edit.FocusSelection)
            {
                return;
            }

            if (DiscreteColors)
            {
                List <Color> selectedColors = new List <Color>();
                foreach (ColorGradient.Point point in edit.Selection)
                {
                    ColorPoint pt = point as ColorPoint;
                    if (pt == null)
                    {
                        continue;
                    }
                    selectedColors.Add(pt.Color.ToRGB().ToArgb());
                }

                using (DiscreteColorPicker picker = new DiscreteColorPicker()) {
                    picker.ValidColors    = ValidDiscreteColors;
                    picker.SelectedColors = selectedColors;
                    if (picker.ShowDialog() == DialogResult.OK)
                    {
                        if (picker.SelectedColors.Count() == 0)
                        {
                            DeleteColor();
                        }
                        else if (picker.SelectedColors.Count() == selectedColors.Count)
                        {
                            int i = 0;
                            foreach (Color selectedColor in picker.SelectedColors)
                            {
                                ColorPoint pt = edit.Selection[i] as ColorPoint;
                                pt.Color = XYZ.FromRGB(selectedColor);
                            }
                        }
                        else
                        {
                            double position = edit.Selection.First().Position;

                            foreach (ColorGradient.Point point in edit.Selection)
                            {
                                edit.Gradient.Colors.Remove(point as ColorPoint);
                            }

                            foreach (Color selectedColor in picker.SelectedColors)
                            {
                                ColorPoint newPoint = new ColorPoint(selectedColor, position);
                                edit.Gradient.Colors.Add(newPoint);
                            }
                        }
                    }
                }
            }
            else
            {
                if (edit.Selection.Count > 1)
                {
                    MessageBox.Show("Non-discrete color gradient, >1 selected point. oops! please report it.");
                }
                ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint;
                if (pt == null)
                {
                    return;
                }
                using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
                    frm.LockValue_V = LockColorEditorHSV_Value;
                    frm.Color       = _xyz;
                    if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
                    {
                        pt.Color             = _xyz = frm.Color;
                        lblColorSelect.Color = _xyz.ToRGB().ToArgb();
                        _mode  = frm.SecondaryMode;
                        _fader = frm.PrimaryFader;
                    }
                }
            }
        }
示例#8
0
        // edits the selected color in the 'edit' control
        private void editSelectedPoints()
        {
            if (edit.Gradient == null || edit.FocusSelection)
                return;

            if (DiscreteColors) {
                List<Color> selectedColors = new List<Color>();
                foreach (ColorGradient.Point point in edit.Selection) {
                    ColorPoint pt = point as ColorPoint;
                    if (pt == null)
                        continue;
                    selectedColors.Add(pt.Color.ToRGB().ToArgb());
                }

                using (DiscreteColorPicker picker = new DiscreteColorPicker()) {
                    picker.ValidColors = ValidDiscreteColors;
                    picker.SelectedColors = selectedColors;
                    if (picker.ShowDialog() == DialogResult.OK) {
                        if (picker.SelectedColors.Count() == 0) {
                            DeleteColor();
                        }
                        else if (picker.SelectedColors.Count() == selectedColors.Count) {
                            int i = 0;
                            foreach (Color selectedColor in picker.SelectedColors) {
                                ColorPoint pt = edit.Selection[i] as ColorPoint;
                                pt.Color = XYZ.FromRGB(selectedColor);
                            }
                        }
                        else {
                            double position = edit.Selection.First().Position;

                            foreach (ColorGradient.Point point in edit.Selection) {
                                edit.Gradient.Colors.Remove(point as ColorPoint);
                            }

                            foreach (Color selectedColor in picker.SelectedColors) {
                                ColorPoint newPoint = new ColorPoint(selectedColor, position);
                                edit.Gradient.Colors.Add(newPoint);
                            }
                        }
                    }
                }
            }
            else {
                if (edit.Selection.Count > 1)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Non-discrete color gradient, >1 selected point. oops! please report it.", "Delete library gradient?", false, false);
                    messageBox.ShowDialog();
                }
                ColorPoint pt = edit.Selection.FirstOrDefault() as ColorPoint;
                if (pt == null)
                    return;
                using (ColorPicker frm = new ColorPicker(_mode, _fader)) {
                    frm.LockValue_V = LockColorEditorHSV_Value;
                    frm.Color = _xyz;
                    if (frm.ShowDialog(this.FindForm()) == DialogResult.OK) {
                        pt.Color = _xyz = frm.Color;
                        lblColorSelect.Color = _xyz.ToRGB().ToArgb();
                        _mode = frm.SecondaryMode;
                        _fader = frm.PrimaryFader;
                    }
                }
            }
        }