Skip to content

Commit

Permalink
Update to .NET 9
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam committed Nov 17, 2024
1 parent 12b7107 commit 41b1b60
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 57 deletions.
2 changes: 1 addition & 1 deletion FreezeFrame.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32611.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreezeFrame", "FreezeFrame\FreezeFrame.csproj", "{5E5D27AA-0750-44E5-9422-980548012BE4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreezeFrame", "FreezeFrame\FreezeFrame.csproj", "{5E5D27AA-0750-44E5-9422-980548012BE4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion FreezeFrame/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace FreezeFrame;

public partial class App : Application
{
Window _window;
Window? _window;

public App()
=> InitializeComponent();
Expand Down
29 changes: 18 additions & 11 deletions FreezeFrame/FreezeFrame.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net9.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>FreezeFrame</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<!--<WindowsPackageType>None</WindowsPackageType>-->
<Nullable>enable</Nullable>
<ApplicationIcon>Resources\FreezeFrameIcon.ico</ApplicationIcon>
<!--<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>-->
<PackageCertificateThumbprint>F4D452B501C18A23E8EED7FA67C7510FA0F9BCCB</PackageCertificateThumbprint>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<GenerateAppInstallerFile>True</GenerateAppInstallerFile>
Expand All @@ -24,6 +23,7 @@
<AppxBundle>Never</AppxBundle>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppInstallerUri>https://www.bricelam.net/FreezeFrame/</AppInstallerUri>
<PublishAot>true</PublishAot>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,14 +37,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.4" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.229-beta">
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.3.0" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down Expand Up @@ -84,4 +83,12 @@
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
</PropertyGroup>

<!-- Publish Properties -->
<PropertyGroup>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">False</PublishReadyToRun>
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
28 changes: 14 additions & 14 deletions FreezeFrame/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public sealed partial class MainWindow : Window
// TODO: Query codecs
static readonly HashSet<string> _knownExtensions = new(StringComparer.OrdinalIgnoreCase) { ".3g2", ".3gp", ".3gp2", ".3gpp", ".asf", ".avi", ".dvr-ms", ".m2t", ".m2ts", ".m4v", ".mkv", ".mod", ".mov", ".mp2v", ".mp4", ".mp4v", ".mpa", ".mpeg", ".mpg", ".mts", ".tod", ".tts", ".uvu", ".vob", ".webm", ".wm", ".wmv" };

string _dir;
string _fileName;
string? _dir;
string? _fileName;
DateTimeOffset _dateTaken;
Geopoint _geotag;
Geopoint? _geotag;
float _width;
float _height;
uint _orientation;
Expand All @@ -53,8 +53,8 @@ public sealed partial class MainWindow : Window
double _finalFrame;
TimeSpan _previousPosition = TimeSpan.MinValue;
double _currentPosition;
CanvasRenderTarget _currentFrame;
MediaPlayer _player;
CanvasRenderTarget? _currentFrame;
MediaPlayer? _player;

double _dragHorizontalOffset;
double _dragVerticalOffset;
Expand Down Expand Up @@ -131,7 +131,7 @@ async Task Open(StorageFile file)
UpdateMinZoomFactor();

_framesPerSecond = (double)videoProperties.FrameRate.Numerator / videoProperties.FrameRate.Denominator;
_finalFrame = Math.Round(source.Duration.Value.TotalSeconds * _framesPerSecond) - 1.0;
_finalFrame = Math.Round(source.Duration!.Value.TotalSeconds * _framesPerSecond) - 1.0;
_slider.Maximum = _finalFrame;
_slider.ThumbToolTipValueConverter = new TimeSpanFormatter(_framesPerSecond);

Expand Down Expand Up @@ -216,7 +216,7 @@ void HandlePlay(object sender, RoutedEventArgs e)
if (_currentFrame is null)
return;

if (_player.CurrentState != MediaPlayerState.Playing)
if (_player!.CurrentState != MediaPlayerState.Playing)
{
_player.Play();
}
Expand Down Expand Up @@ -262,7 +262,7 @@ void HandleSeek(object sender, RangeBaseValueChangedEventArgs e)
if (_currentFrame is null)
return;

_player.Pause();
_player!.Pause();
_player.Position = TimeSpan.FromSeconds(e.NewValue / _framesPerSecond);
}

Expand All @@ -274,7 +274,7 @@ async Task SavePhotoAsync()
if (_currentFrame is null)
return;

var path = Path.Combine(_dir, _fileName + "." + _currentPosition + ".jpg");
var path = Path.Combine(_dir!, _fileName + "." + _currentPosition + ".jpg");
await _currentFrame.SaveAsync(path, CanvasBitmapFileFormat.Auto, 0.95f);

using (var stream = await FileRandomAccessStream.OpenAsync(path, FileAccessMode.ReadWrite))
Expand Down Expand Up @@ -356,16 +356,16 @@ async void HandleKeyDown(object sender, KeyRoutedEventArgs e)
{
case VirtualKey.Left:
if (!IsRateLimited())
_player.StepBackwardOneFrame();
_player!.StepBackwardOneFrame();
break;

case VirtualKey.Right:
if (!IsRateLimited())
_player.StepForwardOneFrame();
_player!.StepForwardOneFrame();
break;

case VirtualKey.G when IsControlDown():
_player.Pause();
_player!.Pause();
var frameNumberBox = new NumberBox
{
Header = "Frame number",
Expand All @@ -390,7 +390,7 @@ async void HandleKeyDown(object sender, KeyRoutedEventArgs e)
break;

case VirtualKey.O when IsControlDown():
_player.Pause();
_player!.Pause();
await Open();
break;

Expand Down Expand Up @@ -490,7 +490,7 @@ bool IsRateLimited()
return false;
}

class TimeSpanFormatter : IValueConverter
partial class TimeSpanFormatter : IValueConverter
{
readonly double _framesPerSecond;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>arm64</Platform>
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier>
<RuntimeIdentifier>win-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>False</SelfContained>
<SelfContained>True</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">False</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>False</SelfContained>
<SelfContained>True</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">False</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>False</SelfContained>
<SelfContained>True</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">False</PublishReadyToRun>
<!--
See https://github.com/microsoft/CsWinRT/issues/373
<PublishTrimmed>True</PublishTrimmed>
-->
</PropertyGroup>
</Project>
16 changes: 10 additions & 6 deletions FreezeFrame/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="FreezeFrame.app"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- The combination of below two tags have the following effect:
1) Per-Monitor for >= Windows 10 Anniversary Update
2) System < Windows 10 Anniversary Update
-->
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
</assembly>

0 comments on commit 41b1b60

Please sign in to comment.