public SettingsWindow() { InitializeComponent(); this.DataContext = this; IsSettingsReadOnly = false; DefaultDatabaseChanged = false; IsSelectDBEnabled = false; SymbologyStandards = new ObservableCollection <string>(); SymbologyStandards.Add(ProSymbolUtilities.GetStandardLabel(ProSymbolUtilities.SupportedStandardsType.mil2525b)); SymbologyStandards.Add(ProSymbolUtilities.GetStandardLabel(ProSymbolUtilities.SupportedStandardsType.mil2525d)); SymbologyStandards.Add(ProSymbolUtilities.GetStandardLabel(ProSymbolUtilities.SupportedStandardsType.mil2525c)); if ((ProSymbolUtilities.ProMajorVersion >= 2) && (ProSymbolUtilities.ProMinorVersion >= 2)) { // APP6D only available after 2.2 SymbologyStandards.Add(ProSymbolUtilities.GetStandardLabel(ProSymbolUtilities.SupportedStandardsType.app6d)); } if ((ProSymbolUtilities.ProMajorVersion >= 2) && (ProSymbolUtilities.ProMinorVersion >= 4)) { // APP6B only available after 2.4 SymbologyStandards.Add(ProSymbolUtilities.GetStandardLabel(ProSymbolUtilities.SupportedStandardsType.app6b)); } }
public async Task <bool> AddFeatureClassToActiveView(string featureClassName) { if (string.IsNullOrEmpty(featureClassName) || string.IsNullOrEmpty(DatabaseName)) { return(await Task.FromResult <bool>(false)); } bool layerAdded = false; await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { string uri = $@"{DatabaseName}\{ProSymbolUtilities.GetDatasetName()}\{featureClassName}"; Item currentItem = ItemFactory.Instance.Create(uri); if (LayerFactory.Instance.CanCreateLayerFrom(currentItem)) { FeatureLayer fl = LayerFactory.Instance.CreateLayer(currentItem, MapView.Active.Map) as FeatureLayer; if (fl != null) { ArcGIS.Core.CIM.CIMDictionaryRenderer dictionaryRenderer = ProSymbolUtilities.CreateDictionaryRenderer(); fl.SetRenderer(dictionaryRenderer); layerAdded = true; } } }); return(await Task.FromResult <bool>(layerAdded)); }
public void PopulateDomains(IReadOnlyList <ArcGIS.Core.Data.Field> fields) { //Get domains for text labels GetDomainAndPopulateList(fields, "reinforced", ReinforcedDomainValues); GetDomainAndPopulateList(fields, "credibility", CredibilityDomainValues); GetDomainAndPopulateList(fields, "reliability", ReliabilityDomainValues); GetDomainAndPopulateList(fields, "signatureequipment", SignatureEquipmentDomainValues); //Get domains for attributes if (ProSymbolUtilities.IsLegacyStandard()) { EntityCodeValues.Clear(); GetDomainAndPopulateList(fields, "affiliation", IdentityDomainValues); GetDomainAndPopulateList(fields, "echelonmobility", EchelonDomainValues); GetDomainAndPopulateList(fields, "extendedfunctioncode", ExtendedFunctionCodeValues); GetDomainAndPopulateList(fields, "hqtffd", TfFdHqDomainValues); } else // 2525D { ExtendedFunctionCodeValues.Clear(); GetDomainAndPopulateList(fields, "identity", IdentityDomainValues); GetDomainAndPopulateList(fields, "echelon", EchelonDomainValues); GetDomainAndPopulateList(fields, "indicator", TfFdHqDomainValues); } GetDomainAndPopulateList(fields, "status", StatusDomainValues); GetDomainAndPopulateList(fields, "operationalcondition", OperationalConditionAmplifierDomainValues); GetDomainAndPopulateList(fields, "mobility", MobilityDomainValues); GetDomainAndPopulateList(fields, "context", ContextDomainValues); GetDomainAndPopulateList(fields, "symbolentity", EntityCodeValues); GetDomainAndPopulateList(fields, "modifier1", Modifier1DomainValues); GetDomainAndPopulateList(fields, "modifier2", Modifier2DomainValues); GetDomainAndPopulateList(fields, "countrycode", CountryCodeDomainValues, true); }
public async Task <bool> IsGDBAndFeatureClassInActiveView(string featureClassName) { string activeGdbPath = DatabaseName; IEnumerable <FeatureLayer> mapLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>(); bool isFeatureClassInActiveView = false; await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(async() => { foreach (var layer in mapLayers) { string fcName = layer.GetFeatureClass().GetName(); isFeatureClassInActiveView = false; // GDB and View feature class name match? if (fcName == featureClassName) { Geodatabase geodatabase = await GetGDBFromLayer(layer); if (geodatabase == null) { isFeatureClassInActiveView = false; } else { string gdbPath = ProSymbolUtilities.GetPathFromGeodatabase(geodatabase); if (gdbPath == activeGdbPath) { isFeatureClassInActiveView = true; break; } // last check if it is EGDB if (string.IsNullOrEmpty(gdbPath) && !string.IsNullOrEmpty(_egdbConnectionString) && (geodatabase != null)) { string cs = ((Datastore)geodatabase).GetConnectionString(); // TODO: find a full-proof method to see if this layer // is the same data source // Note: different threads may have different connection strings // so this comparison is not a full-proof test // if (cs == _egdbConnectionString) // isFeatureClassInActiveView = true; // For now just assume the EGDB is the correct one isFeatureClassInActiveView = true; } } break; } } return(isFeatureClassInActiveView); }); return(isFeatureClassInActiveView); }
protected override void OnClick() { if (!ProSymbolEditorModule._isEnabled) { ProSymbolUtilities.ShowAddInNotEnabledMessageBox(); } MilitarySymbolDockpaneViewModel.Show(); }
public async Task <bool> IsGDBAndFeatureClassInActiveView(string featureClassName) { string activeGdbPath = DatabaseName; IEnumerable <FeatureLayer> mapLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>(); bool isFeatureClassInActiveView = false; await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(async() => { foreach (var layer in mapLayers) { string fcName = layer.GetFeatureClass().GetName(); isFeatureClassInActiveView = false; // GDB and View feature class name match? if (fcName == featureClassName) { Geodatabase geodatabase = await GetGDBFromLayer(layer); if (geodatabase == null) { isFeatureClassInActiveView = false; } else { string gdbPath = ProSymbolUtilities.GetPathFromGeodatabase(geodatabase); if (gdbPath == activeGdbPath) { isFeatureClassInActiveView = true; break; } // last check if it is EGDB if (string.IsNullOrEmpty(gdbPath) && !string.IsNullOrEmpty(_egdbConnectionString) && (geodatabase != null)) { string cs = ((Datastore)geodatabase).GetConnectionString(); if (cs == _egdbConnectionString) { isFeatureClassInActiveView = true; } } } break; } } return(isFeatureClassInActiveView); }); return(isFeatureClassInActiveView); }
public string GetFeatureClassFromMapping(DisplayAttributes displayAttributes, GeometryType geometryType) { if (displayAttributes == null) { return(string.Empty); } if (ProSymbolUtilities.IsLegacyStandard()) { return(GetFeatureClassFromExtendedFunctionCode(displayAttributes.ExtendedFunctionCode, geometryType)); } else // 2525D or APPD { return(GetFeatureClassFromSymbolSet(displayAttributes.SymbolSet, geometryType)); } }
public static string GetLayerFileFromCurrentStandard() { string layerFileStandard = "2525BChange2"; // this name format is slightly different if (ProSymbolUtilities.Standard != SupportedStandardsType.mil2525b) { layerFileStandard = ProSymbolUtilities.StandardString; } string layerFileName = "MilitaryOverlay-" + layerFileStandard + ".lpkx"; string layerFilePath = System.IO.Path.Combine(ProSymbolUtilities.AddinAssemblyLocation(), "LayerFiles", layerFileName); return(layerFilePath); }
private void GeneratePreviewSymbol() { // Step 1: Create a dictionary/map of well known attribute names to values Dictionary <string, string> attributeSet = GenerateAttributeSetDictionary(); // Step 2: Set the SVG Home Folder // This should be within the git clone of joint-military-symbology-xml // ex: C:\Github\joint-military-symbology-xml\svg\MIL_STD_2525D_Symbols // This is called in CheckSettings below, but you should call yourself if // reusing this method //Utilities.SetImageFilesHome(@"C:\Projects\Github\joint-military-symbology-xml\svg\MIL_STD_2525D_Symbols"); string militarySymbolsPath = System.IO.Path.Combine(ProSymbolUtilities.AddinAssemblyLocation(), "Images", "MIL_STD_2525D_Symbols"); bool pathExists = Utilities.SetImageFilesHome(militarySymbolsPath); if (!Utilities.CheckImageFilesHomeExists()) //if (!CheckSettings()) { Console.WriteLine("No SVG Folder, can't continue."); return; } // Step 3: Get the Layered Bitmap from the Library const int width = 256, height = 256; Size exportSize = new Size(width, height); System.Drawing.Bitmap exportBitmap; bool success = Utilities.ExportSymbolFromAttributes(attributeSet, out exportBitmap, exportSize); if (success && exportBitmap != null) { _symbolImage = ProSymbolUtilities.BitMapToBitmapImage(exportBitmap); NotifyPropertyChanged(() => SymbolImage); } if (!success || (exportBitmap == null)) { Console.WriteLine("Export failed!"); _symbolImage = null; NotifyPropertyChanged(() => SymbolImage); return; } }
/// <summary> /// Called when the sketch is finished. /// </summary> protected override async Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry) { // Clear any previous selection using the built-in Pro button/command // TRICKY: Must be called here before the QueuedTask so runs on Main UI Thread ProSymbolUtilities.ClearMapSelection(); return(await QueuedTask.Run(() => { //Return all the features that intersect the sketch geometry var result = MapView.Active.GetFeatures(geometry); if ((result != null) && (result.Count > 0)) { MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.New); } return true; })); }
private System.Threading.Tasks.Task <System.Windows.Media.ImageSource> GetBitmapImageAsync(Dictionary <string, object> attributes) { if ((attributes == null) || (attributes.Count == 0)) { return(null); } return(ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { try { string standard = ProSymbolUtilities.GetDictionaryString(); ArcGIS.Core.CIM.CIMSymbol symbol = ArcGIS.Desktop.Mapping.SymbolFactory.Instance.GetDictionarySymbol(standard, attributes); if (symbol == null) { return null; } // IMPORTANT + WORKAROUND + TRICKY: // Pro SDK does not directly provide a way to set a PATCH_SIZE > 64 pixels // However you can do this if the value is negative (-1) but it transforms/flips the image // Therefore we flip the image back in: // Views\MilitarySymbolDockpane.xaml.cs - Image.RenderTransform // ViewModels\MilitarySymbolDockpaneViewModel.cs - GetClipboardImage // If this ever gets changed/fixed in ProSDK, you must remove the flip there const int PATCH_SIZE = -256; // negative value is a workaround var si = new ArcGIS.Desktop.Mapping.SymbolStyleItem() { Symbol = symbol, PatchHeight = PATCH_SIZE, PatchWidth = PATCH_SIZE }; return si.PreviewImage; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception in GetBitmapImageAsync: " + ex.Message); return null; } })); }
public async void GeneratePreviewSymbol() { // Step 1: Create a dictionary/map of well known attribute names to values Dictionary <string, object> attributeSet = GenerateAttributeSetDictionary(); // Don't create preview until we have the minimum number of attributes in // order to minimize flicker - minimum attributes: // 2525D: { symbolset, entity, affiliation } // 2525B: { extendedfunctioncode, affiliation } int minimumAttributeCount = 4; if (ProSymbolUtilities.IsLegacyStandard()) { minimumAttributeCount = 3; } if (attributeSet.ContainsKey("IsMETOC") && (bool)attributeSet["IsMETOC"]) { ////////////////////////// // WORKAROUND: Pro 2.3 broke exporting METOC by attribute "extendedfunctioncode" // so have to set "sidc" attribute instead if (ProSymbolUtilities.IsNewStyleFormat && attributeSet.ContainsKey("extendedfunctioncode")) { attributeSet.Add("sidc", DisplayAttributes.SymbolIdCode); } // METOC do not have identity/affiliation so have 1 less attribute minimumAttributeCount--; } // Validate that image is ready to be created if ((attributeSet == null) || (attributeSet.Count < minimumAttributeCount)) { _symbolImage = null; return; } _symbolImage = await GetBitmapImageAsync(attributeSet) as BitmapImage; NotifyPropertyChanged(() => SymbolImage); }
public async Task <bool> GDBContainsMilitaryOverlay(GDBProjectItem gdbProjectItem, ProSymbolUtilities.SupportedStandardsType standard) { if (gdbProjectItem == null) { return(false); } string militaryOverlayFeatureDatasetName = ProSymbolUtilities.GetDatasetName(standard); bool gdbContainsMilitaryOverlay = await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run <bool>(() => { using (Datastore datastore = gdbProjectItem.GetDatastore()) { // Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore if (datastore is UnknownDatastore) { return(false); } Geodatabase geodatabase = datastore as Geodatabase; if (geodatabase == null) { return(false); } var defs = geodatabase.GetDefinitions <FeatureDatasetDefinition>().Where(fd => fd.GetName().Contains(militaryOverlayFeatureDatasetName)).ToList();; return(defs.Count > 0); } }); return(gdbContainsMilitaryOverlay); }
private string getSymbolIdCodeFromAttributes() { // Build SIDC from the symbol attributes System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (ProSymbolUtilities.IsLegacyStandard()) { string extendedFunctionCode = ExtendedFunctionCode; if ((ProSymbolUtilities.IsLegacyStandard()) && (!String.IsNullOrEmpty(extendedFunctionCode)) && (extendedFunctionCode.Length >= 10)) { bool isWeather = (extendedFunctionCode[0] == 'W'); if (isWeather) { sb.Append(extendedFunctionCode.Substring(0, 10)); switch (this.SymbolGeometry) { case GeometryType.Point: sb.Append("P--"); break; case GeometryType.Polyline: sb.Append("-L-"); break; case GeometryType.Polygon: sb.Append("--A"); break; default: sb.Append("---"); break; } sb.Append("--"); } else { sb.Append(extendedFunctionCode[0]); if (String.IsNullOrEmpty(Identity)) { sb.Append('U'); } else { sb.Append(Identity); } sb.Append(extendedFunctionCode[2]); if (String.IsNullOrEmpty(Status)) { sb.Append('P'); } else { sb.Append(Status); } sb.Append(extendedFunctionCode.Substring(4, 6)); if (String.IsNullOrEmpty(Indicator)) { sb.Append('-'); } else { sb.Append(Indicator); } if (String.IsNullOrEmpty(Echelon)) { sb.Append('-'); } else { sb.Append(Echelon); } if (String.IsNullOrEmpty(CountryCodeForSIDC) || CountryCodeForSIDC.Length != 2) { sb.Append("--"); } else { sb.Append(CountryCodeForSIDC); } sb.Append("-"); } } } else { // 2525D / APP6D // Version - 1, 2 sb.Append("10"); // identity-context - 3 if (string.IsNullOrEmpty(_context)) { sb.Append("0"); } else { sb.Append(_context); } // identity-affiliation - 4 if (string.IsNullOrEmpty(_identity)) { sb.Append("0"); } else { sb.Append(_identity); } // symbolset - 5, 6 if (string.IsNullOrEmpty(_symbolSet)) { sb.Append("00"); } else { sb.Append(ProSymbolUtilities.ZeroPadLeft(_symbolSet, 2)); } // status/operational condition - 7 if (string.IsNullOrEmpty(_status) && string.IsNullOrEmpty(_operationalCondition)) { sb.Append("0"); } else { if (!string.IsNullOrEmpty(_status)) { sb.Append(_status); } else { sb.Append(_operationalCondition); } } // HQ, TF, FD indicator - 8 if (string.IsNullOrEmpty(_indicator)) { sb.Append("0"); } else { sb.Append(_indicator); } // Echelon/Mobility 9, 10 if (string.IsNullOrEmpty(_echelon) && string.IsNullOrEmpty(_mobility)) { sb.Append("00"); } else { if (!string.IsNullOrEmpty(_echelon)) { sb.Append(ProSymbolUtilities.ZeroPadLeft(_echelon, 2)); } else { sb.Append(ProSymbolUtilities.ZeroPadLeft(_mobility, 2)); } } if (string.IsNullOrEmpty(_symbolEntity)) { sb.Append("000000"); } else { sb.Append(ProSymbolUtilities.ZeroPadLeft(_symbolEntity, 6)); } if (string.IsNullOrEmpty(_modifier1)) { sb.Append("00"); } else { sb.Append(ProSymbolUtilities.ZeroPadLeft(_modifier1, 2)); } if (string.IsNullOrEmpty(_modifier2)) { sb.Append("00"); } else { sb.Append(ProSymbolUtilities.ZeroPadLeft(_modifier2, 2)); } } return(sb.ToString()); }
private async void Button_Click(object sender, RoutedEventArgs e) { // or give user the option of selecting workspace: string selectedGDB = ProSymbolUtilities.BrowseItem(ArcGIS.Desktop.Catalog.ItemFilters.geodatabases); if (string.IsNullOrEmpty(selectedGDB)) { return; } if (DefaultDatabase != selectedGDB) { DefaultDatabaseChanged = true; DefaultDatabase = selectedGDB; // See if the selected database already contains a standard, // if so set the standard, and disable the control var selectedGDBasItem = ArcGIS.Desktop.Core.ItemFactory. Instance.Create(selectedGDB); bool hasStandard = false; ProSymbolUtilities.SupportedStandardsType standardFound = ProSymbolUtilities.SupportedStandardsType.mil2525d; foreach (ProSymbolUtilities.SupportedStandardsType standard in Enum.GetValues(typeof(ProSymbolUtilities.SupportedStandardsType))) { bool containsStandard = await ProSymbolEditorModule.Current.MilitaryOverlaySchema. GDBContainsMilitaryOverlay( selectedGDBasItem as ArcGIS.Desktop.Catalog.GDBProjectItem, standard); if (containsStandard) { hasStandard = true; standardFound = standard; break; } } if (hasStandard) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show( "Database: " + selectedGDB + "\n" + "contains a schema for standard: \n" + ProSymbolUtilities.GetStandardLabel(standardFound) + ".\n" + "Setting standard to this value." , "Database Contains Schema", MessageBoxButton.OK, MessageBoxImage.Information); Standard = standardFound; RaisePropertyChanged("SelectedSymbologyStandard"); } // Disable/enable the standard button if GDB had schema IsSettingsReadOnly = hasStandard; RaisePropertyChanged("IsSettingsNotReadOnly"); RaisePropertyChanged("DefaultDatabase"); } }
// TODO: we may be able to deprecate this method (GDBContainsSchema) and use the method above (GDBContainsMilitaryOverlay) public async Task <bool> GDBContainsSchema(GDBProjectItem gdbProjectItem, ProSymbolUtilities.SupportedStandardsType standard) { bool isSchemaComplete = await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run <bool>(() => { if (gdbProjectItem == null) { return(false); } using (Datastore datastore = gdbProjectItem.GetDatastore()) { // Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore if (datastore is UnknownDatastore) { return(false); } Geodatabase geodatabase = datastore as Geodatabase; if (geodatabase == null) { return(false); } // Set up Fields to check List <string> fieldsToCheck = new List <string>(); if (ProSymbolUtilities.IsLegacyStandard(standard)) { fieldsToCheck.Add("extendedfunctioncode"); } else { // 2525d / app6d fieldsToCheck.Add("symbolset"); fieldsToCheck.Add("symbolentity"); } // Reset schema data model exists to false for each feature class Dictionary <string, bool> featureClassExists = GetFeatureClassExistsMap(standard, geodatabase); IReadOnlyList <FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions <FeatureClassDefinition>(); bool stopLooking = false; foreach (FeatureClassDefinition featureClassDefinition in featureClassDefinitions) { // Stop looking after the first feature class not found if (stopLooking) { return(false); } string featureClassName = featureClassDefinition.GetName(); if (featureClassExists.ContainsKey(featureClassName)) { // Feature Class Exists. Check for fields bool fieldsExist = true; // Don't do this for remote databases (too slow) if (geodatabase.GetGeodatabaseType() != GeodatabaseType.RemoteDatabase) { foreach (string fieldName in fieldsToCheck) { IEnumerable <Field> foundFields = featureClassDefinition.GetFields().Where(x => x.Name == fieldName); if (foundFields.Count() < 1) { fieldsExist = false; return(false); } } } featureClassExists[featureClassName] = fieldsExist; } else { // Key doesn't exist, so ignore } } foreach (KeyValuePair <string, bool> pair in featureClassExists) { if (pair.Value == false) { return(false); } } // If here, schema is complete // Save geodatabase path to use as the selected database _databaseName = gdbProjectItem.Path; _schemaExists = true; _standard = standard; return(true); } }); return(isSchemaComplete); }
public string GetDatasetName() { return(EGDBPrefixName + ProSymbolUtilities.GetDatasetName(ProSymbolUtilities.Standard)); }
public void PopulateFeatureWithAttributes(ref Feature feature) { if (feature == null) { // not normally possible with ref parameter, but check just in case System.Diagnostics.Debug.WriteLine("Null Feature passed to PopulateFeatureWithAttributes"); return; } // Implementation Note: only force a feature field value with domains attached // to null if NullFieldValueFlag("<null>) is set on that field // 2525C/B attributes: if (ProSymbolUtilities.IsLegacyStandard()) { if (!string.IsNullOrEmpty(DisplayAttributes.ExtendedFunctionCode) && (feature.FindField("extendedfunctioncode") >= 0)) { if (DisplayAttributes.ExtendedFunctionCode == ProSymbolUtilities.NullFieldValueFlag) { feature["extendedfunctioncode"] = null; } else { feature["extendedfunctioncode"] = DisplayAttributes.ExtendedFunctionCode; } } if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (feature.FindField("affiliation") >= 0)) { if (DisplayAttributes.Identity == ProSymbolUtilities.NullFieldValueFlag) { feature["affiliation"] = null; } else { feature["affiliation"] = DisplayAttributes.Identity; } } if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (feature.FindField("hqtffd") >= 0)) { if (DisplayAttributes.Indicator == ProSymbolUtilities.NullFieldValueFlag) { feature["hqtffd"] = null; } else { feature["hqtffd"] = DisplayAttributes.Indicator; } } if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (feature.FindField("echelonmobility") >= 0)) { if (DisplayAttributes.Echelon == ProSymbolUtilities.NullFieldValueFlag) { feature["echelonmobility"] = null; } else { feature["echelonmobility"] = DisplayAttributes.Echelon; } } } else // 2525D attributes: { if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (feature.FindField("identity") >= 0)) { if (DisplayAttributes.Identity == ProSymbolUtilities.NullFieldValueFlag) { feature["identity"] = null; } else { feature["identity"] = DisplayAttributes.Identity; } } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolSet) && (feature.FindField("symbolset") >= 0)) { if (DisplayAttributes.SymbolSet == ProSymbolUtilities.NullFieldValueFlag) { feature["symbolset"] = null; } else { feature["symbolset"] = Convert.ToInt32(DisplayAttributes.SymbolSet); } } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolEntity) && (feature.FindField("symbolentity") >= 0)) { if (DisplayAttributes.SymbolEntity == ProSymbolUtilities.NullFieldValueFlag) { feature["symbolentity"] = null; } else { feature["symbolentity"] = Convert.ToInt32(DisplayAttributes.SymbolEntity); } } //Indicator / HQTFFD if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (feature.FindField("indicator") >= 0)) { if (DisplayAttributes.Indicator == ProSymbolUtilities.NullFieldValueFlag) { feature["indicator"] = null; } else { feature["indicator"] = DisplayAttributes.Indicator; } } //Echelon or Mobility if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (feature.FindField("echelon") >= 0)) { if (DisplayAttributes.Echelon == ProSymbolUtilities.NullFieldValueFlag) { feature["echelon"] = null; } else { feature["echelon"] = DisplayAttributes.Echelon; } } if (!string.IsNullOrEmpty(DisplayAttributes.Mobility) && (feature.FindField("mobility") >= 0)) { if (DisplayAttributes.Mobility == ProSymbolUtilities.NullFieldValueFlag) { feature["mobility"] = null; } else { feature["mobility"] = DisplayAttributes.Mobility; } } //Statuses or Operation if (!string.IsNullOrEmpty(DisplayAttributes.OperationalCondition) && (feature.FindField("operationalcondition") >= 0)) { if (DisplayAttributes.OperationalCondition == ProSymbolUtilities.NullFieldValueFlag) { feature["operationalcondition"] = null; } else { feature["operationalcondition"] = DisplayAttributes.OperationalCondition; } } if (!string.IsNullOrEmpty(DisplayAttributes.Context) && (feature.FindField("context") >= 0)) { if (DisplayAttributes.Context == ProSymbolUtilities.NullFieldValueFlag) { feature["context"] = null; } else { feature["context"] = DisplayAttributes.Context; } } //Modifiers if (!string.IsNullOrEmpty(DisplayAttributes.Modifier1) && (feature.FindField("modifier1") >= 0)) { if (DisplayAttributes.Modifier1 == ProSymbolUtilities.NullFieldValueFlag) { feature["modifier1"] = null; } else { feature["modifier1"] = DisplayAttributes.Modifier1; } } if (!string.IsNullOrEmpty(DisplayAttributes.Modifier2) && (feature.FindField("modifier2") >= 0)) { if (DisplayAttributes.Modifier2 == ProSymbolUtilities.NullFieldValueFlag) { feature["modifier2"] = null; } else { feature["modifier2"] = DisplayAttributes.Modifier2; } } } // Applies to all versions of the standard if (!string.IsNullOrEmpty(DisplayAttributes.Status) && (feature.FindField("status") >= 0)) { if (DisplayAttributes.Status == ProSymbolUtilities.NullFieldValueFlag) { feature["status"] = null; } else { feature["status"] = DisplayAttributes.Status; } } //LABELS if ((LabelAttributes.DateTimeValid != null) && (feature.FindField("datetimevalid") >= 0)) { feature["datetimevalid"] = LabelAttributes.DateTimeValid.ToString(); } if ((LabelAttributes.DateTimeExpired != null) && (feature.FindField("datetimeexpired") >= 0)) { feature["datetimeexpired"] = LabelAttributes.DateTimeExpired.ToString(); } if (feature.FindField("uniquedesignation") >= 0) { feature["uniquedesignation"] = LabelAttributes.UniqueDesignation; } if (feature.FindField("staffcomment") >= 0) { feature["staffcomment"] = LabelAttributes.StaffComments; } if (feature.FindField("additionalinformation") >= 0) { feature["additionalinformation"] = LabelAttributes.AdditionalInformation; } if (feature.FindField("type") >= 0) { feature["type"] = LabelAttributes.Type; } if (feature.FindField("commonidentifier") >= 0) { feature["commonidentifier"] = LabelAttributes.CommonIdentifier; } if (feature.FindField("speed") >= 0) { feature["speed"] = LabelAttributes.Speed; } if (feature.FindField("direction") >= 0) { feature["direction"] = LabelAttributes.Direction; } if (feature.FindField("higherFormation") >= 0) { feature["higherFormation"] = LabelAttributes.HigherFormation; } if (!string.IsNullOrEmpty(LabelAttributes.Reinforced) && (feature.FindField("reinforced") >= 0)) { if (LabelAttributes.Reinforced == ProSymbolUtilities.NullFieldValueFlag) { feature["reinforced"] = null; } else { feature["reinforced"] = LabelAttributes.Reinforced; } } if (!string.IsNullOrEmpty(LabelAttributes.Credibility) && (feature.FindField("credibility") >= 0)) { if (LabelAttributes.Credibility == ProSymbolUtilities.NullFieldValueFlag) { feature["credibility"] = null; } else { feature["credibility"] = LabelAttributes.Credibility; } } if (!string.IsNullOrEmpty(LabelAttributes.Reliability) && (feature.FindField("reliability") >= 0)) { if (LabelAttributes.Reliability == ProSymbolUtilities.NullFieldValueFlag) { feature["reliability"] = null; } else { feature["reliability"] = LabelAttributes.Reliability; } } if (!string.IsNullOrEmpty(LabelAttributes.SignatureEquipment) && (feature.FindField("signatureequipment") >= 0)) { if (LabelAttributes.SignatureEquipment == ProSymbolUtilities.NullFieldValueFlag) { feature["signatureequipment"] = null; } else { feature["signatureequipment"] = LabelAttributes.SignatureEquipment; } } if (!string.IsNullOrEmpty(LabelAttributes.CountryCode) && (feature.FindField("countrycode") >= 0)) { if (LabelAttributes.CountryCode == ProSymbolUtilities.NullFieldValueFlag) { feature["countrycode"] = null; } else { feature["countrycode"] = LabelAttributes.CountryCode; } } if (!string.IsNullOrEmpty(LabelAttributes.CountryLabel) && (feature.FindField("countrylabel") >= 0)) { feature["countrylabel"] = LabelAttributes.CountryLabel; } }
public void PopulateRowBufferWithAttributes(ref RowBuffer rowBuffer) { if (rowBuffer == null) { // not normally possible with ref parameter, but check just in case System.Diagnostics.Debug.WriteLine("Null RowBuffer passed to PopulateRowBufferWithAttributes"); return; } if (ProSymbolUtilities.IsLegacyStandard()) { if (!string.IsNullOrEmpty(DisplayAttributes.ExtendedFunctionCode) && (DisplayAttributes.ExtendedFunctionCode != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["extendedfunctioncode"] = DisplayAttributes.ExtendedFunctionCode; } if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (DisplayAttributes.Identity != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["affiliation"] = DisplayAttributes.Identity; } if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (DisplayAttributes.Indicator != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["hqtffd"] = DisplayAttributes.Indicator; } if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (DisplayAttributes.Echelon != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["echelonmobility"] = DisplayAttributes.Echelon; } } else { if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (DisplayAttributes.Identity != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["identity"] = DisplayAttributes.Identity; } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolSet) && (DisplayAttributes.SymbolSet != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["symbolset"] = Convert.ToInt32(DisplayAttributes.SymbolSet); } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolEntity) && (DisplayAttributes.SymbolEntity != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["symbolentity"] = Convert.ToInt32(DisplayAttributes.SymbolEntity); } //Indicator / HQTFFD / if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (DisplayAttributes.Indicator != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["indicator"] = DisplayAttributes.Indicator; } //Echelon or Mobility if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (DisplayAttributes.Echelon != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["echelon"] = DisplayAttributes.Echelon; } if (!string.IsNullOrEmpty(DisplayAttributes.Mobility) && (DisplayAttributes.Mobility != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["mobility"] = DisplayAttributes.Mobility; } //Statuses or Operation if (!string.IsNullOrEmpty(DisplayAttributes.OperationalCondition) && (DisplayAttributes.OperationalCondition != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["operationalcondition"] = DisplayAttributes.OperationalCondition; } // 2525D attributes if (!string.IsNullOrEmpty(DisplayAttributes.Context) && (DisplayAttributes.Context != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["context"] = DisplayAttributes.Context; } if (!string.IsNullOrEmpty(DisplayAttributes.Modifier1) && (DisplayAttributes.Modifier1 != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["modifier1"] = DisplayAttributes.Modifier1; } if (!string.IsNullOrEmpty(DisplayAttributes.Modifier2) && (DisplayAttributes.Modifier2 != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["modifier2"] = DisplayAttributes.Modifier2; } } if (!string.IsNullOrEmpty(DisplayAttributes.Status) && (DisplayAttributes.Status != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["status"] = DisplayAttributes.Status; } //LABELS if (LabelAttributes.DateTimeValid != null) { rowBuffer["datetimevalid"] = LabelAttributes.DateTimeValid.ToString(); } if (LabelAttributes.DateTimeExpired != null) { rowBuffer["datetimeexpired"] = LabelAttributes.DateTimeExpired.ToString(); } if (!string.IsNullOrEmpty(LabelAttributes.UniqueDesignation)) { rowBuffer["uniquedesignation"] = LabelAttributes.UniqueDesignation; } if (!string.IsNullOrEmpty(LabelAttributes.StaffComments)) { rowBuffer["staffcomment"] = LabelAttributes.StaffComments; } if (!string.IsNullOrEmpty(LabelAttributes.AdditionalInformation)) { rowBuffer["additionalinformation"] = LabelAttributes.AdditionalInformation; } if (!string.IsNullOrEmpty(LabelAttributes.Type)) { rowBuffer["type"] = LabelAttributes.Type; } if (!string.IsNullOrEmpty(LabelAttributes.CommonIdentifier)) { rowBuffer["commonidentifier"] = LabelAttributes.CommonIdentifier; } if (LabelAttributes.Speed != null) { //Short rowBuffer["speed"] = LabelAttributes.Speed; } if (LabelAttributes.Direction != null) { //Short rowBuffer["direction"] = LabelAttributes.Direction; } if (!string.IsNullOrEmpty(LabelAttributes.HigherFormation)) { rowBuffer["higherFormation"] = LabelAttributes.HigherFormation; } if (!string.IsNullOrEmpty(LabelAttributes.Reinforced) && (LabelAttributes.Reinforced != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["reinforced"] = LabelAttributes.Reinforced; } if (!string.IsNullOrEmpty(LabelAttributes.Credibility) && (LabelAttributes.Credibility != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["credibility"] = LabelAttributes.Credibility; } if (!string.IsNullOrEmpty(LabelAttributes.Reliability) && (LabelAttributes.Reliability != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["reliability"] = LabelAttributes.Reliability; } if (!string.IsNullOrEmpty(LabelAttributes.SignatureEquipment) && (LabelAttributes.SignatureEquipment != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["signatureequipment"] = LabelAttributes.SignatureEquipment; } if (!string.IsNullOrEmpty(LabelAttributes.CountryCode) && (LabelAttributes.CountryCode != ProSymbolUtilities.NullFieldValueFlag)) { rowBuffer["countrycode"] = LabelAttributes.CountryCode; if (rowBuffer.FindField("countrylabel") >= 0) // does not exist in all versions of the database { rowBuffer["countrylabel"] = LabelAttributes.CountryLabel; } } }
public Dictionary <string, object> GenerateAttributeSetDictionary() { Dictionary <string, object> attributeSet = new Dictionary <string, object>(); bool isMETOC = false; if (ProSymbolUtilities.IsLegacyStandard()) { if (!string.IsNullOrEmpty(DisplayAttributes.ExtendedFunctionCode) && (DisplayAttributes.ExtendedFunctionCode != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["extendedfunctioncode"] = DisplayAttributes.ExtendedFunctionCode; if (DisplayAttributes.ExtendedFunctionCode[0] == 'W') { isMETOC = true; } } if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (DisplayAttributes.Identity != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["affiliation"] = DisplayAttributes.Identity; } if (!string.IsNullOrEmpty(DisplayAttributes.Status) && (DisplayAttributes.Status != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["status"] = DisplayAttributes.Status; } if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (DisplayAttributes.Indicator != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["hqtffd"] = DisplayAttributes.Indicator; } if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (DisplayAttributes.Echelon != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["echelonmobility"] = DisplayAttributes.Echelon; } } else // 2525D { if (!string.IsNullOrEmpty(DisplayAttributes.Identity) && (DisplayAttributes.Identity != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["identity"] = DisplayAttributes.Identity; } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolSet) && (DisplayAttributes.SymbolSet != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["symbolset"] = DisplayAttributes.SymbolSet; if ((DisplayAttributes.SymbolSet == "45") || (DisplayAttributes.SymbolSet == "46")) { isMETOC = true; } } if (!string.IsNullOrEmpty(DisplayAttributes.SymbolEntity) && (DisplayAttributes.SymbolEntity != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["symbolentity"] = DisplayAttributes.SymbolEntity; } if (!string.IsNullOrEmpty(DisplayAttributes.Indicator) && (DisplayAttributes.Indicator != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["indicator"] = DisplayAttributes.Indicator; } //Echelon or Mobility if (!string.IsNullOrEmpty(DisplayAttributes.Echelon) && (DisplayAttributes.Echelon != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["echelon"] = DisplayAttributes.Echelon; } if (!string.IsNullOrEmpty(DisplayAttributes.Mobility) && (DisplayAttributes.Mobility != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["echelon"] = DisplayAttributes.Mobility; } //Statuses or Operation if (!string.IsNullOrEmpty(DisplayAttributes.OperationalCondition) && (DisplayAttributes.OperationalCondition != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["operationalcondition"] = DisplayAttributes.OperationalCondition; } if (!string.IsNullOrEmpty(DisplayAttributes.Status) && (DisplayAttributes.Status != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["operationalcondition"] = DisplayAttributes.Status; } // 2525D attributes if (!string.IsNullOrEmpty(DisplayAttributes.Context) && (DisplayAttributes.Context != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["context"] = DisplayAttributes.Context; } if (!string.IsNullOrEmpty(DisplayAttributes.Modifier1) && (DisplayAttributes.Modifier1 != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["modifier1"] = DisplayAttributes.Modifier1; } if (!string.IsNullOrEmpty(DisplayAttributes.Modifier2) && (DisplayAttributes.Modifier2 != ProSymbolUtilities.NullFieldValueFlag)) { attributeSet["modifier2"] = DisplayAttributes.Modifier2; } } attributeSet.Add("IsMETOC", isMETOC); return(attributeSet); }
private void SetPropertiesFromFieldAttributes(Dictionary <string, string> fieldValues) { if (fieldValues == null) { return; } if (ProSymbolUtilities.IsLegacyStandard()) { if (fieldValues.ContainsKey("extendedfunctioncode")) { DisplayAttributes.ExtendedFunctionCode = fieldValues["extendedfunctioncode"]; } if (fieldValues.ContainsKey("affiliation")) { DisplayAttributes.Identity = fieldValues["affiliation"]; } if (fieldValues.ContainsKey("hqtffd")) { DisplayAttributes.Indicator = fieldValues["hqtffd"]; } if (fieldValues.ContainsKey("echelonmobility")) { DisplayAttributes.Echelon = fieldValues["echelonmobility"]; } } else { if (fieldValues.ContainsKey("identity")) { DisplayAttributes.Identity = fieldValues["identity"]; } if (fieldValues.ContainsKey("symbolset")) { // Tricky symbolset string expected to be len 2 - fixes bug with "01" "02" "05" symbol sets string symbolSetValue = fieldValues["symbolset"]; if (!string.IsNullOrEmpty(symbolSetValue)) { string paddedSymbolSet = symbolSetValue.PadLeft(2, '0'); DisplayAttributes.SymbolSet = paddedSymbolSet; } } if (fieldValues.ContainsKey("symbolentity")) { DisplayAttributes.SymbolEntity = fieldValues["symbolentity"]; } if (fieldValues.ContainsKey("indicator")) { DisplayAttributes.Indicator = fieldValues["indicator"]; } if (fieldValues.ContainsKey("echelon")) { DisplayAttributes.Echelon = fieldValues["echelon"]; } if (fieldValues.ContainsKey("mobility")) { DisplayAttributes.Mobility = fieldValues["mobility"]; } if (fieldValues.ContainsKey("operationalcondition")) { DisplayAttributes.OperationalCondition = fieldValues["operationalcondition"]; } if (fieldValues.ContainsKey("context")) { DisplayAttributes.Context = fieldValues["context"]; } if (fieldValues.ContainsKey("modifier1")) { DisplayAttributes.Modifier1 = fieldValues["modifier1"]; } if (fieldValues.ContainsKey("modifier2")) { DisplayAttributes.Modifier2 = fieldValues["modifier2"]; } } if (fieldValues.ContainsKey("status")) { DisplayAttributes.Status = fieldValues["status"]; } // TRICKY: turn off the UI validation for max length, so this exception is not thrown LabelAttributes.MaxLengthValidationOn = false; //LABELS if (fieldValues.ContainsKey("datetimevalid")) { // TODO: add tryparse LabelAttributes.DateTimeValid = DateTime.Parse(fieldValues["datetimevalid"]); } if (fieldValues.ContainsKey("datetimeexpired")) { // TODO: add tryparse LabelAttributes.DateTimeExpired = DateTime.Parse(fieldValues["datetimeexpired"]); } if (fieldValues.ContainsKey("uniquedesignation")) { LabelAttributes.UniqueDesignation = fieldValues["uniquedesignation"]; } if (fieldValues.ContainsKey("staffcomment")) { LabelAttributes.StaffComments = fieldValues["staffcomment"]; } if (fieldValues.ContainsKey("additionalinformation")) { LabelAttributes.AdditionalInformation = fieldValues["additionalinformation"]; } if (fieldValues.ContainsKey("type")) { LabelAttributes.Type = fieldValues["type"]; } if (fieldValues.ContainsKey("commonidentifier")) { LabelAttributes.CommonIdentifier = fieldValues["commonidentifier"]; } if (fieldValues.ContainsKey("speed")) { LabelAttributes.Speed = short.Parse(fieldValues["speed"]); } if (fieldValues.ContainsKey("direction")) { LabelAttributes.Direction = short.Parse(fieldValues["direction"]); } if (fieldValues.ContainsKey("higherFormation")) { LabelAttributes.HigherFormation = fieldValues["higherFormation"]; } if (fieldValues.ContainsKey("reinforced")) { LabelAttributes.Reinforced = fieldValues["reinforced"]; } if (fieldValues.ContainsKey("credibility")) { LabelAttributes.Credibility = fieldValues["credibility"]; } if (fieldValues.ContainsKey("reliability")) { LabelAttributes.Reliability = fieldValues["reliability"]; } if (fieldValues.ContainsKey("signatureequipment")) { LabelAttributes.SignatureEquipment = fieldValues["signatureequipment"]; } if (fieldValues.ContainsKey("countrycode")) { LabelAttributes.CountryCode = fieldValues["countrycode"]; } // TRICKY: turn UI validation back on LabelAttributes.MaxLengthValidationOn = true; }