Inheritance: System.ComponentModel.PropertyChangedBase
Example #1
0
        public override bool Equals(object obj)
        {
            if ((obj == null) || (GetType() != obj.GetType()))
            {
                return(false);
            }

            SymbolAttributeSet compareObj = obj as SymbolAttributeSet;

            if ((compareObj == null) || (DisplayAttributes == null) || (LabelAttributes == null))
            {
                return(false);
            }

            return(DisplayAttributes.Equals(compareObj.DisplayAttributes) &&
                   LabelAttributes.Equals(compareObj.LabelAttributes));
        }
        private async Task CreateSymbolSetFromFieldValuesAsync()
        {
            try
            {
                Dictionary<string, string> fieldValues = new Dictionary<string, string>();
                await QueuedTask.Run(() =>
                {
                    string oidFieldName = _selectedSelectedFeature.FeatureLayer.GetTable().GetDefinition().GetObjectIDField();
                    QueryFilter queryFilter = new QueryFilter();
                    queryFilter.WhereClause = string.Format("{0} = {1}", oidFieldName, _selectedSelectedFeature.ObjectId);
                    RowCursor cursor = _selectedSelectedFeature.FeatureLayer.Search(queryFilter);
                    Row row = null;

                    if (cursor.MoveNext())
                    {
                        row = cursor.Current;
                    }

                    if (row == null)
                    {
                        return;
                    }

                    //Dictionary<string, string> fieldValuesThread = new Dictionary<string, string>();
                    IReadOnlyList<Field> fields = row.GetFields();
                    lock (_lock)
                    {
                        foreach (Field field in fields)
                        {
                            if (field.FieldType == FieldType.Geometry)
                            {
                                continue;
                            }

                            var fieldValue = row[field.Name];

                            if (fieldValue != null)
                            {
                                fieldValues[field.Name] = fieldValue.ToString();
                            }
                        }
                    }

                    //return fieldVa
                });

                //Transfer field values into SymbolAttributes
                SymbolAttributeSet set = new SymbolAttributeSet(fieldValues);
                set.SymbolTags = "";
                EditSelectedFeatureSymbol = set;
                LoadSymbolIntoWorkflow(true);
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.ToString());
            }

            return;
        }
        private async void GetMilitaryDomainsAsync(SymbolAttributeSet loadSet = null)
        {
            try
            {
                IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
                await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
                {
                    foreach (GDBProjectItem gdbProjectItem in gdbProjectItems)
                    {
                        using (Datastore datastore = gdbProjectItem.GetDatastore())
                        {
                            //Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore
                            if (datastore is UnknownDatastore)
                                    continue;
                            Geodatabase geodatabase = datastore as Geodatabase;

                            string geodatabasePath = geodatabase.GetPath();
                            if (geodatabasePath == ProSymbolEditorModule.Current.MilitaryOverlaySchema.DatabaseName)
                            {
                                //Correct GDB, open the current selected feature class
                                _currentFeatureClass = geodatabase.OpenDataset<FeatureClass>(_currentFeatureClassName);
                                using (_currentFeatureClass)
                                {
                                    ArcGIS.Core.Data.FeatureClassDefinition facilitySiteDefinition = _currentFeatureClass.GetDefinition();
                                    IReadOnlyList<ArcGIS.Core.Data.Field> fields = facilitySiteDefinition.GetFields();

                                    MilitaryFieldsInspectorModel.PopulateDomains(fields);
                                    MilitaryFieldsInspectorModel.CheckLabelFieldsExistence(fields);
                                }

                                break;
                            }
                        }
                    }
                });

                //Check for affiliation tag
                if (_selectedStyleItem != null)
                {
                    string identityCode = "";
                    if (_selectedStyleItem.Tags.ToUpper().Contains("FRIEND"))
                    {
                        identityCode = await GetDomainValueAsync("identity", "Friend");
                    }
                    else if (_selectedStyleItem.Tags.ToUpper().Contains("HOSTILE"))
                    {
                        identityCode = await GetDomainValueAsync("identity", "Hostile/Faker");
                    }
                    else if (_selectedStyleItem.Tags.ToUpper().Contains("NEUTRAL"))
                    {
                        identityCode = await GetDomainValueAsync("identity", "Neutral");
                    }
                    else if (_selectedStyleItem.Tags.ToUpper().Contains("UNKNOWN"))
                    {
                        identityCode = await GetDomainValueAsync("identity", "Unknown");
                    }

                    //Check name of style last to see if it has an affiliation, but no associated tag
                    //But only do this if no tag existed
                    if (identityCode == "")
                    {
                        if (_selectedStyleItem.Name.ToUpper().Contains(": FRIEND"))
                        {
                            identityCode = await GetDomainValueAsync("identity", "Friend");
                        }
                        else if (_selectedStyleItem.Name.ToUpper().Contains(": HOSTILE"))
                        {
                            identityCode = await GetDomainValueAsync("identity", "Hostile/Faker");
                        }
                        else if (_selectedStyleItem.Name.ToUpper().Contains(": NEUTRAL"))
                        {
                            identityCode = await GetDomainValueAsync("identity", "Neutral");
                        }
                        else if (_selectedStyleItem.Name.ToUpper().Contains(": UNKNOWN"))
                        {
                            identityCode = await GetDomainValueAsync("identity", "Unknown");
                        }
                    }

                    if (identityCode != "")
                    {
                        foreach (DomainCodedValuePair dcvp in MilitaryFieldsInspectorModel.IdentityDomainValues)
                        {
                            if (dcvp.Code.ToString() == identityCode)
                            {
                                SymbolAttributeSet.DisplayAttributes.SelectedIdentityDomainPair = dcvp;
                                break;
                            }
                        }
                    }
                }

                //Load any passed in values to selected values for the domain combo boxes
                if (loadSet != null)
                {
                    SymbolAttributeSet.DisplayAttributes.SelectedIdentityDomainPair = MilitaryFieldsInspectorModel.IdentityDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Identity);
                    SymbolAttributeSet.DisplayAttributes.SelectedEchelonDomainPair = MilitaryFieldsInspectorModel.EcholonDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Echelon);
                    SymbolAttributeSet.DisplayAttributes.SelectedMobilityDomainPair = MilitaryFieldsInspectorModel.MobilityDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Mobility);
                    SymbolAttributeSet.DisplayAttributes.SelectedOperationalConditionDomainPair = MilitaryFieldsInspectorModel.OperationalConditionAmplifierDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.OperationalCondition);
                    SymbolAttributeSet.DisplayAttributes.SelectedIndicatorDomainPair = MilitaryFieldsInspectorModel.TfFdHqDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Indicator);
                    SymbolAttributeSet.DisplayAttributes.SelectedStatusDomainPair = MilitaryFieldsInspectorModel.StatusDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Status);
                    SymbolAttributeSet.DisplayAttributes.SelectedContextDomainPair = MilitaryFieldsInspectorModel.ContextDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Context);
                    SymbolAttributeSet.DisplayAttributes.SelectedModifier1DomainPair = MilitaryFieldsInspectorModel.Modifier1DomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Modifier1);
                    SymbolAttributeSet.DisplayAttributes.SelectedModifier2DomainPair = MilitaryFieldsInspectorModel.Modifier2DomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Modifier2);

                    SymbolAttributeSet.LabelAttributes.SelectedCredibilityDomainPair = MilitaryFieldsInspectorModel.CredibilityDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.LabelAttributes.Credibility);
                    SymbolAttributeSet.LabelAttributes.SelectedReinforcedDomainPair = MilitaryFieldsInspectorModel.ReinforcedDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.LabelAttributes.Reinforced);
                    SymbolAttributeSet.LabelAttributes.SelectedReliabilityDomainPair = MilitaryFieldsInspectorModel.ReliabilityDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.LabelAttributes.Reliability);
                    SymbolAttributeSet.LabelAttributes.SelectedCountryCodeDomainPair = MilitaryFieldsInspectorModel.CountryCodeDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.LabelAttributes.CountryCode);
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.ToString());
            }
        }