From 9b8d5861a954610713ae66a53d2ac067991d9b68 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 18 Feb 2017 10:37:11 -0500 Subject: WHOA LUA STUFF :dancer: --- ShiftOS.WinForms/Applications/ExperienceShifter.cs | 51 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/Applications/ExperienceShifter.cs') diff --git a/ShiftOS.WinForms/Applications/ExperienceShifter.cs b/ShiftOS.WinForms/Applications/ExperienceShifter.cs index 2623b88..281b723 100644 --- a/ShiftOS.WinForms/Applications/ExperienceShifter.cs +++ b/ShiftOS.WinForms/Applications/ExperienceShifter.cs @@ -9,6 +9,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using ShiftOS.Objects.ShiftFS; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -42,12 +44,27 @@ namespace ShiftOS.WinForms.Applications public void PopulateDesktops() { lbdesktops.Items.Clear(); - foreach(var desk in Desktop.GetAllDesktops()) + foreach(var desk in GetAllDesktops()) { lbdesktops.Items.Add(desk.DesktopName); } } + public List GetAllDesktops() + { + List dekstops = new List(); + dekstops.Add(new WinformsDesktop()); + if (!Utils.FileExists(Paths.GetPath("conf.sft"))) + Utils.WriteAllText(Paths.GetPath("conf.sft"), JsonConvert.SerializeObject(new ShiftOSConfigFile(), Formatting.Indented)); + + foreach(var script in JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("conf.sft"))).Desktops) + { + if(Utils.FileExists(script)) + dekstops.Add(new LuaDesktop(script)); + } + return dekstops; + } + public void PopulateLaunchers() { lblaunchers.Items.Clear(); @@ -83,5 +100,37 @@ namespace ShiftOS.WinForms.Applications currentUI = "applauncher"; SetupUI(); } + + private void addToolStripMenuItem_Click(object sender, EventArgs e) + { + FileSkimmerBackend.GetFile(new[] { ".lua" }, FileOpenerStyle.Open, new Action((script) => + { + ShiftOSConfigFile conf = new WinForms.ShiftOSConfigFile(); + if (Utils.FileExists(Paths.GetPath("conf.sft"))) + { + conf = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("conf.sft"))); + } + conf.Desktops.Add(script); + Utils.WriteAllText(Paths.GetPath("conf.sft"), JsonConvert.SerializeObject(conf, Formatting.Indented)); + })); + } + + private void lbdesktops_SelectedIndexChanged(object sender, EventArgs e) + { + foreach(var desk in GetAllDesktops()) + { + try + { + if(desk.DesktopName == lbdesktops.SelectedItem.ToString()) + { + Desktop.Init(desk, true); + } + } + catch + { + + } + } + } } } -- cgit v1.2.3