public Swatch(string caption, Rectangle boundsValue, OnCmdEventHandler cmdEventHandler) { if (caption == null) { throw(new ArgumentException("'caption' should not be null.")); } if (cmdEventHandler == null) { throw(new ArgumentException("Event handler must not be empty.")); } this.colorValue = System.Drawing.Color.White; this.caption = caption; this.boundsValue = boundsValue; this.cmdEventHandler = cmdEventHandler; this.font = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold); this.isCmdValue = true; }
public void AddCmd(string caption, OnCmdEventHandler cmdEventHandler) { int left, top; int width, height; // Calculate horizontal extent of current swatches left = 0; foreach (Swatch swatch in this.swatchList) { left += swatch.Bounds.Width; } top = 0; width = Tray.CommandWidth; height = this.height; this.swatchList.Add(new Swatch(caption, new Rectangle(left, top, width, height), cmdEventHandler)); this.Invalidate(); }