Skip to content

Commit

Permalink
Optimize Startup and Enable AppCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Mar 1, 2021
1 parent 9393fd0 commit bac303b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/HandyWinget/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using HandyControl.Controls;
using HandyControl.Themes;
using HandyWinget.Assets;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using nucs.JsonSettings;
using nucs.JsonSettings.Autosave;
using System.IO;
using System.Runtime;
using System.Windows;
using System.Windows.Media;

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

public App()
{
if (!Directory.Exists(Consts.CachePath))
{
Directory.CreateDirectory(Consts.CachePath);
}

ProfileOptimization.SetProfileRoot(Consts.CachePath);
ProfileOptimization.StartProfile("Profile");
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Expand All @@ -28,6 +42,7 @@ protected override void OnStartup(StartupEventArgs e)

UpdateTheme(Settings.Theme);
UpdateAccent(Settings.Accent);
AppCenter.Start(Consts.AppSecret, typeof(Analytics), typeof(Crashes));
}

internal void UpdateTheme(ApplicationTheme theme)
Expand Down
27 changes: 15 additions & 12 deletions src/HandyWinget/Assets/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ namespace HandyWinget.Assets
{
public abstract class Consts
{
public static string AppName = "HandyWinGet";
public static string VersionKey = "VersionCode";
private static string ManifestFolderName = "manifests";
private static string TempFolderName = "Temp";
public static readonly string AppName = "HandyWinGet";
public static readonly string VersionKey = "VersionCode";
private static readonly string ManifestFolderName = "manifests";
private static readonly string TempFolderName = "Temp";

public static string RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName);
public static string TempSetupPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, TempFolderName);
public static string ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, ManifestFolderName);
public static string ConfigPath = Path.Combine(RootPath, "Config.json");
public static readonly string RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName);
public static readonly string TempSetupPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, TempFolderName);
public static readonly string ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppName, ManifestFolderName);
public static readonly string ConfigPath = Path.Combine(RootPath, "Config.json");
public static readonly string CachePath = Path.Combine(RootPath, "Cache");

public static readonly string AppSecret = "0153dc1d-eda3-4da2-98c9-ce29361d622d";

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

public static string IDManX64Location = @"C:\Program Files (x86)\Internet Download Manager\IDMan.exe";
public static string IDManX86Location = @"C:\Program Files\Internet Download Manager\IDMan.exe";
public static readonly string IDManX64Location = @"C:\Program Files (x86)\Internet Download Manager\IDMan.exe";
public static readonly string IDManX86Location = @"C:\Program Files\Internet Download Manager\IDMan.exe";
}
}

0 comments on commit bac303b

Please sign in to comment.