Created
January 11, 2025 18:00
-
-
Save Lamparter/a94407857a2ac215f31f06f6f5b31d69 to your computer and use it in GitHub Desktop.
Abandoned CubeKit usercontrols
This file contains hidden or 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
using Microsoft.Toolkit.Uwp.UI; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Windows.UI; | |
using Windows.UI.Composition; | |
using Windows.UI.Xaml; | |
namespace Cube.UI.Controls.Toolkit | |
{ | |
/// <summary> | |
/// The <see cref="DropShadowPanel"/> control allows the creation of a DropShadow for any Xaml FrameworkElement in markup | |
/// making it easier to add shadows to Xaml without having to directly drop down to Windows.UI.Composition APIs. | |
/// </summary> | |
public partial class DropShadowPanel | |
{ | |
/// <summary> | |
/// Identifies the <see cref="BlurRadius"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty BlurRadiusProperty = | |
DependencyProperty.Register(nameof(BlurRadius), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(9.0, OnBlurRadiusChanged)); | |
/// <summary> | |
/// Identifies the <see cref="Color"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty ColorProperty = | |
DependencyProperty.Register(nameof(Color), typeof(Color), typeof(DropShadowPanel), new PropertyMetadata(Colors.Black, OnColorChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetX"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetXProperty = | |
DependencyProperty.Register(nameof(OffsetX), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetXChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetY"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetYProperty = | |
DependencyProperty.Register(nameof(OffsetY), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetYChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetZ"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetZProperty = | |
DependencyProperty.Register(nameof(OffsetZ), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetZChanged)); | |
/// <summary> | |
/// Identifies the <see cref="ShadowOpacity"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty ShadowOpacityProperty = | |
DependencyProperty.Register(nameof(ShadowOpacity), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(1.0, OnShadowOpacityChanged)); | |
/// <summary> | |
/// Identifies the <see cref="IsMasked"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty IsMaskedProperty = | |
DependencyProperty.Register(nameof(IsMasked), typeof(bool), typeof(DropShadowPanel), new PropertyMetadata(true, OnIsMaskedChanged)); | |
/// <summary> | |
/// Gets DropShadow. Exposes the underlying composition object to allow custom Windows.UI.Composition animations. | |
/// </summary> | |
public DropShadow DropShadow => _dropShadow; | |
/// <summary> | |
/// Gets or sets the mask of the underlying <see cref="Windows.UI.Composition.DropShadow"/>. | |
/// Allows for a custom <see cref="Windows.UI.Composition.CompositionBrush"/> to be set. | |
/// </summary> | |
public CompositionBrush Mask | |
{ | |
get | |
{ | |
return _dropShadow?.Mask; | |
} | |
set | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Mask = value; | |
} | |
} | |
} | |
/// <summary> | |
/// Gets or sets the blur radius of the drop shadow. | |
/// </summary> | |
public double BlurRadius | |
{ | |
get | |
{ | |
return (double)GetValue(BlurRadiusProperty); | |
} | |
set | |
{ | |
SetValue(BlurRadiusProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets the color of the drop shadow. | |
/// </summary> | |
public Color Color | |
{ | |
get | |
{ | |
return (Color)GetValue(ColorProperty); | |
} | |
set | |
{ | |
SetValue(ColorProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets the x offset of the drop shadow. | |
/// </summary> | |
public double OffsetX | |
{ | |
get | |
{ | |
return (double)GetValue(OffsetXProperty); | |
} | |
set | |
{ | |
SetValue(OffsetXProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets the y offset of the drop shadow. | |
/// </summary> | |
public double OffsetY | |
{ | |
get | |
{ | |
return (double)GetValue(OffsetYProperty); | |
} | |
set | |
{ | |
SetValue(OffsetYProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets the z offset of the drop shadow. | |
/// </summary> | |
public double OffsetZ | |
{ | |
get | |
{ | |
return (double)GetValue(OffsetZProperty); | |
} | |
set | |
{ | |
SetValue(OffsetZProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets the opacity of the drop shadow. | |
/// </summary> | |
public double ShadowOpacity | |
{ | |
get | |
{ | |
return (double)GetValue(ShadowOpacityProperty); | |
} | |
set | |
{ | |
SetValue(ShadowOpacityProperty, value); | |
} | |
} | |
/// <summary> | |
/// Gets or sets a value indicating whether the panel uses an alpha mask to create a more precise shadow vs. a quicker rectangle shape. | |
/// </summary> | |
/// <remarks> | |
/// Turn this off to lose fidelity and gain performance of the panel. | |
/// </remarks> | |
public bool IsMasked | |
{ | |
get { return (bool)GetValue(IsMaskedProperty); } | |
set { SetValue(IsMaskedProperty, value); } | |
} | |
private static void OnBlurRadiusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnBlurRadiusChanged((double)e.NewValue); | |
} | |
} | |
private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnColorChanged((Color)e.NewValue); | |
} | |
} | |
private static void OnOffsetXChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetXChanged((double)e.NewValue); | |
} | |
} | |
private static void OnOffsetYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetYChanged((double)e.NewValue); | |
} | |
} | |
private static void OnOffsetZChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetZChanged((double)e.NewValue); | |
} | |
} | |
private static void OnShadowOpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnShadowOpacityChanged((double)e.NewValue); | |
} | |
} | |
private static void OnIsMaskedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.UpdateShadowMask(); | |
} | |
} | |
} | |
} |
This file contains hidden or 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
using Riverside.Toolkit.Controls; | |
using Windows.UI; | |
using Riverside.Toolkit.Helpers; | |
namespace Riverside.Toolkit.UserControls; | |
/// <summary> | |
/// The <see cref="DropShadowPanel"/> control allows the creation of a DropShadow for any Xaml FrameworkElement in markup | |
/// making it easier to add shadows to Xaml without having to directly drop down to Windows.UI.Composition APIs. | |
/// </summary> | |
public partial class DropShadowPanel | |
{ | |
/// <summary> | |
/// Identifies the <see cref="BlurRadius"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty BlurRadiusProperty = | |
DependencyProperty.Register(nameof(BlurRadius), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(9.0, OnBlurRadiusChanged)); | |
/// <summary> | |
/// Identifies the <see cref="Color"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty ColorProperty = | |
DependencyProperty.Register(nameof(Color), typeof(Color), typeof(DropShadowPanel), new PropertyMetadata(Colors.Black, OnColorChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetX"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetXProperty = | |
DependencyProperty.Register(nameof(OffsetX), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetXChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetY"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetYProperty = | |
DependencyProperty.Register(nameof(OffsetY), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetYChanged)); | |
/// <summary> | |
/// Identifies the <see cref="OffsetZ"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty OffsetZProperty = | |
DependencyProperty.Register(nameof(OffsetZ), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(0.0, OnOffsetZChanged)); | |
/// <summary> | |
/// Identifies the <see cref="ShadowOpacity"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty ShadowOpacityProperty = | |
DependencyProperty.Register(nameof(ShadowOpacity), typeof(double), typeof(DropShadowPanel), new PropertyMetadata(1.0, OnShadowOpacityChanged)); | |
/// <summary> | |
/// Identifies the <see cref="IsMasked"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty IsMaskedProperty = | |
DependencyProperty.Register(nameof(IsMasked), typeof(bool), typeof(DropShadowPanel), new PropertyMetadata(true, OnIsMaskedChanged)); | |
/// <summary> | |
/// Gets DropShadow. Exposes the underlying composition object to allow custom Windows.UI.Composition animations. | |
/// </summary> | |
public DropShadow DropShadow => _dropShadow; | |
/// <summary> | |
/// Gets or sets the mask of the underlying <see cref="Windows.UI.Composition.DropShadow"/>. | |
/// Allows for a custom <see cref="Windows.UI.Composition.CompositionBrush"/> to be set. | |
/// </summary> | |
public CompositionBrush Mask | |
{ | |
get => _dropShadow?.Mask; | |
set | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Mask = value; | |
} | |
} | |
} | |
/// <summary> | |
/// Gets or sets the blur radius of the drop shadow. | |
/// </summary> | |
public double BlurRadius | |
{ | |
get => (double)GetValue(BlurRadiusProperty); | |
set => SetValue(BlurRadiusProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets the color of the drop shadow. | |
/// </summary> | |
public Color Color | |
{ | |
get => (Color)GetValue(ColorProperty); | |
set => SetValue(ColorProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets the x offset of the drop shadow. | |
/// </summary> | |
public double OffsetX | |
{ | |
get => (double)GetValue(OffsetXProperty); | |
set => SetValue(OffsetXProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets the y offset of the drop shadow. | |
/// </summary> | |
public double OffsetY | |
{ | |
get => (double)GetValue(OffsetYProperty); | |
set => SetValue(OffsetYProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets the z offset of the drop shadow. | |
/// </summary> | |
public double OffsetZ | |
{ | |
get => (double)GetValue(OffsetZProperty); | |
set => SetValue(OffsetZProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets the opacity of the drop shadow. | |
/// </summary> | |
public double ShadowOpacity | |
{ | |
get => (double)GetValue(ShadowOpacityProperty); | |
set => SetValue(ShadowOpacityProperty, value); | |
} | |
/// <summary> | |
/// Gets or sets a value indicating whether the panel uses an alpha mask to create a more precise shadow vs. a quicker rectangle shape. | |
/// </summary> | |
/// <remarks> | |
/// Turn this off to lose fidelity and gain performance of the panel. | |
/// </remarks> | |
public bool IsMasked | |
{ | |
get => (bool)GetValue(IsMaskedProperty); | |
set => SetValue(IsMaskedProperty, value); | |
} | |
private static void OnBlurRadiusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnBlurRadiusChanged((double)e.NewValue); | |
} | |
} | |
private static void OnColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnColorChanged((Color)e.NewValue); | |
} | |
} | |
private static void OnOffsetXChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetXChanged((double)e.NewValue); | |
} | |
} | |
private static void OnOffsetYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetYChanged((double)e.NewValue); | |
} | |
} | |
private static void OnOffsetZChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnOffsetZChanged((double)e.NewValue); | |
} | |
} | |
private static void OnShadowOpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.OnShadowOpacityChanged((double)e.NewValue); | |
} | |
} | |
private static void OnIsMaskedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && d is DropShadowPanel panel) | |
{ | |
panel.UpdateShadowMask(); | |
} | |
} | |
} |
This file contains hidden or 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
<ResourceDictionary | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"> | |
<Style TargetType="controls:DropShadowPanel"> | |
<Setter Property="IsTabStop" Value="False" /> | |
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |
<Setter Property="HorizontalContentAlignment" Value="Left" /> | |
<Setter Property="VerticalAlignment" Value="Stretch" /> | |
<Setter Property="VerticalContentAlignment" Value="Stretch" /> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="controls:DropShadowPanel"> | |
<Grid | |
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | |
VerticalAlignment="{TemplateBinding VerticalAlignment}" | |
Background="{TemplateBinding Background}" | |
BorderBrush="{TemplateBinding BorderBrush}" | |
BorderThickness="{TemplateBinding BorderThickness}"> | |
<Border | |
x:Name="ShadowElement" | |
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |
</Grid> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
</ResourceDictionary> |
This file contains hidden or 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
using Microsoft.Toolkit.Uwp.UI; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Numerics; | |
using System.Runtime.InteropServices.WindowsRuntime; | |
using Windows.Foundation; | |
using Windows.Foundation.Collections; | |
using Windows.UI; | |
using Windows.UI.Composition; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Controls.Primitives; | |
using Windows.UI.Xaml.Data; | |
using Windows.UI.Xaml.Hosting; | |
using Windows.UI.Xaml.Input; | |
using Windows.UI.Xaml.Media; | |
using Windows.UI.Xaml.Navigation; | |
using Windows.UI.Xaml.Shapes; | |
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | |
namespace Cube.UI.Controls.Toolkit | |
{ | |
/// <summary> | |
/// The <see cref="DropShadowPanel"/> control allows the creation of a DropShadow for any Xaml FrameworkElement in markup | |
/// making it easier to add shadows to Xaml without having to directly drop down to Windows.UI.Composition APIs. | |
/// </summary> | |
[Obsolete("DropShadowPanel will be removed in a future release, please use the AttachedDropShadow or AttachedCardShadow implementations instead.")] | |
[TemplatePart(Name = PartShadow, Type = typeof(Border))] | |
public partial class DropShadowPanel : ContentControl | |
{ | |
private const string PartShadow = "ShadowElement"; | |
private readonly DropShadow _dropShadow; | |
private readonly SpriteVisual _shadowVisual; | |
private Border _border; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="DropShadowPanel"/> class. | |
/// </summary> | |
public DropShadowPanel() | |
{ | |
this.DefaultStyleKey = typeof(DropShadowPanel); | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
Compositor compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; | |
_shadowVisual = compositor.CreateSpriteVisual(); | |
_dropShadow = compositor.CreateDropShadow(); | |
_shadowVisual.Shadow = _dropShadow; | |
} | |
} | |
/// <summary> | |
/// Update the visual state of the control when its template is changed. | |
/// </summary> | |
protected override void OnApplyTemplate() | |
{ | |
if (DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
return; | |
} | |
_border = GetTemplateChild(PartShadow) as Border; | |
if (_border != null) | |
{ | |
ElementCompositionPreview.SetElementChildVisual(_border, _shadowVisual); | |
} | |
ConfigureShadowVisualForCastingElement(); | |
base.OnApplyTemplate(); | |
} | |
/// <inheritdoc/> | |
protected override void OnContentChanged(object oldContent, object newContent) | |
{ | |
if (oldContent != null) | |
{ | |
if (oldContent is FrameworkElement oldElement) | |
{ | |
oldElement.SizeChanged -= OnSizeChanged; | |
} | |
} | |
if (newContent != null) | |
{ | |
if (newContent is FrameworkElement newElement) | |
{ | |
newElement.SizeChanged += OnSizeChanged; | |
} | |
} | |
UpdateShadowMask(); | |
base.OnContentChanged(oldContent, newContent); | |
} | |
private void OnSizeChanged(object sender, SizeChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
UpdateShadowSize(); | |
} | |
} | |
private void ConfigureShadowVisualForCastingElement() | |
{ | |
UpdateShadowMask(); | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
UpdateShadowSize(); | |
} | |
} | |
private void OnBlurRadiusChanged(double newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.BlurRadius = (float)newValue; | |
} | |
} | |
private void OnColorChanged(Color newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Color = newValue; | |
} | |
} | |
private void OnOffsetXChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset((float)newValue, _dropShadow.Offset.Y, _dropShadow.Offset.Z); | |
} | |
} | |
private void OnOffsetYChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset(_dropShadow.Offset.X, (float)newValue, _dropShadow.Offset.Z); | |
} | |
} | |
private void OnOffsetZChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset(_dropShadow.Offset.X, _dropShadow.Offset.Y, (float)newValue); | |
} | |
} | |
private void OnShadowOpacityChanged(double newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Opacity = (float)newValue; | |
} | |
} | |
private void UpdateShadowMask() | |
{ | |
if (DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
return; | |
} | |
if (Content != null && IsMasked) | |
{ | |
CompositionBrush mask = null; | |
// We check for IAlphaMaskProvider first, to ensure that we use the custom | |
// alpha mask even if Content happens to extend any of the other classes | |
if (Content is IAlphaMaskProvider maskedControl) | |
{ | |
if (maskedControl.WaitUntilLoaded && maskedControl is FrameworkElement element && !element.IsLoaded) | |
{ | |
element.Loaded += CustomMaskedElement_Loaded; | |
} | |
else | |
{ | |
mask = maskedControl.GetAlphaMask(); | |
} | |
} | |
else if (Content is Image) | |
{ | |
mask = ((Image)Content).GetAlphaMask(); | |
} | |
else if (Content is Shape) | |
{ | |
mask = ((Shape)Content).GetAlphaMask(); | |
} | |
else if (Content is TextBlock) | |
{ | |
mask = ((TextBlock)Content).GetAlphaMask(); | |
} | |
_dropShadow.Mask = mask; | |
} | |
else | |
{ | |
_dropShadow.Mask = null; | |
} | |
} | |
private void CustomMaskedElement_Loaded(object sender, RoutedEventArgs e) | |
{ | |
if (sender is FrameworkElement element) | |
{ | |
element.Loaded -= CustomMaskedElement_Loaded; | |
_dropShadow.Mask = ((IAlphaMaskProvider)element).GetAlphaMask(); | |
} | |
} | |
private void UpdateShadowOffset(float x, float y, float z) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Offset = new Vector3(x, y, z); | |
} | |
} | |
private void UpdateShadowSize() | |
{ | |
if (_shadowVisual != null) | |
{ | |
Vector2 newSize = new Vector2(0, 0); | |
if (Content is FrameworkElement contentFE) | |
{ | |
newSize = new Vector2((float)contentFE.ActualWidth, (float)contentFE.ActualHeight); | |
} | |
_shadowVisual.Size = newSize; | |
} | |
} | |
} | |
} |
This file contains hidden or 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
<ResourceDictionary | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:controls="using:Riverside.Toolkit.UserControls"> | |
<Style TargetType="controls:DropShadowPanel"> | |
<Setter Property="IsTabStop" Value="False" /> | |
<Setter Property="HorizontalAlignment" Value="Stretch" /> | |
<Setter Property="HorizontalContentAlignment" Value="Left" /> | |
<Setter Property="VerticalAlignment" Value="Stretch" /> | |
<Setter Property="VerticalContentAlignment" Value="Stretch" /> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="controls:DropShadowPanel"> | |
<Grid | |
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" | |
VerticalAlignment="{TemplateBinding VerticalAlignment}" | |
Background="{TemplateBinding Background}" | |
BorderBrush="{TemplateBinding BorderBrush}" | |
BorderThickness="{TemplateBinding BorderThickness}"> | |
<Border | |
x:Name="ShadowElement" | |
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |
</Grid> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
</ResourceDictionary> |
This file contains hidden or 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
using Riverside.Toolkit.Controls.Toolkit; | |
using System.Numerics; | |
using Windows.UI; | |
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | |
namespace Riverside.Toolkit.UserControls; | |
/// <summary> | |
/// The <see cref="DropShadowPanel"/> control allows the creation of a DropShadow for any Xaml FrameworkElement in markup | |
/// making it easier to add shadows to Xaml without having to directly drop down to Microsoft.UI.Composition APIs. | |
/// </summary> | |
[TemplatePart(Name = PartShadow, Type = typeof(Border))] | |
public partial class DropShadowPanel : ContentControl | |
{ | |
private const string PartShadow = "ShadowElement"; | |
private readonly DropShadow _dropShadow; | |
private readonly SpriteVisual _shadowVisual; | |
private Border _border; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="DropShadowPanel"/> class. | |
/// </summary> | |
public DropShadowPanel() | |
{ | |
this.DefaultStyleKey = typeof(DropShadowPanel); | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
Compositor compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; | |
_shadowVisual = compositor.CreateSpriteVisual(); | |
_dropShadow = compositor.CreateDropShadow(); | |
_shadowVisual.Shadow = _dropShadow; | |
} | |
} | |
/// <summary> | |
/// Update the visual state of the control when its template is changed. | |
/// </summary> | |
protected override void OnApplyTemplate() | |
{ | |
if (DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
return; | |
} | |
_border = GetTemplateChild(PartShadow) as Border; | |
if (_border != null) | |
{ | |
ElementCompositionPreview.SetElementChildVisual(_border, _shadowVisual); | |
} | |
ConfigureShadowVisualForCastingElement(); | |
base.OnApplyTemplate(); | |
} | |
/// <inheritdoc/> | |
protected override void OnContentChanged(object oldContent, object newContent) | |
{ | |
if (oldContent != null) | |
{ | |
if (oldContent is FrameworkElement oldElement) | |
{ | |
oldElement.SizeChanged -= OnSizeChanged; | |
} | |
} | |
if (newContent != null) | |
{ | |
if (newContent is FrameworkElement newElement) | |
{ | |
newElement.SizeChanged += OnSizeChanged; | |
} | |
} | |
UpdateShadowMask(); | |
base.OnContentChanged(oldContent, newContent); | |
} | |
private void OnSizeChanged(object sender, SizeChangedEventArgs e) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
UpdateShadowSize(); | |
} | |
} | |
private void ConfigureShadowVisualForCastingElement() | |
{ | |
UpdateShadowMask(); | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
UpdateShadowSize(); | |
} | |
} | |
private void OnBlurRadiusChanged(double newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.BlurRadius = (float)newValue; | |
} | |
} | |
private void OnColorChanged(Color newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Color = newValue; | |
} | |
} | |
private void OnOffsetXChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset((float)newValue, _dropShadow.Offset.Y, _dropShadow.Offset.Z); | |
} | |
} | |
private void OnOffsetYChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset(_dropShadow.Offset.X, (float)newValue, _dropShadow.Offset.Z); | |
} | |
} | |
private void OnOffsetZChanged(double newValue) | |
{ | |
if (!DesignTimeHelpers.IsRunningInLegacyDesignerMode && _dropShadow != null) | |
{ | |
UpdateShadowOffset(_dropShadow.Offset.X, _dropShadow.Offset.Y, (float)newValue); | |
} | |
} | |
private void OnShadowOpacityChanged(double newValue) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Opacity = (float)newValue; | |
} | |
} | |
private void UpdateShadowMask() | |
{ | |
if (DesignTimeHelpers.IsRunningInLegacyDesignerMode) | |
{ | |
return; | |
} | |
if (this.Content != null && this.IsMasked) | |
{ | |
CompositionBrush mask = null; | |
// We check for IAlphaMaskProvider first, to ensure that we use the custom | |
// alpha mask even if Content happens to extend any of the other classes | |
if (this.Content is IAlphaMaskProvider maskedControl) | |
{ | |
if (maskedControl.WaitUntilLoaded && maskedControl is FrameworkElement element && !element.IsLoaded) | |
{ | |
element.Loaded += CustomMaskedElement_Loaded; | |
} | |
else | |
{ | |
mask = maskedControl.GetAlphaMask(); | |
} | |
} | |
else if (this.Content is Image) | |
{ | |
mask = ((Image)this.Content).GetAlphaMask(); | |
} | |
else if (this.Content is Shape) | |
{ | |
mask = ((Shape)this.Content).GetAlphaMask(); | |
} | |
else if (this.Content is TextBlock) | |
{ | |
mask = ((TextBlock)this.Content).GetAlphaMask(); | |
} | |
_dropShadow.Mask = mask; | |
} | |
else | |
{ | |
_dropShadow.Mask = null; | |
} | |
} | |
private void CustomMaskedElement_Loaded(object sender, RoutedEventArgs e) | |
{ | |
if (sender is FrameworkElement element) | |
{ | |
element.Loaded -= CustomMaskedElement_Loaded; | |
_dropShadow.Mask = ((IAlphaMaskProvider)element).GetAlphaMask(); | |
} | |
} | |
private void UpdateShadowOffset(float x, float y, float z) | |
{ | |
if (_dropShadow != null) | |
{ | |
_dropShadow.Offset = new Vector3(x, y, z); | |
} | |
} | |
private void UpdateShadowSize() | |
{ | |
if (_shadowVisual != null) | |
{ | |
var newSize = new Vector2(0, 0); | |
if (this.Content is FrameworkElement contentFE) | |
{ | |
newSize = new Vector2((float)contentFE.ActualWidth, (float)contentFE.ActualHeight); | |
} | |
_shadowVisual.Size = newSize; | |
} | |
} | |
} |
This file contains hidden or 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
<UserControl | |
x:Class="Riverside.Toolkit.UserControls.Glow.GlowBall" | |
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:helpers="using:Riverside.Toolkit.Helpers" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:toolkit="using:Riverside.Toolkit.UserControls" | |
mc:Ignorable="d"> | |
<toolkit:DropShadowPanel | |
HorizontalAlignment="Stretch" | |
VerticalAlignment="Center" | |
ShadowOpacity="1" | |
Color="{x:Bind helpers:ColorHelper.GetLighterColor1(Color), Mode=OneWay}"> | |
<Grid | |
Width="{x:Bind Width, Mode=OneWay}" | |
Height="{x:Bind Height, Mode=OneWay}" | |
HorizontalAlignment="Stretch" | |
VerticalAlignment="Center" | |
Background="{x:Bind Color, Mode=OneWay, Converter={StaticResource ColorToBrush}}" | |
CornerRadius="100" /> | |
</toolkit:DropShadowPanel> | |
</UserControl> |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.InteropServices.WindowsRuntime; | |
using Windows.Foundation; | |
using Windows.Foundation.Collections; | |
using Windows.UI; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Controls.Primitives; | |
using Windows.UI.Xaml.Data; | |
using Windows.UI.Xaml.Input; | |
using Windows.UI.Xaml.Media; | |
using Windows.UI.Xaml.Navigation; | |
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | |
namespace Riverside.Toolkit.UserControls.Glow | |
{ | |
public sealed partial class GlowBall : UserControl | |
{ | |
public Color Color | |
{ | |
get { return (Color)GetValue(ColorProperty); } | |
set { SetValue(ColorProperty, value); } | |
} | |
public static readonly DependencyProperty ColorProperty = | |
DependencyProperty.Register("Color", typeof(Color), typeof(UserControl), null); | |
public GlowBall() => this.InitializeComponent(); | |
} | |
} |
This file contains hidden or 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
<UserControl | |
x:Class="Riverside.Toolkit.Controls.Glow.GlowLine" | |
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:toolkit="using:Riverside.Toolkit.UserControls" | |
d:DesignHeight="300" | |
d:DesignWidth="400" | |
mc:Ignorable="d"> | |
<toolkit:DropShadowPanel | |
BlurRadius="16" | |
ShadowOpacity="0.33" | |
Color="{ThemeResource SystemAccentColorLight3}"> | |
<Grid | |
Width="{x:Bind Width, Mode=OneWay}" | |
Height="{x:Bind Height, Mode=OneWay}" | |
HorizontalAlignment="Stretch" | |
VerticalAlignment="Stretch" | |
Background="{ThemeResource AccentLinearDownGradientBrush}" | |
CornerRadius="2" /> | |
</toolkit:DropShadowPanel> | |
</UserControl> |
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.InteropServices.WindowsRuntime; | |
using Windows.Foundation; | |
using Windows.Foundation.Collections; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Controls.Primitives; | |
using Windows.UI.Xaml.Data; | |
using Windows.UI.Xaml.Input; | |
using Windows.UI.Xaml.Media; | |
using Windows.UI.Xaml.Navigation; | |
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | |
namespace Riverside.Toolkit.UserControls.Glow | |
{ | |
public sealed partial class GlowLine : UserControl | |
{ | |
public GlowLine() | |
{ | |
this.InitializeComponent(); | |
} | |
} | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8" ?> | |
<UserControl | |
x:Class="Riverside.Toolkit.UserControls.ImageFrame" | |
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" | |
mc:Ignorable="d"> | |
<Border | |
Height="197" | |
Margin="8" | |
BorderBrush="Black" | |
BorderThickness="16" | |
CornerRadius="8"> | |
<Image> | |
<Image.Source> | |
<BitmapImage UriSource="{x:Bind Source, Mode=OneWay}" /> | |
</Image.Source> | |
</Image> | |
</Border> | |
</UserControl> |
This file contains hidden or 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
namespace Riverside.Toolkit.UserControls; | |
/// <summary> | |
/// A UserControl that represents an ImageFrame. | |
/// </summary> | |
public sealed partial class ImageFrame : UserControl | |
{ | |
/// <summary> | |
/// Initializes a new instance of the <see cref="ImageFrame"/> class. | |
/// </summary> | |
public ImageFrame() | |
{ | |
InitializeComponent(); | |
} | |
/// <summary> | |
/// Identifies the <see cref="Source"/> dependency property. | |
/// </summary> | |
public static readonly DependencyProperty SourceProperty = | |
DependencyProperty.Register( | |
"Source", // The name of the property | |
typeof(string), // The type of the property | |
typeof(ImageFrame), // The type of the owner class | |
new PropertyMetadata(null) // Default value | |
); | |
/// <summary> | |
/// Gets or sets the source of the content of the ImageFrame. | |
/// </summary> | |
[Browsable(true)] | |
[Category("Common")] | |
[Description("The source of the content of the ImageFrame")] | |
public string Source | |
{ | |
get => GetValue(SourceProperty).ToString().Contains("ms-appx://") | |
? (string)GetValue(SourceProperty) | |
: this.BaseUri + (string)GetValue(SourceProperty); | |
set => SetValue(SourceProperty, value); | |
} | |
} |
This file contains hidden or 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
<UserControl | |
x:Class="Riverside.Toolkit.UserControls.VoiceControl" | |
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:glow="using:Riverside.Toolkit.UserControls.Glow" | |
xmlns:icons="using:Riverside.Toolkit.Icons" | |
xmlns:local="using:Riverside.Toolkit.UserControls" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | |
d:DesignHeight="300" | |
d:DesignWidth="400" | |
Loaded="VoiceControl_Loaded" | |
Unloaded="VoiceControl_Unloaded" | |
mc:Ignorable="d"> | |
<Grid MaxWidth="400" Padding="12"> | |
<StackPanel | |
x:Name="RecordingContent" | |
VerticalAlignment="Center" | |
Spacing="4"> | |
<muxc:ProgressRing x:Name="SpeechProgress" /> | |
<TextBlock x:Name="SpeechText" Text="Placeholder" /> | |
<ListBox x:Name="AlternateList" Visibility="Collapsed" /> | |
<Button | |
x:Name="StopRecordingButton" | |
Width="120" | |
HorizontalAlignment="Right" | |
Background="{ThemeResource MicaDarkBrush}" | |
BorderBrush="{ThemeResource MicaBorderBrush}" | |
BorderThickness="1" | |
Click="Stop_Click" | |
Style="{ThemeResource ToolbarButton}"> | |
<StackPanel Orientation="Horizontal" Spacing="4"> | |
<icons:FluentSymbolIcon Symbol="Stop20" /> | |
<TextBlock VerticalAlignment="Center" Text="Stop Recording" /> | |
</StackPanel> | |
</Button> | |
</StackPanel> | |
<StackPanel | |
x:Name="ErrorContent" | |
Orientation="Horizontal" | |
Spacing="4" | |
Visibility="Collapsed"> | |
<Grid> | |
<icons:FluentSymbolIcon Symbol="ErrorCircle20" /> | |
<glow:GlowBall | |
Width="6" | |
Height="6" | |
HorizontalAlignment="Right" | |
VerticalAlignment="Bottom" | |
Color="Red" /> | |
</Grid> | |
<TextBlock VerticalAlignment="Center" Text="Voice search unavailable" /> | |
</StackPanel> | |
</Grid> | |
</UserControl> |
This file contains hidden or 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
using Riverside.Toolkit.Helpers; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Runtime.InteropServices.WindowsRuntime; | |
using System.Text; | |
using Windows.Foundation; | |
using Windows.Foundation.Collections; | |
using Windows.Media.Capture; | |
using Windows.Media.SpeechRecognition; | |
using Windows.UI.Core; | |
using Windows.UI.Xaml; | |
using Windows.UI.Xaml.Controls; | |
using Windows.UI.Xaml.Controls.Primitives; | |
using Windows.UI.Xaml.Data; | |
using Windows.UI.Xaml.Input; | |
using Windows.UI.Xaml.Media; | |
using Windows.UI.Xaml.Navigation; | |
using Windows.ApplicationModel.Core; | |
using System.Threading.Tasks; | |
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | |
namespace Riverside.Toolkit.UserControls | |
{ | |
public sealed partial class VoiceControl : UserControl | |
{ | |
// LEGACY | |
public event EventHandler<string> SpeechSubmitted; // Text captured from speech | |
public event EventHandler<string> SpeechUnavailable; // No mic or permission disabled | |
private SpeechRecognizer Recognizer; | |
public VoiceControl() => this.InitializeComponent(); | |
private async void CaptureSpeech() | |
{ | |
/*if (await VoiceHelper.RequestMicrophonePermission()) | |
{ | |
SpeechText.Text = string.Empty; | |
SpeechProgress.IsActive = true; | |
StopRecordingButton.Visibility = Visibility.Visible; | |
Recognizer = new SpeechRecognizer(); | |
await Recognizer.CompileConstraintsAsync(); | |
Recognizer.Timeouts.InitialSilenceTimeout = TimeSpan.FromSeconds(5); | |
Recognizer.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(20); | |
Recognizer.Timeouts.BabbleTimeout = TimeSpan.FromSeconds(5); | |
var Session = Recognizer.ContinuousRecognitionSession; | |
Session.ResultGenerated += Session_ResultGenerated; | |
Session.Completed += Session_Completed; | |
await Session.StartAsync(); | |
} | |
else | |
{ | |
RecordingContent.Visibility = Visibility.Collapsed; | |
ErrorContent.Visibility = Visibility.Visible; | |
}*/ | |
} | |
private async void Session_Completed(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionCompletedEventArgs args) | |
{ | |
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, | |
() => | |
{ | |
if (SpeechSubmitted is not null) | |
SpeechSubmitted(this, SpeechText.Text); | |
SpeechProgress.IsActive = false; | |
StopRecordingButton.Visibility = Visibility.Collapsed; | |
}); | |
} | |
private async void Session_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args) | |
{ | |
SpeechRecognitionResult Result = args.Result; | |
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, | |
() => | |
{ | |
if (Result != null) | |
{ | |
SpeechText.Text = Result.Text; | |
AlternateList.ItemsSource = Result.GetAlternates(3); | |
} | |
}); | |
} | |
private async void Stop_Click(object sender, RoutedEventArgs e) => await Recognizer.ContinuousRecognitionSession.StopAsync(); | |
private void VoiceControl_Loaded(object sender, RoutedEventArgs e) => CaptureSpeech(); | |
private async void VoiceControl_Unloaded(object sender, RoutedEventArgs e) | |
{ | |
try | |
{ | |
await Task.Run(async () => | |
{ | |
await Recognizer.ContinuousRecognitionSession.StopAsync(); | |
Recognizer.Dispose(); | |
}); | |
} | |
catch { } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment