/// <summary> /// Displays database attributes so that they can be edited by the user. /// </summary> /// <param name="r">The row of interest</param> /// <returns>True if any changes were saved to the database</returns> internal static bool Update(Row r) { // If the row is associated with any RowText, ensure it is removed from // the spatial index NOW (if we wait until the edit has been completed, // it's possible we won't be able to update the index properly) TextFeature[] text = r.Id.GetRowText(); EditingIndex index = CadastralMapModel.Current.EditingIndex; bool isChanged = false; try { // Remove the text from the spatial index (but see comment below) foreach (TextFeature tf in text) { index.RemoveFeature(tf); } // Display the attribute entry dialog AttributeDataForm dial = new AttributeDataForm(r.Table, r.Data); isChanged = (dial.ShowDialog() == DialogResult.OK); dial.Dispose(); if (isChanged) { IDataServer ds = EditingController.Current.DataServer; if (ds == null) { throw new InvalidOperationException("No database available"); } ds.SaveRow(r.Data); } } finally { // Ensure text has been re-indexed... actually, this is likely to be // redundant, because nothing here has actually altered the stored // width and height of the text (if the attributes have become more // verbose, they'll just be scrunched up a bit tighter). The text // metrics probably should be reworked (kind of like AutoSize for // Windows labels), but I'm not sure whether this demands a formal // editing operation. foreach (TextFeature tf in text) { index.AddFeature(tf); } // Re-display the text if any changes have been saved if (isChanged) { ISpatialDisplay display = EditingController.Current.ActiveDisplay; display.Redraw(); } } return(isChanged); }
/// <summary> /// Adds this feature to the spatial index, and sets the flag bit indicating /// that this feature is indexed. /// </summary> internal void AddToIndex() { EditingIndex index = MapModel.EditingIndex; if (index != null) { index.AddFeature(this); } }
/// <summary> /// Changes the text for this object /// </summary> /// <param name="s">The new value for this geometry</param> internal void SetText(TextFeature label, string s) { CadastralMapModel map = label.MapModel; EditingIndex index = map.EditingIndex; index.RemoveFeature(label); m_Text = s; index.AddFeature(label); }
/// <summary> /// Inserts this feature into the supplied index. This should be called shortly after a model /// is opened (after a prior call to <c>OnLoad</c>). /// </summary> /// <param name="index">The spatial index to add to</param> /// <returns>True if the feature was indexed. False if the feature is currently inactive (not /// added to the index)</returns> /// <remarks>The <see cref="LineFeature"/> class provides an override that also deals with /// indexing for topological elements.</remarks> internal virtual bool AddToIndex(EditingIndex index) { if (IsInactive) { return(false); } index.AddFeature(this); return(true); }
/// <summary> /// Adds the features created by this edit to the model's spatial index. /// </summary> internal void AddToIndex() { EditingIndex index = this.MapModel.EditingIndex; Feature[] fa = this.Features; foreach (Feature f in fa) { index.AddFeature(f); } }