/// <summary> /// Checks whether this ID handle is valid for a specific entity type. /// </summary> /// <param name="ent">The entity type to check.</param> /// <returns>True if this ID handle is suitable for the entity type.</returns> internal bool IsValidFor(IEntity ent) { if (ent == null) { return(false); } IdManager idMan = CadastralMapModel.Current.IdManager; if (idMan == null) { return(true); } // Try to find the ID group for the specified entity type. IIdGroup group = ent.IdGroup; // If we actually found an a group, it has to match the one that we already know about. // If we didn't find a group, this ID is valid only if it is undefined! if (group != null && m_Packet != null) { return(group.Id == m_Packet.IdGroup.Id); } else { return(m_Id == 0); } }
/// <summary> /// Generates an index that cross-references each entity type with its corresponding /// ID group. /// </summary> /// <param name="groups">The ID groups to index</param> /// <returns>Index of the ID groups for each entity type. The key is the ID of the entity type, /// the values are elements in the <paramref name="groups"/> array.</returns> Dictionary <int, IdGroup> GetEntityGroups(IdGroup[] groups) { IEnvironmentContainer ec = EnvironmentContainer.Current; if (ec == null) { return(new Dictionary <int, IdGroup>()); } IEntity[] ents = ec.EntityTypes; Dictionary <int, IdGroup> result = new Dictionary <int, IdGroup>(ents.Length); foreach (IEntity e in ents) { IIdGroup idg = e.IdGroup; if (idg != null && idg.Id > 0) { int gid = idg.Id; IdGroup entGroup = Array.Find <IdGroup>(groups, g => g.Id == gid); Debug.Assert(entGroup != null); result.Add(e.Id, entGroup); } } return(result); }
private void EntityForm_Shown(object sender, EventArgs e) { IEnvironmentContainer ec = EnvironmentContainer.Current; idGroupComboBox.Items.AddRange(ec.IdGroups); layerComboBox.Items.AddRange(ec.Layers); fontComboBox.Items.AddRange(ec.Fonts); IIdGroup g = m_Edit.IdGroup; if (g != null) { idGroupComboBox.SelectedItem = g; } ILayer layer = m_Edit.Layer; if (layer != null) { layerComboBox.SelectedItem = layer; } IFont font = m_Edit.Font; if (font != null) { fontComboBox.SelectedItem = font; } entityNameTextBox.Text = m_Edit.Name; pointCheckbox.Checked = m_Edit.IsPointValid; lineCheckbox.Checked = m_Edit.IsLineValid; boundaryCheckbox.Checked = m_Edit.IsPolygonBoundaryValid; textCheckbox.Checked = m_Edit.IsTextValid; labelCheckbox.Checked = m_Edit.IsPolygonValid; labelCheckbox.Enabled = textCheckbox.Checked; boundaryCheckbox.Enabled = lineCheckbox.Checked; }
internal IdFormatForm(IIdGroup group) { InitializeComponent(); m_Group = group; m_HasCheckDigit = group.HasCheckDigit; // Get the number of characters in the numeric portion // of keys formed for the specified group m_MinWidth = group.LowestId.ToString().Length; m_MaxWidth = group.HighestId.ToString().Length; /* * if (group.Id==0) * { * m_Lead = String.Empty; * m_Trail = String.Empty; * m_IsKeepZeroes = false; * m_NumWidth = m_MaxWidth; * } * else */ ParseFormat(group.KeyFormat); }
internal IdFormatForm(IIdGroup group) { InitializeComponent(); m_Group = group; m_HasCheckDigit = group.HasCheckDigit; // Get the number of characters in the numeric portion // of keys formed for the specified group m_MinWidth = group.LowestId.ToString().Length; m_MaxWidth = group.HighestId.ToString().Length; /* if (group.Id==0) { m_Lead = String.Empty; m_Trail = String.Empty; m_IsKeepZeroes = false; m_NumWidth = m_MaxWidth; } else */ ParseFormat(group.KeyFormat); }
/// <summary> /// Initializes a new instance of the <see cref="IdGroup"/> class. /// </summary> /// <param name="data">The environment definition for the ID group.</param> internal IdGroup(IIdGroup data) : base(data) { m_Packets = new List <IdPacket>(); m_MaxAllocatedId = data.MaxUsedId; }
/// <summary> /// Initializes a new instance of the <see cref="IdGroup"/> class. /// </summary> /// <param name="data">The environment definition for the ID group.</param> internal IdGroup(IIdGroup data) : base(data) { m_Packets = new List<IdPacket>(); m_MaxAllocatedId = data.MaxUsedId; }