Esempio n. 1
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;
                    }
                }
            }
        }
 // 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;
         }
     }
 }
Esempio n. 3
0
 private void whiteButton_Click(object sender, EventArgs e)
 {
     InternalColor = XYZ.FromRGB(new RGB(255, 255, 255));
     lblColorOut.Color = InternalColor.ToRGB();
     UpdatetbValue(null);
 }
Esempio n. 4
0
 private void _module_ColorChanged(object sender, EventArgs e)
 {
     if (_module == null) return;
     InternalColor = _module.XYZ;
     lblColorOut.Color = InternalColor.ToRGB();
     UpdatetbValue(null);
 }
Esempio n. 5
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;
                    }
                }
            }
        }