53ca4611d1
On domain PCs, HKCU policies are controlled by GPO and the Trust Center settings are greyed out. Now also writes to HKLM (requires admin rights) which overrides GPO settings. Shows orange hint in settings when GPO lock is detected: "Auf Domaenen-PCs: App einmalig als Admin starten!" The app tries all 8 combinations: HKCU/HKLM x Policies/direct x 16.0/15.0. Silently skips paths where permissions are denied. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
3.1 KiB
C#
92 lines
3.1 KiB
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using StarfaceOutlookSync.Models;
|
|
|
|
namespace StarfaceOutlookSync.UI
|
|
{
|
|
public class SettingsForm : Form
|
|
{
|
|
private CheckBox _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook;
|
|
private Button _btnSave, _btnCancel;
|
|
private readonly UserSettings _settings;
|
|
|
|
public SettingsForm()
|
|
{
|
|
_settings = UserSettings.Load();
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
Text = "Einstellungen";
|
|
Size = new Size(380, 250);
|
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
|
MaximizeBox = false;
|
|
MinimizeBox = false;
|
|
StartPosition = FormStartPosition.CenterParent;
|
|
Font = new Font("Segoe UI", 9);
|
|
|
|
_chkStartMinimized = new CheckBox
|
|
{
|
|
Text = "Minimiert starten (nur im System Tray)",
|
|
Left = 20, Top = 24, AutoSize = true,
|
|
Checked = _settings.StartMinimized
|
|
};
|
|
|
|
_chkSyncOnStart = new CheckBox
|
|
{
|
|
Text = "Beim Start automatisch synchronisieren",
|
|
Left = 20, Top = 52, AutoSize = true,
|
|
Checked = _settings.SyncOnStart
|
|
};
|
|
|
|
_chkAutoAcceptOutlook = new CheckBox
|
|
{
|
|
Text = "Outlook-Sicherheitsabfrage automatisch erlauben",
|
|
Left = 20, Top = 80, AutoSize = true,
|
|
Checked = _settings.AutoAcceptOutlookPrompt
|
|
};
|
|
|
|
var hintText = "Hinweis: Outlook muss nach Aenderung neu gestartet werden.";
|
|
if (UserSettings.IsOutlookSecurityLockedByPolicy())
|
|
hintText += "\nAuf Domaenen-PCs: App einmalig als Admin starten!";
|
|
|
|
var lblHint = new Label
|
|
{
|
|
Text = hintText,
|
|
Left = 38, Top = 102, Width = 310, Height = 36,
|
|
ForeColor = UserSettings.IsOutlookSecurityLockedByPolicy() ? Color.OrangeRed : Color.Gray,
|
|
Font = new Font("Segoe UI", 8)
|
|
};
|
|
|
|
_btnSave = new Button
|
|
{
|
|
Text = "Speichern", Left = 95, Top = 170, Width = 85, Height = 28,
|
|
DialogResult = DialogResult.None
|
|
};
|
|
_btnSave.Click += (s, e) => Save();
|
|
|
|
_btnCancel = new Button
|
|
{
|
|
Text = "Abbrechen", Left = 189, Top = 170, Width = 85, Height = 28,
|
|
DialogResult = DialogResult.Cancel
|
|
};
|
|
|
|
Size = new Size(380, 260);
|
|
Controls.AddRange(new Control[] { _chkStartMinimized, _chkSyncOnStart, _chkAutoAcceptOutlook, lblHint, _btnSave, _btnCancel });
|
|
AcceptButton = _btnSave;
|
|
CancelButton = _btnCancel;
|
|
}
|
|
|
|
private void Save()
|
|
{
|
|
_settings.StartMinimized = _chkStartMinimized.Checked;
|
|
_settings.SyncOnStart = _chkSyncOnStart.Checked;
|
|
_settings.AutoAcceptOutlookPrompt = _chkAutoAcceptOutlook.Checked;
|
|
_settings.Save();
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
}
|
|
}
|