Skip to content

Commit

Permalink
V.next (#509)
Browse files Browse the repository at this point in the history
* 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 <1378165+dotMorten@users.noreply.github.com>

* Update docs/popup-viewer.md

Co-authored-by: Morten Nielsen <1378165+dotMorten@users.noreply.github.com>

* 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 <mort5161@esri.com>
Co-authored-by: Matvei Stefarov <mstefarov@esri.com>
Co-authored-by: Preeti Maske <pmaske@esri.com>
  • Loading branch information
4 people committed Apr 19, 2023
1 parent 593cc5f commit 3a4c158
Show file tree
Hide file tree
Showing 28 changed files with 2,497 additions and 86 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -9,7 +9,7 @@

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/).

> **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.
> **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.
# Documentation

Expand All @@ -27,6 +27,7 @@ The ArcGIS Maps SDK for .NET Toolkit contains controls and components to acceler
| [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 |
| [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 |
|[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 |
|[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 |
| [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 |
|[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 |
| [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 |
Expand All @@ -35,8 +36,6 @@ The ArcGIS Maps SDK for .NET Toolkit contains controls and components to acceler

## Get started

> **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.
The simplest way to get started is to add the platform-specific NuGet package(s) to your projects:

- WPF: `Esri.ArcGISRuntime.Toolkit.WPF`
Expand Down
5 changes: 3 additions & 2 deletions docs/popup-viewer.md
Expand Up @@ -2,14 +2,15 @@

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

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

## Features

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

> **Important**: PopupViewer does not support charts or multimedia.
> **Important**: Support for charts, multimedia, and attachments is currently only available for WPF.
## Usage

Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
@@ -1,8 +1,8 @@
<Project>

<PropertyGroup>
<ArcGISRuntimeToolkitPackageVersion Condition="'$(ArcGISRuntimeToolkitPackageVersion)'==''">200.0.0</ArcGISRuntimeToolkitPackageVersion>
<ArcGISRuntimePackageVersion Condition="'$(ArcGISRuntimePackageVersion)'==''">200.0.0</ArcGISRuntimePackageVersion>
<ArcGISRuntimeToolkitPackageVersion Condition="'$(ArcGISRuntimeToolkitPackageVersion)'==''">200.1.0</ArcGISRuntimeToolkitPackageVersion>
<ArcGISRuntimePackageVersion Condition="'$(ArcGISRuntimePackageVersion)'==''">200.1.0</ArcGISRuntimePackageVersion>

<!--Common package properties-->
<Authors>Esri Inc.</Authors>
Expand Down
Expand Up @@ -21,7 +21,7 @@
<esriUI:GraphicsOverlay Renderer="{StaticResource SR}" />
</esri:MapView.GraphicsOverlays>
</esri:MapView>
<toolkit:MeasureToolbar VerticalAlignment="Top"
<toolkit:MeasureToolbar VerticalAlignment="Top" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
HorizontalAlignment="Right"
MapView="{Binding ElementName=mapView}" />
</Grid>
Expand Down
Expand Up @@ -7,19 +7,15 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<esri:MapView x:Name="mapView"
Map="https://www.arcgis.com/home/item.html?id=d4fe39d300c24672b1821fa8450b6ae2"
Map="https://www.arcgis.com/home/item.html?id=9f3a674e998f461580006e626611f9ad"
GeoViewTapped="mapView_GeoViewTapped"/>
<esri:PopupViewer x:Name="popupViewer"
Grid.Column="1"
Padding="5"
Width="300"
Visibility="Collapsed"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />


<Grid Background="#AA333333" Visibility="Collapsed" x:Name="PopupBackground" MouseDown="PopupBackground_MouseDown">
<Border BorderBrush="Black" BorderThickness="1" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" >
<esri:PopupViewer x:Name="popupViewer" Margin="5" Width="400" MaxHeight="400" />
</Border>
</Grid>
</Grid>
</UserControl>
Expand Up @@ -32,24 +32,10 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)

// Retrieves or builds Popup from IdentifyLayerResult
var popup = GetPopup(result);

// Displays callout and updates visibility of PopupViewer
if (popup != null)
{
var callout = new CalloutDefinition(popup.GeoElement);
callout.Tag = popup;
callout.ButtonImage = InfoIcon;
callout.OnButtonClick = new Action<object>((s) =>
{
popupViewer.Visibility = Visibility.Visible;
popupViewer.PopupManager = new PopupManager(s as Popup);
});
mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout);
}
else
{
popupViewer.PopupManager = null;
popupViewer.Visibility = Visibility.Collapsed;
PopupBackground.Visibility = Visibility.Visible;
popupViewer.Popup = popup;
}
}
catch (Exception ex)
Expand Down Expand Up @@ -115,5 +101,11 @@ private Popup GetPopup(IEnumerable<IdentifyLayerResult> results)

return null;
}

private void PopupBackground_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
PopupBackground.Visibility = Visibility.Collapsed;
popupViewer.Popup = null;
}
}
}
Expand Up @@ -8,6 +8,11 @@
<UseWPF>true</UseWPF>
<RootNamespace>Esri.ArcGISRuntime.Toolkit</RootNamespace>
<NoWarn>$(NoWarn);NU5105;MC3074;MSB4181;MC1000;MC3066</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETFramework'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETCoreApp'">
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Toolkit/Toolkit.Maui/AssemblyInfo.cs
@@ -1,6 +1,6 @@
#if !__IOS__ && !WINDOWS && !__ANDROID__ && !__MACCATALYST__
// Make sure net6.0 non-os target clearly states which platforms are supported by the toolkit
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows10.0.19041")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows10.0.17763")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("android26.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("ios14.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatform("maccatalyst14.0")]
Expand Down
Expand Up @@ -32,6 +32,8 @@
<EmbeddedResource Include="Assets\x-small.png" />
<EmbeddedResource Include="Assets\x.png" />
<EmbeddedResource Include="Assets\pin-red.png" />
<None Include="build\**\*.*" PackagePath="build;buildTransitive" Pack="true" />
<None Include="Resources\Fonts\calcite-ui-icons-24.ttf" Pack="true" PackagePath="Resources\Fonts" />
</ItemGroup>

<ItemGroup>
Expand Down
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup >
<MauiFont Include="$(MSBuildThisFileDirectory)..\Resources\Fonts\*.*">
<Visible>False</Visible>
</MauiFont>
</ItemGroup>

</Project>
Expand Up @@ -14,7 +14,7 @@
// * limitations under the License.
// ******************************************************************************/

#if WPF || WINDOWS_XAML
#if WINDOWS_XAML
using Esri.ArcGISRuntime.Mapping.Popups;

namespace Esri.ArcGISRuntime.Toolkit.UI.Controls
Expand Down
5 changes: 4 additions & 1 deletion src/Toolkit/Toolkit.UI.Controls/PopupViewer/PopupViewer.cs
Expand Up @@ -14,6 +14,8 @@
// * limitations under the License.
// ******************************************************************************/

#if !WPF

using Esri.ArcGISRuntime.Mapping.Popups;

#if __IOS__
Expand Down Expand Up @@ -51,4 +53,5 @@ public PopupViewer()
set => PopupManagerImpl = value;
}
}
}
}
#endif
@@ -0,0 +1,122 @@
// /*******************************************************************************
// * Copyright 2012-2018 Esri
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// ******************************************************************************/

using Esri.ArcGISRuntime.Mapping.Popups;
using Microsoft.Win32;
using System.Windows.Controls.Primitives;

namespace Esri.ArcGISRuntime.Toolkit.Primitives
{
/// <summary>
/// Supporting control for the <see cref="Esri.ArcGISRuntime.Toolkit.UI.Controls.PopupViewer"/> control,
/// used for rendering a <see cref="AttachmentsPopupElement"/>.
/// </summary>
[TemplatePart(Name ="AttachmentList", Type = typeof(ListBox))]
public class AttachmentsPopupElementView : Control
{
private ListBox? itemsList;
/// <summary>
/// Initializes a new instance of the <see cref="AttachmentsPopupElementView"/> class.
/// </summary>
public AttachmentsPopupElementView()
{
DefaultStyleKey = typeof(AttachmentsPopupElementView);
}

/// <inheritdoc />
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
itemsList = GetTemplateChild("AttachmentList") as ListBox;
if (itemsList != null)
{
itemsList.SelectionMode = SelectionMode.Single;
itemsList.SelectionChanged += ItemsList_SelectionChanged;
LoadAttachments();
}
}

private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(e.AddedItems != null && e.AddedItems.Count > 0)
{
var attachment = e.AddedItems[0] as PopupAttachment;
if(attachment?.Attachment != null)
{
OnAttachmentClicked(attachment);
}
if (sender is Selector s)
s.SelectedValue = null;
}
}

/// <summary>
/// Occurs when an attachment is clicked.
/// </summary>
/// <remarks>Override this to prevent the default "save to file dialog" action.</remarks>
/// <param name="attachment">Attachment clicked.</param>
public virtual async void OnAttachmentClicked(PopupAttachment attachment)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.FileName = attachment.Name;
if (saveFileDialog.ShowDialog() == true)
{
try
{
using var stream = await attachment.Attachment!.GetDataAsync();
using var outfile = saveFileDialog.OpenFile();
await stream.CopyToAsync(outfile);
}
catch { }
}
}

private async void LoadAttachments()
{
if (itemsList is null) return;
Visibility = Visibility.Collapsed;
itemsList.ItemsSource = null;
if (Element is not null)
{
try
{
await Element.GetAttachmentsAsync();
}
catch
{

}
itemsList.ItemsSource = Element?.Attachments;
}
Visibility = (Element?.Attachments?.Count ?? 0) > 0 ? Visibility = Visibility.Visible : Visibility.Collapsed;
}

/// <summary>
/// Gets or sets the AttachmentsPopupElement.
/// </summary>
public AttachmentsPopupElement? Element
{
get { return GetValue(ElementProperty) as AttachmentsPopupElement; }
set { SetValue(ElementProperty, value); }
}

/// <summary>
/// Identifies the <see cref="Element"/> dependency property.
/// </summary>
public static readonly DependencyProperty ElementProperty =
DependencyProperty.Register(nameof(Element), typeof(AttachmentsPopupElement), typeof(AttachmentsPopupElementView), new PropertyMetadata(null, (s, e) => ((AttachmentsPopupElementView)s).LoadAttachments()));
}
}

0 comments on commit 3a4c158

Please sign in to comment.