public void update(LedControl led, int address) { mode.Set(led.Mode.Get()); direction.Set(led.Direction.Get()); colorIndex = led.ColorIndex; this.address = address; }
public LedStore(LedControl led, int address) { mode = new LedControl.Modes(led.Mode.Get()); direction = new LedControl.Directions(led.Direction.Get()); colorIndex = led.ColorIndex; this.address = address; }
private void ledControl_MouseDown(object sender, MouseEventArgs e) { LedControl led = (LedControl)sender; ledIndex = int.Parse((string)(led.Tag)); led.Highlighted = true; isDragging = true; xLoc = xStart = xEnd = (int)(ledIndex % 16); yLoc = yStart = yEnd = (int)(ledIndex / 16); clearSelections(); }
public LedArray() { InitializeComponent(); foreach (Control c in tableLayoutPanel1.Controls) { if (c is LedControl) { LedControl led = (LedControl)c; int index = int.Parse((string)(led.Tag)); leds[index] = led; led.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ledControl_MouseMove); led.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ledControl_MouseDown); led.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ledControl_MouseUp); } } SetStyle(ControlStyles.OptimizedDoubleBuffer, true); }
public bool Compare(LedControl led, int address) { if (led.ColorIndex != colorIndex) { return(false); } if (this.address != address) { return(false); } if (led.Mode.Get() != mode.Get()) { return(false); } if (led.Direction.Get() != direction.Get()) { return(false); } return(true); }
private void ledControl_MouseMove(object sender, MouseEventArgs e) { if (isDragging) { LedControl led = (LedControl)sender; int xExtent = (int)e.X / led.Width; int yExtent = (int)e.Y / led.Height; if (e.X < 0) { xExtent -= 1; } if (e.Y < 0) { yExtent -= 1; } if (xExtent != xSpread || yExtent != ySpread) { xSpread = xExtent; ySpread = yExtent; xStart = xLoc; yStart = yLoc; xEnd = xStart + xSpread; if (xEnd < 0) { xEnd = 0; } if (xEnd > 15) { xEnd = 15; } if (xEnd < xStart) { xStart = xEnd; xEnd = xLoc; } yEnd = yStart + ySpread; if (yEnd < 0) { yEnd = 0; } if (yEnd > 15) { yEnd = 15; } if (yEnd < yStart) { yStart = yEnd; yEnd = yLoc; } for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { int ledAddress = y * 16 + x; if (x < xStart || x > xEnd || y < yStart || y > yEnd) { leds[ledAddress].Highlighted = false; } else { leds[ledAddress].Highlighted = true; } } } } } }