//============================================================================= private void ClearGrips() { foreach (cadGrip g in m_grips) { RemoveVisualChild(g); RemoveLogicalChild(g); } m_grips.Clear(); m_gripToMove = null; }
//============================================================================= protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (!this.IsEnabled) { return; } Point globalPnt = _GetGlobalPoint(e); if (m_NewGeometry != null) { m_NewGeometry.OnMouseLeftButtonClick(globalPnt); this.cadToolTip = m_NewGeometry.Tooltip; if (m_NewGeometry.IsPlaced) { m_NewGeometry.Draw(this, null); m_NewGeometry = null; _OnInternalCommandEnded(); // start new geom _CloneGeom(); } } else { Point localPnt = _GetLocalPoint(e); HitTestResult res = VisualTreeHelper.HitTest(this, localPnt); if (m_gripToMove != null) { m_gripToMove = null; // // End of grip dragging. // Geometry property was changed. _OnInternalCommandEnded(); return; } // moving grip cadGrip _grip = res.VisualHit as cadGrip; if (_grip != null) { m_gripToMove = _grip; return; } SelectedGeometry = res.VisualHit as ICadGeometry; } }
//============================================================================= private void _Cancel() { this.cadToolTip = null; // SelectedGeometry = null; // delete last not initialized if (m_NewGeometry != null) { DrawingVisual dc = m_NewGeometry.GetGeometryWrapper(); RemoveVisualChild(dc); RemoveLogicalChild(dc); m_geometries.Remove(m_NewGeometry); m_NewGeometry = null; } m_gripToMove = null; ClearGrips(); }
//============================================================================= public void ResetGrips() { ClearGrips(); ICadGeometry selectedGeom = SelectedGeometry; if (selectedGeom != null) { List <Point> pnts = selectedGeom.GetGripPoints(); if (pnts != null) { foreach (Point p in pnts) { cadGrip newGrip = new cadGrip(this, selectedGeom, pnts.IndexOf(p)); m_grips.Add(newGrip); AddVisualChild(newGrip); AddLogicalChild(newGrip); } } } }