v1.02 — License troubleshoot UI improvements

- Fix ospp.vbs path: add root\Office16 for Click-to-Run installs
- Individual key cards with per-key remove buttons
- "Remove all" only shown when 2+ keys found
- Collapsible "Details" section (ospp.vbs path + raw output)
- All log/output fields now selectable and copyable (TextBox)
- Parse license entries (name, status, error, key) from dstatus output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hariel1985
2026-03-31 05:51:26 +02:00
szülő 4937ac4b1c
commit e8abb03eee
5 fájl változott, egészen pontosan 264 új sor hozzáadva és 54 régi sor törölve

Fájl megtekintése

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@@ -10,6 +11,7 @@ namespace InstaSoftOfficeTool.Pages
{
private readonly MainWindow _main;
private readonly LicenseManager _licenseManager = new LicenseManager();
private List<LicenseEntry> _entries = new List<LicenseEntry>();
public TroubleshootPage(MainWindow main)
{
@@ -20,56 +22,200 @@ namespace InstaSoftOfficeTool.Pages
private async System.Threading.Tasks.Task RefreshStatus()
{
OutputText.Text = "Keres\u00e9s folyamatban...\n";
OutputText.Text = "";
OsppPathText.Text = "";
KeyCardsPanel.Children.Clear();
BtnRemoveAll.IsEnabled = false;
BtnRemoveAll.Visibility = Visibility.Collapsed;
BtnRefresh.IsEnabled = false;
// Loading indicator
var loadingText = new TextBlock
{
Text = "Keres\u00e9s folyamatban...",
FontSize = 13,
Foreground = (Brush)FindResource("TextSecondaryBrush"),
Margin = new Thickness(0, 8, 0, 8)
};
KeyCardsPanel.Children.Add(loadingText);
bool found = _licenseManager.FindOspp();
if (!found)
{
OsppStatusIcon.Text = "\uE711";
OsppStatusIcon.Foreground = (Brush)FindResource("ErrorBrush");
OsppStatusText.Text = "Az ospp.vbs nem tal\u00e1lhat\u00f3. Nincs telep\u00edtett Office?";
OutputText.Text = "Az ospp.vbs f\u00e1jl nem tal\u00e1lhat\u00f3 a sz\u00e1m\u00edt\u00f3g\u00e9pen.\n\n" +
"Lehets\u00e9ges okok:\n" +
"- Nincs telep\u00edtett Microsoft Office\n" +
"- Az Office nem a szok\u00e1sos helyre lett telep\u00edtve";
KeyCardsPanel.Children.Clear();
var errorCard = new Border
{
Background = (Brush)FindResource("CardBrush"),
BorderBrush = (Brush)FindResource("BorderBrush"),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(8),
Padding = new Thickness(16, 14, 16, 14),
Margin = new Thickness(0, 0, 0, 6)
};
var errorPanel = new StackPanel();
errorPanel.Children.Add(new TextBlock
{
Text = "Az ospp.vbs nem tal\u00e1lhat\u00f3",
FontSize = 14, FontWeight = FontWeights.SemiBold,
Foreground = (Brush)FindResource("ErrorBrush")
});
errorPanel.Children.Add(new TextBlock
{
Text = "Nincs telep\u00edtett Microsoft Office, vagy nem a szok\u00e1sos helyre lett telep\u00edtve.",
FontSize = 12, Foreground = (Brush)FindResource("TextSecondaryBrush"),
TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 0)
});
errorCard.Child = errorPanel;
KeyCardsPanel.Children.Add(errorCard);
BtnRefresh.IsEnabled = true;
return;
}
OsppStatusIcon.Text = "\uE73E";
OsppStatusIcon.Foreground = (Brush)FindResource("SuccessBrush");
OsppStatusText.Text = "ospp.vbs megtal\u00e1lva: " + _licenseManager.OsppPath;
OutputText.Text = "Licenc-\u00e1llapot lek\u00e9rdez\u00e9se...\n";
OsppPathText.Text = "ospp.vbs helye: " + _licenseManager.OsppPath;
try
{
string status = await _licenseManager.GetStatusAsync();
OutputText.Text = status;
var keys = _licenseManager.ParseLicenseKeys(status);
BtnRemoveAll.IsEnabled = keys.Count > 0;
if (keys.Count > 0)
{
OutputText.Text += "\n--- " + keys.Count + " term\u00e9kkulcs tal\u00e1lhat\u00f3 ---";
}
else
{
OutputText.Text += "\n--- Nincs telep\u00edtett term\u00e9kkulcs ---";
}
_entries = _licenseManager.ParseLicenseEntries(status);
BuildKeyCards();
}
catch (Exception ex)
{
KeyCardsPanel.Children.Clear();
OutputText.Text = "Hiba a lek\u00e9rdez\u00e9s sor\u00e1n: " + ex.Message;
}
BtnRefresh.IsEnabled = true;
}
private void BuildKeyCards()
{
KeyCardsPanel.Children.Clear();
if (_entries.Count == 0)
{
var noKeyCard = new Border
{
Background = (Brush)FindResource("CardBrush"),
BorderBrush = (Brush)FindResource("BorderBrush"),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(8),
Padding = new Thickness(16, 14, 16, 14)
};
noKeyCard.Child = new TextBlock
{
Text = "Nincs telep\u00edtett term\u00e9kkulcs.",
FontSize = 13,
Foreground = (Brush)FindResource("TextSecondaryBrush")
};
KeyCardsPanel.Children.Add(noKeyCard);
return;
}
if (_entries.Count > 1)
{
BtnRemoveAll.Visibility = Visibility.Visible;
BtnRemoveAll.IsEnabled = true;
}
foreach (var entry in _entries)
{
KeyCardsPanel.Children.Add(CreateKeyCard(entry));
}
}
private Border CreateKeyCard(LicenseEntry entry)
{
var grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
var infoPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center };
infoPanel.Children.Add(new TextBlock
{
Text = string.IsNullOrEmpty(entry.LicenseName) ? "Ismeretlen licenc" : entry.LicenseName,
FontSize = 13, FontWeight = FontWeights.SemiBold,
TextTrimming = TextTrimming.CharacterEllipsis
});
var statusLine = !string.IsNullOrEmpty(entry.ErrorDescription)
? entry.ErrorDescription
: (!string.IsNullOrEmpty(entry.Status) ? entry.Status : entry.Description);
infoPanel.Children.Add(new TextBlock
{
Text = statusLine,
FontSize = 11, Foreground = (Brush)FindResource("TextSecondaryBrush"),
TextTrimming = TextTrimming.CharacterEllipsis
});
infoPanel.Children.Add(new TextBlock
{
Text = "Kulcs: *****-" + entry.Last5,
FontSize = 11, FontFamily = new FontFamily("Consolas"),
Foreground = (Brush)FindResource("TextSecondaryBrush"),
Margin = new Thickness(0, 2, 0, 0)
});
Grid.SetColumn(infoPanel, 0);
grid.Children.Add(infoPanel);
var removeBtn = new Button
{
Content = "Elt\u00e1vol\u00edt\u00e1s",
Style = (Style)FindResource("SecondaryButton"),
Padding = new Thickness(14, 6, 14, 6),
FontSize = 12,
VerticalAlignment = VerticalAlignment.Center,
Tag = entry.Last5
};
removeBtn.Click += BtnRemoveSingle_Click;
Grid.SetColumn(removeBtn, 1);
grid.Children.Add(removeBtn);
return new Border
{
Background = (Brush)FindResource("CardBrush"),
BorderBrush = (Brush)FindResource("BorderBrush"),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(8),
Padding = new Thickness(16, 10, 16, 10),
Margin = new Thickness(0, 0, 0, 6),
Child = grid
};
}
private async void BtnRemoveSingle_Click(object sender, RoutedEventArgs e)
{
var btn = (Button)sender;
var last5 = (string)btn.Tag;
var result = MessageBox.Show(
"Biztosan el szeretn\u00e9 t\u00e1vol\u00edtani a *****-" + last5 + " kulcsot?",
"Meger\u0151s\u00edt\u00e9s", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result != MessageBoxResult.Yes) return;
btn.IsEnabled = false;
btn.Content = "...";
try
{
await _licenseManager.RemoveKeyAsync(last5);
await RefreshStatus();
}
catch (Exception ex)
{
OutputText.Text += "\nHiba: " + ex.Message;
btn.IsEnabled = true;
btn.Content = "Elt\u00e1vol\u00edt\u00e1s";
}
}
private async void BtnRefresh_Click(object sender, RoutedEventArgs e)
{
await RefreshStatus();
@@ -78,7 +224,7 @@ namespace InstaSoftOfficeTool.Pages
private async void BtnRemoveAll_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show(
"Biztosan el szeretn\u00e9 t\u00e1vol\u00edtani az \u00f6sszes telep\u00edtett term\u00e9kkulcsot?\n\n" +
"Biztosan el szeretn\u00e9 t\u00e1vol\u00edtani az \u00f6sszes telep\u00edtett term\u00e9kkulcsot (" + _entries.Count + " db)?\n\n" +
"Ez nem t\u00f6r\u00f6l adatot, csak az aktiv\u00e1ci\u00f3s \u00e1llapotot \u00e1ll\u00edtja vissza.",
"Meger\u0151s\u00edt\u00e9s", MessageBoxButton.YesNo, MessageBoxImage.Warning);
@@ -87,20 +233,32 @@ namespace InstaSoftOfficeTool.Pages
BtnRemoveAll.IsEnabled = false;
BtnRefresh.IsEnabled = false;
OutputText.Text += "\n\nTerm\u00e9kkulcsok elt\u00e1vol\u00edt\u00e1sa...\n";
try
{
string cleanResult = await _licenseManager.RemoveAllKeysAsync();
OutputText.Text += cleanResult + "\n";
OutputText.Text += "\nK\u00e9sz. Kattintson az '\u00c1llapot friss\u00edt\u00e9se' gombra az eredm\u00e9ny ellen\u0151rz\u00e9s\u00e9hez.";
await _licenseManager.RemoveAllKeysAsync();
await RefreshStatus();
}
catch (Exception ex)
{
OutputText.Text += "Hiba: " + ex.Message;
OutputText.Text += "\nHiba: " + ex.Message;
}
BtnRefresh.IsEnabled = true;
}
private void DetailsExpander_Expanded(object sender, RoutedEventArgs e)
{
// Grow window to fit details
var window = Window.GetWindow(this);
if (window != null && window.Height < 680)
window.Height = 680;
}
private void DetailsExpander_Collapsed(object sender, RoutedEventArgs e)
{
var window = Window.GetWindow(this);
if (window != null)
window.Height = 550;
}
}
}