private void Form1_MouseDown(object sender, MouseEventArgs e) { switch (mouseMode) { case Mode.Quiescent: { if (gripManager.OnMouseDown(e.X, e.Y)) { mouseMode = Mode.DragDrop; } else { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { selRect = new RectFram(toEyeToWorld(e.X, e.Y)); pView.Add(selRect); startSelPoint = new Point2d(e.X, e.Y); Invalidate(); mouseMode = Mode.Selection; } } break; } case Mode.Selection: { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { pView.Select(new Point2dCollection(new Point2d[] { startSelPoint, new Point2d(e.X, e.Y) }), new SR(selected, database.CurrentSpaceId), startSelPoint.X < e.X ? Teigha.GraphicsSystem.SelectionMode.Window : Teigha.GraphicsSystem.SelectionMode.Crossing); pView.Erase(selRect); selRect = null; gripManager.updateSelection(selected); helperDevice.Invalidate(); Invalidate(); } mouseMode = Mode.Quiescent; break; } case Mode.DragDrop: { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { gripManager.DragFinal(toEyeToWorld(e.X, e.Y), true); helperDevice.Model.Invalidate(InvalidationHint.kInvalidateAll); Invalidate(); } mouseMode = Mode.Quiescent; break; } default: break; } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Escape: switch (mouseMode) { case Mode.DragDrop: { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { gripManager.DragFinal(new Point3d(), false); helperDevice.Model.Invalidate(InvalidationHint.kInvalidateAll); Invalidate(); } break; } case Mode.Selection: if (selRect != null) { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { pView.Erase(selRect); selRect = null; } } break; } mouseMode = Mode.Quiescent; foreach (ObjectId id in selected) { gripManager.removeEntityGrips(id, true); } selected.Clear(); if (helperDevice != null) { helperDevice.Invalidate(); } Invalidate(); break; case Keys.Oemplus: break; case Keys.OemMinus: break; } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (selRect != null) { helperDevice.ActiveView.Erase(selRect); } selRect = null; gripManager.uninit(); gripManager = null; if (graphics != null) { graphics.Dispose(); } if (helperDevice != null) { helperDevice.Dispose(); } if (database != null) { database.Dispose(); } dd.Dispose(); }