diff options
| author | Michael <[email protected]> | 2017-02-18 10:37:11 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-18 10:37:11 -0500 |
| commit | 9b8d5861a954610713ae66a53d2ac067991d9b68 (patch) | |
| tree | e550f758e52ec8ca12357d91c9fa13907e70c4f3 /ShiftOS.WinForms/Applications/ExperienceShifter.cs | |
| parent | 30823a0778614d0f9fd6f82b5d9eb03aab41280d (diff) | |
| download | shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.gz shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.bz2 shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.zip | |
WHOA LUA STUFF :dancer:
Diffstat (limited to 'ShiftOS.WinForms/Applications/ExperienceShifter.cs')
| -rw-r--r-- | ShiftOS.WinForms/Applications/ExperienceShifter.cs | 51 |
1 files changed, 50 insertions, 1 deletions
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<IDesktop> GetAllDesktops() + { + List<IDesktop> dekstops = new List<IDesktop>(); + 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<ShiftOSConfigFile>(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<string>((script) => + { + ShiftOSConfigFile conf = new WinForms.ShiftOSConfigFile(); + if (Utils.FileExists(Paths.GetPath("conf.sft"))) + { + conf = JsonConvert.DeserializeObject<ShiftOSConfigFile>(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 + { + + } + } + } } } |
