Skip to content

Commit

Permalink
up to 2.4.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNico98 committed Sep 18, 2024
1 parent c039886 commit a895810
Show file tree
Hide file tree
Showing 1,020 changed files with 682 additions and 91,196 deletions.
Binary file removed .vs/ProjectEvaluation/winhubx.metadata.v7.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/winhubx.metadata.v8.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.v8.bin
Binary file not shown.
Binary file added .vs/ProjectEvaluation/winhubx.strings.v8.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 modified .vs/WinHubX/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/WinHubX/v17/.suo
Binary file not shown.
482 changes: 127 additions & 355 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.8"; // 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
{
MessageBox.Show("Stai usando l'ultima versione disponibile", "Non ci sono aggiornamenti");
}
}
}
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.8"; // 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
2 changes: 1 addition & 1 deletion WinHubX/Forms/Base/FormHome.Designer.cs

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

34 changes: 33 additions & 1 deletion WinHubX/Forms/Base/FormHome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,41 @@ 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.8:\n" +
"- Correzzione 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
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
52 changes: 46 additions & 6 deletions WinHubX/Forms/Personalizzazione office/PersonalizzazioneOffice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ public PersonalizzazioneOffice(Form1 form1, FormOffice formoffice)
radiobutton_office2021.Checked = false;
radiobutton_office365.Checked = false;
this.ActiveControl = progressBar_office;
ExtractFolderToTemp();
}


private void btn_avviainstallazione_Click(object sender, EventArgs e)
{
if (radiobutton_office2021.Checked)
{
if (radioButton_x64.Checked)
{
string xmlFilePath = @"C:\Configurazione2021x64.xml";
ExtractAndSaveResource("Configurazione2021x64.xml", xmlFilePath);
string xmlFilePath = Path.Combine(GetTempFolderPath(), "Configurazione2021x64.xml");

if (checkBox_visio.Checked)
{
Expand Down Expand Up @@ -225,6 +226,36 @@ private void btn_avviainstallazione_Click(object sender, EventArgs e)
}
}

private void ExtractFolderToTemp()
{
try
{
string tempFolder = GetTempFolderPath();

if (!Directory.Exists(tempFolder))
{
Directory.CreateDirectory(tempFolder);
}

// Estrai i file necessari
ExtractAndSaveResource("Configurazione2021x64.xml", Path.Combine(tempFolder, "Configurazione2021x64.xml"));
ExtractAndSaveResource("Configurazione2021x32.xml", Path.Combine(tempFolder, "Configurazione2021x32.xml"));
ExtractAndSaveResource("Configurazione365x64.xml", Path.Combine(tempFolder, "Configurazione365x64.xml"));
ExtractAndSaveResource("Configurazione365x32.xml", Path.Combine(tempFolder, "Configurazione365x32.xml"));
ExtractAndSaveResource("bin.exe", Path.Combine(tempFolder, "bin.exe"));
}
catch (Exception ex)
{
MessageBox.Show($"Errore durante l'estrazione della cartella: {ex.Message}", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private string GetTempFolderPath()
{
return Path.Combine(Path.GetTempPath(), "OfficePersonalizzato");
}


private void AddElementToXml(string xmlFilePath, string xmlToAdd)
{
try
Expand Down Expand Up @@ -451,31 +482,40 @@ private void StartInstallation(string xmlFilePath)
try
{
progressBar_office.Value = 0;
// Determine the path to the executable relative to the application directory
string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
string binExePath = Path.Combine(appDirectory, "Resources", "OfficePersonalizzato", "bin.exe");

// Path to the folder where the executable was extracted
string tempPath = Path.Combine(Path.GetTempPath(), "OfficePersonalizzato");
string binExePath = Path.Combine(tempPath, "bin.exe");

progressBar_office.Value = 15;

// Check if the executable exists
if (!File.Exists(binExePath))
throw new FileNotFoundException("Executable not found.", binExePath);

progressBar_office.Value = 30;

// Prepare the process start information
string arguments = $"/configure \"{xmlFilePath}\"";
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = binExePath,
Arguments = arguments,
WorkingDirectory = Path.GetDirectoryName(binExePath), // Set the working directory
WorkingDirectory = tempPath, // Set the working directory to the temp folder
UseShellExecute = false,
CreateNoWindow = true
};

// Start the process
Process.Start(startInfo);

progressBar_office.Value = 50;
progressBar_office.Value = 75;
MessageBox.Show("Avviata l'installazione personalizzata.", "Operazione completata", MessageBoxButtons.OK, MessageBoxIcon.Information);

// Optionally delete the XML file after installation
File.Delete(xmlFilePath);

progressBar_office.Value = 100;
}
catch (Exception ex)
Expand Down
Loading

0 comments on commit a895810

Please sign in to comment.