Initial release v1.01 — InstaSoft Office Tool
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>
This commit is contained in:
112
Pages/ProductKeyPage.xaml.cs
Normal file
112
Pages/ProductKeyPage.xaml.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using InstaSoftOfficeTool.Models;
|
||||
|
||||
namespace InstaSoftOfficeTool.Pages
|
||||
{
|
||||
public partial class ProductKeyPage : Page, IWizardPage
|
||||
{
|
||||
private readonly MainWindow _main;
|
||||
private readonly InstallConfig _config;
|
||||
private readonly TextBox[] _keyBoxes;
|
||||
private bool _suppressAutoTab;
|
||||
|
||||
public ProductKeyPage(MainWindow main, InstallConfig config)
|
||||
{
|
||||
InitializeComponent();
|
||||
_main = main;
|
||||
_config = config;
|
||||
_keyBoxes = new[] { Key1, Key2, Key3, Key4, Key5 };
|
||||
|
||||
if (!string.IsNullOrEmpty(_config.ProductKey))
|
||||
{
|
||||
var parts = _config.ProductKey.Split('-');
|
||||
for (int i = 0; i < parts.Length && i < 5; i++)
|
||||
{
|
||||
_keyBoxes[i].Text = parts[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void KeyBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (_suppressAutoTab) return;
|
||||
|
||||
var tb = (TextBox)sender;
|
||||
|
||||
var cleaned = Regex.Replace(tb.Text, "[^A-Za-z0-9]", "");
|
||||
if (cleaned != tb.Text)
|
||||
{
|
||||
_suppressAutoTab = true;
|
||||
tb.Text = cleaned;
|
||||
tb.CaretIndex = cleaned.Length;
|
||||
_suppressAutoTab = false;
|
||||
}
|
||||
|
||||
if (tb.Text.Length == 5)
|
||||
{
|
||||
for (int i = 0; i < _keyBoxes.Length - 1; i++)
|
||||
{
|
||||
if (_keyBoxes[i] == tb)
|
||||
{
|
||||
_keyBoxes[i + 1].Focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ValidationMessage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void CbSkipKey_Changed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool skip = CbSkipKey.IsChecked == true;
|
||||
foreach (var box in _keyBoxes)
|
||||
{
|
||||
box.IsEnabled = !skip;
|
||||
if (skip) box.Text = "";
|
||||
}
|
||||
ValidationMessage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
if (CbSkipKey.IsChecked == true)
|
||||
{
|
||||
_config.ProductKey = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool allEmpty = true;
|
||||
foreach (var box in _keyBoxes)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(box.Text))
|
||||
{
|
||||
allEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allEmpty)
|
||||
{
|
||||
_config.ProductKey = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var box in _keyBoxes)
|
||||
{
|
||||
if (box.Text.Length != 5 || !Regex.IsMatch(box.Text, "^[A-Za-z0-9]{5}$"))
|
||||
{
|
||||
ValidationMessage.Text = "A term\u00e9kkulcsnak 5 x 5 alfanumerikus karakterb\u0151l kell \u00e1llnia.";
|
||||
ValidationMessage.Visibility = Visibility.Visible;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_config.ProductKey = string.Join("-",
|
||||
Key1.Text, Key2.Text, Key3.Text, Key4.Text, Key5.Text).ToUpper();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user