-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
76 lines (68 loc) · 2.6 KB
/
App.xaml.cs
File metadata and controls
76 lines (68 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using PiPCrunchy.Services;
using Squirrel;
namespace PiPCrunchy;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
// Handle Squirrel install/update/uninstall events
HandleSquirrelEvents();
// Performance optimization: Enable hardware acceleration for WPF rendering
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default;
// Performance optimization: Set rendering tier to use hardware acceleration
if (RenderCapability.Tier >= 0x00020000)
{
// Rendering tier 2 detected - full hardware acceleration available
Timeline.DesiredFrameRateProperty.OverrideMetadata(
typeof(Timeline),
new FrameworkPropertyMetadata { DefaultValue = 60 }
);
}
// Check for updates in background (silent)
_ = UpdateService.CheckForUpdatesAsync(silent: true);
base.OnStartup(e);
// Ensure WebView2 runtime is available
try
{
var version = Microsoft.Web.WebView2.Core.CoreWebView2Environment.GetAvailableBrowserVersionString();
if (string.IsNullOrEmpty(version))
{
MessageBox.Show(
"WebView2 Runtime is not installed. Please install Microsoft Edge WebView2 Runtime to use this application.\n\n" +
"Download from: https://go.microsoft.com/fwlink/p/?LinkId=2124703",
"WebView2 Runtime Required",
MessageBoxButton.OK,
MessageBoxImage.Error);
Shutdown();
}
}
catch (Exception ex)
{
MessageBox.Show(
$"Error checking WebView2 Runtime: {ex.Message}\n\n" +
"Please install Microsoft Edge WebView2 Runtime.\n" +
"Download from: https://go.microsoft.com/fwlink/p/?LinkId=2124703",
"WebView2 Runtime Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
Shutdown();
}
}
/// <summary>
/// Handle Squirrel install/update/uninstall lifecycle events
/// </summary>
private void HandleSquirrelEvents()
{
SquirrelAwareApp.HandleEvents(
onInitialInstall: UpdateService.OnAppInstall,
onAppUpdate: UpdateService.OnAppUpdate,
onAppUninstall: UpdateService.OnAppUninstall
);
}
}