/// <summary> /// Handles the Finish button. /// </summary> /// <returns>The point created at the intersection (null if an error was reported). /// The caller is responsible for disposing of the dialog and telling the controller /// the command is done)</returns> internal override PointFeature Finish() { // The intersection SHOULD be defined (the Finish button should have // been disabled if it wasn't) IPosition x = intersectInfo.Intersection; if (x == null) { MessageBox.Show("No intersection. Nothing to save"); return(null); } // If we're not doing an update, just save the edit UpdateUI up = (GetCommand() as UpdateUI); if (up == null) { return(SaveDirLine()); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) IntersectDirectionAndLineOperation op = (IntersectDirectionAndLineOperation)up.GetOp(); UpdateItemCollection changes = op.GetUpdateItems(getDirection.Direction, getLine.Line, intersectInfo.ClosestPoint); if (!up.AddUpdate(op, changes)) { return(null); } // Return the point previously created at the intersect return(op.IntersectionPoint); }
/// <summary> /// Initialize for an update (or recall) /// </summary> /// <param name="op">The edit that is being updated or recalled</param> /// <param name="lineNum">The sequence number of the distance involved (relevant only for /// a <see cref="IntersectTwoLinesOperation"/>)</param> internal void ShowUpdate(IntersectOperation op, int lineNum) { // Return if no update object (and no recall op). if (op == null) { return; } // Populate the dialog, depending on what sort of operation we have. if (op.EditId == EditingActionId.LineIntersect) { /* * CeIntersectLine* pOper = dynamic_cast<CeIntersectLine*>(pop); * * if ( linenum==1 ) * this->Show( pOper->GetpArc1() * , pOper->IsSplit1() ); * else * this->Show( pOper->GetpArc2() * , pOper->IsSplit2() ); */ } else if (op.EditId == EditingActionId.DirLineIntersect) { IntersectDirectionAndLineOperation oper = (IntersectDirectionAndLineOperation)op; ShowLine(oper.Line, oper.IsSplit); } else { MessageBox.Show("GetLineControl.ShowUpdate - Unexpected editing operation"); } }
/// <summary> /// Saves a direction-line intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDirLine() { IntersectDirectionAndLineOperation op = null; try { Direction dir = getDirection.Direction; IEntity dirEnt = getDirection.LineType; LineFeature line = getLine.Line; bool wantSplit = getLine.WantSplit; IdHandle pointId = intersectInfo.PointId; PointFeature closeTo = intersectInfo.ClosestPoint; if (closeTo == null) { IPosition xsect; if (!dir.Intersect(line, closeTo, out xsect, out closeTo)) { throw new Exception("Cannot calculate intersection point"); } Debug.Assert(closeTo != null); } op = new IntersectDirectionAndLineOperation(dir, line, wantSplit, closeTo); op.Execute(pointId, dirEnt); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }