Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Samples/PhotoEditor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ A mini-app for viewing and editing image files, demonstrating XAML layout, data
### PhotoEditor C# Sample Application
![Photo Editor csharp sample showing the image collection page, and editing controls](images/CS_Picture1.png)

> **Note**. The C# (`cs-winui`) sample has been refreshed to modern Windows App SDK conventions: it targets Windows App SDK 1.8, uses a Mica backdrop with a `TitleBar`, the `App.MainWindow`/`DispatcherQueue` window lifecycle, and nullable reference types, with the legacy UWP `ApiInformation`/`ConnectedAnimationService.GetForCurrentView` and contract-based conditional XAML removed. It loads its bundled sample photos from the app's install location (`Assets\Samples`).

## Features

Photo Editor demonstrates:
Expand All @@ -41,8 +43,7 @@ Photo Editor demonstrates:
* XAML styling and UI customization, including [connected animations](https://docs.microsoft.com/windows/uwp/design/motion/connected-animation).
* Image effects from [**Windows.UI.Composition**](https://docs.microsoft.com/uwp/api/windows.ui.composition).
* Loading images from the **Pictures** library using data virtualization to increase performance when there are numerous files.
* The [**Microsoft.Graphics.Win2D**](https://microsoft.github.io/Win2D/WinUI3/html/Introduction.htm) NuGet package (an easy-to-use Windows Runtime API for immediate-mode 2D graphics rendering).
For WinUI).
* The [**Microsoft.Graphics.Win2D**](https://microsoft.github.io/Win2D/WinUI3/html/Introduction.htm) NuGet package (an easy-to-use Windows Runtime API for immediate-mode 2D graphics rendering for WinUI).

### C++/WinRT-specific features

Expand Down
54 changes: 54 additions & 0 deletions Samples/PhotoEditor/cs-winui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## .NET / Visual Studio
[Bb]in/
[Oo]bj/
[Dd]ebug/
[Rr]elease/
.vs/
*.user
*.suo
*.userosscache
*.sln.docstates
artifacts/

# Build logs
[Ll]og/
[Ll]ogs/
*.log
*.binlog

# Test results
[Tt]est[Rr]esult*/
*.trx
*.coverage
*.coveragexml

# NuGet
*.nupkg
*.snupkg
*.nuget.props
*.nuget.targets
project.lock.json

# MSIX packaging output
AppPackages/
BundleArtifacts/
*.msix
*.msixupload
*.appx
*.appxbundle
*.appxupload

# Publish output
publish/
*.pubxml
PublishScripts/

# Code analysis and tooling
_ReSharper*/
*.DotSettings.user
*.dotCover
.idea/

# Generated files
Generated\ Files/
*_wpftmp.csproj
9 changes: 4 additions & 5 deletions Samples/PhotoEditor/cs-winui/App.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) Microsoft Corporation.
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->

<Application
Expand All @@ -10,12 +10,11 @@
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<SolidColorBrush x:Key="RatingControlSelectedForeground" Color="White"/>

<!-- Window width adaptive breakpoints. -->
<SolidColorBrush x:Key="RatingControlSelectedForeground" Color="White" />

<!-- Window width adaptive breakpoints. -->
<x:Double x:Key="MinWindowBreakpoint">0</x:Double>
<x:Double x:Key="MediumWindowBreakpoint">641</x:Double>
<x:Double x:Key="LargeWindowBreakpoint">1008</x:Double>
Expand Down
54 changes: 39 additions & 15 deletions Samples/PhotoEditor/cs-winui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
using System;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace PhotoEditor;

namespace PhotoEditor
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
public partial class App : Application
/// <summary>
/// Gets the application's main window. WinUI 3 desktop has no <c>Window.Current</c>,
/// so the sample tracks the main window here (migration: Window.Current -> App.MainWindow).
/// </summary>
public static MainWindow MainWindow { get; private set; } = null!;

/// <summary>
/// Gets the DispatcherQueue for the UI thread. Replaces UWP's CoreDispatcher.
/// </summary>
public static DispatcherQueue MainDispatcherQueue { get; private set; } = null!;

/// <summary>
/// Gets the HWND of the main window, used to associate pickers with the window
/// (migration: pickers must be initialized with the owning window handle).
/// </summary>
public static IntPtr WindowHandle { get; private set; }

public App()
{
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
Window = new MainWindow();
Window.Activate();
WindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(Window);
}
public static MainWindow Window { get; private set; }
public static IntPtr WindowHandle { get; private set; }
InitializeComponent();
}

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
MainWindow = new MainWindow();
MainDispatcherQueue = MainWindow.DispatcherQueue;
WindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);

// Navigate only after MainWindow is assigned: pages read App.MainWindow in OnNavigatedTo.
MainWindow.NavigateToMainPage();
MainWindow.Activate();
}
}
}
Binary file added Samples/PhotoEditor/cs-winui/Assets/AppIcon.ico
Binary file not shown.
Binary file modified Samples/PhotoEditor/cs-winui/Assets/LockScreenLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Samples/PhotoEditor/cs-winui/Assets/SplashScreen.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Samples/PhotoEditor/cs-winui/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 14 additions & 37 deletions Samples/PhotoEditor/cs-winui/DetailPage.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<!-- Copyright (c) Microsoft Corporation.
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->

<Page x:Class="PhotoEditor.DetailPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:PhotoEditor"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
RequestedTheme="Dark">
mc:Ignorable="d">

<Page.Resources>
<Flyout x:Key="zoomFlyout">
Expand Down Expand Up @@ -37,11 +35,7 @@
</StackPanel>
</Flyout>

<ControlTemplate TargetType="Slider" x:Key="FancySliderControlTemplate"
xmlns:contract6Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,6)"
xmlns:contract6NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,6)"
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)">
<ControlTemplate TargetType="Slider" x:Key="FancySliderControlTemplate">
<Grid Margin="{TemplateBinding Padding}">
<Grid.Resources>
<Style TargetType="Thumb" x:Key="SliderThumbStyle">
Expand Down Expand Up @@ -239,16 +233,8 @@

Height="{ThemeResource SliderTrackThemeHeight}"
Grid.Row="1"
Grid.ColumnSpan="3"
contract7Present:RadiusX="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7Present:RadiusY="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}" />
<Rectangle x:Name="HorizontalDecreaseRect" Fill="{TemplateBinding Foreground}" Grid.Row="1"
contract7Present:RadiusX="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7Present:RadiusY="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}" />
Grid.ColumnSpan="3" />
<Rectangle x:Name="HorizontalDecreaseRect" Fill="{TemplateBinding Foreground}" Grid.Row="1" />
<TickBar x:Name="TopTickBar"
Visibility="Collapsed"
Fill="{ThemeResource SliderTickBarFill}"
Expand Down Expand Up @@ -299,19 +285,11 @@
Fill="{TemplateBinding Background}"
Width="{ThemeResource SliderTrackThemeHeight}"
Grid.Column="1"
Grid.RowSpan="3"
contract7Present:RadiusX="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7Present:RadiusY="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}" />
Grid.RowSpan="3" />
<Rectangle x:Name="VerticalDecreaseRect"
Fill="{TemplateBinding Foreground}"
Grid.Column="1"
Grid.Row="2"
contract7Present:RadiusX="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7Present:RadiusY="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource TopLeftCornerRadiusDoubleValueConverter}}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Converter={StaticResource BottomRightCornerRadiusDoubleValueConverter}}" />
Grid.Row="2" />
<TickBar x:Name="LeftTickBar"
Visibility="Collapsed"
Fill="{ThemeResource SliderTickBarFill}"
Expand Down Expand Up @@ -350,7 +328,7 @@

</Page.Resources>

<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<RelativePanel>
<StackPanel x:Name="TitlePanel" Orientation="Horizontal">
<AppBarButton x:Name="BackButton" Click="BackButton_Click" Margin="0, 0, 12, 0">
<SymbolIcon Symbol="Back"/>
Expand All @@ -364,7 +342,7 @@
Visibility="{x:Bind item.NeedsSaved, Mode=OneWay}" />
</StackPanel>
<CommandBar x:Name="MainCommandBar"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Background="Transparent"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignTopWithPanel="True"
OverflowButtonVisibility="Collapsed"
Expand Down Expand Up @@ -466,12 +444,11 @@
Text="{x:Bind item.ImageTitle, Mode=TwoWay}"
Padding="12"
Grid.ColumnSpan="2" />
<muxc:RatingControl Value="{x:Bind item.ImageRating, Mode=TwoWay}"
Padding="12"
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,0,0,16">
</muxc:RatingControl>
<RatingControl Value="{x:Bind item.ImageRating, Mode=TwoWay}"
Padding="12"
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,0,0,16" />


<Slider Header="Exposure"
Expand Down
Loading