Files
OfficeTool/Pages/ConfigPage.xaml.cs
hariel1985 486589f9bc 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>
2026-04-02 07:07:27 +02:00

104 sor
3.4 KiB
C#

using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using InstaSoftOfficeTool.Models;
namespace InstaSoftOfficeTool.Pages
{
public partial class ConfigPage : Page, IWizardPage
{
private readonly MainWindow _main;
private readonly InstallConfig _config;
private readonly List<CheckBox> _appCheckBoxes = new List<CheckBox>();
public ConfigPage(MainWindow main, InstallConfig config)
{
InitializeComponent();
_main = main;
_config = config;
// Restore arch
if (_config.Architecture == "32")
{
Rb32.IsChecked = true;
}
// Populate language combo
foreach (var lang in LanguageList.Languages)
{
CbLanguage.Items.Add(new ComboBoxItem
{
Content = lang.Name + " (" + lang.Code + ")",
Tag = lang.Code
});
}
// Select current language
for (int i = 0; i < CbLanguage.Items.Count; i++)
{
var item = (ComboBoxItem)CbLanguage.Items[i];
if ((string)item.Tag == _config.Language)
{
CbLanguage.SelectedIndex = i;
break;
}
}
if (CbLanguage.SelectedIndex < 0) CbLanguage.SelectedIndex = 0;
// Populate app checkboxes
foreach (var app in ExcludableApps.Apps)
{
// Ha m\u00e1r van ment\u00e9s a configban, azt haszn\u00e1ljuk; k\u00fcl\u00f6nben a default\u00f6t
bool isChecked = _config.ExcludedApps.Count > 0
? !_config.ExcludedApps.Contains(app.Id)
: app.DefaultChecked;
bool isProPlus = _config.Edition != null &&
_config.Edition.ProductId.Contains("ProPlus");
bool isStandard = _config.Edition != null &&
_config.Edition.ProductId.Contains("Standard");
bool unavailable = false;
if (app.MinEdition == "proplus" && !isProPlus)
unavailable = true;
else if (app.MinEdition == "standard+" && !isProPlus && !isStandard)
unavailable = true;
var cb = new CheckBox
{
Content = app.DisplayName,
IsChecked = unavailable ? false : isChecked,
IsEnabled = !unavailable,
Tag = app.Id,
Style = (Style)FindResource("FluentCheckBox"),
Margin = new Thickness(0, 4, 24, 4),
MinWidth = 160
};
_appCheckBoxes.Add(cb);
AppCheckBoxes.Children.Add(cb);
}
}
public bool Validate()
{
_config.Architecture = Rb64.IsChecked == true ? "64" : "32";
if (CbLanguage.SelectedItem is ComboBoxItem selected)
{
_config.Language = (string)selected.Tag;
}
_config.ExcludedApps.Clear();
foreach (var cb in _appCheckBoxes)
{
if (cb.IsChecked != true || !cb.IsEnabled)
{
_config.ExcludedApps.Add((string)cb.Tag);
}
}
return true;
}
}
}