void InitUpdate(LineExtensionOperation pop) { Form parent = ParentForm; parent.Text = "Update Line Extension"; m_ExtendLine = pop.ExtendedLine; m_IsExtendFromEnd = pop.IsExtendFromEnd; m_Length = new Distance(pop.Length); // Was an extension line added? m_WantLine = (pop.NewLine != null); // Scroll the entity combo to the previously defined // entity type for the extension point. PointFeature point = pop.NewPoint; IEntity ent = point.EntityType; if (ent != null) { pointTypeComboBox.SelectEntity(ent); } // Display the original observed length. lengthTextBox.Text = m_Length.Format(); // Display the point key (if any) idComboBox.DropDownStyle = ComboBoxStyle.DropDown; idComboBox.Text = point.FormattedKey; }
/// <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()); }
private void LineExtensionControl_Load(object sender, EventArgs e) { // If we are doing an update select the previously defined // entity type, and show the key that was assigned to the point. LineExtensionOperation pop = this.UpdateOp; if (pop == null) { // Initialize combo box with a list of all point entity types // for the currently active layer. IEntity ent = pointTypeComboBox.Load(SpatialType.Point); // Load the ID combo (reserving the first available ID). IdHelper.LoadIdCombo(idComboBox, ent, m_PointId); // If we are auto-numbering, disable the combo. if (m_Cmd.Controller.IsAutoNumber) { idComboBox.Enabled = false; } // We may be recalling an old operation. if (m_Length.IsDefined) { lengthTextBox.Text = m_Length.Format(); } } else { pointTypeComboBox.SelectedValueChanged -= pointTypeComboBox_SelectedValueChanged; idComboBox.SelectedValueChanged -= idComboBox_SelectedValueChanged; // Initialize combo box with a list of all point entity types // for the currently active layer. IEntity ent = pointTypeComboBox.Load(SpatialType.Point); InitUpdate(pop); // All the user can update is the length of the extension, and the end of // the line to extend from. newPointGroupBox.Enabled = false; } wantLineCheckBox.Checked = m_WantLine; // De-select the line we're extending (if it's highlighted, and we're extending // on a circle construction line, it can be difficult to see stuff we draw here). m_Cmd.Controller.ClearSelection(); }
internal LineExtensionControl(LineExtensionUI cmd, LineFeature extendLine, Operation recall) { InitializeComponent(); Zero(); m_Cmd = cmd; m_ExtendLine = extendLine; LineExtensionOperation op = (recall as LineExtensionOperation); if (op != null) { m_IsExtendFromEnd = op.IsExtendFromEnd; m_Length = new Distance(op.Length); m_WantLine = (op.NewLine != null); } }
internal void Draw() { ISpatialDisplay display = m_Cmd.ActiveDisplay; // Draw the line we're extending in a special colour (any highlighting it // originally had should have been removed during LineExtensionControl_Load) if (m_ExtendLine != null) { m_ExtendLine.Draw(display, Color.DarkBlue); } // If we're doing an update, draw the original extension in grey. LineExtensionOperation pop = UpdateOp; if (pop != null) { LineFeature origLine = pop.NewLine; if (origLine != null) { origLine.Draw(display, Color.Gray); } PointFeature origPoint = pop.NewPoint; if (origPoint != null) { origPoint.Draw(display, Color.Gray); } } // Calculate the start and end points of the extension, initially // assuming that it's a straight line extension. IPosition start, end; if (LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end)) { // Draw the straight extension line IDrawStyle style = (m_WantLine ? new DrawStyle(Color.Magenta) : new DottedStyle(Color.Magenta)); LineSegmentGeometry seg = new LineSegmentGeometry(start, end); seg.Render(display, style); } else { // Perhaps it's a circular arc ... IPosition center; bool iscw; if (LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end, out center, out iscw)) { // And draw the curve. IDrawStyle style = (m_WantLine ? new DrawStyle(Color.Magenta) : new DottedStyle(Color.Magenta)); IPointGeometry c = PointGeometry.Create(center); CircularArcGeometry arc = new CircularArcGeometry(c, start, end, iscw); arc.Render(display, style); } else if (m_ExtendLine != null) { // Get the position we're extending from. end = (m_IsExtendFromEnd ? m_ExtendLine.EndPoint : m_ExtendLine.StartPoint); } } // If we actually got something, draw the end point. if (end != null) { IDrawStyle style = m_Cmd.Controller.DrawStyle; style.FillColor = Color.Magenta; style.Render(display, end); } }