CPSystemNamer.cs
Copy Code
|
|
---|---|
//----------------------------------------------------------------------------------- //Telvent, Inc. //Copyright 2010 //----------------------------------------------------------------------------------- //Module Name: CPSystemNamer //Description: // //Written: 9/20/2010 by Daniel Rouleau //----------------------------------------------------------------------------------- using System.Runtime.InteropServices; using System; using Miner.Interop; using Miner.ComCategories; using Esri.ArcGIS.Geodatabase; namespace Miner.Samples { [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [Guid("F9CF6D7F-80E2-4370-B07A-4B170690A7DE")] [ComponentCategory(ComCategory.MMDisplayNameObjects)] public sealed class CPSystemNamer : IMMDisplayNamer { //Member constants private const string _id = "ID"; private const string _protectionType = "ProtectionType"; private static readonly Resourcer Resourcer = new Resourcer(); #region IMMDisplayNamer Implementation public string DisplayString(IRow pRow) { IFields fields = pRow.Fields; //Get ID and ProtectionType field indices int idIndex = fields.FindField(_id); int protectionTypeIndex = fields.FindField(_protectionType); //Store ID value string id = pRow.get_Value(idIndex) == null ? Resourcer.GetString("CustomDisplayNamers.NullValue") : Convert.ToString(pRow.get_Value(idIndex)); //store ProtectionType field value string protectionType = pRow.get_Value(protectionTypeIndex) as string; if (protectionType == null) { protectionType = Resourcer.GetString("CustomDisplayNamers.NullValue"); } else { //Get appropriate ProtectionType code description from subtype domain //or default domain ICodedValueDomain pCVDomain = CustomNamerUtils.GetCVDomain(pRow, protectionTypeIndex); if (pCVDomain != null) { protectionType = CustomNamerUtils.GetCVDescFromCode(pCVDomain, protectionType); } else { protectionType = "Protection Type Code: " + protectionType; } } string displayString = id + " - " + protectionType; //Return display string return displayString; } public bool get_Enabled(IDataset pDataset) { bool result = false; //Enable only on "CPSystem" model name IObjectClass objectClass = pDataset as IObjectClass; if (objectClass != null) { if (CustomNamerUtils.GetModelNameMgr.ContainsClassModelName(objectClass, "CPSystem")) { result = true; } } return result; } public string Name { get { return "Minerville CP System Display Namer"; } } #endregion IMMDisplayNamer Implementation } } |