/// <summary> /// Gets the attributes for a new label. /// </summary> /// <param name="id">The ID that will be assigned to the new label</param> /// <returns>True if attributes entered OK (m_LastRow defined).</returns> bool GetAttributes(string id) { // There HAS to be a schema. if (m_Schema==null) return false; // Although unlikely, it is conceivable that the attributes have already // been loaded into the database. In that case, display the existing // attributes for editing. AttributeDataForm dial; DataRow[] existingData = AttributeData.FindByKey(m_Schema, id); if (existingData.Length > 0) dial = new AttributeDataForm(m_Schema, existingData[0]); else dial = new AttributeDataForm(m_Schema, id); if (dial.ShowDialog() == DialogResult.OK) m_LastRow = dial.Data; else m_LastRow = null; dial.Dispose(); return (m_LastRow != null); }
/// <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; }