Skip to content

Commit

Permalink
Merge branch 'main' into betterSettingsControls
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlodotexe authored Dec 21, 2024
2 parents 80fa31b + 2c0f9b3 commit f05799a
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See https://github.com/devcontainers/images/tree/main/src/dotnet for image choices
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:8.0
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:9.0

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "8.0",
"VARIANT": "9.0",
// Options
"NODE_VERSION": "lts/*"
}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ on:
merge_group:

env:
DOTNET_VERSION: ${{ '8.0.201' }}
DOTNET_INSTALL_DIR: dotnet-install
DOTNET_ROOT: dotnet-install
DOTNET_VERSION: ${{ '9.0.x' }}
ENABLE_DIAGNOSTICS: true
MSBUILD_VERBOSITY: normal
#COREHOST_TRACE: 1
Expand Down Expand Up @@ -59,7 +57,7 @@ jobs:
# Build both Uno.UI/WinUI2/UWP and Uno.WinUI/WinUI3/WindowsAppSDK versions of our packages using a matrix
build:
needs: [Xaml-Style-Check]
runs-on: windows-latest-large
runs-on: windows-latest

# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<!-- See https://github.com/CommunityToolkit/Windows/pull/567#issuecomment-2498739244 -->
<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
<NoWarn>$(NoWarn);TKSMPL0014;</NoWarn>
</PropertyGroup>

<Import Project="Windows.Toolkit.Common.props" />
Expand Down
6 changes: 5 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<Project>
<ItemGroup>
<!-- Workaround for WebView2 on uap pulling in Microsoft.VCLibs.Desktop when it shouldn't -->
<SDKReference Remove="Microsoft.VCLibs.Desktop, Version=14.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="6.7.0" PrivateAssets="all" Pack="false" />
<PackageReference Include="NuGet.Build.Tasks.Pack" Version="6.12.1" PrivateAssets="all" Pack="false" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

Expand Down
19 changes: 9 additions & 10 deletions components/Behaviors/samples/InvokeActionsSample.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<!-- 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. -->
<!-- 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. -->
<Page x:Class="BehaviorsExperiment.Samples.InvokeActionsActivitySample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:CommunityToolkit.WinUI.Animations"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BehaviorsExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -20,9 +19,9 @@
IsSequential="True">
<ani:StartAnimationActivity Animation="{Binding ElementName=FadeOutAnimation}" />
<ani:InvokeActionsActivity>
<interactions:ChangePropertyAction PropertyName="Foreground"
TargetObject="{Binding ElementName=MyText}"
Value="Purple" />
<interactivity:ChangePropertyAction PropertyName="Foreground"
TargetObject="{Binding ElementName=MyText}"
Value="Purple" />
<!--<mediaactions:PlaySoundAction Source="Assets/Llama.mp3"/>-->
</ani:InvokeActionsActivity>
<ani:StartAnimationActivity Animation="{Binding ElementName=FadeInAnimation}"
Expand Down Expand Up @@ -53,12 +52,12 @@
</TextBlock>

<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<interactions:ChangePropertyAction PropertyName="Foreground"
TargetObject="{Binding ElementName=MyText}"
Value="White" />
<interactivity:EventTriggerBehavior EventName="Click">
<interactivity:ChangePropertyAction PropertyName="Foreground"
TargetObject="{Binding ElementName=MyText}"
Value="White" />
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}" />
</interactions:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity">

<StackPanel MaxWidth="480"
Spacing="8">
<TextBox PlaceholderText="Set the focus to this TextBox and press enter">
<interactivity:Interaction.Behaviors>
<behaviors:KeyDownTriggerBehavior Key="Enter">
<core:CallMethodAction MethodName="IncrementCount"
TargetObject="{x:Bind}" />
<interactivity:CallMethodAction MethodName="IncrementCount"
TargetObject="{x:Bind}" />
</behaviors:KeyDownTriggerBehavior>
</interactivity:Interaction.Behaviors>
</TextBox>
Expand Down
5 changes: 2 additions & 3 deletions components/Behaviors/samples/NavigateToUriActionSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity">

<Button Content="Click to navigate">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<interactivity:EventTriggerBehavior EventName="Click">
<behaviors:NavigateToUriAction NavigateUri="https://aka.ms/toolkit/windows" />
</core:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xmlns:ani="using:CommunityToolkit.WinUI.Animations"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:local="using:BehaviorsExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down Expand Up @@ -55,9 +54,9 @@
</Image>

<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<interactivity:EventTriggerBehavior EventName="Click">
<behaviors:StartAnimationAction Animation="{Binding ElementName=MoveAnimation}" />
</interactions:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
</Page>
8 changes: 4 additions & 4 deletions components/Behaviors/src/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.0.1"/>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed" Version="3.0.0-preview2"/>
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Uwp.Managed" Version="2.3.1-uno.2" />
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Interactivity" Version="3.0.0-dev.17.g7c09b9114d" />
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0-preview2" />
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.3.1-uno.2" />
<PackageReference Include="Uno.Microsoft.Xaml.Behaviors.Interactivity.WinUI" Version="3.0.0-dev.17.g7c09b9114d" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions components/CameraPreview/samples/CameraPreviewSample.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected async override void OnNavigatedFrom(NavigationEventArgs e)
await CleanUpAsync();
}

private async void Application_Suspending(object sender, SuspendingEventArgs e)
private async void Application_Suspending(object? sender, SuspendingEventArgs e)
{
if (Frame?.CurrentSourcePageType == typeof(CameraPreviewSample))
{
Expand All @@ -102,7 +102,7 @@ private async void Application_Suspending(object sender, SuspendingEventArgs e)
}
}

private async void Application_Resuming(object sender, object e)
private async void Application_Resuming(object? sender, object e)
{
if (CameraPreviewControl != null)
{
Expand All @@ -113,19 +113,19 @@ private async void Application_Resuming(object sender, object e)
}
}

private void CameraPreviewControl_FrameArrived(object sender, FrameEventArgs e)
private void CameraPreviewControl_FrameArrived(object? sender, FrameEventArgs e)
{
_currentVideoFrame = e.VideoFrame;
}

private void CameraPreviewControl_PreviewFailed(object sender, PreviewFailedEventArgs e)
private void CameraPreviewControl_PreviewFailed(object? sender, PreviewFailedEventArgs e)
{
ErrorBar.Message = e.Error;
ErrorBar.IsOpen = true;
}


private async void CaptureButton_Click(object sender, RoutedEventArgs e)
private async void CaptureButton_Click(object? sender, RoutedEventArgs e)
{
var softwareBitmap = _currentVideoFrame?.SoftwareBitmap;

Expand Down
2 changes: 1 addition & 1 deletion components/ColorPicker/src/ColorPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ private void UpdateVisualState(bool useTransitions = true)
VisualStateManager.GoToState(this, (Truth(IsColorPaletteVisible, IsColorSpectrumVisible, IsColorChannelTextInputVisible) <= 1) ? "ColorPanelSelectorCollapsed" : "ColorPanelSelectorVisible", useTransitions);
}

public static int Truth(params bool[] booleans)
private static int Truth(params bool[] booleans)
{
return booleans.Count(b => b);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@
<_LayoutFile Remove="@(_LayoutFile)" Condition="$([System.String]::Copy(&quot;%(_LayoutFile.TargetPath)&quot;).StartsWith('CommunityToolkit.WinUI.Controls.Segmented\'))" />
</ItemGroup>
</Target>

<!--
Known platform issue
error IL2059: Unrecognized value passed to the parameter 'type' of method
'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)'.
It's not possible to guarantee the availability of the target static constructor.
-->
<PropertyGroup>
<NoWarn>$(NoWarn)IL2059;</NoWarn>
</PropertyGroup>
</Project>
9 changes: 5 additions & 4 deletions components/Converters/src/ColorToDisplayNameConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public object Convert(
// Invalid color value provided
return DependencyProperty.UnsetValue;
}
#if HAS_UNO
// ColorHelper.ToDisplayName not yet supported on Uno Platform.
// Track https://github.com/unoplatform/uno/issues/18004
return "Not supported";

#if WINDOWS_UWP && NET8_0_OR_GREATER
// Windows.UI.ColorHelper not yet supported on modern uwp.
// Following advice from Sergio0694
return color.ToString();
#elif WINUI2
return Windows.UI.ColorHelper.ToDisplayName(color);
#elif WINUI3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ public sealed partial class ResourceNameToResourceStringConverter : IValueConver
/// <param name="parameter">Optional parameter. Not used.</param>
/// <param name="language">The language of the conversion.</param>
/// <returns>The string corresponding to the resource name.</returns>
public object Convert(object value, Type targetType, object parameter, string language)
public object? Convert(object value, Type targetType, object parameter, string language)
{
if (value == null)
var stringValue = value?.ToString();
if (stringValue is null)
{
return string.Empty;
}

#if WINAPPSDK && !HAS_UNO
return _resourceManager.MainResourceMap.TryGetValue(value.ToString()).ValueAsString;
return _resourceManager.MainResourceMap.TryGetValue(stringValue).ValueAsString;
#else
return _resourceLoader.GetString(value.ToString());
return _resourceLoader.GetString(stringValue);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static StringExtensions()
/// You can retrieve this from a UIElement.UIContext, XamlRoot.UIContext (XamlIslands), or Window.UIContext.</param>
/// <returns>string value for given resource or empty string if not found.</returns>
////[SupportedOSPlatform("Windows10.0.18362.0")]
public static string GetViewLocalized(this string resourceKey, UIContext? uiContext = null)
public static string? GetViewLocalized(this string resourceKey, UIContext? uiContext = null)
{
if (uiContext != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,9 @@ public static IEnumerable<FrameworkElement> FindParents(this FrameworkElement el
/// </summary>
/// <param name="element">The parent element.</param>
/// <returns>The retrieved content control, or <see langword="null"/> if not available.</returns>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "This method is currently not safe for trimming, and annotations here wouldn't help.")]
#endif
public static UIElement? GetContentControl(this FrameworkElement element)
{
Type type = element.GetType();
Expand Down
15 changes: 14 additions & 1 deletion components/ImageCropper/src/ImageCropper.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ private static async Task CropImageAsync(WriteableBitmap writeableBitmap, IRando
using (var sourceStream = writeableBitmap.PixelBuffer.AsStream())
{
var buffer = new byte[sourceStream.Length];
await sourceStream.ReadAsync(buffer, 0, buffer.Length);
var pos = 0;

while (pos < buffer.Length)
{
var remaining = buffer.Length - pos;
var read = await sourceStream.ReadAsync(buffer, pos, remaining);
if (read == 0)
{
break;
}

pos += read;
}

var bitmapEncoder = await BitmapEncoder.CreateAsync(GetEncoderId(bitmapFileFormat), stream);
bitmapEncoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied, (uint)writeableBitmap.PixelWidth, (uint)writeableBitmap.PixelHeight, 96.0, 96.0, buffer);
bitmapEncoder.BitmapTransform.Bounds = new BitmapBounds
Expand Down
5 changes: 2 additions & 3 deletions components/Media/samples/BlurEffectAnimationSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:CommunityToolkit.WinUI.Animations"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:media="using:CommunityToolkit.WinUI.Media">

Expand Down Expand Up @@ -38,9 +37,9 @@
</ani:Explicit.Animations>

<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Loaded">
<interactivity:EventTriggerBehavior EventName="Loaded">
<behaviors:StartAnimationAction Animation="{x:Bind BlurAnimation}" />
</interactions:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Border>
</Page>
5 changes: 2 additions & 3 deletions components/Media/samples/ColorEffectAnimationSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:CommunityToolkit.WinUI.Animations"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:media="using:CommunityToolkit.WinUI.Media">

Expand Down Expand Up @@ -38,9 +37,9 @@
</ani:Explicit.Animations>

<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Loaded">
<interactivity:EventTriggerBehavior EventName="Loaded">
<behaviors:StartAnimationAction Animation="{x:Bind ColorAnimation}" />
</interactions:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Border>

Expand Down
5 changes: 2 additions & 3 deletions components/Media/samples/CrossFadeEffectAnimationSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ani="using:CommunityToolkit.WinUI.Animations"
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:media="using:CommunityToolkit.WinUI.Media">

Expand Down Expand Up @@ -43,9 +42,9 @@
</ani:Explicit.Animations>

<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Loaded">
<interactivity:EventTriggerBehavior EventName="Loaded">
<behaviors:StartAnimationAction Animation="{x:Bind CrossFadeAnimation}" />
</interactions:EventTriggerBehavior>
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Border>
</Page>
Loading

0 comments on commit f05799a

Please sign in to comment.