private void panelCross_MouseMove(object sender, MouseEventArgs e) { if (mouseSelection == null) { return; } if (mouseSelection.Button != e.Button) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } var pos = GetMousePosition(e.Location); if (pos == null) { return; } if (mouseSelection.End == pos.Value) { return; } mouseSelection.End = pos.Value; //TODO partial invalidate need panelCross.Invalidate(); }
private void panelCross_MouseUp(object sender, MouseEventArgs e) { if (mouseSelection == null) { return; } if (mouseSelection.Button != e.Button) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } int x1 = Math.Min(mouseSelection.Begin.X, mouseSelection.End.X), x2 = Math.Max(mouseSelection.Begin.X, mouseSelection.End.X), y1 = Math.Min(mouseSelection.Begin.Y, mouseSelection.End.Y), y2 = Math.Max(mouseSelection.Begin.Y, mouseSelection.End.Y); for (int i = x1; i <= x2; i++) { for (int j = y1; j <= y2; j++) { cross.SetCell(i, j, mouseSelection.NewCellState); } } cross.HistoryNextStep(); mouseSelection = null; if (!editorMode) { //TODO need async update cross.CheckLines(); } else { var oldSize = new Size(cross.MaxCountTop, cross.MaxCountLeft); cross.CalcLines(); var newSize = new Size(cross.MaxCountTop, cross.MaxCountLeft); if (oldSize != newSize) { UpdateSize(); } } UpdateBtnState(); //TODO partial invalidate need panelCross.Invalidate(); }
private void panelCross_MouseDown(object sender, MouseEventArgs e) { // 1. pressed other button // 2. pressed not left or not right button or pressed more than one button // then cancel selection if ((mouseSelection != null && mouseSelection.Button != e.Button) || (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } // mouse position outgoing of the map, ignore var pos = GetMousePosition(e.Location); if (pos == null) { return; } var newCellState = (e.Button == MouseButtons.Left) ? Cross.CellState.Fill : (e.Button == MouseButtons.Right) ? Cross.CellState.Dot : Cross.CellState.Unknown; if (!editorMode) { // if oldCellState == newCellState then cells must be cleaned newCellState = (cross.GetCell(pos.Value.X, pos.Value.Y) == newCellState) ? Cross.CellState.Unknown : newCellState; } mouseSelection = new MouseGroupSelection { Button = e.Button, NewCellState = newCellState, Begin = pos.Value, End = pos.Value }; //TODO more partial invalidation need panelCross.Invalidate(new Rectangle(e.X - scaleSize, e.Y - scaleSize, scaleSize * 2, scaleSize * 2)); }
private void panelCross_MouseUp(object sender, MouseEventArgs e) { if (mouseSelection == null) return; if (mouseSelection.Button != e.Button) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } int x1 = Math.Min(mouseSelection.Begin.X, mouseSelection.End.X), x2 = Math.Max(mouseSelection.Begin.X, mouseSelection.End.X), y1 = Math.Min(mouseSelection.Begin.Y, mouseSelection.End.Y), y2 = Math.Max(mouseSelection.Begin.Y, mouseSelection.End.Y); for (int i = x1; i <= x2; i++) for (int j = y1; j <= y2; j++) cross.SetCell(i, j, mouseSelection.NewCellState); cross.HistoryNextStep(); mouseSelection = null; if (!editorMode) { //TODO need async update cross.CheckLines(); } else { var oldSize = new Size(cross.MaxCountTop, cross.MaxCountLeft); cross.CalcLines(); var newSize = new Size(cross.MaxCountTop, cross.MaxCountLeft); if (oldSize != newSize) UpdateSize(); } UpdateBtnState(); //TODO partial invalidate need panelCross.Invalidate(); }
private void panelCross_MouseMove(object sender, MouseEventArgs e) { if (mouseSelection == null) return; if (mouseSelection.Button != e.Button) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } var pos = GetMousePosition(e.Location); if (pos == null) return; if (mouseSelection.End == pos.Value) return; mouseSelection.End = pos.Value; //TODO partial invalidate need panelCross.Invalidate(); }
private void panelCross_MouseDown(object sender, MouseEventArgs e) { // 1. pressed other button // 2. pressed not left or not right button or pressed more than one button // then cancel selection if ((mouseSelection != null && mouseSelection.Button != e.Button) || (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)) { mouseSelection = null; //TODO partial invalidate need panelCross.Invalidate(); return; } // mouse position outgoing of the map, ignore var pos = GetMousePosition(e.Location); if (pos == null) return; var newCellState = (e.Button == MouseButtons.Left) ? Cross.CellState.Fill : (e.Button == MouseButtons.Right) ? Cross.CellState.Dot : Cross.CellState.Unknown; if (!editorMode) { // if oldCellState == newCellState then cells must be cleaned newCellState = (cross.GetCell(pos.Value.X, pos.Value.Y) == newCellState) ? Cross.CellState.Unknown : newCellState; } mouseSelection = new MouseGroupSelection { Button = e.Button, NewCellState = newCellState, Begin = pos.Value, End = pos.Value }; //TODO more partial invalidation need panelCross.Invalidate(new Rectangle(e.X - scaleSize, e.Y - scaleSize, scaleSize*2, scaleSize*2)); }