Fixes:
1. Updates from .NET 5 (not supported) to .NET 6 (LTS)
2. Removing UWP-only APIs
3. Fixing modern C# compiler warnings.
This commit is contained in:
Jeffrey Stall (MS) 2024-04-22 13:27:24 -07:00
Родитель 3770a6d2e7
Коммит b99e063402
15 изменённых файлов: 20 добавлений и 359 удалений

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.19041</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RootNamespace>ExpressionBuilder</RootNamespace>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>CompositionSampleGallery</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>

Просмотреть файл

@ -29,7 +29,7 @@ namespace CompositionSampleGallery
{
InitializeComponent();
SampleComboBox.ItemsSource = new[] { "XAML Connected Animation", "Custom Connected Animation" };
SampleComboBox.ItemsSource = new[] { "XAML Connected Animation" };
SampleComboBox.SelectedIndex = 0;
}
@ -39,10 +39,6 @@ namespace CompositionSampleGallery
{
SamplesFrame.Navigate(typeof(ConnectedAnimationSample));
}
else if (SampleComboBox.SelectedIndex == 1)
{
SamplesFrame.Navigate(typeof(CustomConnectedAnimation));
}
}
}
}

Просмотреть файл

@ -1,32 +0,0 @@
<Page
x:Class="CompositionSampleGallery.CustomConnectedAnimation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CompositionSampleGallery"
xmlns:common="using:SamplesCommon"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:data="using:CompositionSampleGallery.Shared"
mc:Ignorable="d">
<Grid x:Name="MyGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" SizeChanged="Grid_SizeChanged" Margin="5">
<Grid.Clip>
<RectangleGeometry x:Name="GridClip" />
</Grid.Clip>
<GridView x:Name="ThumbnailList"
IsItemClickEnabled="True"
ItemClick="ThumbnailList_Click"
Loaded="ThumbnailList_Loaded"
ItemsSource="{x:Bind Model.Nature}">
<GridView.ItemTemplate>
<DataTemplate x:DataType="data:Thumbnail">
<common:CompositionImage Source="{x:Bind ImageUrl}"
Width="240"
Height="160"
Stretch="Fill"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Grid>
</Page>

Просмотреть файл

@ -1,120 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using SamplesCommon;
using Windows.Foundation;
using Microsoft.UI.Composition;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
using CompositionSampleGallery.Shared;
namespace CompositionSampleGallery
{
public sealed partial class CustomConnectedAnimation : Page
{
private ConnectedTransition _currentTransition;
public struct ContinuityData
{
public SpriteVisual sprite;
public Frame frame;
public UIElement parent;
public CompositionImage image;
}
public struct DetailsInfo
{
public Thumbnail thumbanil;
}
public CustomConnectedAnimation()
{
Model = new LocalDataSource();
this.InitializeComponent();
NavigationCacheMode = NavigationCacheMode.Enabled;
}
public LocalDataSource Model
{
get; set;
}
private void ThumbnailList_Click(object sender, ItemClickEventArgs e)
{
GridView gridView = (GridView)sender;
GridViewItem item = (GridViewItem)gridView.ContainerFromItem(e.ClickedItem);
CompositionImage image = VisualTreeHelperExtensions.GetFirstDescendantOfType<CompositionImage>(item);
// We are about to transition to a new page. Cancel any outstanding transitions.
if (_currentTransition != null)
{
if (!_currentTransition.Completed)
{
_currentTransition.Cancel();
}
_currentTransition = null;
}
DetailsInfo info;
info.thumbanil = (Thumbnail)e.ClickedItem;
// Setup the new transition and trigger the navigation
ConnectedTransition transition = new ConnectedTransition();
transition.Initialize(Frame, image, info);
Frame.Navigate(typeof(CustomConnectedAnimationDetail), transition);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Store the incoming parameter
if (e.Parameter is ConnectedTransition)
{
_currentTransition = (ConnectedTransition)e.Parameter;
}
else
{
// Should not run ConnectedTransition
_currentTransition = null;
}
//Hide the back button on the list page as there is no where to go back to.
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.Collapsed;
}
private void ThumbnailList_Loaded(object sender, RoutedEventArgs args)
{
if (_currentTransition != null)
{
DetailsInfo info = (DetailsInfo)_currentTransition.Payload;
GridViewItem item = (GridViewItem)ThumbnailList.ContainerFromItem(info.thumbanil);
CompositionImage image = VisualTreeHelperExtensions.GetFirstDescendantOfType<CompositionImage>(item);
ScrollViewer scrollViewer = VisualTreeHelperExtensions.GetFirstDescendantOfType<ScrollViewer>(ThumbnailList);
// Kick off the transition now that the page has loaded
_currentTransition.Start(MyGrid, image, scrollViewer, ThumbnailList);
}
}
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
GridClip.Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height);
}
}
}

Просмотреть файл

@ -1,112 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//*********************************************************
using System;
using Windows.UI.Core;
using Windows.Foundation;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Navigation;
namespace CompositionSampleGallery
{
public sealed partial class CustomConnectedAnimationDetail : Page
{
private ConnectedTransition
_currentTransition;
private CustomConnectedAnimation.DetailsInfo
_detailsInfo;
private Frame _host;
public CustomConnectedAnimationDetail()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
_currentTransition = (ConnectedTransition)e.Parameter;
_detailsInfo = (CustomConnectedAnimation.DetailsInfo)_currentTransition.Payload;
_host = _currentTransition.Host as Frame;
Title.Text = _detailsInfo.thumbanil.Name;
DetailText.Text = _detailsInfo.thumbanil.Description;
// Enable the back button
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = _host.CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
SystemNavigationManager.GetForCurrentView().BackRequested += CustomConnectedAnimationDetail_BackRequested;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
// Unregister the handler
SystemNavigationManager manager = SystemNavigationManager.GetForCurrentView();
manager.BackRequested -= CustomConnectedAnimationDetail_BackRequested;
manager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
private void CustomConnectedAnimationDetail_BackRequested(object sender, BackRequestedEventArgs e)
{
if (!e.Handled)
{
// We are about to transition to a new page. Cancel any outstanding transitions.
if (_currentTransition != null)
{
if (!_currentTransition.Completed)
{
_currentTransition.Cancel();
}
_currentTransition = null;
}
// Setup the new transition and trigger the navigation
ConnectedTransition transition = new ConnectedTransition();
transition.Initialize(_host, ThumbnailImage, _detailsInfo);
_host.Navigate(typeof(CustomConnectedAnimation), transition);
// We've got it handled
e.Handled = true;
}
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (_currentTransition != null)
{
CustomConnectedAnimation.DetailsInfo info = (CustomConnectedAnimation.DetailsInfo)_currentTransition.Payload;
// Update the Thumbnail image to point to the proper album art
ThumbnailImage.Source = new Uri(info.thumbanil.ImageUrl);
// Kick off the transition now that the page has loaded
_currentTransition.Start(MyGrid, ThumbnailImage, MyScroller, MyScroller);
}
}
private void MainGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
GridClip.Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height);
}
}
}

Просмотреть файл

@ -1,72 +0,0 @@
<Page
x:Class="CompositionSampleGallery.CustomConnectedAnimationDetail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CompositionSampleGallery"
xmlns:common="using:SamplesCommon"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Loaded="Page_Loaded">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" x:Name="MyGrid" SizeChanged="MainGrid_SizeChanged" Margin="20">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="NarrowView">
<VisualState.StateTriggers>
<!-- Adaptive trigger switches repositions the TextBlock for Desktop and Phone -->
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="Description.(RelativePanel.RightOf)" Value="{x:Null}" />
<Setter Target="Description.(RelativePanel.Below)" Value="ThumbnailInfoPanel" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="WideView">
<VisualState.StateTriggers>
<!-- Adaptive trigger switches repositions the TextBlock for Desktop and Phone -->
<AdaptiveTrigger MinWindowWidth="600" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="Description.(RelativePanel.RightOf)" Value="ThumbnailInfoPanel" />
<Setter Target="Description.(RelativePanel.Below)" Value="{x:Null}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.Clip>
<RectangleGeometry x:Name="GridClip"/>
</Grid.Clip>
<ScrollViewer x:Name="MyScroller" HorizontalAlignment="Stretch">
<RelativePanel HorizontalAlignment="Stretch">
<StackPanel Background="LightSteelBlue" x:Name="ThumbnailInfoPanel" VerticalAlignment="Top" Width="500">
<TextBlock x:Name="Title" Style="{ThemeResource TitleTextBlockStyle}" Margin="10,10,10,0" TextWrapping="WrapWholeWords" />
<TextBlock x:Name="DetailText" Style="{ThemeResource CaptionTextBlockStyle}" Margin="10,0,10,10"/>
<common:CompositionImage x:Name="ThumbnailImage"
Height="320"
Width="480"
HorizontalAlignment="Center"
Stretch="Fill"
Margin="10,0,10,10" />
</StackPanel>
<TextBlock x:Name="Description"
TextWrapping="Wrap"
RelativePanel.Below="ThumbnailInfoPanel"
RelativePanel.AlignRightWithPanel="True"
Margin="10,0,10,10">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec efficitur, eros sit amet laoreet scelerisque,
nunc odio ultricies metus, ut consectetur nulla massa eu nibh. Phasellus in lorem id nunc euismod tempus. Phasellus et nulla non turpis tempor blandit ut eget turpis.
Phasellus ac ornare elit, ut scelerisque dolor. Nam vel finibus lorem. Aenean malesuada pulvinar eros id ornare. Fusce blandit ante eget dolor efficitur suscipit.
Phasellus ac lacus nibh. Aenean eget blandit risus, in lacinia mi. Proin fermentum ante eros, non sollicitudin mi pretium eu. Curabitur suscipit lectus arcu, eget
pretium quam sagittis non. Mauris purus mauris, condimentum nec laoreet sit amet, imperdiet sit amet nisi. Sed interdum, urna et aliquam porta, elit velit tincidunt orci,
vitae vestibulum risus lacus at nulla. Phasellus sapien ipsum, pellentesque varius enim nec, iaculis aliquet enim. Nulla id dapibus ante. Sed hendrerit sagittis leo, commodo
fringilla ligula rutrum ut. Nullam sodales, ex ut pellentesque scelerisque, sapien nulla mattis lectus, vel ullamcorper leo enim ac mi. Sed consectetur vitae velit in consequat.
Pellentesque ac condimentum justo, at feugiat nulla. Sed ut congue neque. Nam gravida quam ac urna porttitor, ut bibendum ante mattis. Cras viverra cursus sapien, et sollicitudin
risus fringilla eget. Nulla facilisi. Duis pellentesque scelerisque nisi, facilisis malesuada massa gravida et. Vestibulum ac leo sed orci tincidunt feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc id leo vestibulum, vulputate ipsum sit amet, scelerisque velit. Curabitur imperdiet justo et tortor dignissim, sit amet volutpat sem ullamcorper. Nam mollis ullamcorper tellus vitae convallis. Aliquam eleifend elit nec tincidunt pharetra. Aliquam turpis eros, mollis et nunc quis, porta molestie justo. Etiam ultrices sem non turpis imperdiet dictum. Aliquam molestie elit in urna sodales, nec luctus dui laoreet. Curabitur molestie risus vel ligula efficitur, non fringilla urna iaculis. Curabitur neque tortor, facilisis quis dictum facilisis, facilisis et ante. Sed nisl erat, semper vitae efficitur ut, congue vitae quam. Ut auctor lacus sit amet varius placerat. Sed ac tellus tempus, ultricies est quis, tempor felis. Nulla vel faucibus elit, eu tincidunt eros. Nulla blandit id nisl ut porta. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam suscipit tellus a mattis pulvinar. Sed et libero vel ligula elementum suscipit. Ut elementum libero at sagittis pharetra. Fusce ultrices odio sapien, a posuere est consectetur ut.
</TextBlock>
</RelativePanel>
</ScrollViewer>
</Grid>
</Page>

Просмотреть файл

@ -34,32 +34,32 @@
Margin="10">
<TextBlock HorizontalAlignment="Center">Blur Radius</TextBlock>
<Slider
Value="{x:Bind Shadow.BlurRadius, Mode=TwoWay}"
Value="{x:Bind RenderShadow.BlurRadius, Mode=TwoWay}"
HorizontalAlignment="Stretch"
Minimum="0" Maximum="100"
Margin="0, 20, 10, 0"/>
<TextBlock HorizontalAlignment="Center">Opacity</TextBlock>
<Slider
Value="{x:Bind Shadow.ShadowOpacity, Mode=TwoWay}"
Value="{x:Bind RenderShadow.ShadowOpacity, Mode=TwoWay}"
HorizontalAlignment="Stretch"
Minimum="0" Maximum="1"
StepFrequency=".1"
Margin="0, 20, 10, 0"/>
<TextBlock HorizontalAlignment="Center">Offset - X</TextBlock>
<Slider
Value="{x:Bind Shadow.OffsetX, Mode=TwoWay}"
Value="{x:Bind RenderShadow.OffsetX, Mode=TwoWay}"
HorizontalAlignment="Stretch"
Minimum="-200" Maximum="200"
Margin="0, 20, 10, 0"/>
<TextBlock HorizontalAlignment="Center">Offset - Y</TextBlock>
<Slider
Value="{x:Bind Shadow.OffsetY, Mode=TwoWay}"
Value="{x:Bind RenderShadow.OffsetY, Mode=TwoWay}"
HorizontalAlignment="Stretch"
Minimum="-200" Maximum="200"
Margin="0, 20, 10, 0"/>
<TextBlock HorizontalAlignment="Center">Shadow Color</TextBlock>
<common:ColorMixer
Color="{Binding ElementName=Shadow, Path=Color, Mode=TwoWay}"
Color="{Binding ElementName=RenderShadow, Path=Color, Mode=TwoWay}"
HorizontalAlignment="Stretch"
Margin="0, 20, 10, 0"/>
</StackPanel>
@ -68,7 +68,7 @@
<Grid x:Name="ShadowContainer" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<common:CompositionShadow x:Name="Shadow"
<common:CompositionShadow x:Name="RenderShadow"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<common:CompositionImage x:Name="Image"

Просмотреть файл

@ -17,6 +17,7 @@ using SamplesCommon;
using Microsoft.UI;
using Microsoft.UI.Composition;
using Microsoft.UI.Xaml.Hosting;
using System.Reflection;
namespace CompositionSampleGallery
{
@ -79,12 +80,12 @@ namespace CompositionSampleGallery
if (_isMaskEnabled) //then remove mask
{
_image.Brush = _maskBrush.Source; //set set composition image's brush to (the initial) surfacebrush (source)
Shadow.Mask = null; //remove mask from shadow
RenderShadow.Mask = null; //remove mask from shadow
}
else //add mask
{
_image.Brush = _maskBrush; //set composition image's brush to maskbrush
Shadow.Mask = _maskBrush.Mask; //add mask to shadow
RenderShadow.Mask = _maskBrush.Mask; //add mask to shadow
}
// Update bool

Просмотреть файл

@ -98,7 +98,7 @@
<TextBlock Text="Rotation"
FontWeight="Bold"
Margin="10,0,10,0"/>
<Slider x:Name="Rotation"
<Slider x:Name="RenderRotation"
Margin="10,0,10,10"
Minimum="0"
Maximum="360"

Просмотреть файл

@ -154,7 +154,7 @@ namespace CompositionSampleGallery
{
_image.Brush.Scale = new Vector2((float)ScaleX.Value, (float)ScaleY.Value);
_image.Brush.Offset = new Vector2((float)OffsetX.Value, (float)OffsetY.Value);
_image.Brush.RotationAngleInDegrees = (float)Rotation.Value;
_image.Brush.RotationAngleInDegrees = (float)RenderRotation.Value;
_image.Brush.Stretch = CompositionStretch.None;
_image.Brush.CenterPoint = new Vector2(_sprite.Size.X / 2f, _sprite.Size.Y / 2f);
}

Просмотреть файл

@ -234,7 +234,7 @@ namespace CompositionSampleGallery
{
for (int column = 0; column < _columns; ++column)
{
if (content == _content[row, column])
if (content == (object) _content[row, column])
{
return _shadows[row, column];
}

Просмотреть файл

@ -136,7 +136,7 @@ namespace CompositionSampleGallery
// Get the Visual associated with the sender and animate its position and width.
AnimateToNewPosition((SpriteVisual)((FrameworkElement)sender).Tag);
if (sender == TextLines.Children.First())
if (sender == (object) TextLines.Children.First())
{
// Pointer is over the top line.
switch (_currentColorScheme)
@ -147,7 +147,7 @@ namespace CompositionSampleGallery
break;
}
}
else if (sender == TextLines.Children.Last())
else if (sender == (object) TextLines.Children.Last())
{
// Pointer is over the bottom line.
switch (_currentColorScheme)

Просмотреть файл

@ -30,7 +30,7 @@ namespace CompositionSampleGallery
private static string _sessionId = null;
private static string _machineId = Guid.Empty.ToString();
private static bool _isInitialized = false;
//private static bool _isInitialized = false;
private struct AppInsightsEvent
{
@ -79,7 +79,7 @@ namespace CompositionSampleGallery
}
}
_isInitialized = true;
//_isInitialized = true;
});
initializeClient.Start();

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.19041</TargetFramework>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17134.0</TargetPlatformMinVersion>
<RootNamespace>SamplesCommon</RootNamespace>