v1.16 — Remove PowerShell edition, restore flat project structure
PowerShell version removed — will use OV code signing certificate instead. Files moved back from src/ to project root. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
263
Pages/ProgressPage.xaml.cs
Normal file
263
Pages/ProgressPage.xaml.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using InstaSoftOfficeTool.Models;
|
||||
using InstaSoftOfficeTool.Services;
|
||||
|
||||
namespace InstaSoftOfficeTool.Pages
|
||||
{
|
||||
public partial class ProgressPage : Page
|
||||
{
|
||||
private readonly MainWindow _main;
|
||||
private readonly InstallConfig _config;
|
||||
|
||||
public ProgressPage(MainWindow main, InstallConfig config)
|
||||
{
|
||||
InitializeComponent();
|
||||
_main = main;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async void StartInstallation()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Step 1: Download ODT
|
||||
SetStepActive(Step1Icon, Step1Text);
|
||||
AppendLog("ODT let\u00f6lt\u00e9se indul...");
|
||||
|
||||
var downloader = new OdtDownloader();
|
||||
downloader.StatusChanged += msg => Dispatcher.Invoke(() => AppendLog(msg));
|
||||
|
||||
bool downloaded = await downloader.DownloadAndExtractAsync();
|
||||
if (!downloaded)
|
||||
{
|
||||
SetStepError(Step1Icon, Step1Text);
|
||||
ShowDone(false, "Az ODT let\u00f6lt\u00e9se sikertelen.");
|
||||
return;
|
||||
}
|
||||
SetStepDone(Step1Icon, Step1Text);
|
||||
|
||||
// Step 2: Generate config XML
|
||||
SetStepActive(Step2Icon, Step2Text);
|
||||
AppendLog("Konfigur\u00e1ci\u00f3s XML gener\u00e1l\u00e1sa...");
|
||||
|
||||
string xml = OdtXmlGenerator.Generate(_config);
|
||||
string xmlPath = Path.Combine(downloader.OdtFolder, "configuration.xml");
|
||||
File.WriteAllText(xmlPath, xml);
|
||||
AppendLog("XML mentve: " + xmlPath);
|
||||
|
||||
SetStepDone(Step2Icon, Step2Text);
|
||||
|
||||
// Step 3: Run setup.exe /configure
|
||||
SetStepActive(Step3Icon, Step3Text);
|
||||
AppendLog("Office telep\u00edt\u00e9s ind\u00edt\u00e1sa...");
|
||||
AppendLog("setup.exe /configure \"" + xmlPath + "\"");
|
||||
|
||||
int exitCode = await downloader.RunSetupAsync(xmlPath, msg =>
|
||||
Dispatcher.Invoke(() => AppendLog(msg)));
|
||||
|
||||
if (exitCode == 0)
|
||||
{
|
||||
SetStepDone(Step3Icon, Step3Text);
|
||||
ShowDone(true, "Az Office sikeresen telep\u00fclt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetStepError(Step3Icon, Step3Text);
|
||||
ShowDone(false, "A telep\u00edt\u00e9s hibak\u00f3ddal fejez\u0151d\u00f6tt be: " + exitCode);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppendLog("HIBA: " + ex.Message);
|
||||
ShowDone(false, "V\u00e1ratlan hiba t\u00f6rt\u00e9nt.");
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendLog(string text)
|
||||
{
|
||||
LogText.Text += DateTime.Now.ToString("HH:mm:ss") + " " + text + "\n";
|
||||
LogText.ScrollToEnd();
|
||||
}
|
||||
|
||||
private void SetStepActive(TextBlock icon, TextBlock text)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
icon.Text = "\uE72A";
|
||||
icon.Foreground = (Brush)FindResource("AccentBrush");
|
||||
text.Foreground = (Brush)FindResource("TextPrimaryBrush");
|
||||
text.FontWeight = FontWeights.SemiBold;
|
||||
});
|
||||
}
|
||||
|
||||
private void SetStepDone(TextBlock icon, TextBlock text)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
icon.Text = "\uE73E";
|
||||
icon.Foreground = (Brush)FindResource("SuccessBrush");
|
||||
text.Foreground = (Brush)FindResource("SuccessBrush");
|
||||
text.FontWeight = FontWeights.Normal;
|
||||
});
|
||||
}
|
||||
|
||||
private void SetStepError(TextBlock icon, TextBlock text)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
icon.Text = "\uE711";
|
||||
icon.Foreground = (Brush)FindResource("ErrorBrush");
|
||||
text.Foreground = (Brush)FindResource("ErrorBrush");
|
||||
text.FontWeight = FontWeights.Normal;
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowDone(bool success, string message)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainProgress.IsIndeterminate = false;
|
||||
MainProgress.Value = 100;
|
||||
TitleText.Text = success ? "Telep\u00edt\u00e9s befejezve" : "Telep\u00edt\u00e9s sikertelen";
|
||||
|
||||
DoneIcon.Text = success ? "\uE73E" : "\uE711";
|
||||
DoneIcon.Foreground = success
|
||||
? (Brush)FindResource("SuccessBrush")
|
||||
: (Brush)FindResource("ErrorBrush");
|
||||
DoneText.Text = message;
|
||||
DoneText.Foreground = DoneIcon.Foreground;
|
||||
DonePanel.Visibility = Visibility.Visible;
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Show activate card if no product key was provided
|
||||
if (string.IsNullOrEmpty(_config.ProductKey))
|
||||
{
|
||||
ActivateCard.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
// Show launch buttons
|
||||
BuildLaunchButtons();
|
||||
LaunchCard.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
_main.ShowCloseButton();
|
||||
});
|
||||
}
|
||||
|
||||
private void BuildLaunchButtons()
|
||||
{
|
||||
LaunchButtons.Children.Clear();
|
||||
|
||||
var apps = new[]
|
||||
{
|
||||
("Word", "WINWORD.EXE"),
|
||||
("Excel", "EXCEL.EXE"),
|
||||
("PowerPoint", "POWERPNT.EXE"),
|
||||
("Outlook", "OUTLOOK.EXE"),
|
||||
};
|
||||
|
||||
foreach (var (name, exe) in apps)
|
||||
{
|
||||
// Skip if excluded
|
||||
if (_config.ExcludedApps.Contains(name == "Word" ? "Word" :
|
||||
name == "Excel" ? "Excel" :
|
||||
name == "PowerPoint" ? "PowerPoint" :
|
||||
name == "Outlook" ? "Outlook" : ""))
|
||||
continue;
|
||||
|
||||
var btn = new Button
|
||||
{
|
||||
Content = name,
|
||||
Style = (Style)FindResource("SecondaryButton"),
|
||||
Padding = new Thickness(18, 8, 18, 8),
|
||||
FontSize = 13,
|
||||
Margin = new Thickness(0, 0, 8, 0),
|
||||
Tag = exe
|
||||
};
|
||||
btn.Click += LaunchApp_Click;
|
||||
LaunchButtons.Children.Add(btn);
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchApp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var btn = (Button)sender;
|
||||
var exe = (string)btn.Tag;
|
||||
|
||||
try
|
||||
{
|
||||
// Try common Office paths
|
||||
var paths = new[]
|
||||
{
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
"Microsoft Office", "root", "Office16", exe),
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
|
||||
"Microsoft Office", "root", "Office16", exe),
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||
"Microsoft Office", "Office16", exe),
|
||||
};
|
||||
|
||||
foreach (var path in paths)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Process.Start(path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: let Windows find it
|
||||
Process.Start(exe);
|
||||
}
|
||||
catch
|
||||
{
|
||||
AppendLog("Nem siker\u00fclt elind\u00edtani: " + exe);
|
||||
}
|
||||
}
|
||||
|
||||
private async void BtnActivateNow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string key = await _main.AskProductKeyAsync();
|
||||
if (string.IsNullOrEmpty(key)) return;
|
||||
|
||||
BtnActivateNow.IsEnabled = false;
|
||||
BtnActivateNow.Content = "Aktiv\u00e1l\u00e1s...";
|
||||
|
||||
var lm = new LicenseManager();
|
||||
if (!lm.FindOspp())
|
||||
{
|
||||
AppendLog("Az ospp.vbs nem tal\u00e1lhat\u00f3.");
|
||||
BtnActivateNow.IsEnabled = true;
|
||||
BtnActivateNow.Content = "Aktiv\u00e1l\u00e1s";
|
||||
return;
|
||||
}
|
||||
|
||||
AppendLog("Term\u00e9kkulcs telep\u00edt\u00e9se: " + key);
|
||||
string inpResult = await lm.InstallKeyAsync(key);
|
||||
AppendLog(inpResult);
|
||||
|
||||
AppendLog("Aktiv\u00e1l\u00e1s...");
|
||||
string actResult = await lm.ActivateAsync();
|
||||
AppendLog(actResult);
|
||||
|
||||
if (actResult.Contains("successful") || actResult.Contains("sikeres"))
|
||||
{
|
||||
BtnActivateNow.Content = "Aktiv\u00e1lva \u2713";
|
||||
AppendLog("Az Office sikeresen aktiv\u00e1lva!");
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnActivateNow.IsEnabled = true;
|
||||
BtnActivateNow.Content = "Aktiv\u00e1l\u00e1s";
|
||||
AppendLog("Az aktiv\u00e1l\u00e1s eredm\u00e9ny\u00e9t ellen\u0151rizze a kimenetben.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user