diff --git a/src/StarfaceOutlookSync/UI/MainForm.cs b/src/StarfaceOutlookSync/UI/MainForm.cs index 35170ffe..15778e24 100644 --- a/src/StarfaceOutlookSync/UI/MainForm.cs +++ b/src/StarfaceOutlookSync/UI/MainForm.cs @@ -18,7 +18,7 @@ namespace StarfaceOutlookSync.UI private NotifyIcon _trayIcon; private ContextMenuStrip _trayMenu; private ListView _profileList; - private Button _btnNew, _btnEdit, _btnDelete, _btnSync, _btnSettings, _btnInfo; + private Button _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnInfo; private StatusStrip _statusBar; private ToolStripStatusLabel _statusLabel; private Timer _autoSyncTimer; @@ -97,16 +97,19 @@ namespace StarfaceOutlookSync.UI _btnDelete = new Button { Text = "Loeschen", Width = 80, Height = 30 }; _btnDelete.Click += (s, e) => DeleteProfile(); - _btnSync = new Button { Text = "Jetzt synchronisieren", Width = 150, Height = 30 }; + _btnSync = new Button { Text = "Synchronisieren", Width = 110, Height = 30 }; _btnSync.Click += async (s, e) => await SyncSelectedProfile(); - _btnSettings = new Button { Text = "Einstellungen", Width = 100, Height = 30 }; + _btnReset = new Button { Text = "Sync Reset", Width = 80, Height = 30 }; + _btnReset.Click += (s, e) => ResetSync(); + + _btnSettings = new Button { Text = "Einstellungen", Width = 95, Height = 30 }; _btnSettings.Click += (s, e) => ShowSettings(); _btnInfo = new Button { Text = "Info", Width = 50, Height = 30 }; _btnInfo.Click += (s, e) => ShowAbout(); - buttonPanel.Controls.AddRange(new Control[] { _btnNew, _btnEdit, _btnDelete, _btnSync, _btnSettings, _btnInfo }); + buttonPanel.Controls.AddRange(new Control[] { _btnNew, _btnEdit, _btnDelete, _btnSync, _btnReset, _btnSettings, _btnInfo }); // Statusbar _statusBar = new StatusStrip(); @@ -255,6 +258,36 @@ namespace StarfaceOutlookSync.UI } } + private void ResetSync() + { + if (_profileList.SelectedItems.Count == 0) + { + MessageBox.Show("Bitte ein Profil auswaehlen.", "Sync Reset", + MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + + var profile = _profileList.SelectedItems[0].Tag as SyncProfile; + if (profile == null) return; + + var msg = $"Sync-Zuordnungen fuer '{profile.Name}' zuruecksetzen?\n\n" + + "Alle Kontakt-Verknuepfungen werden geloescht.\n" + + "Beim naechsten Sync werden die Kontakte neu abgeglichen.\n" + + "Es werden keine Kontakte geloescht."; + + if (MessageBox.Show(msg, "Sync Reset", + MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) + { + _profileManager.SaveMappings(profile.Id, new List()); + // LastSync auch zuruecksetzen + profile.LastSync = ""; + _profileManager.UpdateProfile(profile); + RefreshProfileList(); + MessageBox.Show("Sync-Zuordnungen wurden zurueckgesetzt.", + "Sync Reset", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + private Task SyncSelectedProfile() { if (_profileList.SelectedItems.Count == 0)