Skip to content

Commit 3a4c158

Browse files
dotMortenMorten NielsenmstefarovpMaske
authored
V.next (#509)
* v200.1 * WPF Popupviewer updates (#491) * Switch to use PopupElements for popup viewer control * Address namespace changes * Update WindowsAppSDK version to match MAUI requirements (#500) * Update deprecated property * Add properties to allow compiling for .NET Framework * Fix typo * Avoid navigation string resources in toolkit package * Updates relevant to popupviewer enhancements (cherry picked from commit 273a7d7) * Update README.md Co-authored-by: Morten Nielsen <[email protected]> * Update docs/popup-viewer.md Co-authored-by: Morten Nielsen <[email protected]> * Fix min-version support in MAUI * Maui: Ensure fonts are packaged and deployed * Add support for basic HTML in popups (#504) * Work around asset deployment issues caused by WinAppSDK See microsoft/WindowsAppSDK#3546 for details * Also include assets in lib folder for library layout Follow-up to work around issue microsoft/WindowsAppSDK#3546 * Set background on toolbar --------- Co-authored-by: Morten Nielsen <[email protected]> Co-authored-by: Matvei Stefarov <[email protected]> Co-authored-by: Preeti Maske <[email protected]>
1 parent 593cc5f commit 3a4c158

28 files changed

+2497
-86
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
The ArcGIS Maps SDK for .NET Toolkit contains controls and components to accelerate your development with [ArcGIS Maps SDK for .NET](https://developers.arcgis.com/net/).
1111

12-
> **Note**: At version 200.0, Toolkit assemblies are now built individually for each platform. Please replace any existing `Esri.ArcGISRuntime.Toolkit` NuGet reference with Toolkit NuGet package specific to that platform. For example if you have a WPF application using Toolkit, you will need to uninstall `Esri.ArcGISRuntime.Toolkit` NuGet package and add `Esri.ArcGISRuntime.Toolkit.WPF` NuGet package.
12+
> **Note**: Starting at version 200.0, Toolkit assemblies are now built individually for each platform. Please replace any existing `Esri.ArcGISRuntime.Toolkit` NuGet reference with Toolkit NuGet package specific to that platform. For example if you have a WPF application using Toolkit, you will need to uninstall `Esri.ArcGISRuntime.Toolkit` NuGet package and add `Esri.ArcGISRuntime.Toolkit.WPF` NuGet package.
1313
1414
# Documentation
1515

@@ -27,6 +27,7 @@ The ArcGIS Maps SDK for .NET Toolkit contains controls and components to acceler
2727
| [Legend](docs/legend.md) | <img src="https://user-images.githubusercontent.com/1378165/73389924-011fc200-428a-11ea-91bf-4ea1c2bf6683.png" width="105" title="Legend" />| Display a legend for a map or scene view. | WinUI, MAUI, UWP, WPF |
2828
| [MeasureToolbar](docs/measure-toolbar.md) | ![MeasureToolbar](https://user-images.githubusercontent.com/1378165/73389958-0f6dde00-428a-11ea-8c78-7192d49ea605.png) | Measure distances, areas, and features in a map view. | UWP, WPF |
2929
|[OverviewMap](docs/overview-map.md) | <img src="https://user-images.githubusercontent.com/29742178/121975740-34f07000-cd37-11eb-9162-462925cb3fe7.png" width="150" title="Overview Map" /> | Display an interactive inset map for a map or scene. | WinUI, MAUI, UWP, WPF |
30+
|[PopupViewer](docs/popup-viewer.md) | <img src="https://user-images.githubusercontent.com/3878047/228625594-d0009216-0cb3-4836-9a62-e197371779ac.png" width="150" title="Popup Viewer" /> | Displays information from simple popups. | WinUI, MAUI, UWP, WPF |
3031
| [ScaleLine](docs/scale-line.md) | ![ScaleLine](https://user-images.githubusercontent.com/1378165/73390077-3debb900-428a-11ea-8b2f-dfd4914a637e.png) | Display the current scale reference for a map. | WinUI, MAUI, UWP, WPF |
3132
|[SearchView](docs/search-view.md) | <img title="Search View" width="150" src="https://user-images.githubusercontent.com/29742178/142301018-4bbeb0f2-3021-49a7-b5ec-f642c5700bd0.png" /> | Search using one or more locators, with support for suggestions, automatic zooming, and custom search sources. | WinUI, MAUI, UWP, WPF |
3233
| [SymbolDisplay](docs/symbol-display.md) | ![SymbolDisplay](https://user-images.githubusercontent.com/1378165/73390051-31676080-428a-11ea-9feb-afb5d2aa6385.png) | Render a symbol in a control. | WinUI, MAUI, UWP, WPF |
@@ -35,8 +36,6 @@ The ArcGIS Maps SDK for .NET Toolkit contains controls and components to acceler
3536

3637
## Get started
3738

38-
> **Note**: At version 200.0, Toolkit assemblies are now built individually for each platform. Please replace any existing `Esri.ArcGISRuntime.Toolkit` NuGet reference with Toolkit NuGet package specific to that platform. For example if you have a WPF application using Toolkit, you will need to uninstall `Esri.ArcGISRuntime.Toolkit` NuGet package and add `Esri.ArcGISRuntime.Toolkit.WPF` NuGet package.
39-
4039
The simplest way to get started is to add the platform-specific NuGet package(s) to your projects:
4140

4241
- WPF: `Esri.ArcGISRuntime.Toolkit.WPF`

docs/popup-viewer.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
Displays information from simple [popups](https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/configure-pop-ups.htm).
44

5-
<img src="https://user-images.githubusercontent.com/1378165/73389991-1e549080-428a-11ea-81f3-b2f9c29f61ad.png" width="120" />
5+
<img src="https://user-images.githubusercontent.com/3878047/228625594-d0009216-0cb3-4836-9a62-e197371779ac.png" width="120" />
66

77
## Features
88

99
- Supports limited text display from HTML-based popups.
10+
- Supports charts, media, attachments.
1011
- Supports basic display of fields and values in non-HTML-based popups.
1112

12-
> **Important**: PopupViewer does not support charts or multimedia.
13+
> **Important**: Support for charts, multimedia, and attachments is currently only available for WPF.
1314
1415
## Usage
1516

src/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22

33
<PropertyGroup>
4-
<ArcGISRuntimeToolkitPackageVersion Condition="'$(ArcGISRuntimeToolkitPackageVersion)'==''">200.0.0</ArcGISRuntimeToolkitPackageVersion>
5-
<ArcGISRuntimePackageVersion Condition="'$(ArcGISRuntimePackageVersion)'==''">200.0.0</ArcGISRuntimePackageVersion>
4+
<ArcGISRuntimeToolkitPackageVersion Condition="'$(ArcGISRuntimeToolkitPackageVersion)'==''">200.1.0</ArcGISRuntimeToolkitPackageVersion>
5+
<ArcGISRuntimePackageVersion Condition="'$(ArcGISRuntimePackageVersion)'==''">200.1.0</ArcGISRuntimePackageVersion>
66

77
<!--Common package properties-->
88
<Authors>Esri Inc.</Authors>

src/Samples/Toolkit.SampleApp.UWP/Samples/MeasureToolbar/MeasureToolbarSample.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<esriUI:GraphicsOverlay Renderer="{StaticResource SR}" />
2222
</esri:MapView.GraphicsOverlays>
2323
</esri:MapView>
24-
<toolkit:MeasureToolbar VerticalAlignment="Top"
24+
<toolkit:MeasureToolbar VerticalAlignment="Top" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
2525
HorizontalAlignment="Right"
2626
MapView="{Binding ElementName=mapView}" />
2727
</Grid>

src/Samples/Toolkit.SampleApp.WPF/Samples/PopupViewer/PopupViewerSample.xaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@
77
mc:Ignorable="d"
88
d:DesignHeight="300" d:DesignWidth="600">
99
<Grid>
10-
<Grid.ColumnDefinitions>
11-
<ColumnDefinition Width="*"/>
12-
<ColumnDefinition Width="Auto"/>
13-
</Grid.ColumnDefinitions>
1410
<esri:MapView x:Name="mapView"
15-
Map="https://www.arcgis.com/home/item.html?id=d4fe39d300c24672b1821fa8450b6ae2"
11+
Map="https://www.arcgis.com/home/item.html?id=9f3a674e998f461580006e626611f9ad"
1612
GeoViewTapped="mapView_GeoViewTapped"/>
17-
<esri:PopupViewer x:Name="popupViewer"
18-
Grid.Column="1"
19-
Padding="5"
20-
Width="300"
21-
Visibility="Collapsed"
22-
HorizontalAlignment="Stretch"
23-
VerticalAlignment="Stretch" />
13+
14+
15+
<Grid Background="#AA333333" Visibility="Collapsed" x:Name="PopupBackground" MouseDown="PopupBackground_MouseDown">
16+
<Border BorderBrush="Black" BorderThickness="1" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" >
17+
<esri:PopupViewer x:Name="popupViewer" Margin="5" Width="400" MaxHeight="400" />
18+
</Border>
19+
</Grid>
2420
</Grid>
2521
</UserControl>

src/Samples/Toolkit.SampleApp.WPF/Samples/PopupViewer/PopupViewerSample.xaml.cs

+8-16
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,10 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
3232

3333
// Retrieves or builds Popup from IdentifyLayerResult
3434
var popup = GetPopup(result);
35-
36-
// Displays callout and updates visibility of PopupViewer
3735
if (popup != null)
3836
{
39-
var callout = new CalloutDefinition(popup.GeoElement);
40-
callout.Tag = popup;
41-
callout.ButtonImage = InfoIcon;
42-
callout.OnButtonClick = new Action<object>((s) =>
43-
{
44-
popupViewer.Visibility = Visibility.Visible;
45-
popupViewer.PopupManager = new PopupManager(s as Popup);
46-
});
47-
mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
48-
}
49-
else
50-
{
51-
popupViewer.PopupManager = null;
52-
popupViewer.Visibility = Visibility.Collapsed;
37+
PopupBackground.Visibility = Visibility.Visible;
38+
popupViewer.Popup = popup;
5339
}
5440
}
5541
catch (Exception ex)
@@ -115,5 +101,11 @@ private Popup GetPopup(IEnumerable<IdentifyLayerResult> results)
115101

116102
return null;
117103
}
104+
105+
private void PopupBackground_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
106+
{
107+
PopupBackground.Visibility = Visibility.Collapsed;
108+
popupViewer.Popup = null;
109+
}
118110
}
119111
}

src/Samples/Toolkit.SampleApp.WPF/Toolkit.SampleApp.WPF.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<UseWPF>true</UseWPF>
99
<RootNamespace>Esri.ArcGISRuntime.Toolkit</RootNamespace>
1010
<NoWarn>$(NoWarn);NU5105;MC3074;MSB4181;MC1000;MC3066</NoWarn>
11+
</PropertyGroup>
12+
<PropertyGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETFramework'">
13+
<PlatformTarget>AnyCPU</PlatformTarget>
14+
</PropertyGroup>
15+
<PropertyGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETCoreApp'">
1116
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
1217
</PropertyGroup>
1318

src/Toolkit/Toolkit.Maui/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#if !__IOS__ && !WINDOWS && !__ANDROID__ && !__MACCATALYST__
22
// Make sure net6.0 non-os target clearly states which platforms are supported by the toolkit
3-
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows10.0.19041")]
3+
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows10.0.17763")]
44
[assembly: System.Runtime.Versioning.SupportedOSPlatform("android26.0")]
55
[assembly: System.Runtime.Versioning.SupportedOSPlatform("ios14.0")]
66
[assembly: System.Runtime.Versioning.SupportedOSPlatform("maccatalyst14.0")]

src/Toolkit/Toolkit.Maui/Esri.ArcGISRuntime.Toolkit.Maui.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<EmbeddedResource Include="Assets\x-small.png" />
3333
<EmbeddedResource Include="Assets\x.png" />
3434
<EmbeddedResource Include="Assets\pin-red.png" />
35+
<None Include="build\**\*.*" PackagePath="build;buildTransitive" Pack="true" />
36+
<None Include="Resources\Fonts\calcite-ui-icons-24.ttf" Pack="true" PackagePath="Resources\Fonts" />
3537
</ItemGroup>
3638

3739
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<ItemGroup >
5+
<MauiFont Include="$(MSBuildThisFileDirectory)..\Resources\Fonts\*.*">
6+
<Visible>False</Visible>
7+
</MauiFont>
8+
</ItemGroup>
9+
10+
</Project>

src/Toolkit/Toolkit.UI.Controls/PopupViewer/PopupViewer.Windows.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// * limitations under the License.
1515
// ******************************************************************************/
1616

17-
#if WPF || WINDOWS_XAML
17+
#if WINDOWS_XAML
1818
using Esri.ArcGISRuntime.Mapping.Popups;
1919

2020
namespace Esri.ArcGISRuntime.Toolkit.UI.Controls

src/Toolkit/Toolkit.UI.Controls/PopupViewer/PopupViewer.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// * limitations under the License.
1515
// ******************************************************************************/
1616

17+
#if !WPF
18+
1719
using Esri.ArcGISRuntime.Mapping.Popups;
1820

1921
#if __IOS__
@@ -51,4 +53,5 @@ public PopupManager? PopupManager
5153
set => PopupManagerImpl = value;
5254
}
5355
}
54-
}
56+
}
57+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// /*******************************************************************************
2+
// * Copyright 2012-2018 Esri
3+
// *
4+
// * Licensed under the Apache License, Version 2.0 (the "License");
5+
// * you may not use this file except in compliance with the License.
6+
// * You may obtain a copy of the License at
7+
// *
8+
// * http://www.apache.org/licenses/LICENSE-2.0
9+
// *
10+
// * Unless required by applicable law or agreed to in writing, software
11+
// * distributed under the License is distributed on an "AS IS" BASIS,
12+
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// * See the License for the specific language governing permissions and
14+
// * limitations under the License.
15+
// ******************************************************************************/
16+
17+
using Esri.ArcGISRuntime.Mapping.Popups;
18+
using Microsoft.Win32;
19+
using System.Windows.Controls.Primitives;
20+
21+
namespace Esri.ArcGISRuntime.Toolkit.Primitives
22+
{
23+
/// <summary>
24+
/// Supporting control for the <see cref="Esri.ArcGISRuntime.Toolkit.UI.Controls.PopupViewer"/> control,
25+
/// used for rendering a <see cref="AttachmentsPopupElement"/>.
26+
/// </summary>
27+
[TemplatePart(Name ="AttachmentList", Type = typeof(ListBox))]
28+
public class AttachmentsPopupElementView : Control
29+
{
30+
private ListBox? itemsList;
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="AttachmentsPopupElementView"/> class.
33+
/// </summary>
34+
public AttachmentsPopupElementView()
35+
{
36+
DefaultStyleKey = typeof(AttachmentsPopupElementView);
37+
}
38+
39+
/// <inheritdoc />
40+
public override void OnApplyTemplate()
41+
{
42+
base.OnApplyTemplate();
43+
itemsList = GetTemplateChild("AttachmentList") as ListBox;
44+
if (itemsList != null)
45+
{
46+
itemsList.SelectionMode = SelectionMode.Single;
47+
itemsList.SelectionChanged += ItemsList_SelectionChanged;
48+
LoadAttachments();
49+
}
50+
}
51+
52+
private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
53+
{
54+
if(e.AddedItems != null && e.AddedItems.Count > 0)
55+
{
56+
var attachment = e.AddedItems[0] as PopupAttachment;
57+
if(attachment?.Attachment != null)
58+
{
59+
OnAttachmentClicked(attachment);
60+
}
61+
if (sender is Selector s)
62+
s.SelectedValue = null;
63+
}
64+
}
65+
66+
/// <summary>
67+
/// Occurs when an attachment is clicked.
68+
/// </summary>
69+
/// <remarks>Override this to prevent the default "save to file dialog" action.</remarks>
70+
/// <param name="attachment">Attachment clicked.</param>
71+
public virtual async void OnAttachmentClicked(PopupAttachment attachment)
72+
{
73+
SaveFileDialog saveFileDialog = new SaveFileDialog();
74+
saveFileDialog.FileName = attachment.Name;
75+
if (saveFileDialog.ShowDialog() == true)
76+
{
77+
try
78+
{
79+
using var stream = await attachment.Attachment!.GetDataAsync();
80+
using var outfile = saveFileDialog.OpenFile();
81+
await stream.CopyToAsync(outfile);
82+
}
83+
catch { }
84+
}
85+
}
86+
87+
private async void LoadAttachments()
88+
{
89+
if (itemsList is null) return;
90+
Visibility = Visibility.Collapsed;
91+
itemsList.ItemsSource = null;
92+
if (Element is not null)
93+
{
94+
try
95+
{
96+
await Element.GetAttachmentsAsync();
97+
}
98+
catch
99+
{
100+
101+
}
102+
itemsList.ItemsSource = Element?.Attachments;
103+
}
104+
Visibility = (Element?.Attachments?.Count ?? 0) > 0 ? Visibility = Visibility.Visible : Visibility.Collapsed;
105+
}
106+
107+
/// <summary>
108+
/// Gets or sets the AttachmentsPopupElement.
109+
/// </summary>
110+
public AttachmentsPopupElement? Element
111+
{
112+
get { return GetValue(ElementProperty) as AttachmentsPopupElement; }
113+
set { SetValue(ElementProperty, value); }
114+
}
115+
116+
/// <summary>
117+
/// Identifies the <see cref="Element"/> dependency property.
118+
/// </summary>
119+
public static readonly DependencyProperty ElementProperty =
120+
DependencyProperty.Register(nameof(Element), typeof(AttachmentsPopupElement), typeof(AttachmentsPopupElementView), new PropertyMetadata(null, (s, e) => ((AttachmentsPopupElementView)s).LoadAttachments()));
121+
}
122+
}

0 commit comments

Comments
 (0)