Add Outlook folder browser and user settings
- Replace Outlook folder ComboBox with TextBox + Browse button that opens a TreeView-based folder browser dialog - Add per-user settings stored in %AppData% (not HKLM) with option to start minimized (System Tray only) - Add Settings button to main window - Settings are per-user, independent of profiles Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,14 +15,18 @@ namespace StarfaceOutlookSync.UI
|
||||
private readonly bool _isNew;
|
||||
|
||||
// Controls
|
||||
private TextBox _txtName, _txtHost, _txtPort, _txtLoginId, _txtPassword;
|
||||
private TextBox _txtName, _txtHost, _txtPort, _txtLoginId, _txtPassword, _txtOutlookFolder;
|
||||
private CheckBox _chkSsl, _chkEnabled;
|
||||
private ComboBox _cmbAddressBook, _cmbOutlookFolder, _cmbDirection;
|
||||
private ComboBox _cmbAddressBook, _cmbDirection;
|
||||
private Button _btnBrowseFolder;
|
||||
private NumericUpDown _numAutoSync;
|
||||
private Button _btnTest, _btnLoadBooks, _btnSave, _btnCancel;
|
||||
private Label _lblTestResult;
|
||||
|
||||
private List<StarfaceAddressBook> _addressBooks = new List<StarfaceAddressBook>();
|
||||
private List<string> _outlookFolderPaths = new List<string>();
|
||||
private string _selectedOutlookPath = "";
|
||||
private string _selectedOutlookName = "";
|
||||
|
||||
public ProfileEditorForm(SyncProfile profile)
|
||||
{
|
||||
@@ -87,8 +91,11 @@ namespace StarfaceOutlookSync.UI
|
||||
panel.Controls.Add(MakeSectionLabel("Outlook-Einstellungen", 12, y)); y += 26;
|
||||
|
||||
panel.Controls.Add(MakeLabel("Kontakte-Ordner:", 12, y)); y += 22;
|
||||
_cmbOutlookFolder = new ComboBox { Left = 12, Top = y, Width = 420, DropDownStyle = ComboBoxStyle.DropDownList };
|
||||
panel.Controls.Add(_cmbOutlookFolder); y += 32;
|
||||
_txtOutlookFolder = new TextBox { Left = 12, Top = y, Width = 330, ReadOnly = true, BackColor = SystemColors.Window };
|
||||
_btnBrowseFolder = new Button { Text = "Durchsuchen...", Left = 348, Top = y - 1, Width = 84, Height = 24 };
|
||||
_btnBrowseFolder.Click += (s, e) => BrowseOutlookFolder();
|
||||
panel.Controls.Add(_txtOutlookFolder);
|
||||
panel.Controls.Add(_btnBrowseFolder); y += 32;
|
||||
|
||||
panel.Controls.Add(MakeLabel("Sync-Richtung:", 12, y)); y += 22;
|
||||
_cmbDirection = new ComboBox { Left = 12, Top = y, Width = 250, DropDownStyle = ComboBoxStyle.DropDownList };
|
||||
@@ -132,18 +139,12 @@ namespace StarfaceOutlookSync.UI
|
||||
{
|
||||
using (var outlook = new OutlookContactsService())
|
||||
{
|
||||
var folders = outlook.GetContactFolderPaths();
|
||||
_cmbOutlookFolder.Items.Clear();
|
||||
foreach (var f in folders)
|
||||
_cmbOutlookFolder.Items.Add(f);
|
||||
if (folders.Count > 0)
|
||||
_cmbOutlookFolder.SelectedIndex = 0;
|
||||
_outlookFolderPaths = outlook.GetContactFolderPaths();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_cmbOutlookFolder.Items.Add("\\\\Kontakte");
|
||||
_cmbOutlookFolder.SelectedIndex = 0;
|
||||
_outlookFolderPaths = new List<string> { "\\\\Kontakte" };
|
||||
}
|
||||
|
||||
// Bestehende Werte laden
|
||||
@@ -160,15 +161,10 @@ namespace StarfaceOutlookSync.UI
|
||||
|
||||
_cmbDirection.SelectedIndex = (int)_existingProfile.SyncDirection;
|
||||
|
||||
// Outlook-Ordner auswaehlen
|
||||
for (int i = 0; i < _cmbOutlookFolder.Items.Count; i++)
|
||||
{
|
||||
if (_cmbOutlookFolder.Items[i].ToString() == _existingProfile.OutlookFolderPath)
|
||||
{
|
||||
_cmbOutlookFolder.SelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Outlook-Ordner
|
||||
_selectedOutlookPath = _existingProfile.OutlookFolderPath;
|
||||
_selectedOutlookName = _existingProfile.OutlookFolderName;
|
||||
_txtOutlookFolder.Text = _selectedOutlookPath;
|
||||
|
||||
// Adressbuch
|
||||
if (_existingProfile.StarfaceAddressBook != null)
|
||||
@@ -178,6 +174,26 @@ namespace StarfaceOutlookSync.UI
|
||||
_cmbAddressBook.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else if (_outlookFolderPaths.Count > 0)
|
||||
{
|
||||
// Standard-Ordner vorauswaehlen
|
||||
_selectedOutlookPath = _outlookFolderPaths[0];
|
||||
_selectedOutlookName = _selectedOutlookPath.Substring(_selectedOutlookPath.LastIndexOf('\\') + 1);
|
||||
_txtOutlookFolder.Text = _selectedOutlookPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void BrowseOutlookFolder()
|
||||
{
|
||||
using (var browser = new OutlookFolderBrowserForm(_outlookFolderPaths, _selectedOutlookPath))
|
||||
{
|
||||
if (browser.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
_selectedOutlookPath = browser.SelectedFolderPath;
|
||||
_selectedOutlookName = browser.SelectedFolderName;
|
||||
_txtOutlookFolder.Text = _selectedOutlookPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private StarfaceConnection GetConnection()
|
||||
@@ -292,10 +308,12 @@ namespace StarfaceOutlookSync.UI
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedFolder = _cmbOutlookFolder.SelectedItem?.ToString() ?? "";
|
||||
var folderName = selectedFolder;
|
||||
if (folderName.Contains("\\"))
|
||||
folderName = folderName.Substring(folderName.LastIndexOf('\\') + 1);
|
||||
if (string.IsNullOrEmpty(_selectedOutlookPath))
|
||||
{
|
||||
MessageBox.Show("Bitte einen Outlook-Kontaktordner waehlen.",
|
||||
"Fehler", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var profile = new SyncProfile
|
||||
{
|
||||
@@ -303,8 +321,8 @@ namespace StarfaceOutlookSync.UI
|
||||
Name = _txtName.Text.Trim(),
|
||||
StarfaceConnection = GetConnection(),
|
||||
StarfaceAddressBook = _addressBooks[_cmbAddressBook.SelectedIndex],
|
||||
OutlookFolderPath = selectedFolder,
|
||||
OutlookFolderName = folderName,
|
||||
OutlookFolderPath = _selectedOutlookPath,
|
||||
OutlookFolderName = _selectedOutlookName,
|
||||
SyncDirection = (SyncDirection)_cmbDirection.SelectedIndex,
|
||||
Enabled = _chkEnabled.Checked,
|
||||
AutoSyncIntervalMinutes = (int)_numAutoSync.Value,
|
||||
|
||||
Reference in New Issue
Block a user