Office deployment wizard for InstaSoft customers: - Install Office 2019/2021/2024 (Standard, Professional Plus, Home & Business) - Auto-download ODT from Microsoft, generate config XML, run setup - Remove existing Office installations (C2R + MSI) - License troubleshooting via ospp.vbs (dstatus, unpkey) - Fluent Design UI (WPF .NET Framework 4.8, Win7+ compatible) - Hungarian interface, multi-language Office installation - Product key input with auto-activation support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
206 sor
6.4 KiB
C#
206 sor
6.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Shapes;
|
|
using InstaSoftOfficeTool.Models;
|
|
using InstaSoftOfficeTool.Pages;
|
|
|
|
namespace InstaSoftOfficeTool
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
private InstallConfig _config = new InstallConfig();
|
|
private List<Page> _wizardPages;
|
|
private int _currentPageIndex = -1;
|
|
private string _currentFlow; // "install", "remove", "license"
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
NavigateToWelcome();
|
|
}
|
|
|
|
public void NavigateToWelcome()
|
|
{
|
|
_currentFlow = null;
|
|
_currentPageIndex = -1;
|
|
_config = new InstallConfig();
|
|
BtnBack.Visibility = Visibility.Collapsed;
|
|
BtnNext.Visibility = Visibility.Collapsed;
|
|
StepIndicator.Children.Clear();
|
|
ContentFrame.Navigate(new WelcomePage(this));
|
|
}
|
|
|
|
public void StartInstallFlow()
|
|
{
|
|
_currentFlow = "install";
|
|
_config = new InstallConfig();
|
|
_wizardPages = new List<Page>
|
|
{
|
|
new VersionPage(this, _config),
|
|
new EditionPage(this, _config),
|
|
new ConfigPage(this, _config),
|
|
new ProductKeyPage(this, _config),
|
|
new SummaryPage(this, _config),
|
|
new ProgressPage(this, _config)
|
|
};
|
|
_currentPageIndex = 0;
|
|
ShowCurrentPage();
|
|
}
|
|
|
|
public void StartRemoveFlow()
|
|
{
|
|
_currentFlow = "remove";
|
|
_wizardPages = new List<Page>
|
|
{
|
|
new RemovePage(this)
|
|
};
|
|
_currentPageIndex = 0;
|
|
BtnNext.Visibility = Visibility.Collapsed;
|
|
BtnBack.Visibility = Visibility.Visible;
|
|
StepIndicator.Children.Clear();
|
|
ContentFrame.Navigate(_wizardPages[0]);
|
|
}
|
|
|
|
public void StartLicenseFlow()
|
|
{
|
|
_currentFlow = "license";
|
|
_wizardPages = new List<Page>
|
|
{
|
|
new TroubleshootPage(this)
|
|
};
|
|
_currentPageIndex = 0;
|
|
BtnNext.Visibility = Visibility.Collapsed;
|
|
BtnBack.Visibility = Visibility.Visible;
|
|
StepIndicator.Children.Clear();
|
|
ContentFrame.Navigate(_wizardPages[0]);
|
|
}
|
|
|
|
private void ShowCurrentPage()
|
|
{
|
|
if (_currentPageIndex < 0 || _currentPageIndex >= _wizardPages.Count) return;
|
|
|
|
ContentFrame.Navigate(_wizardPages[_currentPageIndex]);
|
|
UpdateStepIndicator();
|
|
UpdateButtons();
|
|
}
|
|
|
|
private void UpdateStepIndicator()
|
|
{
|
|
StepIndicator.Children.Clear();
|
|
if (_currentFlow != "install") return;
|
|
|
|
// Only show dots for install flow (6 steps, but last is progress - no dot)
|
|
int totalDots = _wizardPages.Count - 1; // exclude progress page
|
|
for (int i = 0; i < totalDots; i++)
|
|
{
|
|
var dot = new Ellipse
|
|
{
|
|
Margin = new Thickness(4, 0, 4, 0)
|
|
};
|
|
|
|
if (i <= _currentPageIndex)
|
|
{
|
|
dot.Width = 10;
|
|
dot.Height = 10;
|
|
dot.Fill = (SolidColorBrush)FindResource("AccentBrush");
|
|
}
|
|
else
|
|
{
|
|
dot.Width = 8;
|
|
dot.Height = 8;
|
|
dot.Fill = (SolidColorBrush)FindResource("BorderBrush");
|
|
}
|
|
|
|
StepIndicator.Children.Add(dot);
|
|
}
|
|
}
|
|
|
|
private void UpdateButtons()
|
|
{
|
|
BtnBack.Visibility = _currentPageIndex > 0 ? Visibility.Visible : Visibility.Visible;
|
|
BtnNext.Visibility = Visibility.Visible;
|
|
|
|
// Last step before progress = "Telep\u00edt\u00e9s ind\u00edt\u00e1sa"
|
|
if (_currentPageIndex == _wizardPages.Count - 2)
|
|
{
|
|
BtnNext.Content = "Telep\u00edt\u00e9s ind\u00edt\u00e1sa";
|
|
}
|
|
// On progress page, hide both
|
|
else if (_currentPageIndex == _wizardPages.Count - 1 &&
|
|
_wizardPages[_currentPageIndex] is ProgressPage)
|
|
{
|
|
BtnNext.Visibility = Visibility.Collapsed;
|
|
BtnBack.Visibility = Visibility.Collapsed;
|
|
StepIndicator.Children.Clear();
|
|
}
|
|
else
|
|
{
|
|
BtnNext.Content = "Tov\u00e1bb \u2192";
|
|
}
|
|
}
|
|
|
|
private void BtnBack_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_currentPageIndex > 0 && _currentFlow == "install")
|
|
{
|
|
_currentPageIndex--;
|
|
ShowCurrentPage();
|
|
}
|
|
else
|
|
{
|
|
NavigateToWelcome();
|
|
}
|
|
}
|
|
|
|
private void BtnNext_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (_currentFlow != "install") return;
|
|
|
|
// Validate current page
|
|
var currentPage = _wizardPages[_currentPageIndex];
|
|
if (currentPage is IWizardPage wizardPage && !wizardPage.Validate())
|
|
return;
|
|
|
|
if (_currentPageIndex < _wizardPages.Count - 1)
|
|
{
|
|
_currentPageIndex++;
|
|
|
|
// Refresh edition page when version changes
|
|
if (_currentPageIndex == 1)
|
|
{
|
|
_wizardPages[1] = new EditionPage(this, _config);
|
|
}
|
|
|
|
ShowCurrentPage();
|
|
|
|
// Auto-start if we're on progress page
|
|
if (_wizardPages[_currentPageIndex] is ProgressPage progressPage)
|
|
{
|
|
progressPage.StartInstallation();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowCloseButton()
|
|
{
|
|
BtnNext.Content = "Bez\u00e1r\u00e1s";
|
|
BtnNext.Visibility = Visibility.Visible;
|
|
BtnNext.Click -= BtnNext_Click;
|
|
BtnNext.Click += (s, e) => Close();
|
|
}
|
|
|
|
public void ShowBackToHomeButton()
|
|
{
|
|
BtnBack.Content = "\u2190 F\u0151oldal";
|
|
BtnBack.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
|
|
public interface IWizardPage
|
|
{
|
|
bool Validate();
|
|
}
|
|
}
|