Example #1
0
        private void DiscreteColorPicker_Load(object sender, EventArgs e)
        {
            if (ValidColors == null)
            {
                throw new Exception("Valid Colors not set");
            }

            if (_selectedColors == null)
            {
                _selectedColors = new List <Color>();
            }

            tableLayoutPanelColors.Controls.Clear();

            foreach (Color validColor in ValidColors)
            {
                DiscreteColorPickerItem control = new DiscreteColorPickerItem();
                control.Color           = validColor;
                control.SingleColorOnly = SingleColorOnly;
                if (_selectedColors.Any(x => x.ToArgb() == validColor.ToArgb()))
                {
                    control.Selected = true;
                }
                control.SelectedChanged += control_SelectedChanged;
                tableLayoutPanelColors.Controls.Add(control);
            }
            if (SingleColorOnly)
            {
                labelSelectPrompt.Text = "Select a discrete color.";
                this.Text = "Select Color";
            }
        }
Example #2
0
        private void control_SelectedChanged(object sender, EventArgs e)
        {
            if (!SingleColorOnly)
            {
                return;
            }

            DiscreteColorPickerItem dcpi = sender as DiscreteColorPickerItem;

            if (dcpi == null)
            {
                return;
            }

            if (!dcpi.Selected)
            {
                return;
            }

            foreach (Control control in tableLayoutPanelColors.Controls)
            {
                if (control != sender)
                {
                    (control as DiscreteColorPickerItem).Selected = false;
                }
            }
        }
Example #3
0
		private void DiscreteColorPicker_Load(object sender, EventArgs e)
		{
			if (ValidColors == null) {
				throw new Exception("Valid Colors not set");
			}

			if (_selectedColors == null) {
				_selectedColors = new List<Color>();
			}

			tableLayoutPanelColors.Controls.Clear();

			foreach (Color validColor in ValidColors) {
				DiscreteColorPickerItem control = new DiscreteColorPickerItem();
				control.Color = validColor;
				control.SingleColorOnly = SingleColorOnly;
				if (_selectedColors.Any(x => x.ToArgb() == validColor.ToArgb())) {
					control.Selected = true;
				}
				control.SelectedChanged += control_SelectedChanged;
				tableLayoutPanelColors.Controls.Add(control);
			}
		}