Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNico98 committed Sep 26, 2024
2 parents 5b138a4 + 2914e90 commit 1305a26
Show file tree
Hide file tree
Showing 1,026 changed files with 1,141 additions and 91,228 deletions.
Binary file removed .vs/ProjectEvaluation/winhubx.metadata.v7.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/winhubx.metadata.v9.bin
Binary file not shown.
Binary file removed .vs/ProjectEvaluation/winhubx.projects.v7.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/winhubx.projects.v9.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/winhubx.strings.v9.bin
Binary file not shown.
Binary file modified .vs/WinHubX/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/WinHubX/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/WinHubX/v17/.suo
Binary file not shown.
296 changes: 296 additions & 0 deletions .vs/WinHubX/v17/DocumentLayout.backup.json

Large diffs are not rendered by default.

490 changes: 166 additions & 324 deletions .vs/WinHubX/v17/DocumentLayout.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions WinHubX/Dialog/Tools/DialogMsPCManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private void btnClose_Click(object sender, EventArgs e)

private void btnDownload_Click(object sender, EventArgs e)
{
string fileName = "MSPCManagerSetup.exe";
string resourceName = "WinHubX.Resources.MSPCManagerSetup.exe";
string fileName = "MSPCManagerSetup.msixbundle";
string resourceName = "WinHubX.Resources.MSPCManagerSetup.msixbundle";
string tempPath = Path.GetTempPath();
string tempFilePath = Path.Combine(tempPath, fileName);

Expand All @@ -52,13 +52,15 @@ private void btnDownload_Click(object sender, EventArgs e)
}
}

Process.Start(tempFilePath);
// Use explorer.exe to handle the msixbundle installation
Process.Start("explorer.exe", tempFilePath);
this.Close();
}
catch (Exception ex)
{
MessageBox.Show($"Errore nell'avviare l'applicazione: {ex.Message}");
}
}

}
}
120 changes: 67 additions & 53 deletions WinHubX/Forms/Base/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,49 @@ public Form1()
formHome.FormBorderStyle = FormBorderStyle.None;
PnlFormLoader.Controls.Add(formHome);
formHome.Show();
CheckForUpdatesOnStartup();
}

private async void CheckForUpdatesOnStartup()
{
// Chiama il nuovo metodo per verificare gli aggiornamenti
await CheckForUpdatesAsync();
}

private async Task CheckForUpdatesAsync()
{
string updateInfoUrl = "https://raw.githubusercontent.com/MrNico98/WinHubX/main/update.json";
string currentVersion = "2.4.0.9"; // Inserisci qui il numero di versione corrente dell'applicazione

try
{
using (var client = new HttpClient())
{
var response = await client.GetStringAsync(updateInfoUrl);
dynamic updateInfo = JsonConvert.DeserializeObject(response);

string latestVersion = updateInfo.version;

if (latestVersion != currentVersion)
{
DialogResult result = MessageBox.Show($"Nuova versione ({latestVersion}) disponibile. Note di rilascio: {updateInfo.releaseNotes}. Vuoi aggiornare?", "Aggiornamento Disponibile", MessageBoxButtons.YesNo);

if (result == DialogResult.Yes)
{
string updateUrl = updateInfo.updateUrl;
await DownloadAndUpdate(updateUrl, latestVersion);
}
}
else
{

}
}
}
catch (Exception ex)
{
MessageBox.Show($"Errore durante il controllo degli aggiornamenti: {ex.Message}", "Errore");
}
}

public static void RemoveRegistryKeys()
Expand Down Expand Up @@ -215,8 +257,8 @@ private async void btnupdate_Click(object sender, EventArgs e)
{
swap_pnlNav(btnupdate);

string updateInfoUrl = "https://aimodsitalia.store/WinHubX/update.json";
string currentVersion = "2.4.0.3"; // Inserisci qui il numero di versione corrente dell'applicazione
string updateInfoUrl = "https://raw.githubusercontent.com/MrNico98/WinHubX/main/update.json";
string currentVersion = "2.4.0.9"; // Inserisci qui il numero di versione corrente dell'applicazione

try
{
Expand Down Expand Up @@ -250,10 +292,9 @@ private async void btnupdate_Click(object sender, EventArgs e)
}
private async Task DownloadAndUpdate(string updateUrl, string version)
{
string updateFileName = $"WinHubX_SystemMonitorApp{version}.exe";
string updateFileName = $"WinHubX{version}.exe";
string updateFilePath = Path.Combine(Path.GetTempPath(), updateFileName);

// Mostra il form di progresso
using (var progressForm = new ProgressForm())
{
progressForm.Show();
Expand All @@ -264,15 +305,30 @@ private async Task DownloadAndUpdate(string updateUrl, string version)
using (var client = new HttpClient())
{
// Scarica il file di aggiornamento
progressForm.SetStatus("Scaricamento file di aggiornamento...", 0);
progressForm.SetStatus("Download file di aggiornamento...", 0);
await DownloadFileWithProgress(client, updateUrl, updateFilePath, progressForm);
}

// Esegui l'aggiornamento in un nuovo thread
Thread updateThread = new Thread(() => ExecuteUpdate(updateFilePath));
updateThread.Start();

// Chiudi la finestra principale dell'applicazione, lasciando il thread di aggiornamento in esecuzione
string currentExecutablePath = Application.ExecutablePath;
string oldExecutablePath = Path.ChangeExtension(currentExecutablePath, ".old");
if (File.Exists(oldExecutablePath))
{
File.Delete(oldExecutablePath);
}
File.Move(currentExecutablePath, oldExecutablePath);
File.Move(updateFilePath, currentExecutablePath);
Process.Start(currentExecutablePath);
Task.Run(async () =>
{
await Task.Delay(5000);
if (File.Exists(oldExecutablePath))
{
File.Delete(oldExecutablePath);
}
if (File.Exists(updateFilePath))
{
File.Delete(updateFilePath);
}
});
Application.Exit();
}
catch (Exception ex)
Expand All @@ -286,48 +342,6 @@ private async Task DownloadAndUpdate(string updateUrl, string version)
}
}

private void ExecuteUpdate(string updateFilePath)
{
try
{
// Attendere un breve intervallo per garantire che l'applicazione principale sia chiusa
Thread.Sleep(2000);

// Ottieni il percorso dell'eseguibile corrente
string currentExecutablePath = Application.ExecutablePath;
string oldExecutablePath = Path.ChangeExtension(currentExecutablePath, ".old");

// Rinominare l'eseguibile corrente a .old
if (File.Exists(currentExecutablePath))
{
File.Move(currentExecutablePath, oldExecutablePath);
}

// Sostituisci l'eseguibile con la nuova versione
File.Move(updateFilePath, currentExecutablePath);

// Avvia il nuovo eseguibile
var processStartInfo = new ProcessStartInfo
{
FileName = currentExecutablePath,
Arguments = "/silent",
UseShellExecute = true,
Verb = "runas" // Richiede privilegi di amministratore, se necessario
};

Process.Start(processStartInfo);
}
catch (Exception ex)
{
MessageBox.Show($"Errore durante l'aggiornamento: {ex.Message}", "Errore");
}
finally
{
// Chiudi l'applicazione attuale
Environment.Exit(0);
}
}

private async Task DownloadFileWithProgress(HttpClient client, string url, string filePath, ProgressForm progressForm)
{
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead))
Expand Down
2 changes: 1 addition & 1 deletion WinHubX/Forms/Base/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@
<value>CenterScreen</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Form1</value>
<value>WinHubX</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>Form1</value>
Expand Down
40 changes: 5 additions & 35 deletions WinHubX/Forms/Base/FormHome.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 38 additions & 1 deletion WinHubX/Forms/Base/FormHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,46 @@ public static void infoWHXChangelog(object sender, EventArgs e)
#region descrizione WinHubX

string description = "Changelog WinHubX\n\n" +
"06/09/2024 - v2.4.0.3:\n" +
"17/09/2024 - v2.4.0.9:\n" +
"- Fix link lite\n" +
"\n" +
"\n" +
"\n" +
"17/09/2024 - v2.4.0.8:\n" +
"- Correzione crazione ISO windows10 e 11\n" +
"- Modifica visualizzazione creazione iso\n" +
"- Aggiornamento iso Lite 10x64 e 11\n" +
"- Modificata logica update app\n" +
"- Aggiunte informazioni driver sui bottoni\n" +
"\n" +
"\n" +
"\n" +
"07/09/2024 - v2.4.0.7:\n" +
"- Aggiornato PC Manager\n" +
"- Fix ScrubberOffice\n" +
"\n" +
"\n" +
"\n" +
"07/09/2024 - v2.4.0.6:\n" +
"- Fix isotool11\n" +
"\n" +
"\n" +
"\n" +
"07/09/2024 - v2.4.0.5:\n" +
"- Fix Personalizzazione office\n" +
"\n" +
"\n" +
"\n" +
"05/09/2024 - v2.4.0.4:\n" +
"- Fix Vari\n" +
"\n" +
"\n" +
"\n" +
"04/09/2024 - v2.4.0.3:\n" +
"- Eliminato personalizzazioni\n" +
"- Eliminato monitoraggio\n" +
"- Aggiornato WSA\n" +
"- Aggiornato codici creazione iso\n" +
"- Aggiunto WinHubX-SystemTray\n" +
"- Aggiunto update\n" +
"\n" +
Expand Down
4 changes: 2 additions & 2 deletions WinHubX/Forms/Base/FormHome.resx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down
19 changes: 17 additions & 2 deletions WinHubX/Forms/Base/FormOffice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,25 @@ private void btnScrubber_Click(object sender, EventArgs e)
string resourcePath = $"{assemblyName}.Resources.WinHubXOfficeScrubber.ps1";
byte[] exeBytes = LoadEmbeddedResource(resourcePath);
string ps1FilePath = Path.Combine(Path.GetTempPath(), "WinHubXOfficeScrubber.ps1");

// Scrivi il file PowerShell nella cartella temporanea
File.WriteAllBytes(ps1FilePath, exeBytes);
StartPowerShell(ps1FilePath);

// Controlla se il file è stato scritto correttamente
if (File.Exists(ps1FilePath))
{
StartPowerShell(ps1FilePath);
}
else
{
MessageBox.Show($"Il file {ps1FilePath} non è stato estratto correttamente.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
// Gestione delle eccezioni
MessageBox.Show($"Si è verificato un errore: {ex.Message}", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally { }
}

private byte[] LoadEmbeddedResource(string resourcePath)
Expand Down
Loading

0 comments on commit 1305a26

Please sign in to comment.