v1.15 — PowerShell edition + repo restructure
- New powershell/InstaSoftOfficeTool.ps1: single-file WPF GUI version - Same Fluent Design UI, no compilation needed - Runs on any Windows 7+ with PowerShell 5.1 (built-in) - Chrome won't flag .ps1 files as "rarely downloaded" - Auto-elevates to admin - Moved C# source to src/ subfolder - Updated .gitignore for nested bin/obj folders Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,311 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using InstaSoftOfficeTool.Services;
|
||||
|
||||
namespace InstaSoftOfficeTool.Pages
|
||||
{
|
||||
public partial class TroubleshootPage : Page
|
||||
{
|
||||
private readonly MainWindow _main;
|
||||
private readonly LicenseManager _licenseManager = new LicenseManager();
|
||||
private List<LicenseEntry> _entries = new List<LicenseEntry>();
|
||||
|
||||
public TroubleshootPage(MainWindow main)
|
||||
{
|
||||
InitializeComponent();
|
||||
_main = main;
|
||||
Loaded += async (s, e) => await RefreshStatus();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task RefreshStatus()
|
||||
{
|
||||
OutputText.Text = "";
|
||||
OsppPathText.Text = "";
|
||||
KeyCardsPanel.Children.Clear();
|
||||
BtnRemoveAll.IsEnabled = false;
|
||||
BtnRemoveAll.Visibility = Visibility.Collapsed;
|
||||
BtnRefresh.IsEnabled = false;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
OsppPathText.Text = "ospp.vbs helye: " + _licenseManager.OsppPath;
|
||||
|
||||
try
|
||||
{
|
||||
string status = await _licenseManager.GetStatusAsync();
|
||||
OutputText.Text = status;
|
||||
|
||||
_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);
|
||||
|
||||
// Right side: Activate + Remove buttons
|
||||
var btnPanel = new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
};
|
||||
|
||||
var activateBtn = new Button
|
||||
{
|
||||
Content = "Aktiv\u00e1l\u00e1s",
|
||||
Style = (Style)FindResource("PrimaryButton"),
|
||||
Padding = new Thickness(14, 6, 14, 6),
|
||||
FontSize = 12,
|
||||
Tag = entry.Last5
|
||||
};
|
||||
activateBtn.Click += BtnActivateSingle_Click;
|
||||
btnPanel.Children.Add(activateBtn);
|
||||
|
||||
var removeBtn = new Button
|
||||
{
|
||||
Content = "Elt\u00e1vol\u00edt\u00e1s",
|
||||
Style = (Style)FindResource("SecondaryButton"),
|
||||
Padding = new Thickness(14, 6, 14, 6),
|
||||
FontSize = 12,
|
||||
Tag = entry.Last5,
|
||||
Margin = new Thickness(6, 0, 0, 0)
|
||||
};
|
||||
removeBtn.Click += BtnRemoveSingle_Click;
|
||||
btnPanel.Children.Add(removeBtn);
|
||||
|
||||
Grid.SetColumn(btnPanel, 1);
|
||||
grid.Children.Add(btnPanel);
|
||||
|
||||
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 BtnActivateSingle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string key = await _main.AskProductKeyAsync();
|
||||
if (string.IsNullOrEmpty(key)) return;
|
||||
|
||||
var btn = (Button)sender;
|
||||
btn.IsEnabled = false;
|
||||
btn.Content = "...";
|
||||
|
||||
DetailsExpander.IsExpanded = true;
|
||||
OutputText.Text = "Term\u00e9kkulcs telep\u00edt\u00e9se: " + key + "\n";
|
||||
|
||||
try
|
||||
{
|
||||
string inpResult = await _licenseManager.InstallKeyAsync(key);
|
||||
OutputText.Text += inpResult + "\n";
|
||||
|
||||
OutputText.Text += "Aktiv\u00e1l\u00e1s...\n";
|
||||
string actResult = await _licenseManager.ActivateAsync();
|
||||
OutputText.Text += actResult;
|
||||
|
||||
await RefreshStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OutputText.Text += "\nHiba: " + ex.Message;
|
||||
btn.IsEnabled = true;
|
||||
btn.Content = "Aktiv\u00e1l\u00e1s";
|
||||
}
|
||||
}
|
||||
|
||||
private async void BtnRemoveSingle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var btn = (Button)sender;
|
||||
var last5 = (string)btn.Tag;
|
||||
|
||||
bool confirmed = await _main.ConfirmAsync(
|
||||
"Kulcs elt\u00e1vol\u00edt\u00e1sa",
|
||||
"Biztosan el szeretn\u00e9 t\u00e1vol\u00edtani a *****-" + last5 + " kulcsot?",
|
||||
"Elt\u00e1vol\u00edt\u00e1s", "M\u00e9gse", DialogType.Question);
|
||||
|
||||
if (!confirmed) 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();
|
||||
}
|
||||
|
||||
private async void BtnRemoveAll_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool confirmed = await _main.ConfirmAsync(
|
||||
"\u00d6sszes kulcs elt\u00e1vol\u00edt\u00e1sa",
|
||||
"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.",
|
||||
"\u00d6sszes elt\u00e1vol\u00edt\u00e1sa", "M\u00e9gse");
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
BtnRemoveAll.IsEnabled = false;
|
||||
BtnRefresh.IsEnabled = false;
|
||||
|
||||
try
|
||||
{
|
||||
await _licenseManager.RemoveAllKeysAsync();
|
||||
await RefreshStatus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OutputText.Text += "\nHiba: " + ex.Message;
|
||||
}
|
||||
|
||||
BtnRefresh.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void DetailsExpander_Expanded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_main.Height = 680;
|
||||
}
|
||||
|
||||
private void DetailsExpander_Collapsed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_main.Height = 550;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user