Upload via GUI (180 Dateien)
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace DeskCore;
|
||||
|
||||
/// <summary>Einstellungen der Desktop-Boxen: Portale, Schnell verstecken, Peek, Chamäleon und Snapshots.</summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
/// <summary>Box geschlossen o. Ä. → Kennzeichnung "hat Box" in der Seitenleiste aktualisieren.</summary>
|
||||
public void RefreshFromFences()
|
||||
{
|
||||
Refresh();
|
||||
if (InSettings) { LoadFenceSettings(); LoadDesktopSettings(); }
|
||||
}
|
||||
|
||||
private void LoadFenceSettings()
|
||||
{
|
||||
QuickHideToggle.IsChecked = S.QuickHide;
|
||||
PeekToggle.IsChecked = S.PeekEnabled;
|
||||
PeekHint.Text = $"{Hotkey.Describe(S.PeekModifiers, S.PeekKey)} holt alle Boxen vor die offenen Fenster. " +
|
||||
"Nochmal drücken, Esc oder woanders hinklicken schickt sie zurück.";
|
||||
ChameleonToggle.IsChecked = S.FenceChameleon;
|
||||
SnapshotList.ItemsSource = null;
|
||||
SnapshotList.ItemsSource = S.Snapshots.OrderByDescending(x => x.Created).ToList();
|
||||
}
|
||||
|
||||
private void AddPortal_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int before = S.Fences.Count;
|
||||
FenceManager.AddPortal();
|
||||
if (S.Fences.Count > before) ShowToast("Ordner-Portal liegt jetzt auf dem Desktop", "");
|
||||
LoadSettingsView();
|
||||
}
|
||||
|
||||
private void QuickHideToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
S.QuickHide = QuickHideToggle.IsChecked == true;
|
||||
S.Save();
|
||||
DesktopToggle.Apply();
|
||||
}
|
||||
|
||||
private void PeekToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
S.PeekEnabled = PeekToggle.IsChecked == true;
|
||||
S.Save();
|
||||
if (!App.ApplyPeekHotkey())
|
||||
PeekHint.Text = "⚠ Diese Tastenkombination ist schon von einem anderen Programm belegt.";
|
||||
}
|
||||
|
||||
private void ChameleonToggle_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
S.FenceChameleon = ChameleonToggle.IsChecked == true;
|
||||
S.Save();
|
||||
FenceManager.RefreshAll();
|
||||
}
|
||||
|
||||
// ---------- Snapshots ----------
|
||||
|
||||
private void SaveSnapshot_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (S.Fences.Count == 0)
|
||||
{
|
||||
ShowToast("Es gibt noch keine Boxen zum Speichern", "", info: true);
|
||||
return;
|
||||
}
|
||||
var name = Dialog.Prompt(this, "Anordnung speichern", "Name für diese Anordnung (z. B. „Arbeit“ oder „Zocken“):",
|
||||
$"Anordnung {S.Snapshots.Count + 1}", "Speichern",
|
||||
t => t.Trim().Length == 0 ? "Bitte einen Namen eingeben." : t.Contains('"') ? "Bitte ohne Anführungszeichen." : null);
|
||||
if (name is null) return;
|
||||
bool replace = S.Snapshots.Any(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
FenceManager.SaveSnapshot(name);
|
||||
LoadFenceSettings();
|
||||
ShowToast(replace ? $"Anordnung „{name}“ aktualisiert" : $"Anordnung „{name}“ gespeichert", "");
|
||||
}
|
||||
|
||||
private void RestoreSnapshot(FenceSnapshot snap)
|
||||
{
|
||||
var before = FenceManager.RestoreSnapshot(snap);
|
||||
var entry = new UndoEntry($"Anordnung „{snap.Name}“ laden");
|
||||
entry.Add(() => { FenceManager.ApplyFences(before); return null; });
|
||||
Undo.Push(entry);
|
||||
Refresh();
|
||||
ShowToast($"Anordnung „{snap.Name}“ wiederhergestellt", "", undoable: true);
|
||||
}
|
||||
|
||||
private void RestoreSnapshot_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if ((sender as FrameworkElement)?.Tag is FenceSnapshot snap) RestoreSnapshot(snap);
|
||||
}
|
||||
|
||||
private void DeleteSnapshot_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if ((sender as FrameworkElement)?.Tag is not FenceSnapshot snap) return;
|
||||
S.Snapshots.Remove(snap);
|
||||
S.Save();
|
||||
var entry = new UndoEntry($"Anordnung „{snap.Name}“ löschen");
|
||||
entry.Add(() => { S.Snapshots.Add(snap); S.Save(); return null; });
|
||||
Undo.Push(entry);
|
||||
LoadFenceSettings();
|
||||
ShowToast($"Anordnung „{snap.Name}“ gelöscht", "", undoable: true);
|
||||
}
|
||||
|
||||
/// <summary>Für die Befehlszeile: DeskCore.exe --snapshot "Name".</summary>
|
||||
public void RestoreSnapshotByName(string name)
|
||||
{
|
||||
var snap = S.Snapshots.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
if (snap is null) App.TrayIcon?.Notify("Anordnung nicht gefunden", $"Es gibt keine gespeicherte Anordnung „{name}“.");
|
||||
else RestoreSnapshot(snap);
|
||||
}
|
||||
|
||||
// ---------- Regeln: Name oder Dateityp ----------
|
||||
|
||||
private void RuleKind_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if ((sender as FrameworkElement)?.Tag is not SortRule r) return;
|
||||
r.Kind = r.Kind == "Typ" ? "Name" : "Typ";
|
||||
S.Save();
|
||||
LoadSettingsView();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user