From 6b804f03ebcdd1c5aa145f29ae71b62bd61f8cb9 Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Tue, 19 Jul 2016 21:53:26 -0400 Subject: Full ShiftUI conversion The only bugs are that windows don't show in the center of the screen, and Gecko webbrowsers are not serializing properly to be converted to ShiftUI widgets (you can use the ToWidget() extension method to convert a WinForms control to a ShiftUI widget) Also multiple desktop panels are removed due to some odd bug I can't diagnose. Will add them back in the future. Promise. I loved creating GNOME2 skins. --- source/WindowsFormsApplication1/API.cs | 151 +++++---------------------------- 1 file changed, 20 insertions(+), 131 deletions(-) (limited to 'source/WindowsFormsApplication1/API.cs') diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs index 4199223..27625bd 100644 --- a/source/WindowsFormsApplication1/API.cs +++ b/source/WindowsFormsApplication1/API.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Media; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; +using ShiftUI; using System.IO.Compression; using System.Drawing; using Newtonsoft.Json; @@ -83,7 +83,7 @@ namespace ShiftOS public class API { public static Dictionary OpenGUIDs = new Dictionary(); - public static Dictionary DEF_PanelGUIDs = new Dictionary(); + public static Dictionary DEF_PanelGUIDs = new Dictionary(); /// @@ -119,7 +119,7 @@ namespace ShiftOS public static bool InfoboxesPlaySounds = true; - public static void SkinControl(Control c) + public static void SkinWidget(Widget c) { if(c is Button) { @@ -128,9 +128,9 @@ namespace ShiftOS } if(c is Panel || c is FlowLayoutPanel) { - foreach(Control child in c.Controls) + foreach(Widget child in c.Widgets) { - SkinControl(child); + SkinWidget(child); } } } @@ -1070,136 +1070,25 @@ namespace ShiftOS { API.CurrentSession = new ShiftOSDesktop(); } - try + + formToCreate.Text = AppName; + formToCreate.TopMost = true; + formToCreate.Show(); + var brdr = new WindowBorder(AppName, AppIcon); + brdr.Tag = "api_brdr"; + formToCreate.Widgets.Add(brdr); + brdr.Show(); + foreach(Widget widget in formToCreate.Body.Widgets) { - if (Upgrades["multitasking"] == false && formToCreate.Name != "infobox") + if(widget != brdr) { - CloseEverything(); + brdr.pgcontents.Widgets.Add(widget); + widget.Show(); } - var bw = new BackgroundWorker(); - bw.DoWork += (object sen, DoWorkEventArgs eva) => - { - WindowComposition.SafeToAddControls = false; - //bugfix: Close any terminal if WindowedTerminal isn't installed. - if (Upgrades["windowedterminal"] == false) - { - API.CurrentSession.Invoke(new Action(() => - { - foreach (Form frm in OpenPrograms) - { - if (frm.Name.ToLower() == "terminal") - { - API.CurrentSession.Invoke(new Action(() => - { - frm.Close(); - })); - } - } - })); - } - WindowBorder brdr = new WindowBorder(AppName, AppIcon); - brdr.Name = "api_brdr"; - formToCreate.Controls.Add(brdr); - formToCreate.ShowInTaskbar = false; - brdr.Show(); - formToCreate.FormBorderStyle = FormBorderStyle.None; - brdr.Dock = DockStyle.Fill; - BordersToUpdate.Add(brdr); - List duplicates = new List(); - foreach (Control ctrl in formToCreate.Controls) - { - if (ctrl.Name != "api_brdr") - { - ctrl.Hide(); - brdr.pgcontents.Controls.Add(ctrl); - duplicates.Add(ctrl); - } - } - foreach (Control ctrl in duplicates) - { - try - { - formToCreate.Controls.Remove(ctrl); - ctrl.Show(); - SkinControl(ctrl); - } - catch - { - API.CurrentSession.Invoke(new Action(() => - { - ctrl.Show(); - SkinControl(ctrl); - })); - } - } - WindowComposition.ShowForm(formToCreate, CurrentSkin.WindowOpenAnimation); - API.CurrentSession.Invoke(new Action(() => - { - brdr.justopened = true; - formToCreate.TopMost = true; - - //Open terminal on CTRL+T press on any form. - formToCreate.KeyDown += (object sender, KeyEventArgs e) => - { - if (e.KeyCode == Keys.T && e.Control && formToCreate.Name != "Terminal") - { - CurrentSession.InvokeCTRLT(); - } - if (formToCreate.Name != "Terminal" || Upgrades["windowedterminal"] == true) - { - //Movable Windows - if (API.Upgrades["movablewindows"] == true) - { - if (e.KeyCode == Keys.A && e.Control) - { - e.Handled = true; - formToCreate.Location = new Point(formToCreate.Location.X - 30, formToCreate.Location.Y); - } - if (e.KeyCode == Keys.D && e.Control) - { - e.Handled = true; - formToCreate.Location = new Point(formToCreate.Location.X + 30, formToCreate.Location.Y); - } - if (e.KeyCode == Keys.W && e.Control) - { - e.Handled = true; - formToCreate.Location = new Point(formToCreate.Location.X, formToCreate.Location.Y - 30); - } - if (e.KeyCode == Keys.S && e.Control) - { - e.Handled = true; - formToCreate.Location = new Point(formToCreate.Location.X, formToCreate.Location.Y + 30); - } - } - } - }; - formToCreate.TransparencyKey = Skinning.Utilities.globaltransparencycolour; - OpenPrograms.Add(formToCreate); - if (AppName == "Enemy Hacker") - { - API.CurrentSession.Invoke(new Action(() => - { - formToCreate.Left = Screen.PrimaryScreen.Bounds.Width - formToCreate.Width; - })); - } - else if (AppName == "You") - { - API.CurrentSession.Invoke(new Action(() => - { - formToCreate.Left = 0; - })); - } - })); - WindowComposition.SafeToAddControls = true; - API.OpenGUIDs.Add(formToCreate, Guid.NewGuid().ToString()); - API.CurrentSession.Invoke(new Action(() => { CurrentSession.InvokeWindowOp("open", formToCreate); })); - }; - bw.RunWorkerAsync(); - } - catch - { - } + brdr.Dock = DockStyle.Fill; + formToCreate.Body.BorderStyle = BorderStyle.None; + brdr.setupall(); } /// -- cgit v1.2.3