private Bitmap penImageFromInfo(penInfo p) { if (surface != null) { return(getPenImage(surface.getPenImage(p.size, p.size, p.color, p.type, 1.0))); } else { return(new Bitmap(16, 16)); } }
private void pen1Btn_SelectionChanged(object sender, EventArgs <int, bool> e) { if (((bitmapSwitchButton)sender).data != null) { switchingPen = true; ((bitmapSwitchButton)sender).selected = true; penInfo p = (penInfo)((bitmapSwitchButton)sender).data; colourBtn.BackColor = p.color; typeSelect.SelectedIndex = (int)p.type - 1; sizeSelect.Value = p.size; if (this.surface != null) { this.surface.setPen(p.size, p.color, p.type); updateCurrentPenImage(); } switchingPen = false; } }
public void Attach(OverlayPaintArea surface) { if (this.surface != null) { this.surface.ctrls = null; } this.surface = surface; this.surface.ctrls = this; pen1Btn.Image = penImageFromInfo((penInfo)pen1Btn.data); pen2Btn.Image = penImageFromInfo((penInfo)pen2Btn.data); pen3Btn.Image = penImageFromInfo((penInfo)pen3Btn.data); pen4Btn.Image = penImageFromInfo((penInfo)pen4Btn.data); pen5Btn.Image = penImageFromInfo((penInfo)pen5Btn.data); pen6Btn.Image = penImageFromInfo((penInfo)pen6Btn.data); pen7Btn.Image = penImageFromInfo((penInfo)pen7Btn.data); penInfo p = (penInfo)pen1Btn.data; this.surface.setPen(p.size, p.color, p.type); onLayersChanged(null, null); surface.onLayersChanged = new EventHandler(onLayersChanged); //updateCurrentPenImage(); }
private bool settingPenInfo = false; // to block onPenUpdated wnen it's jut a set change public void SetPenBtnInfo(int index, int size, Color colour, OverlayPaintArea.penType type) { penInfo tmpInfo = new penInfo(size, colour, type); Bitmap tmpImg = penImageFromInfo(tmpInfo); bool isSel = false; switch (index) { case 1: pen1Btn.data = tmpInfo; pen1Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen1Btn) { isSel = true; } break; case 2: pen2Btn.data = tmpInfo; pen2Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen2Btn) { isSel = true; } break; case 3: pen3Btn.data = tmpInfo; pen3Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen3Btn) { isSel = true; } break; case 4: pen4Btn.data = tmpInfo; pen4Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen4Btn) { isSel = true; } break; case 5: pen5Btn.data = tmpInfo; pen5Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen5Btn) { isSel = true; } break; case 6: pen6Btn.data = tmpInfo; pen6Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen6Btn) { isSel = true; } break; case 7: pen7Btn.data = tmpInfo; pen7Btn.Image = tmpImg; if (pen1Btn.getSelected() == pen7Btn) { isSel = true; } break; } if ((surface != null) && (isSel)) { this.surface.setPen(size, colour, type); settingPenInfo = true; colourBtn.BackColor = colour; typeSelect.SelectedIndex = (int)type - 1; sizeSelect.Value = size; settingPenInfo = false; } }