private void bntGroup_Click(object sender, EventArgs e) { if (statusPaint.isSelectedShape) { statusPaint.isStart = true;// Shape lgroup = new GroupShape(); for (int i = 0; i < lShape.Count; i++) { if (lShape[i].isSelected) { if (lShape[i] is GroupShape) { for (int index = 0; index < lShape[i].lGroup.Count; index++) { Shape temp = lShape[i].lGroup[index]; lgroup.lGroup.Add(temp); } lShape[i].lGroup.Clear(); lShape.Remove(lShape[i]); i--; } else { lgroup.lGroup.Add(lShape[i]); lShape.Remove(lShape[i]); i--; } } } if (lgroup.lGroup.Count > 0) { FindRegion.regionOfGroup(lgroup); lgroup.isSelected = true; lShape.Add(lgroup); indexShapeSelected = lShape.Count - 1; } plMain.Refresh(); } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { pressControl = e.Control; this.plMain.Focus(); if (statusPaint.isSelectedShape) { switch (e.KeyCode) { case Keys.Delete: case Keys.Back: { bntEaser.PerformClick(); break; } default: { break; } } if (e.Shift) { if (indexShapeSelected != -1 && indexShapeSelected < lShape.Count && lShape[indexShapeSelected] is GroupShape) // unGroup { if (e.Control == true && e.KeyCode == Keys.G) { for (int i = 0; i < lShape[indexShapeSelected].lGroup.Count; i++) { Shape temp = lShape[indexShapeSelected].lGroup[i]; lShape.Add(temp); } lShape[indexShapeSelected].lGroup.Clear(); lShape.Remove(lShape[indexShapeSelected]); statusPaint.isSelectedOneShape = false; statusPaint.isStart = true; plMain.Refresh(); } } } else { if (e.Control == true && e.KeyCode == Keys.G) // Group { Shape lgroup = new GroupShape(); for (int i = 0; i < lShape.Count; i++) { if (lShape[i].isSelected) { if (lShape[i] is GroupShape) { for (int index = 0; index < lShape[i].lGroup.Count; index++) { Shape temp = lShape[i].lGroup[index]; lgroup.lGroup.Add(temp); } lShape[i].lGroup.Clear(); lShape.Remove(lShape[i]); i--; } else { lgroup.lGroup.Add(lShape[i]); lShape.Remove(lShape[i]); i--; } } } if (lgroup.lGroup.Count > 0) { FindRegion.regionOfGroup(lgroup); lgroup.isSelected = true; lShape.Add(lgroup); indexShapeSelected = lShape.Count - 1; } plMain.Refresh(); } } } }