/// <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(SaveDirDir()); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) IntersectTwoDirectionsOperation op = (IntersectTwoDirectionsOperation)up.GetOp(); UpdateItemCollection changes = op.GetUpdateItems(getDirection1.Direction, getDirection2.Direction); if (!up.AddUpdate(op, changes)) { return(null); } // Return the point previously created at the intersect return(op.IntersectionPoint); }
/// <summary> /// Saves a direction-direction intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDirDir() { IntersectTwoDirectionsOperation op = null; try { Direction d1 = getDirection1.Direction; IEntity e1 = getDirection1.LineType; Direction d2 = getDirection2.Direction; IEntity e2 = getDirection2.LineType; IdHandle pointId = intersectInfo.PointId; op = new IntersectTwoDirectionsOperation(d1, d2); op.Execute(pointId, e1, e2); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }