Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
593cc5f
commit 3a4c158
Showing
28 changed files
with
2,497 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Toolkit/Toolkit.Maui/build/Esri.ArcGISRuntime.Toolkit.Maui.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
src/Toolkit/Toolkit.WPF/UI/Controls/PopupViewer/AttachmentsPopupElementView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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())); | ||
} | ||
} |
Oops, something went wrong.