DeskCore 1.0.0

Desktop-Icons in eigene Kategorien sortieren: Windows-11-Design (hell/dunkel),
Desktop-Boxen, automatisches Einsortieren nach Regeln, Rückgängig, Suche,
Infobereich mit Tastenkürzel, Sicherung als ZIP und Installer ohne Adminrechte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 20:19:32 +02:00
co-authored by Claude Opus 5.5
commit 77bb3e6b9d
36 changed files with 5894 additions and 0 deletions
+76
View File
@@ -0,0 +1,76 @@
using System.IO;
namespace DeskCore;
/// <summary>
/// Übernimmt Daten früherer Namen dieser App ("DesktopSortierer", "DeskHub") einmalig nach "DeskCore".
/// Darf Storage/AppSettings nicht anfassen – läuft, bevor deren Pfade festgelegt werden.
/// </summary>
public static class Migration
{
private const string NewName = "DeskCore";
/// <summary>Frühere Namen, neuester zuerst.</summary>
private static readonly string[] LegacyNames = ["DeskHub", "DesktopSortierer"];
private static readonly Environment.SpecialFolder[] Folders =
[
Environment.SpecialFolder.UserProfile, // Kategorien
Environment.SpecialFolder.ApplicationData, // Einstellungen
Environment.SpecialFolder.LocalApplicationData, // Zwischenablage für Rückgängig
];
public static void Run()
{
if (FindLegacy() is { } legacy)
{
foreach (var folder in Folders)
{
var baseDir = Environment.GetFolderPath(folder);
var oldPath = Path.Combine(baseDir, legacy);
var newPath = Path.Combine(baseDir, NewName);
if (!Directory.Exists(oldPath) || Directory.Exists(newPath)) continue;
try { Directory.Move(oldPath, newPath); } // gleiches Laufwerk → sofort, auch bei großen Ordnern
catch { /* z. B. Ordner gerade im Explorer geöffnet → Pick() nimmt den alten weiter */ }
}
}
Autostart.Migrate();
}
/// <summary>
/// Ältester noch vorhandener Datenbestand dieser App. "DeskHub" heißt auch ein anderes Programm –
/// deshalb zählt ein Ordner nur, wenn dort unsere Einstellungsdatei liegt.
/// </summary>
private static string? FindLegacy()
{
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (Directory.Exists(Path.Combine(appData, NewName))) return null; // schon umgezogen
foreach (var name in LegacyNames)
if (IsOurs(Path.Combine(appData, name))) return name;
// Ganz alte Versionen hatten evtl. noch keine Einstellungsdatei – nur die Kategorien
var profile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
return Directory.Exists(Path.Combine(profile, "DesktopSortierer")) ? "DesktopSortierer" : null;
}
private static bool IsOurs(string settingsDir)
{
try
{
var file = Path.Combine(settingsDir, "settings.json");
if (!File.Exists(file)) return false;
var json = File.ReadAllText(file);
return json.Contains("\"CategoryOrder\"") && json.Contains("\"FencesEnabled\"");
}
catch { return false; }
}
/// <summary>Neuer Ordner – außer der Umzug hat nicht geklappt und nur der alte existiert.</summary>
public static string Pick(Environment.SpecialFolder folder, params string[] sub)
{
var baseDir = Environment.GetFolderPath(folder);
if (!Directory.Exists(Path.Combine(baseDir, NewName)) && FindLegacy() is { } legacy
&& Directory.Exists(Path.Combine(baseDir, legacy)))
return Path.Combine([baseDir, legacy, .. sub]);
return Path.Combine([baseDir, NewName, .. sub]);
}
}