From 28a087d2d4961fd80d827df968de0f6f63da07eb Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 4 Feb 2017 11:14:39 -0500 Subject: Add name changer backend You can use the DefaultTitleAttribute on an IShiftOSWindow to specify a default title for the window and name changer entry. --- ShiftOS_TheReturn/AppearanceManager.cs | 45 ++++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/Skinning.cs | 3 +++ 2 files changed, 48 insertions(+) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index dd205b2..112bca5 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -75,6 +76,39 @@ namespace ShiftOS.Engine } } + public static IEnumerable GetAllWindowTypes() + { + List types = new List(); + foreach(var file in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(file.EndsWith(".exe") || file.EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(file); + foreach(var type in asm.GetTypes()) + { + if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) + types.Add(type); + } + } + catch { } + } + } + return types; + } + + public static string GetDefaultTitle(Type winType) + { + foreach(var attrib in winType.GetCustomAttributes(false)) + { + if(attrib is DefaultTitleAttribute) + { + return (attrib as DefaultTitleAttribute).Title; + } + } + return winType.Name; + } public static string LastTerminalText { get; set; } public static int CurrentPosition { get; set; } @@ -205,4 +239,15 @@ namespace ShiftOS.Engine string Text { get; set; } IShiftOSWindow ParentWindow { get; set; } } + + public class DefaultTitleAttribute : Attribute + { + public DefaultTitleAttribute(string title) + { + Title = title; + } + + public string Title { get; private set; } + } + } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 80945b8..b3dddd3 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -137,6 +137,9 @@ namespace ShiftOS.Engine { return JsonConvert.SerializeObject(this, Formatting.Indented); } + [ShifterHidden] + public Dictionary AppNames = new Dictionary(); + [ShifterMeta("Windows")] [ShifterCategory("Titlebar")] [RequiresUpgrade("shift_title_text")] -- cgit v1.2.3