Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
Expand All @@ -617,8 +618,9 @@
<TextBlock x:Name="Icon" VerticalAlignment="Center" Margin="0,0,4,0" FontFamily="{StaticResource ToolkitIconsFontFamily}" Grid.RowSpan="2" />
<TextBlock x:Name="Title" TextWrapping="NoWrap" Text="{Binding AssociationResult.Title, RelativeSource={RelativeSource Mode=TemplatedParent}}" Style="{StaticResource FeatureFormViewTitleStyle}"
VerticalAlignment="Center" Grid.Column="1" TextTrimming="CharacterEllipsis" />
<TextBlock x:Name="FractionAlong" Visibility="Collapsed" Grid.Column="2" Grid.RowSpan="2" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTipService.ToolTip="{Binding ElementName=FractionAlong, Path=Text}" />
<TextBlock x:Name="ConnectionInfo" Visibility="Collapsed" Grid.Column="1" Grid.Row="1" TextTrimming="CharacterEllipsis" ToolTipService.ToolTip="{Binding ElementName=ConnectionInfo, Path=Text}" />
<TextBlock Text="&#xE76C;" Grid.Column="2" VerticalAlignment="Center" Margin="4,0" Grid.RowSpan="2" FontFamily="Segoe MDL2 Assets" />
<TextBlock Text="&#xE76C;" Grid.Column="3" VerticalAlignment="Center" Margin="4,0" Grid.RowSpan="2" FontFamily="Segoe MDL2 Assets" />
</Grid>
</ControlTemplate>
</Setter.Value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
xmlns:un="using:Esri.ArcGISRuntime.UtilityNetworks"
>

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../../Themes/SharedResources.xaml" />
</ResourceDictionary.MergedDictionaries>

<SolidColorBrush x:Key="FeatureFormAccentBrush" Color="#007AC2" />
<Thickness x:Key="FeatureFormElementInputMargin">0,0,0,5</Thickness>
<internal:VisibilityConverter x:Key="FeatureFormViewVisibilityConverter"/>
Expand Down Expand Up @@ -451,16 +455,18 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<FontIcon x:Name="Icon" Width="20" VerticalAlignment="Center" Margin="-8,0,4,0" FontFamily="/Esri.ArcGISRuntime.Toolkit.WinUI/Assets/toolkit-icons.ttf#calcite-ui-icons-24" Grid.RowSpan="2" />
<FontIcon x:Name="Icon" Width="20" VerticalAlignment="Center" Margin="-8,0,4,0" FontFamily="{StaticResource toolkit-icons}" Grid.RowSpan="2" />
<TextBlock x:Name="Title" TextWrapping="NoWrap" Text="{Binding AssociationResult.Title, RelativeSource={RelativeSource Mode=TemplatedParent}}" Style="{StaticResource FeatureFormViewTitleStyle}"
VerticalAlignment="Center" Grid.Column="1" TextTrimming="CharacterEllipsis" />
<TextBlock x:Name="FractionAlong" Visibility="Collapsed" Grid.Column="2" Grid.RowSpan="2" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTipService.ToolTip="{Binding ElementName=FractionAlong, Path=Text}" />
<TextBlock x:Name="ConnectionInfo" Visibility="Collapsed" Grid.Column="1" Grid.Row="1" TextTrimming="CharacterEllipsis" ToolTipService.ToolTip="{Binding ElementName=ConnectionInfo, Path=Text}" />
<FontIcon Glyph="&#xE76C;" Grid.Column="2" VerticalAlignment="Center" Margin="4,0" Grid.RowSpan="2" />
<FontIcon Glyph="&#xE76C;" Grid.Column="3" VerticalAlignment="Center" Margin="4,0" Grid.RowSpan="2" />
</Grid>
</ControlTemplate>
</Setter.Value>
Expand Down
14 changes: 7 additions & 7 deletions src/Toolkit/Toolkit/LocalizedStrings/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@
<comment>The text used to display the number of associations for a group in a UtilityAssociationsPopupElement's filter result</comment>
</data>
<data name="PopupViewerUtilityAssociationsVisibleContent" xml:space="preserve">
<value>visible content</value>
<value>Visible content</value>
<comment>The text used to indicate the associated feature is a visible content in a UtilityAssociationsPopupElement's group result</comment>
</data>
<data name="PopupViewerUtilityAssociationsNonVisibleContent" xml:space="preserve">
<value>content</value>
<value>Content</value>
<comment>The text used to indicate the associated feature is non-visible content in a UtilityAssociationsPopupElement's group result</comment>
</data>
<data name="PopupViewerUtilityAssociationsFilterByTitle" xml:space="preserve">
Expand Down Expand Up @@ -590,12 +590,12 @@
<comment>The percentage fraction along an edge of a utility element association</comment>
</data>
<data name="FeatureFormUtilityElementIsContentVisible" xml:space="preserve">
<value>Is content visible: Yes</value>
<comment>Whether content is visible on a utility element association</comment>
<value>Visible content</value>
<comment>The text used to indicate the associated feature is a visible content in a UtilityAssociationsFormElement's group result</comment>
</data>
<data name="FeatureFormUtilityElementIsContentNotVisible" xml:space="preserve">
<value>Is content visible: No</value>
<comment>Whether content is not visible on a utility element association</comment>
<data name="FeatureFormUtilityElementIsContentNotVisible" xml:space="preserve">
<value>Content</value>
<comment>The text used to indicate the associated feature is non-visible content in a UtilityAssociationsFormElement's group result</comment>
</data>
<data name="FeatureFormUtilityElementTerminalName" xml:space="preserve">
<value>Terminal: {0}</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private static object BuildDefaultTemplate()
layout.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
layout.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star));
layout.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
layout.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));
layout.RowDefinitions.Add(new RowDefinition(GridLength.Auto));
layout.RowDefinitions.Add(new RowDefinition(GridLength.Auto));

Expand All @@ -49,6 +50,11 @@ private static object BuildDefaultTemplate()
Grid.SetColumn(title, 1);
layout.Add(title);

Label fractionAlong = new Label() { VerticalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.TailTruncation };
Grid.SetColumn(fractionAlong, 2);
Grid.SetRowSpan(fractionAlong, 2);
layout.Add(fractionAlong);

Label connectionInfo = new Label() { Style = FeatureFormView.GetFeatureFormCaptionStyle(), IsVisible = false, LineBreakMode = LineBreakMode.TailTruncation, Margin = new Thickness(0,0,2,0) };
connectionInfo.SetBinding(ToolTipProperties.TextProperty, static (Label label) => label.Text, source: RelativeBindingSource.Self);
Grid.SetRow(connectionInfo, 1);
Expand All @@ -57,7 +63,7 @@ private static object BuildDefaultTemplate()

Image image = new Image() { WidthRequest = 18, HeightRequest = 18, VerticalOptions = LayoutOptions.Center };
image.Source = new FontImageSource() { Glyph = ToolkitIcons.ChevronRight, Color = Colors.Gray, FontFamily = ToolkitIcons.FontFamilyName, Size = 18 };
Grid.SetColumn(image, 2);
Grid.SetColumn(image, 3);
Grid.SetRowSpan(image, 2);
layout.Add(image);
// TODO: Set theme-based background once https://github.com/dotnet/maui/issues/26620 is addressed
Expand All @@ -69,6 +75,7 @@ private static object BuildDefaultTemplate()

INameScope nameScope = new NameScope();
NameScope.SetNameScope(layout, nameScope);
nameScope.RegisterName("FractionAlong", fractionAlong);
nameScope.RegisterName("Icon", icon);
nameScope.RegisterName("ConnectionInfo", connectionInfo);
return layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using Esri.ArcGISRuntime.Toolkit.Internal;
using Esri.ArcGISRuntime.UtilityNetworks;
using System.Text;
using Esri.ArcGISRuntime.Data;




Expand Down Expand Up @@ -111,71 +113,87 @@ private void UpdateView()
};
}
#endif
// One of the elements is this associated feature. We want to display info about the other element
// Use the guids to figure out whether this is the To or From element, and select the other one to
// display information on.
var guidField = (AssociationResult?.AssociatedFeature.FeatureTable as Data.ArcGISFeatureTable)?.GlobalIdField;
Guid? guid = null;
if (guidField is not null && AssociationResult?.AssociatedFeature.Attributes.ContainsKey(guidField) == true)

if (GetTemplateChild("FractionAlong") is TextBlock fractionAlong)
{
guid = (Guid?)AssociationResult?.AssociatedFeature.Attributes[guidField];
fractionAlong.Text = AssociationResult != null &&
AssociationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityMidspan &&
AssociationResult.Association.FractionAlongEdge > 0
? $"{Math.Round(AssociationResult.Association.FractionAlongEdge * 100)} %"
: string.Empty;
#if MAUI
fractionAlong.IsVisible = fractionAlong.Text?.Length > 0;
#else
fractionAlong.Visibility = fractionAlong.Text?.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
#endif
}
UtilityElement? otherElement = null;
if (AssociationResult?.Association.FromElement.GlobalId == guid)
otherElement = AssociationResult?.Association.ToElement;
if (AssociationResult?.Association.ToElement.GlobalId == guid)
otherElement = AssociationResult?.Association.FromElement;

if (GetTemplateChild("ConnectionInfo") is TextBlock connectionInfo)
{
StringBuilder sb = new StringBuilder();
bool showFraction = AssociationResult?.Association.AssociationType == UtilityAssociationType.Connectivity;
if (showFraction)
{
var fraction = AssociationResult?.Association.FractionAlongEdge ?? 0;
if (fraction == 0)
fraction = otherElement?.FractionAlongEdge ?? 0;
if (sb.Length > 0)
sb.Append(" ");
sb.Append(string.Format(Properties.Resources.GetString("FeatureFormUtilityElementFractionAlongEdge")!, fraction.ToString("P0")));
}
connectionInfo.Text = GetAssociationProperty(AssociationResult);
#if MAUI
connectionInfo.IsVisible = connectionInfo.Text?.Length > 0;
#else
connectionInfo.Visibility = connectionInfo.Text?.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
#endif
}
}

private string GetAssociationProperty(UtilityAssociationResult? associationResult)
{
if (associationResult is null ||
associationResult.AssociatedFeature is not ArcGISFeature feature ||
feature.FeatureTable is not ArcGISFeatureTable table ||
feature.GetAttributeValue(table.GlobalIdField) is not Guid associatedFeatureGlobalId)
{
return string.Empty;
}

if (associationResult.Association.AssociationType == UtilityAssociationType.Containment &&
associationResult.Association.ToElement.GlobalId.Equals(associatedFeatureGlobalId))
{
var contentVisibility = associationResult.Association.IsContainmentVisible ?
Properties.Resources.GetString("FeatureFormUtilityElementIsContentVisible") :
Properties.Resources.GetString("FeatureFormUtilityElementIsContentNotVisible");
return contentVisibility ?? string.Empty;
}

string? terminalName = otherElement?.Terminal?.Name;
if (!string.IsNullOrEmpty(terminalName))
if (associationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityFromSide ||
associationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityMidspan ||
associationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityToSide ||
associationResult.Association.AssociationType == UtilityAssociationType.Connectivity)
{
if (associationResult.Association.FromElement.GlobalId.Equals(associatedFeatureGlobalId) &&
associationResult.Association.FromElement.Terminal is UtilityTerminal fromTerminal)
{
if (sb.Length > 0)
sb.Append(" ");
sb.Append(string.IsNullOrEmpty(terminalName) ? "" : string.Format(Properties.Resources.GetString("FeatureFormUtilityElementTerminalName")!, terminalName));
return fromTerminal.Name;
}

bool showIscontentVisible = AssociationResult?.Association.AssociationType == UtilityAssociationType.Containment && otherElement == AssociationResult?.Association.ToElement;
if (showIscontentVisible)
if (associationResult.Association.ToElement.GlobalId.Equals(associatedFeatureGlobalId) &&
associationResult.Association.ToElement.Terminal is UtilityTerminal toTerminal)
{
if (sb.Length > 0)
sb.Append(" ");
sb.Append(AssociationResult?.Association.IsContainmentVisible == true ? Properties.Resources.GetString("FeatureFormUtilityElementIsContentVisible") : Properties.Resources.GetString("FeatureFormUtilityElementIsContentNotVisible"));
return toTerminal.Name;
}
connectionInfo.Text = sb.ToString().Trim();
#if MAUI
connectionInfo.IsVisible = connectionInfo.Text.Length > 0;
#else
connectionInfo.Visibility = connectionInfo.Text.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
#endif
}

return string.Empty;
}

private string GetIconGlyph()
{
if (AssociationResult is not null)
{
if (AssociationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityFromSide)
return ToolkitIcons.ConnectionEndLeft;
if (AssociationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityToSide)
return ToolkitIcons.ConnectionEndRight;
if (AssociationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityMidspan)
return ToolkitIcons.ConnectionMiddle;;
}
return "";
if (AssociationResult?.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityFromSide)
return ToolkitIcons.ConnectionEndLeft;

if (AssociationResult?.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityToSide)
return ToolkitIcons.ConnectionEndRight;

if (AssociationResult?.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityMidspan)
return ToolkitIcons.ConnectionMiddle;

if (AssociationResult?.Association.AssociationType == UtilityAssociationType.Connectivity)
return ToolkitIcons.ConnectionToConnection;

return string.Empty;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private static object BuildDefaultTemplate()

Label fractionAlong = new Label() { VerticalOptions = LayoutOptions.Center, LineBreakMode = LineBreakMode.TailTruncation };
Grid.SetColumn(fractionAlong, 2);
Grid.SetRowSpan(fractionAlong, 2);
layout.Add(fractionAlong);

Label connectionInfo = new Label() { Style = PopupViewer.GetPopupViewerCaptionStyle(), IsVisible = false, LineBreakMode = LineBreakMode.TailTruncation, Margin = new Thickness(0, 0, 2, 0) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void UpdateView()
fractionAlong.Text = AssociationResult != null &&
AssociationResult.Association.AssociationType == UtilityAssociationType.JunctionEdgeObjectConnectivityMidspan &&
AssociationResult.Association.FractionAlongEdge > 0
? $"{AssociationResult.Association.FractionAlongEdge * 100} %"
? $"{Math.Round(AssociationResult.Association.FractionAlongEdge * 100)} %"
: string.Empty; ;
#if MAUI
fractionAlong.IsVisible = fractionAlong.Text?.Length > 0;
Expand Down