// Propagate SelectionChanged event void _palette_SelectionChanged(object sender, ColorPickerEventArgs e) { if (SelectionChanged != null) { SelectionChanged(this, e); } }
private void colorPickerSecondary_Click(object sender, ColorPickerEventArgs e) { colorDialog1.Color = colorPickerSecondary.Value; if (colorDialog1.ShowDialog() == DialogResult.OK) { SetSecondaryColor(colorDialog1.Color); } }
// Raise Click event protected void RaiseClickEvent() { if (Click != null) { ColorPickerEventArgs args = new ColorPickerEventArgs(); args.Value = Value; Click(this, args); } }
/// <summary> /// Updates the selected palette item. /// </summary> /// <param name="index">New palette index</param> /// <param name="scrollIntoView">Control will be scrolled so /// that new item is fully visible when true</param> protected void SetSelected(int index, bool scrollIntoView) { // Something to do only if item has changed if (index != _selected) { // Get update region if (_selected >= 0) { Invalidate(IndexToRectangle(_selected)); } if (index >= 0) { Rectangle rect = IndexToRectangle(index); Invalidate(rect); // Scroll if needed if (_autoScroll && scrollIntoView) { if (rect.Top < 0) { // Scroll up Point point = new Point(0, -AutoScrollPosition.Y); point.Y += (rect.Top - Margins); AutoScrollPosition = point; } else if (rect.Bottom >= ClientRectangle.Bottom) { // Scroll down Point point = new Point(0, -AutoScrollPosition.Y); point.Y += ((rect.Bottom - ClientRectangle.Bottom) + Margins); AutoScrollPosition = point; } } } // Update selected index _selected = index; // Raise SelectionChanged event if (SelectionChanged != null && _selected >= 0) { ColorPickerEventArgs args = new ColorPickerEventArgs(); args.Value = ColorItems[_selected]; SelectionChanged(this, args); } } }
// Propagate Click event void _palette_Click(object sender, ColorPickerEventArgs e) { Value = e.Value; _dropDown.Close(ToolStripDropDownCloseReason.ItemClicked); RaiseClickEvent(); }