Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #355 from Esri/dev
Browse files Browse the repository at this point in the history
March 2019 Release
  • Loading branch information
dfoll authored Mar 21, 2019
2 parents 25fda3b + 66a8f4a commit b975bbb
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 34 deletions.
4 changes: 4 additions & 0 deletions source/ProSymbolEditor/Models/MilitaryFieldsInspectorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class MilitaryFieldsInspectorModel : PropertyChangedBase
public ObservableCollection<DomainCodedValuePair> Modifier2DomainValues { get; set; }
public ObservableCollection<DomainCodedValuePair> CountryCodeDomainValues { get; set; }
public ObservableCollection<DomainCodedValuePair> ExtendedFunctionCodeValues { get; set; }
public ObservableCollection<DomainCodedValuePair> EntityCodeValues { get; set; }

public Visibility DateTimeValidFieldExists
{
Expand Down Expand Up @@ -189,6 +190,7 @@ public MilitaryFieldsInspectorModel()
MobilityDomainValues = new ObservableCollection<DomainCodedValuePair>();
TfFdHqDomainValues = new ObservableCollection<DomainCodedValuePair>();
ContextDomainValues = new ObservableCollection<DomainCodedValuePair>();
EntityCodeValues = new ObservableCollection<DomainCodedValuePair>();
Modifier1DomainValues = new ObservableCollection<DomainCodedValuePair>();
Modifier2DomainValues = new ObservableCollection<DomainCodedValuePair>();
CountryCodeDomainValues = new ObservableCollection<DomainCodedValuePair>();
Expand Down Expand Up @@ -262,6 +264,7 @@ public void PopulateDomains(IReadOnlyList<ArcGIS.Core.Data.Field> fields)

if (ProSymbolUtilities.Standard == ProSymbolUtilities.SupportedStandardsType.mil2525c_b2)
{
EntityCodeValues.Clear();
GetDomainAndPopulateList(fields, "affiliation", IdentityDomainValues);
GetDomainAndPopulateList(fields, "echelonmobility", EchelonDomainValues);
GetDomainAndPopulateList(fields, "extendedfunctioncode", ExtendedFunctionCodeValues);
Expand All @@ -279,6 +282,7 @@ public void PopulateDomains(IReadOnlyList<ArcGIS.Core.Data.Field> fields)
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public override int GetHashCode()
//Base attributes
private string _symbolSet;
private string _symbolEntity;
private DomainCodedValuePair _selectedEntityCodeDomainPair;
private string _identity;
private DomainCodedValuePair _selectedIdentityDomainPair;
private string _status;
Expand Down Expand Up @@ -230,6 +231,28 @@ public DomainCodedValuePair SelectedExtendedFunctionCodeDomainPair
}
}

[ScriptIgnore, Browsable(false)]
public DomainCodedValuePair SelectedEntityCodeDomainPair
{
get
{
return _selectedEntityCodeDomainPair;
}
set
{
_selectedEntityCodeDomainPair = value;
if (_selectedEntityCodeDomainPair != null)
{
_symbolEntity = _selectedEntityCodeDomainPair.Code.ToString();
NotifyPropertyChanged(() => SelectedEntityCodeDomainPair);
}
else
{
_symbolEntity = "";
}
}
}

public DisplayAttributes() { }

#region Getters/Setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ protected MilitarySymbolDockpaneViewModel()
BindingOperations.EnableCollectionSynchronization(MilitaryFieldsInspectorModel.CredibilityDomainValues, _lock);
BindingOperations.EnableCollectionSynchronization(MilitaryFieldsInspectorModel.CountryCodeDomainValues, _lock);
BindingOperations.EnableCollectionSynchronization(MilitaryFieldsInspectorModel.ExtendedFunctionCodeValues, _lock);
BindingOperations.EnableCollectionSynchronization(MilitaryFieldsInspectorModel.EntityCodeValues, _lock);

//Set up Commands
SearchResultCommand = new RelayCommand(SearchStylesAsync, param => true);
Expand Down Expand Up @@ -735,19 +736,29 @@ public SymbolStyleItem SelectedStyleItem

//Parse key for symbol id codes
string[] symbolIdCode = GetSymbolIdCodeFromStyle(_selectedStyleItem);
_symbolAttributeSet.DisplayAttributes.SymbolSet = symbolIdCode[0];
_symbolAttributeSet.DisplayAttributes.SymbolEntity = symbolIdCode[1];

if (symbolIdCode.Length >= 2)
{
_symbolAttributeSet.DisplayAttributes.SymbolSet = symbolIdCode[0];
_symbolAttributeSet.DisplayAttributes.SymbolEntity = symbolIdCode[1];
}

SymbolAttributeSet loadSet = new SymbolAttributeSet();

// Set 2525C_B2 SIDC/attribute if applicable
if (ProSymbolUtilities.Standard == ProSymbolUtilities.SupportedStandardsType.mil2525c_b2)
if ((ProSymbolUtilities.Standard == ProSymbolUtilities.SupportedStandardsType.mil2525c_b2)
&& (symbolIdCode.Length >= 3))
{
string functionCode = symbolIdCode[2];
_symbolAttributeSet.DisplayAttributes.ExtendedFunctionCode = functionCode;

loadSet.DisplayAttributes.ExtendedFunctionCode = functionCode;
}
else
{
loadSet.DisplayAttributes.SymbolSet = _symbolAttributeSet.DisplayAttributes.SymbolSet;
loadSet.DisplayAttributes.SymbolEntity = _symbolAttributeSet.DisplayAttributes.SymbolEntity;
}

//Get feature class name to generate domains
_currentFeatureClassName = _symbolSetMappings.GetFeatureClassFromMapping(
Expand Down Expand Up @@ -1325,7 +1336,7 @@ private async void SaveEdits(object parameter)
ArcGIS.Core.Geometry.Geometry savedGeometry = null;

IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(async () =>
{
try
{
Expand All @@ -1342,7 +1353,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
continue;

//Find the correct gdb for the one with the complete schema
string geodatabasePath = gdbProjectItem.Path;
string geodatabasePath = gdbProjectItem.Path;
if (geodatabasePath == ProSymbolEditorModule.Current.MilitaryOverlaySchema.DatabaseName)
{
EditOperation editOperation = new EditOperation();
Expand Down Expand Up @@ -1374,27 +1385,21 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
}
}, _selectedSelectedFeature.FeatureLayer.GetTable());

var task = editOperation.ExecuteAsync();
modificationResult = task.Result;
modificationResult = await editOperation.ExecuteAsync();

if (!modificationResult)
{
message = editOperation.ErrorMessage;
QueuedTask.Run(async () =>
{
await Project.Current.DiscardEditsAsync();
});
await Project.Current.DiscardEditsAsync();
}
else
{
QueuedTask.Run(async () =>
{
await Project.Current.SaveEditsAsync();
});
await Project.Current.SaveEditsAsync();
}
}
}
}
}
} // ifcorrect geodatabase
} // using
} // for each
} // try
catch (Exception exception)
{
message = exception.ToString();
Expand All @@ -1404,15 +1409,12 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>

if (modificationResult)
{
// Now actually save the edits
await ArcGIS.Desktop.Core.Project.Current.SaveEditsAsync();

// Reselect the saved feature (so UI is updated and feature flashed)
if (savedGeometry != null)
{
await QueuedTask.Run(() =>
{
MapView.Active.SelectFeatures(savedGeometry, SelectionCombinationMethod.New);
MapView.Active.SelectFeatures(savedGeometry, SelectionCombinationMethod.And);
});
}
}
Expand Down Expand Up @@ -2247,7 +2249,7 @@ private async void OnMapSelectionChanged(ArcGIS.Desktop.Mapping.Events.MapSelect
await QueuedTask.Run(() =>
{
ArcGIS.Core.Data.Field symbolSetField = kvp.Key.GetTable().GetDefinition().GetFields().FirstOrDefault(x => x.Name == symbolSetFieldName);
if (symbolSetField == null)
if (symbolSetField == null)
{
// then feature does not have required field, skip
// Note: we used to issue a warning, but it was requested to remove
Expand Down Expand Up @@ -2293,8 +2295,8 @@ await QueuedTask.Run(() =>
{
SelectedFeature newSelectedFeature = new SelectedFeature(kvp.Key, id);

if ((row.FindField(symbolSetFieldName) >=0) &&
( row[symbolSetFieldName] != null))
if ((row.FindField(symbolSetFieldName) >= 0) &&
(row[symbolSetFieldName] != null))
{
string symbolSetString = row[symbolSetFieldName].ToString();
foreach (KeyValuePair<object, string> symbolSetKeyValuePair in symbolSetDomainSortedList)
Expand All @@ -2307,10 +2309,10 @@ await QueuedTask.Run(() =>
}
}

if (!string.IsNullOrEmpty(symbolEntityFieldName) &&
if (!string.IsNullOrEmpty(symbolEntityFieldName) &&
(row.FindField(symbolEntityFieldName) >= 0) &&
(row[symbolEntityFieldName] != null) &&
(symbolEntityDomainSortedList !=null))
(row[symbolEntityFieldName] != null) &&
(symbolEntityDomainSortedList != null))
{
string symbolEntityString = row[symbolEntityFieldName].ToString();

Expand All @@ -2325,15 +2327,20 @@ await QueuedTask.Run(() =>
}

SelectedFeaturesCollection.Add(newSelectedFeature);

// Stop after the first one added
break;
}
} // for each id
});
}

SelectedSelectedFeature = SelectedFeaturesCollection.FirstOrDefault();
if (SelectedFeaturesCollection.Count > 1)
{
// TRICKY: if > 1 feature selected, we want to select the last one, since that will be drawn on top/visible
SelectedSelectedFeature = SelectedFeaturesCollection.Last();
}
else
{
SelectedSelectedFeature = SelectedFeaturesCollection.FirstOrDefault();
}
}

private async Task CheckAddinEnabled()
Expand Down Expand Up @@ -2545,6 +2552,10 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
SymbolAttributeSet.DisplayAttributes.SelectedExtendedFunctionCodeDomainPair
= MilitaryFieldsInspectorModel.ExtendedFunctionCodeValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.ExtendedFunctionCode);

if (loadSet.DisplayAttributes.SymbolEntity != null)
SymbolAttributeSet.DisplayAttributes.SelectedEntityCodeDomainPair
= MilitaryFieldsInspectorModel.EntityCodeValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.SymbolEntity);

if (loadSet.DisplayAttributes.Identity != null)
SymbolAttributeSet.DisplayAttributes.SelectedIdentityDomainPair
= MilitaryFieldsInspectorModel.IdentityDomainValues.FirstOrDefault(pair => pair.Code.ToString() == loadSet.DisplayAttributes.Identity);
Expand Down
32 changes: 31 additions & 1 deletion source/ProSymbolEditor/Views/SymbolView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -107,7 +108,7 @@
Grid.Row="2"
Grid.Column="0"
Margin="5,5,5,5"
Content="Operational Condition Amplifier"
Content="Operational Condition"
Visibility="{Binding ElementName=operationalConditionAmplifierComboBox, Path=Visibility}" />
<ComboBox
x:Name="operationalConditionAmplifierComboBox"
Expand Down Expand Up @@ -302,6 +303,35 @@
</ComboBox.Style>
</ComboBox>

<!-- Entity Code (2525D Only) -->
<Label
Grid.Row="10"
Grid.Column="0"
Margin="5,5,5,5"
Content="Entity"
Visibility="{Binding ElementName=entityCodeComboBox, Path=Visibility}" />
<ComboBox
x:Name="entityCodeComboBox"
Grid.Row="10"
Grid.Column="1"
Margin="5,5,5,5"
DisplayMemberPath="Name"
ItemContainerStyle="{DynamicResource Esri_HighlightListBoxItem}"
ItemsSource="{Binding MilitaryFieldsInspectorModel.EntityCodeValues}"
SelectedItem="{Binding SymbolAttributeSet.DisplayAttributes.SelectedEntityCodeDomainPair, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Code"
ToolTip="{Binding Path=SelectedItem.Name, RelativeSource={RelativeSource Self}}">
<ComboBox.Style>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Style.Triggers>
<Trigger Property="HasItems" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>

<!-- Extended Function Code (2525C_B2 Only) -->
<Label
Grid.Row="5"
Expand Down

0 comments on commit b975bbb

Please sign in to comment.