Merge branch 'master' into viewportbehavior
This commit is contained in:
Коммит
a7c272a3d9
|
@ -136,6 +136,11 @@ namespace Microsoft.Toolkit.Parsers.Markdown.Inlines
|
|||
|
||||
// The URL must have at least one character after the http:// and at least one dot.
|
||||
int pos = tripPos + 3;
|
||||
if (pos > maxEnd)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int dotIndex = markdown.IndexOf('.', pos, maxEnd - pos);
|
||||
if (dotIndex == -1 || dotIndex == pos)
|
||||
{
|
||||
|
|
|
@ -283,6 +283,7 @@
|
|||
<Content Include="Icons\Notifications.png" />
|
||||
<Content Include="Icons\Services.png" />
|
||||
<Content Include="SamplePages\OnDevice\OnDevice.png" />
|
||||
<Content Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelper.png" />
|
||||
<Content Include="SamplePages\ImageCropper\ImageCropper.png" />
|
||||
<Content Include="SamplePages\TabView\TabView.png" />
|
||||
<Content Include="SamplePages\PeoplePicker\PeoplePicker.png" />
|
||||
|
@ -351,6 +352,7 @@
|
|||
<Content Include="SamplePages\RadialGauge\RadialGauge.png" />
|
||||
<Content Include="SamplePages\RadialGradientBrush\RadialGradientBrush.png" />
|
||||
<Content Include="SamplePages\RadialProgressBar\RadialProgressBar.png" />
|
||||
<Content Include="SamplePages\RemoteDevicePicker\RemoteDevicePicker.png" />
|
||||
<Content Include="SamplePages\ReorderGridAnimation\ReorderGrid.png" />
|
||||
<Content Include="SamplePages\Rotate\RotateBehavior.png" />
|
||||
<Content Include="SamplePages\Saturation\SaturationBehavior.png" />
|
||||
|
@ -520,6 +522,7 @@
|
|||
<Content Include="SamplePages\GazeInteraction\GazeInteractionCode.bind" />
|
||||
<Content Include="SamplePages\GazeTracing\GazeTracingCode.bind" />
|
||||
<Content Include="SamplePages\InfiniteCanvas\InfiniteCanvas.bind" />
|
||||
<Content Include="SamplePages\RemoteDevicePicker\RemoteDevicePickerCode.bind" />
|
||||
<Content Include="SamplePages\PlannerTaskList\PlannerTaskListXaml.bind" />
|
||||
<Content Include="SamplePages\DataGrid\DataGridCode.bind" />
|
||||
<Content Include="SamplePages\ViewportBehavior\ViewportBehaviorCode.bind" />
|
||||
|
@ -530,6 +533,9 @@
|
|||
<Compile Include="SamplePages\OnDevice\OnDevicePage.xaml.cs">
|
||||
<DependentUpon>OnDevicePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelperPage.xaml.cs">
|
||||
<DependentUpon>RemoteDeviceHelperPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\ImageCropper\AspectRatioConfig.cs" />
|
||||
<Compile Include="SamplePages\ImageCropper\ImageCropperPage.xaml.cs">
|
||||
<DependentUpon>ImageCropperPage.xaml</DependentUpon>
|
||||
|
@ -538,6 +544,7 @@
|
|||
<Compile Include="Shell.SamplePicker.cs" />
|
||||
<Content Include="SamplePages\ViewportBehavior\ViewportBehaviorXaml.bind" />
|
||||
<Content Include="SamplePages\OnDevice\OnDeviceXaml.bind" />
|
||||
<Content Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelperCode.bind" />
|
||||
<Content Include="SamplePages\ImageCropper\ImageCropperXaml.bind" />
|
||||
<Content Include="SamplePages\ImageCropper\ImageCropperCode.bind" />
|
||||
</ItemGroup>
|
||||
|
@ -696,6 +703,9 @@
|
|||
<DependentUpon>FocusTrackerPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\BackgroundTaskHelper\TestBackgroundTask.cs" />
|
||||
<Compile Include="SamplePages\RemoteDevicePicker\RemoteDevicePickerControlPage.xaml.cs">
|
||||
<DependentUpon>RemoteDevicePickerControlPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SamplePages\RssParser\RssParserPage.xaml.cs">
|
||||
<DependentUpon>RssParserPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -956,6 +966,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\RemoteDeviceHelper\RemoteDeviceHelperPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\ImageCropper\ImageCropperPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -1108,6 +1122,10 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="SamplePages\RemoteDevicePicker\RemoteDevicePickerControlPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SamplePages\RssParser\RssParserPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
|
||||
<Identity Name="52b9212c-97a9-4639-9426-3e1ea9c1569e" Publisher="CN=Nikola" Version="4.0.0.0" />
|
||||
<mp:PhoneIdentity PhoneProductId="52b9212c-97a9-4639-9426-3e1ea9c1569e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
|
@ -43,6 +43,7 @@
|
|||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<Capability Name="privateNetworkClientServer" />
|
||||
<uap3:Capability Name="remoteSystem" />
|
||||
<DeviceCapability Name="location" />
|
||||
<DeviceCapability Name="bluetooth" />
|
||||
<DeviceCapability Name="webcam" />
|
||||
|
|
Двоичные данные
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RemoteDeviceHelper/RemoteDeviceHelper.png
Normal file
Двоичные данные
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RemoteDeviceHelper/RemoteDeviceHelper.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.0 KiB |
|
@ -0,0 +1,35 @@
|
|||
c#
|
||||
|
||||
// without filters
|
||||
|
||||
RemoteDeviceHelper _remoteDeviceHelper = new RemoteDeviceHelper();
|
||||
DevicesList.DataContext = _remoteDeviceHelper;
|
||||
|
||||
// with filters
|
||||
|
||||
var filters = new List<IRemoteSystemFilter>
|
||||
{
|
||||
new RemoteSystemDiscoveryTypeFilter(RemoteSystemDiscoveryType.Cloud),
|
||||
new RemoteSystemAuthorizationKindFilter(RemoteSystemAuthorizationKind.SameUser),
|
||||
new RemoteSystemStatusTypeFilter(RemoteSystemStatusType.Available)
|
||||
};
|
||||
|
||||
RemoteDeviceHelper _remoteDeviceHelper = new RemoteDeviceHelper(filters);
|
||||
DevicesList.DataContext = _remoteDeviceHelper;
|
||||
|
||||
xaml
|
||||
|
||||
<ListView ItemsSource="{Binding RemoteSystems}" x:Name="DevicesList">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding DisplayName}" Tag="{Binding }" Grid.Row="0" />
|
||||
<TextBlock Text="{Binding ModelDisplayName}" Tag="{Binding }" Grid.Row="1" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
|
@ -0,0 +1,59 @@
|
|||
<Page
|
||||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.RemoteDeviceHelperPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.RemoteDeviceHelper"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Page.Resources>
|
||||
<converters:RemoteSystemKindToSymbolConverter x:Key="KindToImageConverter" />
|
||||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid BorderBrush="{StaticResource SystemControlBackgroundBaseMediumBrush}" BorderThickness="0,0,3,0" >
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Filters" HorizontalAlignment="Center" HorizontalTextAlignment="Center"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Row="1" x:Name="filterStackPanel">
|
||||
<ComboBox Header="Discovery Type" x:Name="discoveryType" Margin="10" HorizontalAlignment="Stretch"/>
|
||||
<ComboBox Header="Authorization Type" x:Name="authorizationType" Margin="10" HorizontalAlignment="Stretch"/>
|
||||
<ComboBox Header="Device Status" x:Name="statusType" Margin="10" HorizontalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
<Button Content="Filter" Tapped="Button_Tapped" Grid.Row="2" HorizontalAlignment="Center" Width="{Binding ElementName=filterStackPanel, Path=ActualWidth}" Margin="10"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ListView Grid.Column="1" ItemsSource="{Binding RemoteSystems}" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="DevicesList">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Kind, Converter={StaticResource KindToImageConverter}}" FontFamily="Segoe MDL2 Assets" VerticalAlignment="Center" FontSize="{StaticResource HubHeaderThemeFontSize}" />
|
||||
<Grid Grid.Column="1" Margin="10,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding DisplayName}" Tag="{Binding }" Grid.Row="0" VerticalAlignment="Center" Margin="10,0" />
|
||||
<TextBlock Text="{Binding ModelDisplayName}" Tag="{Binding }" Grid.Row="1" VerticalAlignment="Center" Margin="10,0" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,50 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.System.RemoteSystems;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class RemoteDeviceHelperPage : Page
|
||||
{
|
||||
private RemoteDeviceHelper _remoteDeviceHelper;
|
||||
|
||||
public RemoteDeviceHelperPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
var selectionEnum = Enum.GetNames(typeof(RemoteSystemDiscoveryType)).Cast<string>().OrderBy(q => q).ToList();
|
||||
discoveryType.ItemsSource = selectionEnum;
|
||||
discoveryType.SelectedIndex = 0;
|
||||
|
||||
selectionEnum = Enum.GetNames(typeof(RemoteSystemAuthorizationKind)).Cast<string>().OrderBy(q => q).ToList();
|
||||
authorizationType.ItemsSource = selectionEnum;
|
||||
authorizationType.SelectedIndex = 0;
|
||||
|
||||
selectionEnum = Enum.GetNames(typeof(RemoteSystemStatusType)).Cast<string>().OrderBy(q => q).ToList();
|
||||
statusType.ItemsSource = selectionEnum;
|
||||
statusType.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void Button_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
|
||||
{
|
||||
var filters = new List<IRemoteSystemFilter>
|
||||
{
|
||||
new RemoteSystemDiscoveryTypeFilter((RemoteSystemDiscoveryType)Enum.Parse(typeof(RemoteSystemDiscoveryType), discoveryType?.SelectedValue.ToString())),
|
||||
new RemoteSystemAuthorizationKindFilter((RemoteSystemAuthorizationKind)Enum.Parse(typeof(RemoteSystemAuthorizationKind), authorizationType?.SelectedValue.ToString())),
|
||||
new RemoteSystemStatusTypeFilter((RemoteSystemStatusType)Enum.Parse(typeof(RemoteSystemStatusType), statusType?.SelectedValue.ToString()))
|
||||
};
|
||||
|
||||
|
||||
|
||||
_remoteDeviceHelper = new RemoteDeviceHelper(filters);
|
||||
DevicesList.DataContext = _remoteDeviceHelper;
|
||||
}
|
||||
}
|
||||
}
|
Двоичные данные
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RemoteDevicePicker/RemoteDevicePicker.png
Normal file
Двоичные данные
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RemoteDevicePicker/RemoteDevicePicker.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.0 KiB |
|
@ -0,0 +1,17 @@
|
|||
RemoteDevicePicker remoteDevicePicker = new RemoteDevicePicker()
|
||||
{
|
||||
Title = "Pick Remote Device",
|
||||
SelectionMode = RemoteDevicesSelectionMode.Multiple
|
||||
};
|
||||
|
||||
var remoteSystems = await remoteDevicePicker.PickDeviceAsync();
|
||||
await new MessageDialog($"You picked {remoteSystems.Count().ToString()} Device(s)" + Environment.NewLine + string.Join(",", remoteSystems.Select(x => x.DisplayName.ToString()).ToList())).ShowAsync();
|
||||
|
||||
RemoteDevicePicker remoteDevicePicker = new RemoteDevicePicker(RemoteSystemDiscoveryType.Proximal, RemoteSystemAuthorizationKind.Anonymous, RemoteSystemStatusType.Any)
|
||||
{
|
||||
Title = "Pick Remote Device",
|
||||
SelectionMode = RemoteDevicesSelectionMode.Multiple
|
||||
};
|
||||
|
||||
var remoteSystems = await remoteDevicePicker.PickDeviceAsync();
|
||||
await new MessageDialog($"You picked {remoteSystems.Count().ToString()} Device(s)" + Environment.NewLine + string.Join(",", remoteSystems.Select(x => x.DisplayName.ToString()).ToList())).ShowAsync();
|
|
@ -0,0 +1,23 @@
|
|||
<Page
|
||||
x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.RemoteDevicePickerControlPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Button Content="Pick Device(s)" HorizontalAlignment="Center" VerticalAlignment="Center" Tapped="Button_Tapped" Grid.Row="0" Width="{Binding ElementName=MyComboBox, Path=ActualWidth}" />
|
||||
<CheckBox Content="Show Advanced Filters" Grid.Row="1" x:Name="ShowAdvancedFilters"/>
|
||||
<ComboBox x:Name="MyComboBox" Grid.Row="2" MinWidth="200" Header="Selection Mode" />
|
||||
</Grid>
|
||||
<controls:InAppNotification x:Name="MyInAppNotification" ShowDismissButton="False" />
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,35 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Toolkit.Uwp.UI.Controls;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
public sealed partial class RemoteDevicePickerControlPage : Page
|
||||
{
|
||||
public RemoteDevicePickerControlPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
var selectionEnum = Enum.GetNames(typeof(RemoteDeviceSelectionMode)).Cast<string>().ToList();
|
||||
MyComboBox.ItemsSource = selectionEnum;
|
||||
MyComboBox.SelectedIndex = 1;
|
||||
}
|
||||
|
||||
private async void Button_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
var remoteDevicePicker = new RemoteDevicePicker()
|
||||
{
|
||||
Title = "Pick Remote Device",
|
||||
SelectionMode = (RemoteDeviceSelectionMode)Enum.Parse(typeof(RemoteDeviceSelectionMode), MyComboBox.SelectedValue.ToString()),
|
||||
ShowAdvancedFilters = ShowAdvancedFilters.IsChecked.Value
|
||||
};
|
||||
var remoteSystems = await remoteDevicePicker.PickDeviceAsync();
|
||||
MyInAppNotification.Show($"You picked {remoteSystems.Count().ToString()} Device(s)" + Environment.NewLine + string.Join(",", remoteSystems.Select(x => x.DisplayName.ToString()).ToList()), 2000);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -305,6 +305,15 @@
|
|||
"BadgeUpdateVersionRequired": "Fall Creators Update required",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/InfiniteCanvas.md"
|
||||
},
|
||||
{
|
||||
"Name": "RemoteDevicePicker",
|
||||
"Type": "RemoteDevicePickerControlPage",
|
||||
"About": "Remote Device Picker Control for Project Rome.",
|
||||
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/RemoteDevicePicker",
|
||||
"CodeFile": "RemoteDevicePickerCode.bind",
|
||||
"Icon": "/SamplePages/RemoteDevicePicker/RemoteDevicePicker.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/RemoteDevicePicker.md"
|
||||
},
|
||||
{
|
||||
"Name": "ImageCropper",
|
||||
"Type": "ImageCropperPage",
|
||||
|
@ -781,6 +790,15 @@
|
|||
"About": "The ThemeListener allows you to keep track of changes to the System Theme.",
|
||||
"Icon": "/Assets/Helpers.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/helpers/ThemeListener.md"
|
||||
},
|
||||
{
|
||||
"Name": "RemoteDeviceHelper",
|
||||
"Type": "RemoteDeviceHelperPage",
|
||||
"About": "Allows you to easily enumerate remote devices ( Project Rome ).",
|
||||
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp/Helpers/RemoteDeviceHelper/RemoteDeviceHelper.cs",
|
||||
"CodeFile": "RemoteDeviceHelperCode.bind",
|
||||
"Icon": "/SamplePages/RemoteDeviceHelper/RemoteDeviceHelper.png",
|
||||
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/helpers/RemoteDeviceHelper.md"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Extensions;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Automation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
|
@ -66,6 +68,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
Width = _normalModeWidth;
|
||||
VisualStateManager.GoToState(this, "Expanded", true);
|
||||
var name = StringExtensions.GetLocalized("WindowsCommunityToolkit_BladeView_ExpandButton_Collapsed", "Microsoft.Toolkit.Uwp.UI.Controls/Resources");
|
||||
if (_enlargeButton != null)
|
||||
{
|
||||
AutomationProperties.SetName(_enlargeButton, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,6 +84,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
Width = double.NaN;
|
||||
VisualStateManager.GoToState(this, "Collapsed", true);
|
||||
var name = StringExtensions.GetLocalized("WindowsCommunityToolkit_BladeView_ExpandButton_Expanded", "Microsoft.Toolkit.Uwp.UI.Controls/Resources");
|
||||
if (_enlargeButton != null)
|
||||
{
|
||||
AutomationProperties.SetName(_enlargeButton, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,4 +110,4 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
IsExpanded = !IsExpanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,11 +162,10 @@
|
|||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="14"
|
||||
Foreground="{TemplateBinding CloseButtonForeground}" />
|
||||
<Button Name="CloseButton"
|
||||
<Button Name="CloseButton"
|
||||
Grid.Column="2"
|
||||
TabIndex="0"
|
||||
HorizontalAlignment="Right"
|
||||
AutomationProperties.Name="Cancel"
|
||||
Background="{TemplateBinding CloseButtonBackground}"
|
||||
Style="{StaticResource ButtonRevealStyle}"
|
||||
BorderThickness="1"
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
mc:Ignorable="d">
|
||||
|
||||
<converters:EmptyObjectToObjectConverter x:Key="NullToVisibilityConverter" EmptyValue="Collapsed" NotEmptyValue="Visible" />
|
||||
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
|
||||
|
||||
<Style x:Key="HeaderToggleButtonStyle"
|
||||
TargetType="ToggleButton">
|
||||
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundTransparentBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource ToggleButtonBorderThemeThickness}" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Padding" Value="2,0,0,0" />
|
||||
<Setter Property="Height" Value="40" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
|
@ -322,6 +323,26 @@
|
|||
<ColumnDefinition x:Name="ColumnTwo"
|
||||
Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<controls:LayoutTransformControl x:Name="PART_LayoutTransformer"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<controls:LayoutTransformControl.Transform>
|
||||
<RotateTransform x:Name="RotateLayoutTransform" Angle="0" />
|
||||
</controls:LayoutTransformControl.Transform>
|
||||
<ToggleButton x:Name="PART_ExpanderToggleButton"
|
||||
MinWidth="40"
|
||||
MinHeight="40"
|
||||
AutomationProperties.Name="Expand"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Style="{TemplateBinding HeaderStyle}"
|
||||
TabIndex="0" />
|
||||
</controls:LayoutTransformControl>
|
||||
<Grid x:Name="PART_ContentOverlay"
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="1"
|
||||
|
@ -334,6 +355,8 @@
|
|||
<ContentControl Content="{TemplateBinding ContentOverlay}"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
IsEnabled="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BoolNegationConverter}}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<ContentControl.RenderTransform>
|
||||
|
@ -361,26 +384,6 @@
|
|||
<ScaleTransform />
|
||||
</Grid.RenderTransform>
|
||||
</Grid>
|
||||
<controls:LayoutTransformControl x:Name="PART_LayoutTransformer"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<controls:LayoutTransformControl.Transform>
|
||||
<RotateTransform x:Name="RotateLayoutTransform" Angle="0" />
|
||||
</controls:LayoutTransformControl.Transform>
|
||||
<ToggleButton x:Name="PART_ExpanderToggleButton"
|
||||
MinWidth="40"
|
||||
MinHeight="40"
|
||||
AutomationProperties.Name="Expand"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Style="{TemplateBinding HeaderStyle}"
|
||||
TabIndex="0" />
|
||||
</controls:LayoutTransformControl>
|
||||
</Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="DisplayModeAndDirectionStates">
|
||||
|
|
|
@ -2,8 +2,13 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.Toolkit.Uwp.Extensions;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Automation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
|
||||
|
@ -163,6 +168,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
DefaultStyleKey = typeof(GridSplitter);
|
||||
Loaded += GridSplitter_Loaded;
|
||||
string automationName = StringExtensions.GetLocalized("WindowsCommunityToolkit_GridSplitter_AutomationName", "/Microsoft.Toolkit.Uwp.UI.Controls/Resources");
|
||||
AutomationProperties.SetName(this, automationName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.Toolkit.Uwp.Extensions;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Automation;
|
||||
using Windows.UI.Xaml.Automation.Peers;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
|
@ -32,6 +36,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public event InAppNotificationClosedEventHandler Closed;
|
||||
|
||||
private AutomationPeer peer;
|
||||
|
||||
private void DismissButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Dismiss(InAppNotificationDismissKind.User);
|
||||
|
@ -47,9 +53,29 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
_animationTimer.Stop();
|
||||
Opened?.Invoke(this, EventArgs.Empty);
|
||||
SetValue(AutomationProperties.NameProperty, StringExtensions.GetLocalized("WindowsCommunityToolkit_InAppNotification_NameProperty", "/Microsoft.Toolkit.Uwp.UI.Controls/Resources"));
|
||||
peer = FrameworkElementAutomationPeer.CreatePeerForElement(ContentTemplateRoot);
|
||||
if (Content.GetType() == typeof(string))
|
||||
{
|
||||
AutomateTextNotification(Content.ToString());
|
||||
}
|
||||
|
||||
_animationTimer.Tick -= OpenAnimationTimer_Tick;
|
||||
}
|
||||
|
||||
private void AutomateTextNotification(string message)
|
||||
{
|
||||
if (peer != null)
|
||||
{
|
||||
peer.SetFocus();
|
||||
peer.RaiseNotificationEvent(
|
||||
AutomationNotificationKind.Other,
|
||||
AutomationNotificationProcessing.ImportantMostRecent,
|
||||
StringExtensions.GetLocalized("WindowsCommunityToolkit_InAppNotification_Events_NewNotificationMessage", "/Microsoft.Toolkit.Uwp.UI.Controls/Resources") + message,
|
||||
Guid.NewGuid().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void DismissAnimationTimer_Tick(object sender, object e)
|
||||
{
|
||||
_animationTimer.Stop();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal event EventHandler CommandExecuted;
|
||||
|
||||
internal void Undo(Rect viewPort)
|
||||
internal void Undo(Rect viewPort, float zoomFactor)
|
||||
{
|
||||
if (_undoCommands.Count != 0)
|
||||
{
|
||||
|
@ -28,11 +28,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
command.Undo();
|
||||
_redoCommands.Push(command);
|
||||
|
||||
ReDraw(viewPort);
|
||||
ReDraw(viewPort, zoomFactor);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Redo(Rect viewPort)
|
||||
internal void Redo(Rect viewPort, float zoomFactor)
|
||||
{
|
||||
if (_redoCommands.Count != 0)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
command.Execute();
|
||||
_undoCommands.Push(command);
|
||||
|
||||
ReDraw(viewPort);
|
||||
ReDraw(viewPort, zoomFactor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Input.Inking;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
|
@ -13,6 +15,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public partial class InfiniteCanvasVirtualDrawingSurface
|
||||
{
|
||||
internal List<InkStroke> ExportInkStrokes()
|
||||
{
|
||||
return _drawableList.OfType<InkDrawable>().SelectMany(id => id.Strokes).ToList();
|
||||
}
|
||||
|
||||
internal void Erase(Point point, Rect viewPort, float zoomFactor)
|
||||
{
|
||||
const int tolerance = 5;
|
||||
|
@ -37,7 +44,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
var toRemove = _visibleList.ElementAt(i);
|
||||
ExecuteEraseInk(toRemove);
|
||||
ReDraw(viewPort);
|
||||
ReDraw(viewPort, zoomFactor);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.UI.Composition;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Windows.Foundation;
|
||||
using Windows.Graphics;
|
||||
using Windows.Storage;
|
||||
using Windows.UI;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
|
@ -20,13 +22,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public partial class InfiniteCanvasVirtualDrawingSurface
|
||||
{
|
||||
private const float BaseCanvasDPI = 96;
|
||||
|
||||
private readonly List<IDrawable> _visibleList = new List<IDrawable>();
|
||||
private readonly List<IDrawable> _drawableList = new List<IDrawable>();
|
||||
|
||||
internal void ReDraw(Rect viewPort)
|
||||
internal void ReDraw(Rect viewPort, float zoom)
|
||||
{
|
||||
var toDraw = GetDrawingBoundaries(viewPort);
|
||||
using (var drawingSession = CanvasComposition.CreateDrawingSession(_drawingSurface, toDraw))
|
||||
|
||||
var scale = _screenScale * zoom;
|
||||
|
||||
using (var drawingSession = CanvasComposition.CreateDrawingSession(_drawingSurface, ScaleRect(toDraw, scale), BaseCanvasDPI * (float)scale))
|
||||
{
|
||||
drawingSession.Clear(Colors.White);
|
||||
foreach (var drawable in _visibleList)
|
||||
|
@ -36,6 +43,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
private Rect ScaleRect(Rect rect, double scale)
|
||||
{
|
||||
return new Rect(rect.X * scale, rect.Y * scale, rect.Width * scale, rect.Height * scale);
|
||||
}
|
||||
|
||||
internal CanvasRenderTarget ExportMaxOffScreenDrawings()
|
||||
{
|
||||
var toDraw = GetMaxDrawingsBoundaries();
|
||||
|
@ -59,7 +71,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
});
|
||||
}
|
||||
|
||||
internal void RenderFromJsonAndDraw(Rect viewPort, string json)
|
||||
internal void RenderFromJsonAndDraw(Rect viewPort, string json, float zoom)
|
||||
{
|
||||
_visibleList.Clear();
|
||||
_drawableList.Clear();
|
||||
|
@ -83,7 +95,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
_drawableList.Add(drawable);
|
||||
}
|
||||
|
||||
ReDraw(viewPort);
|
||||
ReDraw(viewPort, zoom);
|
||||
}
|
||||
|
||||
private Rect GetDrawingBoundaries(Rect viewPort)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Windows.Foundation;
|
||||
|
||||
|
@ -50,5 +51,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
_selectedTextDrawableIndex = _drawableList.Count - 1;
|
||||
}
|
||||
|
||||
internal List<string> ExportText()
|
||||
{
|
||||
return _drawableList.OfType<TextDrawable>().Select(td => td.Text).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.Graphics.Canvas;
|
|||
using Microsoft.Graphics.Canvas.UI.Composition;
|
||||
using Windows.Graphics;
|
||||
using Windows.Graphics.DirectX;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.UI.Composition;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
@ -25,6 +26,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private SpriteVisual _myDrawingVisual;
|
||||
private CompositionVirtualDrawingSurface _drawingSurface;
|
||||
private CompositionSurfaceBrush _surfaceBrush;
|
||||
private double _screenScale;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InfiniteCanvasVirtualDrawingSurface"/> class.
|
||||
|
@ -49,7 +51,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
ElementCompositionPreview.SetElementChildVisual(this, _myDrawingVisual);
|
||||
}
|
||||
|
||||
internal void ConfigureSpriteVisual(double width, double height)
|
||||
internal void ConfigureSpriteVisual(double width, double height, float zoomFactor)
|
||||
{
|
||||
var size = new SizeInt32
|
||||
{
|
||||
|
@ -68,8 +70,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
_surfaceBrush.VerticalAlignmentRatio = 0;
|
||||
_surfaceBrush.TransformMatrix = Matrix3x2.CreateTranslation(0, 0);
|
||||
|
||||
SetScale(zoomFactor);
|
||||
|
||||
_myDrawingVisual.Brush = _surfaceBrush;
|
||||
_surfaceBrush.Offset = new Vector2(0, 0);
|
||||
}
|
||||
|
||||
internal void SetScale(float zoomFactor)
|
||||
{
|
||||
_screenScale = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
|
||||
var scale = _screenScale * zoomFactor;
|
||||
_surfaceBrush.Scale = new Vector2((float)(1 / scale));
|
||||
_surfaceBrush.BitmapInterpolationMode = CompositionBitmapInterpolationMode.NearestNeighbor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// work around to virtual drawing surface bug.
|
||||
await Task.Delay(1000);
|
||||
_drawingSurfaceRenderer.ReDraw(ViewPort);
|
||||
_drawingSurfaceRenderer.ReDraw(ViewPort, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
private void InkScrollViewer_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
|
@ -138,6 +138,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (!e.IsIntermediate)
|
||||
{
|
||||
_drawingSurfaceRenderer.SetScale(_infiniteCanvasScrollViewer.ZoomFactor);
|
||||
|
||||
ReDrawCanvas();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Windows.Foundation;
|
||||
|
@ -307,12 +308,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
_inkCanvas.Height = CanvasHeight;
|
||||
_drawingSurfaceRenderer.Width = CanvasWidth;
|
||||
_drawingSurfaceRenderer.Height = CanvasHeight;
|
||||
_drawingSurfaceRenderer.ConfigureSpriteVisual(CanvasWidth, CanvasHeight);
|
||||
_drawingSurfaceRenderer.ConfigureSpriteVisual(CanvasWidth, CanvasHeight, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
private void ReDrawCanvas()
|
||||
{
|
||||
_drawingSurfaceRenderer.ReDraw(ViewPort);
|
||||
_drawingSurfaceRenderer.ReDraw(ViewPort, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -320,7 +321,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public void Redo()
|
||||
{
|
||||
_drawingSurfaceRenderer.Redo(ViewPort);
|
||||
_drawingSurfaceRenderer.Redo(ViewPort, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -328,7 +329,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
public void Undo()
|
||||
{
|
||||
_drawingSurfaceRenderer.Undo(ViewPort);
|
||||
_drawingSurfaceRenderer.Undo(ViewPort, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -341,13 +342,31 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return _drawingSurfaceRenderer.GetSerializedList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the InfiniteCanvas ink strokes.
|
||||
/// </summary>
|
||||
/// <returns>list of InkStrokes</returns>
|
||||
public List<InkStroke> ExportInkStrokes()
|
||||
{
|
||||
return _drawingSurfaceRenderer.ExportInkStrokes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export the InfiniteCanvas raw text.
|
||||
/// </summary>
|
||||
/// <returns>list of strings</returns>
|
||||
public List<string> ExportText()
|
||||
{
|
||||
return _drawingSurfaceRenderer.ExportText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Import InfiniteCanvas from json string and render the new canvas, this function will empty the Redo/Undo queue.
|
||||
/// </summary>
|
||||
/// <param name="json">InfiniteCanvas json representation</param>
|
||||
public void ImportFromJson(string json)
|
||||
{
|
||||
_drawingSurfaceRenderer.RenderFromJsonAndDraw(ViewPort, json);
|
||||
_drawingSurfaceRenderer.RenderFromJsonAndDraw(ViewPort, json, _infiniteCanvasScrollViewer.ZoomFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="ColorCode.UWP" Version="2.0.6" />
|
||||
<PackageReference Include="Robmikh.CompositionSurfaceFactory" Version="0.7.3" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
|
||||
|
@ -20,6 +19,29 @@
|
|||
<None Include="VisualStudioToolsManifest.xml" Pack="true" PackagePath="tools" />
|
||||
<None Include="$(OutDir)\Design\$(MSBuildProjectName).Design.dll" Pack="true" PackagePath="lib\$(TargetFramework)\Design" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="ImageCropper\ImageCropper.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Update="ImageCropper\ImageCropperThumb.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="RemoteDevicePicker\RemoteDevicePicker.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PRIResource Include="Strings\en-us\Resources.resw" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
|
||||
|
||||
|
||||
<!-- https://weblogs.asp.net/rweigelt/disable-warnings-in-generated-c-files-of-uwp-app -->
|
||||
<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2">
|
||||
|
|
|
@ -0,0 +1,360 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.System.RemoteSystems;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Picker Control to show List of Remote Devices that are accessible
|
||||
/// </summary>
|
||||
[TemplatePart(Name = "PART_ListDevices", Type = typeof(ListView))]
|
||||
[TemplatePart(Name = "PART_ListDeviceTypes", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "PART_ProgressRing", Type = typeof(ProgressRing))]
|
||||
[TemplatePart(Name = "DiscoveryType", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "StatusType", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "AuthorizationType", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "AdvancedFiltersGrid", Type = typeof(Grid))]
|
||||
public sealed class RemoteDevicePicker : ContentDialog
|
||||
{
|
||||
private ListView _listDevices;
|
||||
private ComboBox _listDeviceTypes;
|
||||
private ProgressRing _progressRing;
|
||||
private Grid _commandSpace;
|
||||
private ComboBox _deviceDiscovery;
|
||||
private ComboBox _deviceStatus;
|
||||
private ComboBox _authorizationType;
|
||||
private Grid _advancedFiltersGrid;
|
||||
private RemoteSystemDiscoveryTypeFilter _discoveryFilter;
|
||||
private RemoteSystemAuthorizationKindFilter _authorizationKindFilter;
|
||||
private RemoteSystemStatusTypeFilter _statusFilter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets List of All Remote Systems based on Selection Filter
|
||||
/// </summary>
|
||||
private ObservableCollection<RemoteSystem> RemoteSystems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DeviceList Selection Mode. Defaults to ListViewSelectionMode.Single
|
||||
/// </summary>
|
||||
public RemoteDeviceSelectionMode SelectionMode
|
||||
{
|
||||
get { return (RemoteDeviceSelectionMode)GetValue(SelectionModeProperty); }
|
||||
set { SetValue(SelectionModeProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dependency property for <see cref="SelectionMode"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SelectionModeProperty = DependencyProperty.Register(
|
||||
nameof(SelectionMode),
|
||||
typeof(RemoteDeviceSelectionMode),
|
||||
typeof(RemoteDevicePicker),
|
||||
new PropertyMetadata(RemoteDeviceSelectionMode.Single));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether Advanced Filters visible or not
|
||||
/// </summary>
|
||||
public bool ShowAdvancedFilters
|
||||
{
|
||||
get { return (bool)GetValue(ShowAdvancedFiltersProperty); }
|
||||
set { SetValue(ShowAdvancedFiltersProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dependency property for <see cref="ShowAdvancedFilters"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowAdvancedFiltersProperty = DependencyProperty.Register(
|
||||
nameof(ShowAdvancedFilters),
|
||||
typeof(bool),
|
||||
typeof(RemoteDevicePicker),
|
||||
new PropertyMetadata(false));
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteDevicePicker"/> class.
|
||||
/// </summary>
|
||||
public RemoteDevicePicker()
|
||||
{
|
||||
DefaultStyleKey = typeof(RemoteDevicePicker);
|
||||
RemoteSystems = new ObservableCollection<RemoteSystem>();
|
||||
PrimaryButtonClick += RemoteDevicePicker_PrimaryButtonClick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteDevicePicker"/> class with filters.
|
||||
/// </summary>
|
||||
public RemoteDevicePicker(RemoteSystemDiscoveryType remoteSystemDiscoveryType, RemoteSystemAuthorizationKind remoteSystemAuthorizationKind, RemoteSystemStatusType remoteSystemStatusType)
|
||||
{
|
||||
DefaultStyleKey = typeof(RemoteDevicePicker);
|
||||
RemoteSystems = new ObservableCollection<RemoteSystem>();
|
||||
PrimaryButtonClick += RemoteDevicePicker_PrimaryButtonClick;
|
||||
|
||||
_discoveryFilter = new RemoteSystemDiscoveryTypeFilter(remoteSystemDiscoveryType);
|
||||
_authorizationKindFilter = new RemoteSystemAuthorizationKindFilter(remoteSystemAuthorizationKind);
|
||||
_statusFilter = new RemoteSystemStatusTypeFilter(remoteSystemStatusType);
|
||||
}
|
||||
|
||||
private void RemoteDevicePicker_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
if (_listDevices.SelectedItems.Count > 0)
|
||||
{
|
||||
_listDevices.SelectedItems.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate Picker UI
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public async Task<IEnumerable<RemoteSystem>> PickDeviceAsync()
|
||||
{
|
||||
await ShowAsync();
|
||||
IEnumerable<RemoteSystem> devices = ReturnDevices();
|
||||
return devices;
|
||||
}
|
||||
|
||||
internal IEnumerable<RemoteSystem> ReturnDevices()
|
||||
{
|
||||
List<RemoteSystem> returnValue = new List<RemoteSystem>();
|
||||
foreach (RemoteSystem item in _listDevices.SelectedItems)
|
||||
{
|
||||
returnValue.Add(item);
|
||||
}
|
||||
|
||||
return returnValue.AsEnumerable();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
Focus(FocusState.Programmatic);
|
||||
UnhookEvents();
|
||||
|
||||
_listDevices = GetTemplateChild("PART_ListDevices") as ListView;
|
||||
_listDeviceTypes = GetTemplateChild("PART_ListDeviceTypes") as ComboBox;
|
||||
_progressRing = GetTemplateChild("PART_ProgressRing") as ProgressRing;
|
||||
_commandSpace = GetTemplateChild("CommandSpace") as Grid;
|
||||
_deviceDiscovery = GetTemplateChild("DiscoveryType") as ComboBox;
|
||||
_deviceStatus = GetTemplateChild("StatusType") as ComboBox;
|
||||
_authorizationType = GetTemplateChild("AuthorizationType") as ComboBox;
|
||||
_advancedFiltersGrid = GetTemplateChild("AdvancedFiltersGrid") as Grid;
|
||||
|
||||
var deviceList = typeof(RemoteSystemKinds).GetProperties().Select(a => a.Name).ToList();
|
||||
deviceList.Add("All");
|
||||
deviceList.Add("Unknown");
|
||||
|
||||
if (_listDeviceTypes != null)
|
||||
{
|
||||
_listDeviceTypes.ItemsSource = deviceList.OrderBy(a => a.ToString());
|
||||
_listDeviceTypes.SelectionChanged += ListDeviceTypes_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_listDevices != null)
|
||||
{
|
||||
_listDevices.SelectionChanged += ListDevices_SelectionChanged;
|
||||
_listDevices.ContainerContentChanging += ListDevices_ContainerContentChanging;
|
||||
|
||||
_listDevices.SelectionMode = SelectionMode == RemoteDeviceSelectionMode.Single ? ListViewSelectionMode.Single : ListViewSelectionMode.Multiple;
|
||||
_listDevices.IsMultiSelectCheckBoxEnabled = SelectionMode == RemoteDeviceSelectionMode.Multiple ? true : false;
|
||||
if (_listDevices.SelectionMode == ListViewSelectionMode.Single)
|
||||
{
|
||||
_listDevices.DoubleTapped += ListDevices_DoubleTapped;
|
||||
}
|
||||
}
|
||||
|
||||
if (_advancedFiltersGrid != null)
|
||||
{
|
||||
_advancedFiltersGrid.Visibility = ShowAdvancedFilters || (_discoveryFilter != null && _statusFilter != null && _authorizationKindFilter != null) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
LoadFilters();
|
||||
|
||||
if (_deviceDiscovery != null)
|
||||
{
|
||||
_deviceDiscovery.SelectionChanged += Filters_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_authorizationType != null)
|
||||
{
|
||||
_authorizationType.SelectionChanged += Filters_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_deviceStatus != null)
|
||||
{
|
||||
_deviceStatus.SelectionChanged += Filters_SelectionChanged;
|
||||
}
|
||||
|
||||
BuildFilters(_discoveryFilter, _authorizationKindFilter, _statusFilter);
|
||||
|
||||
IsSecondaryButtonEnabled = false;
|
||||
|
||||
UpdateProgressRing(true);
|
||||
UpdateList();
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
private void UnhookEvents()
|
||||
{
|
||||
if (_listDeviceTypes != null)
|
||||
{
|
||||
_listDeviceTypes.SelectionChanged -= ListDeviceTypes_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_listDevices != null)
|
||||
{
|
||||
_listDevices.SelectionChanged -= ListDevices_SelectionChanged;
|
||||
_listDevices.DoubleTapped -= ListDevices_DoubleTapped;
|
||||
_listDevices.ContainerContentChanging -= ListDevices_ContainerContentChanging;
|
||||
_listDeviceTypes.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
if (_deviceDiscovery != null)
|
||||
{
|
||||
_deviceDiscovery.SelectionChanged -= Filters_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_authorizationType != null)
|
||||
{
|
||||
_authorizationType.SelectionChanged -= Filters_SelectionChanged;
|
||||
}
|
||||
|
||||
if (_deviceStatus != null)
|
||||
{
|
||||
_deviceStatus.SelectionChanged -= Filters_SelectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void Filters_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
_discoveryFilter = new RemoteSystemDiscoveryTypeFilter((RemoteSystemDiscoveryType)Enum.Parse(typeof(RemoteSystemDiscoveryType), _deviceDiscovery?.SelectedValue.ToString()));
|
||||
_authorizationKindFilter = new RemoteSystemAuthorizationKindFilter((RemoteSystemAuthorizationKind)Enum.Parse(typeof(RemoteSystemAuthorizationKind), _authorizationType?.SelectedValue.ToString()));
|
||||
_statusFilter = new RemoteSystemStatusTypeFilter((RemoteSystemStatusType)Enum.Parse(typeof(RemoteSystemStatusType), _deviceStatus?.SelectedValue.ToString()));
|
||||
|
||||
BuildFilters(_discoveryFilter, _authorizationKindFilter, _statusFilter);
|
||||
}
|
||||
|
||||
private void LoadFilters()
|
||||
{
|
||||
var discoveryType = typeof(RemoteSystemDiscoveryType).GetEnumNames().OrderBy(a => a.ToString()).ToList();
|
||||
_deviceDiscovery.ItemsSource = discoveryType;
|
||||
|
||||
if (_discoveryFilter != null)
|
||||
{
|
||||
_deviceDiscovery.SelectedValue = _discoveryFilter.RemoteSystemDiscoveryType.ToString();
|
||||
}
|
||||
|
||||
var statusType = typeof(RemoteSystemStatusType).GetEnumNames().OrderBy(a => a.ToString()).ToList();
|
||||
_deviceStatus.ItemsSource = statusType;
|
||||
|
||||
if (_statusFilter != null)
|
||||
{
|
||||
_deviceStatus.SelectedValue = _statusFilter.RemoteSystemStatusType.ToString();
|
||||
}
|
||||
|
||||
var authType = typeof(RemoteSystemAuthorizationKind).GetEnumNames().OrderBy(a => a.ToString()).ToList();
|
||||
_authorizationType.ItemsSource = authType;
|
||||
|
||||
if (_authorizationKindFilter != null)
|
||||
{
|
||||
_authorizationType.SelectedValue = _authorizationKindFilter.RemoteSystemAuthorizationKind.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildFilters(RemoteSystemDiscoveryTypeFilter discoveryFilter, RemoteSystemAuthorizationKindFilter authorizationKindFilter, RemoteSystemStatusTypeFilter statusFilter)
|
||||
{
|
||||
var filters = new List<IRemoteSystemFilter>();
|
||||
if (discoveryFilter != null)
|
||||
{
|
||||
filters.Add(discoveryFilter);
|
||||
}
|
||||
|
||||
if (authorizationKindFilter != null)
|
||||
{
|
||||
filters.Add(authorizationKindFilter);
|
||||
}
|
||||
|
||||
if (statusFilter != null)
|
||||
{
|
||||
filters.Add(statusFilter);
|
||||
}
|
||||
|
||||
var remoteDeviceHelper = new RemoteDeviceHelper(filters);
|
||||
RemoteSystems = remoteDeviceHelper.RemoteSystems;
|
||||
|
||||
UpdateProgressRing(true);
|
||||
UpdateList();
|
||||
}
|
||||
|
||||
private void ListDevices_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
|
||||
{
|
||||
var model = (RemoteSystem)args.Item;
|
||||
switch (model.Status)
|
||||
{
|
||||
case RemoteSystemStatus.Available:
|
||||
args.ItemContainer.IsEnabled = true;
|
||||
args.ItemContainer.IsHitTestVisible = true;
|
||||
break;
|
||||
|
||||
case RemoteSystemStatus.DiscoveringAvailability:
|
||||
case RemoteSystemStatus.Unavailable:
|
||||
case RemoteSystemStatus.Unknown:
|
||||
args.ItemContainer.IsEnabled = false;
|
||||
args.ItemContainer.IsHitTestVisible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_listDevices.SelectedItems.Count > 0)
|
||||
{
|
||||
IsSecondaryButtonEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsSecondaryButtonEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListDevices_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
|
||||
{
|
||||
ReturnDevices();
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void ListDeviceTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) => UpdateList();
|
||||
|
||||
private void UpdateList()
|
||||
{
|
||||
var bindingList = new ObservableCollection<RemoteSystem>();
|
||||
if (RemoteSystems != null)
|
||||
{
|
||||
var bindinglist = _listDeviceTypes.SelectedValue.ToString().Equals("All")
|
||||
? RemoteSystems
|
||||
: new ObservableCollection<RemoteSystem>(RemoteSystems.Where(a => a.Kind.Equals(_listDeviceTypes.SelectedValue.ToString(), StringComparison.OrdinalIgnoreCase)).ToList());
|
||||
|
||||
_listDevices.ItemsSource = bindinglist;
|
||||
UpdateProgressRing(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgressRing(bool state)
|
||||
{
|
||||
if (_progressRing != null)
|
||||
{
|
||||
_progressRing.IsActive = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
|
||||
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
|
||||
|
||||
<converters:RemoteSystemKindToSymbolConverter x:Key="KindToImageConverter" />
|
||||
|
||||
<Thickness x:Key="RemoteDevicePickerMargin" >12,5</Thickness>
|
||||
|
||||
<Style TargetType="local:RemoteDevicePicker">
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlPageTextBaseHighBrush}" />
|
||||
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="MaxHeight" Value="{ThemeResource ContentDialogMaxHeight}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource ContentDialogMinHeight}" />
|
||||
<Setter Property="MaxWidth" Value="{ThemeResource ContentDialogMaxWidth}" />
|
||||
<Setter Property="MinWidth" Value="{ThemeResource ContentDialogMinWidth}" />
|
||||
<Setter Property="PrimaryButtonText" Value="Cancel" />
|
||||
<Setter Property="SecondaryButtonText" Value="Select" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="local:RemoteDevicePicker">
|
||||
<Border x:Name="Container">
|
||||
<Grid x:Name="LayoutRoot">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="BackgroundElement"
|
||||
Background="{TemplateBinding Background}"
|
||||
FlowDirection="{TemplateBinding FlowDirection}"
|
||||
BorderThickness="{ThemeResource ContentDialogBorderWidth}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundAccentBrush}"
|
||||
MaxWidth="{TemplateBinding MaxWidth}"
|
||||
MaxHeight="{TemplateBinding MaxHeight}"
|
||||
MinWidth="{TemplateBinding MinWidth}"
|
||||
MinHeight="{TemplateBinding MinHeight}">
|
||||
<Grid x:Name="DialogSpace" VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer x:Name="ContentScrollViewer"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Disabled"
|
||||
ZoomMode="Disabled"
|
||||
IsTabStop="False">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentControl x:Name="Title"
|
||||
Margin="{ThemeResource ContentDialogTitleMargin}"
|
||||
Content="{TemplateBinding Title}"
|
||||
ContentTemplate="{TemplateBinding TitleTemplate}"
|
||||
FontSize="20"
|
||||
FontFamily="XamlAutoFontFamily"
|
||||
FontWeight="Normal"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
IsTabStop="False"
|
||||
MaxHeight="{ThemeResource ContentDialogTitleMaxHeight}">
|
||||
<ContentControl.Template>
|
||||
<ControlTemplate TargetType="ContentControl">
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
MaxLines="2"
|
||||
TextWrapping="Wrap"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Margin="12,12,12,0"
|
||||
ContentTransitions="{TemplateBinding ContentTransitions}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
</ControlTemplate>
|
||||
</ContentControl.Template>
|
||||
</ContentControl>
|
||||
<ProgressRing x:Name="PART_ProgressRing" Width="25" Height="25" IsActive="True" Grid.Column="2" Margin="5" HorizontalAlignment="Right"/>
|
||||
</StackPanel>
|
||||
<Grid VerticalAlignment="Center" Grid.Row="2" Margin="{StaticResource RemoteDevicePickerMargin}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Device Type: " VerticalAlignment="Center" />
|
||||
<ComboBox x:Name="PART_ListDeviceTypes" Margin="10,4" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" SelectedIndex="0" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="3" MaxWidth="{ThemeResource ContentDialogMinWidth}" Visibility="Collapsed" x:Name="AdvancedFiltersGrid" Margin="12,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Device Discovery Type: " VerticalAlignment="Center" />
|
||||
<ComboBox x:Name="DiscoveryType" Margin="10,4" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" SelectedIndex="0" />
|
||||
<TextBlock Text="Device Availability: " VerticalAlignment="Center" Grid.Row="1"/>
|
||||
<ComboBox x:Name="StatusType" Margin="10,4" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" SelectedIndex="0" Grid.Row="1"/>
|
||||
<TextBlock Text="Device User Type: " VerticalAlignment="Center" Grid.Row="2"/>
|
||||
<ComboBox x:Name="AuthorizationType" Margin="10,4" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.Column="1" SelectedIndex="0" Grid.Row="2"/>
|
||||
</Grid>
|
||||
<ScrollContentPresenter x:Name="Content"
|
||||
FontSize="{ThemeResource ControlContentThemeFontSize}"
|
||||
FontFamily="{ThemeResource ContentControlThemeFontFamily}"
|
||||
Margin="{ThemeResource ContentDialogContentMargin}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Grid.Row="4" TextWrapping="Wrap">
|
||||
<ContentPresenter.Content>
|
||||
<ListView x:Name="PART_ListDevices" IsItemClickEnabled="True" IsDoubleTapEnabled="True" IsMultiSelectCheckBoxEnabled="True">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Kind, Converter={StaticResource KindToImageConverter}}" FontFamily="Segoe MDL2 Assets" VerticalAlignment="Center" FontSize="{StaticResource HubHeaderThemeFontSize}" />
|
||||
<Grid Grid.Column="1" Margin="8,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding DisplayName}" Tag="{Binding }" Grid.Row="0" VerticalAlignment="Center" Margin="10,0" />
|
||||
<TextBlock Text="{Binding ModelDisplayName}" Tag="{Binding }" Grid.Row="1" VerticalAlignment="Center" Margin="10,0" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ContentPresenter.Content>
|
||||
</ScrollContentPresenter>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<Grid x:Name="CommandSpace" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="Button1Host"
|
||||
Margin="{ThemeResource ContentDialogButton1HostMargin}"
|
||||
MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
|
||||
MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
|
||||
Height="{ThemeResource ContentDialogButtonHeight}"
|
||||
HorizontalAlignment="Stretch" />
|
||||
<Border x:Name="Button2Host"
|
||||
Margin="{ThemeResource ContentDialogButton2HostMargin}"
|
||||
MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
|
||||
MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
|
||||
Height="{ThemeResource ContentDialogButtonHeight}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Stretch" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,22 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Remote Devices Selection Mode.
|
||||
/// </summary>
|
||||
public enum RemoteDeviceSelectionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Pick Single Device
|
||||
/// </summary>
|
||||
Single,
|
||||
|
||||
/// <summary>
|
||||
/// Pick Multiple Devices
|
||||
/// </summary>
|
||||
Multiple
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Converter to convert Device Type to Icon
|
||||
/// </summary>
|
||||
public class RemoteSystemKindToSymbolConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
string finalvalue = string.Empty;
|
||||
switch ((string)value)
|
||||
{
|
||||
case "Desktop":
|
||||
finalvalue = "\xE770";
|
||||
break;
|
||||
|
||||
case "Phone":
|
||||
case "Unknown":
|
||||
finalvalue = "\xE8EA";
|
||||
break;
|
||||
|
||||
case "Xbox":
|
||||
finalvalue = "\xE990";
|
||||
break;
|
||||
|
||||
case "Tablet":
|
||||
finalvalue = "\xE70A";
|
||||
break;
|
||||
|
||||
case "Laptop":
|
||||
finalvalue = "\xE7F8";
|
||||
break;
|
||||
|
||||
case "Holographic":
|
||||
finalvalue = "\xF4BF";
|
||||
break;
|
||||
|
||||
case "Hub":
|
||||
finalvalue = "\xE8AE";
|
||||
break;
|
||||
|
||||
case "Iot":
|
||||
finalvalue = "\xF22C";
|
||||
break;
|
||||
|
||||
default:
|
||||
finalvalue = "\xE770";
|
||||
break;
|
||||
}
|
||||
|
||||
return finalvalue;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="WindowsCommunityToolkit_BladeView_ExpandButton_Collapsed" xml:space="preserve">
|
||||
<value>Collapse Blade</value>
|
||||
<comment>Narrator Resource for BladeView collapsed status</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_BladeView_ExpandButton_Expanded" xml:space="preserve">
|
||||
<value>Expand Blade</value>
|
||||
<comment>Narrator Resource for BladeView expanded status</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_GridSplitter_AutomationName" xml:space="preserve">
|
||||
<value>GridSpliter</value>
|
||||
<comment>Narrator Resource for GridSplitter control</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_InAppNotification_Events_NewNotificationMessage" xml:space="preserve">
|
||||
<value>New notification</value>
|
||||
<comment>Narrator resource for a new notification using the InAppNotification</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_InAppNotification_NameProperty" xml:space="preserve">
|
||||
<value>Notification</value>
|
||||
<comment>Name property for InAppNotification</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_TabView_CloseButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Close tab</value>
|
||||
<comment>Narrator Resource for TabView Close Button.</comment>
|
||||
</data>
|
||||
<data name="WindowsCommunityToolkit_TabView_CloseButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Close tab</value>
|
||||
<comment>Tooltip for TabView Close Button.</comment>
|
||||
</data>
|
||||
</root>
|
|
@ -114,7 +114,7 @@
|
|||
<Style TargetType="local:TabView">
|
||||
<Setter Property="Background" Value="{ThemeResource TabViewBackground}" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="TabNavigation" Value="Once" />
|
||||
<Setter Property="TabNavigation" Value="Local" />
|
||||
<Setter Property="IsSwipeEnabled" Value="False" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
|
||||
|
@ -296,6 +296,7 @@
|
|||
Background="{TemplateBinding Background}"
|
||||
Visibility="Collapsed">
|
||||
<Button x:Name="CloseButton"
|
||||
x:Uid="/Microsoft.Toolkit.Uwp.UI.Controls/Resources/WindowsCommunityToolkit_TabView_CloseButton"
|
||||
Style="{StaticResource TabViewItemCloseButtonStyle}">
|
||||

|
||||
</Button>
|
||||
|
@ -711,6 +712,7 @@
|
|||
|
||||
<ScrollContentPresenter x:Name="ScrollContentPresenter"
|
||||
Grid.Column="1"
|
||||
TabFocusNavigation="Once"
|
||||
Margin="{TemplateBinding Padding}" />
|
||||
|
||||
<RepeatButton x:Name="ScrollForwardButton"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/LayoutTransformControl/LayoutTransformControl.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/CameraPreview/CameraPreview.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/InfiniteCanvas/InfiniteCanvas.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/RemoteDevicePicker/RemoteDevicePicker.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/TabView/TabView.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/ImageCropper/ImageCropperThumb.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/ImageCropper/ImageCropper.xaml" />
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Extensions
|
|||
{
|
||||
// when exiting change the cursor to the target Mouse.Cursor value of the new element
|
||||
CoreCursor cursor;
|
||||
if (e.OriginalSource is FrameworkElement newElement)
|
||||
if (sender != e.OriginalSource && e.OriginalSource is FrameworkElement newElement)
|
||||
{
|
||||
cursor = _cursors[GetCursor(newElement)];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// UWP specific helpers for working with strings.
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
private static ResourceLoader _independentLoader = ResourceLoader.GetForViewIndependentUse();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the provided resource for the current view context.
|
||||
/// </summary>
|
||||
/// <param name="resourceKey">Resource key to retrieve.</param>
|
||||
/// <returns>string value for given resource or empty string if not found.</returns>
|
||||
public static string GetViewLocalized(this string resourceKey)
|
||||
{
|
||||
return ResourceLoader.GetForCurrentView().GetString(resourceKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the provided resource for the given key for use independent of the UI thread.
|
||||
/// </summary>
|
||||
/// <param name="resourceKey">Resource key to retrieve.</param>
|
||||
/// <returns>string value for given resource or empty string if not found.</returns>
|
||||
public static string GetLocalized(this string resourceKey)
|
||||
{
|
||||
return _independentLoader.GetString(resourceKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the provided resource for the given key for use independent of the UI thread.
|
||||
/// </summary>
|
||||
/// <param name="resourceKey">Resource key to retrieve.</param>
|
||||
/// <param name="resourcePath">Resource path to retrieve.</param>
|
||||
/// <returns>string value for given resource or empty string if not found.</returns>
|
||||
public static string GetLocalized(this string resourceKey, string resourcePath)
|
||||
{
|
||||
return ResourceLoader.GetForViewIndependentUse(resourcePath).GetString(resourceKey);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.System.RemoteSystems;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper to List Remote Devices that are accessible
|
||||
/// </summary>
|
||||
public class RemoteDeviceHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a List of All Remote Systems based on Selection Filter
|
||||
/// </summary>
|
||||
public ObservableCollection<RemoteSystem> RemoteSystems { get; private set; }
|
||||
|
||||
private RemoteSystemWatcher _remoteSystemWatcher;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteDeviceHelper"/> class.
|
||||
/// </summary>
|
||||
public RemoteDeviceHelper()
|
||||
{
|
||||
RemoteSystems = new ObservableCollection<RemoteSystem>();
|
||||
GenerateSystems();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RemoteDeviceHelper"/> class.
|
||||
/// </summary>
|
||||
public RemoteDeviceHelper(List<IRemoteSystemFilter> filter)
|
||||
{
|
||||
RemoteSystems = new ObservableCollection<RemoteSystem>();
|
||||
GenerateSystemsWithFilterAsync(filter);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate Enumeration
|
||||
/// </summary>
|
||||
public void GenerateSystems()
|
||||
{
|
||||
GenerateSystemsWithFilterAsync(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate Enumeration with specific RemoteSystemStatusType
|
||||
/// </summary>
|
||||
private void GenerateSystemsByFilters(RemoteSystemStatusType remoteSystemStatusType, RemoteSystemAuthorizationKind remoteSystemAuthorizationKind, RemoteSystemDiscoveryType remoteSystemDiscoveryType)
|
||||
{
|
||||
var remoteSystemStatusTypeFilter = new RemoteSystemStatusTypeFilter(remoteSystemStatusType);
|
||||
var remoteSystemDiscoveryTypeFilter = new RemoteSystemDiscoveryTypeFilter(remoteSystemDiscoveryType);
|
||||
var remoteSystemAuthorizationKindFilter = new RemoteSystemAuthorizationKindFilter(remoteSystemAuthorizationKind);
|
||||
var filters = new List<IRemoteSystemFilter>();
|
||||
if (remoteSystemStatusTypeFilter != null)
|
||||
{
|
||||
filters.Add(remoteSystemStatusTypeFilter);
|
||||
}
|
||||
|
||||
if (remoteSystemDiscoveryTypeFilter != null)
|
||||
{
|
||||
filters.Add(remoteSystemDiscoveryTypeFilter);
|
||||
}
|
||||
|
||||
if (remoteSystemAuthorizationKindFilter != null)
|
||||
{
|
||||
filters.Add(remoteSystemAuthorizationKindFilter);
|
||||
}
|
||||
|
||||
GenerateSystemsWithFilterAsync(filters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiate Enumeration with specific RemoteSysemKind with Filters
|
||||
/// </summary>
|
||||
private async void GenerateSystemsWithFilterAsync(List<IRemoteSystemFilter> filter)
|
||||
{
|
||||
var accessStatus = await RemoteSystem.RequestAccessAsync();
|
||||
if (accessStatus == RemoteSystemAccessStatus.Allowed)
|
||||
{
|
||||
_remoteSystemWatcher = filter != null ? RemoteSystem.CreateWatcher(filter) : RemoteSystem.CreateWatcher();
|
||||
_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;
|
||||
_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
|
||||
_remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
|
||||
_remoteSystemWatcher.EnumerationCompleted += RemoteSystemWatcher_EnumerationCompleted;
|
||||
_remoteSystemWatcher.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoteSystemWatcher_EnumerationCompleted(RemoteSystemWatcher sender, RemoteSystemEnumerationCompletedEventArgs args)
|
||||
{
|
||||
_remoteSystemWatcher.Stop();
|
||||
}
|
||||
|
||||
private async void RemoteSystemWatcher_RemoteSystemUpdated(RemoteSystemWatcher sender, RemoteSystemUpdatedEventArgs args)
|
||||
{
|
||||
await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
|
||||
{
|
||||
RemoteSystems.Remove(RemoteSystems.First(a => a.Id == args.RemoteSystem.Id));
|
||||
RemoteSystems.Add(args.RemoteSystem);
|
||||
});
|
||||
}
|
||||
|
||||
private async void RemoteSystemWatcher_RemoteSystemRemoved(RemoteSystemWatcher sender, RemoteSystemRemovedEventArgs args)
|
||||
{
|
||||
await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
|
||||
{
|
||||
RemoteSystems.Remove(RemoteSystems.First(a => a.Id == args.RemoteSystemId));
|
||||
});
|
||||
}
|
||||
|
||||
private async void RemoteSystemWatcher_RemoteSystemAdded(RemoteSystemWatcher sender, RemoteSystemAddedEventArgs args)
|
||||
{
|
||||
await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
|
||||
{
|
||||
RemoteSystems.Add(args.RemoteSystem);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -159,6 +159,17 @@ namespace Microsoft.Toolkit.Extensions
|
|||
return Truncate(value, length, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provide better linking for resourced strings.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the string being linked.</param>
|
||||
/// <param name="args">The object which will receive the linked String.</param>
|
||||
/// <returns>Truncated string.</returns>
|
||||
public static string AsFormat(this string format, params object[] args)
|
||||
{
|
||||
return string.Format(format, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates a string to the specified length.
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче