/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("LineExtensionUI.DialFinish - No dialog!"); return(false); } // If we are doing an update, alter the original operation. UpdateUI up = this.Update; if (up != null) { // Get the original operation. LineExtensionOperation pop = (up.GetOp() as LineExtensionOperation); if (pop == null) { MessageBox.Show("LineExtensionUI.DialFinish - Unexpected edit type."); return(false); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = pop.GetUpdateItems(m_Dialog.IsExtendFromEnd, m_Dialog.Length); if (!up.AddUpdate(pop, changes)) { return(false); } } else { // Get info from the dialog m_IsExtendFromEnd = m_Dialog.IsExtendFromEnd; m_Length = m_Dialog.Length; IdHandle idh = m_Dialog.PointId; CadastralMapModel map = CadastralMapModel.Current; m_LineType = (m_Dialog.WantLine ? map.DefaultLineType : null); // Execute the edit LineExtensionOperation op = null; try { op = new LineExtensionOperation(m_ExtendLine, m_IsExtendFromEnd, m_Length); op.Execute(idh, m_LineType); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); return(false); } } // Destroy the dialog(s). KillDialogs(); // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("SimpleLineSubdivisionUI.DialFinish - No dialog!"); return(false); } // De-select the line that's being split Controller.ClearSelection(); // Get info from the dialog. m_Length = m_Dialog.Length; // If we are doing an update, alter the original operation. UpdateUI up = this.Update; if (up != null) { // Get the original operation. SimpleLineSubdivisionOperation pop = (up.GetOp() as SimpleLineSubdivisionOperation); if (pop == null) { MessageBox.Show("SimpleLineSubdivisionUI.DialFinish - Unexpected edit type."); return(false); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = pop.GetUpdateItems(m_Length, m_Dialog.IsFromEnd); if (!up.AddUpdate(pop, changes)) { return(false); } } else { // Execute the edit SimpleLineSubdivisionOperation op = null; try { op = new SimpleLineSubdivisionOperation(m_Line, m_Length, m_Dialog.IsFromEnd); op.Execute(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); return(false); } } // Destroy the dialog(s). KillDialogs(); // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("NewCircleUI.DialFinish - No dialog!"); return(false); } // Get info from the dialog. PointFeature center = m_Dialog.Center; Observation radius = m_Dialog.Radius; // Both items must be defined (the dialog should have confirmed // this in its OnOK handler). if (center == null || radius == null) { MessageBox.Show("NewCircleUI.DialFinish - Insufficient data to add circle."); return(false); } // If we are doing an update, alter the original operation. UpdateUI pup = this.Update; if (pup != null) { // Get the original operation. NewCircleOperation pop = (pup.GetOp() as NewCircleOperation); if (pop == null) { MessageBox.Show("NewCircleUI.DialFinish - Unexpected edit type."); return(false); } pop.Correct(center, radius); } else { // Create empty persistent object (adds to current session) NewCircleOperation op = null; try { op = new NewCircleOperation(center, radius); op.Execute(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); return(false); } } // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { throw new Exception("NewPointUI.DialFinish -- No dialog!"); } // Hide the dialog so it doesn't become part of any saved display m_Dialog.Visible = false; // If we are doing an update, remember the changes UpdateUI up = this.Update; if (up != null) { // Remember the changes as part of the UI object (the original edit remains // unchanged for now) Operation revisedEdit = up.GetOp(); UpdateItemCollection changes = m_Dialog.GetUpdateItems(); if (!up.AddUpdate(revisedEdit, changes)) { return(false); } } else { // Save the new point. PointFeature p = m_Dialog.Save(); if (p == null) { return(false); } // Ensure the point is on screen, and select it. Controller.EnsureVisible(p, true); } // Get the base class to finish up. return(FinishCommand()); }
internal override bool DialFinish(Control wnd) { if (m_Dialog == null && m_UpDial == null) { throw new Exception("LineSubdivisionUI.DialFinish - No dialog!"); } UpdateUI up = this.Update; bool doAbort = false; if (up != null) { // Get the original operation. LineSubdivisionOperation pop = (up.GetOp() as LineSubdivisionOperation); if (pop == null) { MessageBox.Show("LineSubdivisionUI.DialFinish - Unexpected edit type."); return(false); } // Ensure we've got the edit for the primary face if (!pop.IsPrimaryFace) { pop = pop.OtherSide; Debug.Assert(pop != null); Debug.Assert(pop.IsPrimaryFace); } // Package up any changes to the primary face UpdateItemCollection changes = pop.GetUpdateItems(m_UpDial.WorkingFace1); if (changes.Count > 0) { up.AddUpdate(pop, changes); } // If a second face has just been defined, append a new edit. LineSubdivisionFace face2 = m_UpDial.WorkingFace2; if (face2 != null) { if (pop.OtherSide == null) { AddOtherSide(pop, face2); } else { changes = pop.OtherSide.GetUpdateItems(face2); if (changes.Count > 0) { up.AddUpdate(pop.OtherSide, changes); } } } // If all we've done is add a new face, UpdateUI.AddUpdate wouldn't have been // called, which will later lead to an exception from UpdateUI.FinishCommand (via // the FinishCommand done below). So remember to abort in that case. doAbort = (up.HasRevisions == false); } else { // Ensure that the parent line has been de-selected by the view. Controller.ClearSelection(); // Get the dialog to save. m_Dialog.Save(); } // Destroy the dialog(s). KillDialogs(); // Get the base class to finish up. if (doAbort) { return(AbortCommand()); } else { return(FinishCommand()); } }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns>True if command finished ok</returns> internal override bool DialFinish(Control wnd) { // If it's the offset dialog that's just finished, grab info // from it, delete it, and go to the dialog for the first // terminal line. ISpatialDisplay view = ActiveDisplay; UpdateUI up = this.Update; if (m_ParDial != null) { // Get info from dialog (it'll be ONE of the two). The dialog // should only call this function after validating that one // of them is defined. m_OffsetPoint = m_ParDial.OffsetPoint; if (m_OffsetPoint == null) { m_Offset = m_ParDial.OffsetDistance; } // Destroy the dialog. KillDialogs(); // Calculate the positions for the parallel points. Calculate(); // Repaint what we know about. Draw(); // And start the dialog for the first terminal line. if (up != null) { m_TermDial1 = new TerminalControl(up, false); } else { m_TermDial1 = new TerminalControl(this, false); } //m_TermDial1.Show(); this.Container.Display(m_TermDial1); return(true); } if (m_TermDial1 != null) { // Get the first terminal line (if any). And the position. m_TermLine1 = m_TermDial1.TerminalLine; m_Term1 = m_TermDial1.TerminalPosition; // And move on to the 2nd terminal dialog. KillDialogs(); // Repaint what we know about. Draw(); // And start the dialog for the first terminal line. if (up != null) { m_TermDial2 = new TerminalControl(up, true); } else { m_TermDial2 = new TerminalControl(this, true); } this.Container.Display(m_TermDial2); //m_TermDial2.Show(); return(true); } if (m_TermDial2 == null) { throw new Exception("ParallelLineUI.DialFinish - No dialog!"); } // Get the nortthern terminal line (if any). And the position. m_TermLine2 = m_TermDial2.TerminalLine; m_Term2 = m_TermDial2.TerminalPosition; // Erase everything special that we've drawn. ErasePainting(); // And ensure the view has nothing selected (sometimes the line // last selected had been unhighlighted, although it's end points // stay highlighted for some reason). EditingController.Current.ClearSelection(); // If we are doing an update, remember the changes if (up != null) { // Get the original operation. ParallelLineOperation op = (ParallelLineOperation)up.GetOp(); if (op == null) { throw new Exception("ParallelLineUI.DialFinish - Unexpected edit type."); } // Note the offset (it SHOULD be defined) Observation offset = null; if (m_Offset != null) { offset = m_Offset; } else if (m_OffsetPoint != null) { offset = new OffsetPoint(m_OffsetPoint); } Debug.Assert(offset != null); // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = op.GetUpdateItems(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed); if (!up.AddUpdate(op, changes)) { return(false); } } else { Observation offset = m_Offset; if (offset == null && m_OffsetPoint != null) { offset = new OffsetPoint(m_OffsetPoint); } Debug.Assert(offset != null); // Execute the edit ParallelLineOperation op = null; try { op = new ParallelLineOperation(m_Line, offset, m_TermLine1, m_TermLine2, m_IsReversed); op.Execute(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); return(false); } } // Destroy the dialog(s). KillDialogs(); // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Starts the user interface (if any) for this command. /// </summary> /// <returns>True if command started ok.</returns> internal override bool Run() { // Don't run more than once. if (m_ParDial != null || m_TermDial1 != null || m_TermDial2 != null) { throw new Exception("ParallelLineUI.Run - Command is already running."); } // If we're doing an update, get the reference line from the original op. ParallelLineOperation op = null; UpdateUI up = this.Update; if (up != null) { op = (up.GetOp() as ParallelLineOperation); if (op == null) { throw new Exception("ParallelLineUI.Run - Unexpected edit type."); } // Pick up the line that acted as the reference line. m_Line = op.ReferenceLine; } // If it wasn't an update, we might be recalling an old op. if (op == null) { op = (this.Recall as ParallelLineOperation); } // Get old observations if necessary. if (op != null) { // Pick up the offset. Observation offset = op.Offset; // Is it an observed distance? Distance dist = (offset as Distance); if (dist != null) { m_Offset = new Distance(dist); } else { // The only other thing it could be is an offset point. OffsetPoint offPoint = (offset as OffsetPoint); if (offPoint != null) { m_OffsetPoint = offPoint.Point; } } m_IsReversed = op.IsArcReversed; m_TermLine1 = op.Terminal1; m_TermLine2 = op.Terminal2; // Ensure the reference line has been selected/highlighted (this may end up // calling OnSelectLine) EditingController.Current.Select(m_Line); // Calculate stuff & paint what we've got. Calculate(); Paint(null); } // Create modeless dialog. if (up != null) { m_ParDial = new ParallelControl(up); } else { m_ParDial = new ParallelControl(this); } this.Container.Display(m_ParDial); return(true); }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("RadialUI.DialFinish - No dialog!"); return(false); } // Handle any sub-dialog request. if (m_Dialog != wnd) { return(m_Dialog.DialFinish(wnd)); } // If we are doing an update, remember the changes UpdateUI up = this.Update; if (up != null) { RadialOperation pop = (up.GetOp() as RadialOperation); if (pop == null) { MessageBox.Show("RadialUI.DialFinish - Unexpected edit type."); return(false); } // Get info from the dialog. Direction dir = m_Dialog.Direction; Observation len = m_Dialog.Length; // The direction and length must both be defined. if (dir == null || len == null) { MessageBox.Show("Missing parameters for sideshot update."); return(false); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = pop.GetUpdateItems(dir, len); if (!up.AddUpdate(pop, changes)) { return(false); } } else { // Get info from the dialog. Direction dir = m_Dialog.Direction; Observation len = m_Dialog.Length; IdHandle idh = m_Dialog.PointId; IEntity lineEnt = null; if (m_Dialog.WantLine) { lineEnt = CadastralMapModel.Current.DefaultLineType; if (lineEnt == null) { throw new InvalidOperationException("No default entity type for lines"); } } // The direction, length, and point entity type must all be defined. if (dir == null || len == null || idh.Entity == null) { MessageBox.Show("Missing parameters for sideshot creation."); return(false); } RadialOperation pop = null; try { pop = new RadialOperation(dir, len); pop.Execute(idh, lineEnt); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } } // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Initializes a new instance of the <see cref="UpdatePathForm"/> class. /// </summary> /// <param name="update">The update command that's driving things (not null).</param> /// <exception cref="ArgumentNullException">If the supplied update command is null.</exception> internal UpdatePathForm(UpdateUI update) { InitializeComponent(); Owner = EditingController.Current.MainForm; if (update == null) throw new ArgumentNullException(); m_UpdCmd = update; m_CurFaceIndex = -1; m_pop = null; // Get the object that was selected for update. m_pop = (m_UpdCmd.GetOp() as PathOperation); if (m_pop == null) throw new ArgumentException("Cannot obtain original connection path for update"); // Get a working copy of the connection path legs // TODO - This will not be suitable in a situation where staggered legs have been created Leg[] legs = PathParser.CreateLegs(m_pop.EntryString, m_pop.EntryUnit); m_Faces = new List<LegFace>(); foreach (Leg leg in legs) { m_Faces.Add(leg.PrimaryFace); if (leg.AlternateFace != null) m_Faces.Add(leg.AlternateFace); } m_Edits = new PathEditor(legs); }