Skip to content
Merged
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
9 changes: 2 additions & 7 deletions AtlasToolbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ private void AtlasButton_Click(object sender, RoutedEventArgs e)
}
}

#region Search experiment
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
var configItem = RootList.Where(item => item.Name == args.SelectedItem.ToString()).FirstOrDefault();
Expand Down Expand Up @@ -440,13 +441,6 @@ private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestB
}
}


//private async Task<IEnumerable<ConfigurationSubMenuViewModel>> GetSubMenuViewModels()
//{
// var vms = await Task.Run(() => App._host.Services.GetServices<ConfigurationSubMenuViewModel>());
// return vms;
//}

private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
// Since selecting an item will also change the text,
Expand All @@ -473,5 +467,6 @@ private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTex
sender.ItemsSource = suitableItems;
}
}
#endregion Search experiment
}
}
24 changes: 21 additions & 3 deletions AtlasToolbox/Utils/CommandPromptHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;

namespace AtlasToolbox.Utils
{
Expand Down Expand Up @@ -26,14 +27,31 @@ public static string RunCommand(string command, bool noWindow = true, bool waitF
string output = commandPrompt.StandardOutput.ReadToEnd();
string error = commandPrompt.StandardError.ReadToEnd();

string result = output + (string.IsNullOrWhiteSpace(error) ? "" : "\n[Error]\n" + error);
App.logger.Info($"[CMD] {command}:\n\t{result}");

if (waitForExit)
commandPrompt.WaitForExit();

string result = output + (string.IsNullOrWhiteSpace(error) ? "" : "\n[Error]\n" + error);
App.logger.Info($"[CMD] {command}:\n\t{result}");
return result;
}
}

public static void RunCommandToUpdate(string command, bool exitEnv = true)
{
using (Process commandPrompt = new Process())
{
commandPrompt.StartInfo.FileName = "cmd.exe";
commandPrompt.StartInfo.Arguments = $"/c {command}";
commandPrompt.StartInfo.CreateNoWindow = true;
commandPrompt.StartInfo.UseShellExecute = false;

commandPrompt.Start();

if (exitEnv)
Environment.Exit(0);
}
}
/// <summary>
/// Restarts explorer.exe
/// if there's a better way to do this, please make a PR
Expand Down
28 changes: 18 additions & 10 deletions AtlasToolbox/Utils/ToolboxUpdateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@
using System.Linq;
using System.Text.Json;
using System.IO;
using System.Threading.Tasks;

namespace AtlasToolbox.Utils
{
public class ToolboxUpdateHelper
{
const string RELEASE_URL = "https://api.github.com/repos/atlas-os/atlas-toolbox/releases/latest";
const string RELEASE_URL = "https://api.github.com/repos/TheyCreeper/atlas-toolbox/releases/latest";
public static string commandUpdate;
public static JsonDocument result;
public static bool CheckUpdates()
{
try
{
// get the api result
string htmlContent = CommandPromptHelper.ReturnRunCommand("curl " + RELEASE_URL);
var result = JsonDocument.Parse(htmlContent);
result = JsonDocument.Parse(htmlContent);
string tagName = result.RootElement.GetProperty("tag_name").GetString();

// Format everything to compare
int version = int.Parse(RegistryHelper.GetValue($@"HKLM\SOFTWARE\AtlasOS\Toolbox", "Version").ToString().Replace(".", ""));

if (int.Parse(tagName.Replace(".", "").Replace("v", "")) > version)
{
// get the download link and create a temporary directory
string downloadUrl = result.RootElement.GetProperty("assets")[0].GetProperty("browser_download_url").GetString();
string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(tempDirectory);
//// get the download link and create a temporary directory
//string downloadUrl = result.RootElement.GetProperty("assets")[0].GetProperty("browser_download_url").GetString();
//string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
//Directory.CreateDirectory(tempDirectory);

CommandPromptHelper.RunCommand($"cd {tempDirectory} && curl -LSs {downloadUrl} -O \"setup.exe\"");
commandUpdate = $"{tempDirectory}\\{downloadUrl.Split('/').Last()} /silent /install";
//CommandPromptHelper.RunCommand($"cd {tempDirectory} && curl -LSs {downloadUrl} -O \"setup.exe\"");
//commandUpdate = $"{tempDirectory}\\{downloadUrl.Split('/').Last()} /silent /install";
return true;
}
}catch
Expand All @@ -42,8 +44,14 @@ public static bool CheckUpdates()
public static void InstallUpdate()
{
// Call the installer and close Toolbox
CommandPromptHelper.RunCommand(commandUpdate, true, false);
Environment.Exit(0);
// get the download link and create a temporary directory
string downloadUrl = result.RootElement.GetProperty("assets")[0].GetProperty("browser_download_url").GetString();
string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(tempDirectory);

CommandPromptHelper.RunCommand($"cd {tempDirectory} && curl -LSs {downloadUrl} -O \"setup.exe\"");
commandUpdate = $"{tempDirectory}\\{downloadUrl.Split('/').Last()} /silent /install";
CommandPromptHelper.RunCommandToUpdate(commandUpdate);
}
}
}
58 changes: 44 additions & 14 deletions Installer/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ ChangesAssociations=yes
DisableProgramGroupPage=yes

;Test
;LicenseFile=C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\LICENSE
LicenseFile=C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\LICENSE
;Prod
LicenseFile=D:\a\atlas-toolbox\atlas-toolbox\LICENSE
;LicenseFile=D:\a\atlas-toolbox\atlas-toolbox\LICENSE

OutputBaseFilename=AtlasToolbox-Setup
SolidCompression=yes
Expand All @@ -48,11 +48,11 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{

[Files]
; Test code
;Source: "C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\AtlasToolbox\bin\x64\Release\net8.0-windows10.0.26100.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
;Source: "C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\Installer\Toolbox\*"; DestDir: "C:\Windows\AtlasModules\Toolbox"; Flags: ignoreversion recursesubdirs
Source: "C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\AtlasToolbox\bin\x64\Release\net8.0-windows10.0.26100.0\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\TheyCreeper\Documents\dev\atlas-toolbox\Installer\Toolbox\*"; DestDir: "C:\Windows\AtlasModules\Toolbox"; Flags: ignoreversion recursesubdirs
; Prod code
Source: "D:\a\atlas-toolbox\atlas-toolbox\Deploy\src\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "D:\a\atlas-toolbox\atlas-toolbox\Installer\Toolbox\*"; DestDir: "C:\Windows\AtlasModules\Toolbox"; Flags: ignoreversion recursesubdirs
;Source: "D:\a\atlas-toolbox\atlas-toolbox\Deploy\src\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
;Source: "D:\a\atlas-toolbox\atlas-toolbox\Installer\Toolbox\*"; DestDir: "C:\Windows\AtlasModules\Toolbox"; Flags: ignoreversion recursesubdirs

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Expand All @@ -71,11 +71,41 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runascurrentuser
Filename: {sys}\taskkill.exe; Parameters: "/f /im AtlasToolbox.exe"; Flags: skipifdoesntexist runhidden

[Code]
function InitializeSetup: Boolean;
begin
// comment out functions to disable installing them
Dependency_AddDotNet8;

Result := True;
end;
; Commented since we seem to not need this anymore
;[Code]
;
;function CheckDotNetVersionAt(const Key, Value: String): Boolean;
;var
; VersionStr: String;
;begin
; Result := RegQueryStringValue(HKLM64, Key, Value, VersionStr);
; if Result then
; Result := (Length(VersionStr) >= 2) and (Copy(VersionStr, 1, 2) = '8.');
;end;
;
;function IsDotNet8RuntimeInstalled(): Boolean;
;begin
; Result :=
; CheckDotNetVersionAt(
; 'SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.NETCore.App',
; 'Version'
; )
; or
; CheckDotNetVersionAt(
; 'SOFTWARE\dotnet\Setup\InstalledVersions\x64\sharedfx\Microsoft.WindowsDesktop.App',
; 'Version'
; );
;
; if not Result then
; Log('No .NET 8 runtime found.');
;end;
;
;function InitializeSetup(): Boolean;
;begin
; if not IsDotNet8RuntimeInstalled() then
; begin
; Dependency_AddDotNet8;
;
; Result := True;
; end;
;
Loading