Skip to content

Commit bac303b

Browse files
committedMar 1, 2021
Optimize Startup and Enable AppCenter
1 parent 9393fd0 commit bac303b

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed
 

‎src/HandyWinget/App.xaml.cs

+15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using HandyControl.Controls;
22
using HandyControl.Themes;
33
using HandyWinget.Assets;
4+
using Microsoft.AppCenter;
5+
using Microsoft.AppCenter.Analytics;
6+
using Microsoft.AppCenter.Crashes;
47
using nucs.JsonSettings;
58
using nucs.JsonSettings.Autosave;
69
using System.IO;
10+
using System.Runtime;
711
using System.Windows;
812
using System.Windows.Media;
913

@@ -13,6 +17,16 @@ public partial class App : Application
1317
{
1418
ISettings Settings = JsonSettings.Load<ISettings>().EnableAutosave();
1519

20+
public App()
21+
{
22+
if (!Directory.Exists(Consts.CachePath))
23+
{
24+
Directory.CreateDirectory(Consts.CachePath);
25+
}
26+
27+
ProfileOptimization.SetProfileRoot(Consts.CachePath);
28+
ProfileOptimization.StartProfile("Profile");
29+
}
1630
protected override void OnStartup(StartupEventArgs e)
1731
{
1832
base.OnStartup(e);
@@ -28,6 +42,7 @@ protected override void OnStartup(StartupEventArgs e)
2842

2943
UpdateTheme(Settings.Theme);
3044
UpdateAccent(Settings.Accent);
45+
AppCenter.Start(Consts.AppSecret, typeof(Analytics), typeof(Crashes));
3146
}
3247

3348
internal void UpdateTheme(ApplicationTheme theme)

‎src/HandyWinget/Assets/Consts.cs

+15-12
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ namespace HandyWinget.Assets
55
{
66
public abstract class Consts
77
{
8-
public static string AppName = "HandyWinGet";
9-
public static string VersionKey = "VersionCode";
10-
private static string ManifestFolderName = "manifests";
11-
private static string TempFolderName = "Temp";
8+
public static readonly string AppName = "HandyWinGet";
9+
public static readonly string VersionKey = "VersionCode";
10+
private static readonly string ManifestFolderName = "manifests";
11+
private static readonly string TempFolderName = "Temp";
1212

13-
public static string RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName);
14-
public static string TempSetupPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, TempFolderName);
15-
public static string ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, ManifestFolderName);
16-
public static string ConfigPath = Path.Combine(RootPath, "Config.json");
13+
public static readonly string RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName);
14+
public static readonly string TempSetupPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, TempFolderName);
15+
public static readonly string ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, ManifestFolderName);
16+
public static readonly string ConfigPath = Path.Combine(RootPath, "Config.json");
17+
public static readonly string CachePath = Path.Combine(RootPath, "Cache");
18+
19+
public static readonly string AppSecret = "0153dc1d-eda3-4da2-98c9-ce29361d622d";
1720

18-
public static string WingetRepository = "https://github.com/microsoft/winget-cli/releases";
19-
public static string WingetPkgsRepository = "https://github.com/microsoft/winget-pkgs/archive/master.zip";
21+
public static readonly string WingetRepository = "https://github.com/microsoft/winget-cli/releases";
22+
public static readonly string WingetPkgsRepository = "https://github.com/microsoft/winget-pkgs/archive/master.zip";
2023

21-
public static string IDManX64Location = @"C:\Program Files (x86)\Internet Download Manager\IDMan.exe";
22-
public static string IDManX86Location = @"C:\Program Files\Internet Download Manager\IDMan.exe";
24+
public static readonly string IDManX64Location = @"C:\Program Files (x86)\Internet Download Manager\IDMan.exe";
25+
public static readonly string IDManX86Location = @"C:\Program Files\Internet Download Manager\IDMan.exe";
2326
}
2427
}

0 commit comments

Comments
 (0)
Please sign in to comment.