Files
DeskCore/Models.cs
T
M_ViperandClaude Opus 5.5 77bb3e6b9d 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>
2026-10-01 20:19:32 +02:00

98 lines
3.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.ComponentModel;
using System.IO;
using System.Windows.Media;
namespace DeskCore;
public class CategoryItem
{
public required string Name { get; init; }
public bool IsDesktop { get; init; }
public int Count { get; set; }
public string Folder => IsDesktop ? Storage.UserDesktop : Storage.CategoryPath(Name);
public CategoryMeta? Meta => IsDesktop ? null : AppSettings.Current.Categories.GetValueOrDefault(Name);
public string Glyph => IsDesktop ? "" : Meta?.Glyph ?? "";
public Brush? GlyphBrush => CategoryColors.Brush(Meta?.Color);
public bool HasFence => Meta?.Fence == true;
}
public static class CategoryColors
{
public static readonly (string Name, string Hex)[] All =
[
("Blau", "#3B82F6"), ("Türkis", "#12A594"), ("Grün", "#22A06B"), ("Gelb", "#E2A600"),
("Orange", "#F07A1A"), ("Rot", "#E5484D"), ("Pink", "#D6409F"), ("Lila", "#8E4EC6"), ("Grau", "#8B8D98"),
];
public static Brush? Brush(string? hex)
{
if (string.IsNullOrEmpty(hex)) return null;
try
{
var b = new SolidColorBrush((Color)ColorConverter.ConvertFromString(hex));
b.Freeze();
return b;
}
catch { return null; }
}
}
public static class CategoryGlyphs
{
public static readonly (string Glyph, string Name)[] All =
[
("", "Ordner"), ("", "Spiele"), ("", "Arbeit"), ("", "Code"),
("", "Musik"), ("", "Video"), ("", "Bilder"), ("", "Internet"),
("", "Mail"), ("", "Shopping"), ("", "System"), ("", "Werkzeuge"),
("", "Dokumente"), ("", "Favoriten"), ("", "Herz"), ("", "Cloud"),
("", "Downloads"), ("", "Personen"), ("", "Bibliothek"), ("", "Rechner"),
("", "Ideen"), ("", "Zuhause"), ("", "Lernen"), ("", "Erweiterungen"),
("", "Computer"), ("", "Sicherheit"), ("", "Ebenen"),
];
}
public class IconItem : INotifyPropertyChanged
{
public required string Path { get; init; }
public string? Category { get; init; }
private ImageSource? _icon;
public ImageSource? Icon
{
get => _icon;
set { _icon = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Icon))); }
}
/// <summary>Nur für Desktop-Icons: Kategorie, in der bereits eine Kopie liegt.</summary>
public string? SortedInto { get; init; }
public bool IsSorted => SortedInto is not null;
public string Name => Storage.DisplayName(Path);
public string TypeText
{
get
{
if (Directory.Exists(Path)) return "Ordner";
var ext = System.IO.Path.GetExtension(Path).ToLowerInvariant();
return ext switch
{
".lnk" => "Verknüpfung",
".url" => "Internetverknüpfung",
".exe" => "Programm",
"" => "Datei",
_ => ext.TrimStart('.').ToUpperInvariant() + "-Datei",
};
}
}
public string LocationText => SortedInto is not null ? $"✓ gesichert in {SortedInto}" : Category ?? "";
public string ToolTip =>
SortedInto is not null ? $"{Name}\n✓ Bereits gesichert in „{SortedInto}“ – kann vom Desktop gelöscht werden." :
Category is not null ? $"{Name}\nOrt: {Category}" : $"{Name}\n{TypeText}";
public event PropertyChangedEventHandler? PropertyChanged;
}