private void Form1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { using (Teigha.GraphicsSystem.View pView = helperDevice.ActiveView) { ClearSelection(); selRect = new RectFram(toEyeToWorld(e.X, e.Y)); pView.Add(selRect); startSelPoint = new Point2d(e.X, e.Y); Invalidate(); selRect.setValue(toEyeToWorld(e.X + _SelectRegion, e.Y + _SelectRegion)); pView.Select( new Point2dCollection(new Point2d[] { startSelPoint, new Point2d(e.X + _SelectRegion, e.Y + _SelectRegion) }), 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(); } } else if (e.Button == MouseButtons.Right) { _IsMoving = true; startSelPoint = new Point2d(e.X, e.Y); } }
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; } }
public bool OnMouseDown(int x, int y) { endHover(); ExGripDataCollection aKeys = new ExGripDataCollection(); locateGripsAt(x, y, ref aKeys); if (aKeys.Count > 0) { //if ( bShift ) TODO { bool bMakeHot = true; foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict) { foreach (ExGripData exgrData in grData.Value.DataArray) { if (GripData.DrawType.HotGrip == exgrData.Status) { bMakeHot = false; break; } } foreach (ExGripDataSubent grDatSub in grData.Value.DataSub) { foreach (ExGripData exgrData in grDatSub.SubData) { if (GripData.DrawType.HotGrip == exgrData.Status) { bMakeHot = false; break; } } if (bMakeHot == false) { break; } } if (bMakeHot == false) { break; } } if (bMakeHot) { foreach (ExGripData exgrData in aKeys) { exgrData.Status = GripData.DrawType.HotGrip; } } aActiveKeys = new ExGripDataCollection(); locateGripsByStatus(GripData.DrawType.HotGrip, ref aActiveKeys); if (aActiveKeys.Count == 0) { // Valid situation. // If trigger grip performed entity modification and returned eGripHotToWarm // then nothing is to be done cause entity modification will cause reactor to regen grips. return(false); } foreach (ExGripData exgrData in aActiveKeys) { exgrData.Status = GripData.DrawType.DragImageGrip; } foreach (KeyValuePair <ObjectId, ExGripDataExt> grData in m_gripDataDict) { bool bActive = false; foreach (ExGripData exgrData in grData.Value.DataArray) { if (GripData.DrawType.DragImageGrip == exgrData.Status) { bActive = true; m_aDrags.Add(new ExGripDrag(grData.Key, this)); break; } } foreach (ExGripDataSubent grDatSub in grData.Value.DataSub) { foreach (ExGripData exgrData in grDatSub.SubData) { if (GripData.DrawType.DragImageGrip == exgrData.Status) { bActive = true; m_aDrags.Add(new ExGripDrag(exgrData.SubentPath, this)); break; } } if (bActive == true) { break; } } } using (Teigha.GraphicsSystem.View pView = m_pDevice.ActiveView) { foreach (ExGripDrag grDrag in m_aDrags) { grDrag.notifyDragStarted(); grDrag.cloneEntity(); pView.Add(grDrag); } } m_ptBasePoint = aKeys[0].Point; m_ptLastPoint = m_ptBasePoint; } } else { return(false); } return(true); }