From dcb7c04de1ac07f7004af7d5af8450308ba2e29d Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Sat, 23 Jul 2016 15:25:46 -0400 Subject: Fix panel buttons --- source/WindowsFormsApplication1/Apps/Shifter.cs | 24 +++++++++++- .../Desktop/ShiftOSDesktop.cs | 9 +++++ .../WindowsFormsApplication1/SkinEngine/skins.cs | 44 ++++++++++++++-------- 3 files changed, 59 insertions(+), 18 deletions(-) (limited to 'source/WindowsFormsApplication1') diff --git a/source/WindowsFormsApplication1/Apps/Shifter.cs b/source/WindowsFormsApplication1/Apps/Shifter.cs index ff618cb..3e16184 100644 --- a/source/WindowsFormsApplication1/Apps/Shifter.cs +++ b/source/WindowsFormsApplication1/Apps/Shifter.cs @@ -36,14 +36,14 @@ select new { Type = t, Attributes = attributes.Cast() btn.Text = type.Attributes.First().Name; btn.Click += (o, a) => { - ShowAllPropertyGridsInCategory(btn.Text); + ShowAllPropertyGridsInCategory(Activator.CreateInstance(type.Type)); }; pnlcategories.Widgets.Add(btn); btn.Show(); } } - public void ShowAllPropertyGridsInCategory(string cat) + public void ShowAllPropertyGridsInCategory(object cls) { } @@ -53,13 +53,33 @@ select new { Type = t, Attributes = attributes.Cast() [ShifterPropertyGrid("Desktop")] public class ShifterDesktopSettings { + [Upgrade("skinning")] [SkinMap("images/desktopbackground")] public Image DesktopBackground { get; set; } + [Upgrade("shiftdesktopbackground")] [SkinMap("skin/desktopbackgroundcolour")] public Color DesktopBackgroundColor { get; set; } } + public class UpgradeAttribute : Attribute + { + public UpgradeAttribute(string upgrade) + { + upg = upgrade; + } + + private string upg = ""; + + public bool UpgradeInstalled + { + get + { + return API.Upgrades[upg]; + } + } + } + public class SkinMapAttribute : Attribute { public SkinMapAttribute(string varName) diff --git a/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs b/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs index d8be8a0..6d8af77 100644 --- a/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs +++ b/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs @@ -170,6 +170,15 @@ namespace ShiftOS private void ShiftOSDesktop_Load(object sender, EventArgs e) { + this.pnlpanelbuttonholder.AutoSize = false; + this.pnlpanelbuttonholder.WidgetAdded += (o, a) => + { + pnlpanelbuttonholder.Width += a.Widget.Width + API.CurrentSkin.panelbuttongap; + }; + this.pnlpanelbuttonholder.WidgetRemoved += (o, a) => + { + pnlpanelbuttonholder.Width -= a.Widget.Width + API.CurrentSkin.panelbuttongap; + }; Viruses.CheckForInfected(); this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; diff --git a/source/WindowsFormsApplication1/SkinEngine/skins.cs b/source/WindowsFormsApplication1/SkinEngine/skins.cs index d18770d..b9688ba 100644 --- a/source/WindowsFormsApplication1/SkinEngine/skins.cs +++ b/source/WindowsFormsApplication1/SkinEngine/skins.cs @@ -574,33 +574,45 @@ namespace Skinning /// public static void loadskin() { - if (Directory.Exists(Paths.LoadedSkin)) + try { - string rawData = File.ReadAllText(Paths.LoadedSkin + "data.json"); - loadedSkin = JsonConvert.DeserializeObject(rawData); - if (File.Exists(Paths.LoadedSkin + "panels.json")) + if (Directory.Exists(Paths.LoadedSkin)) { - try - { - string panels = File.ReadAllText(Paths.LoadedSkin + "panels.json"); - loadedSkin.DesktopPanels = JsonConvert.DeserializeObject>(panels); - Application.LoadSkin(loadedSkin); //Send the skin to ShiftUI so buttons and stuff get rendered with custom colors. - LoadPanels(); - } - catch + string rawData = File.ReadAllText(Paths.LoadedSkin + "data.json"); + loadedSkin = JsonConvert.DeserializeObject(rawData); + if (File.Exists(Paths.LoadedSkin + "panels.json")) { + try + { + string panels = File.ReadAllText(Paths.LoadedSkin + "panels.json"); + loadedSkin.DesktopPanels = JsonConvert.DeserializeObject>(panels); + Application.LoadSkin(loadedSkin); //Send the skin to ShiftUI so buttons and stuff get rendered with custom colors. + LoadPanels(); + } + catch + { + } } - } - loadimages(); - LoadEmbeddedNamePack(); + loadimages(); + LoadEmbeddedNamePack(); + } + else + { + loadedSkin = new Skin(); + Application.LoadSkin(loadedSkin); + loadedskin_images = new Images(); + saveskin(); + } } - else + catch { loadedSkin = new Skin(); + Application.LoadSkin(loadedSkin); loadedskin_images = new Images(); saveskin(); + } } -- cgit v1.2.3