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/Apps/BitnoteWallet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/WindowsFormsApplication1/Apps/BitnoteWallet.cs') diff --git a/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs b/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs index 6d5cb9f..7b19c70 100644 --- a/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs +++ b/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs @@ -10,7 +10,7 @@ using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; +using ShiftUI; namespace ShiftOS { -- cgit v1.2.3 From b52090021ff0ae61db652e8a486cbff6732f5ec5 Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Wed, 20 Jul 2016 13:52:12 -0400 Subject: Move ShiftUI designer to ShiftOS and add prober for ShiftOS to allow ShiftUI designer to design ShiftOS forms. --- source/ShiftOS.sln | 6 ++ source/ShiftUI/Theming/ShiftOS.cs | 5 ++ source/ShiftUI/Theming/ThemeSkinnable.cs | 33 +++++----- source/WindowsFormsApplication1/API.cs | 1 + .../WindowsFormsApplication1/Apps/BitnoteWallet.cs | 15 +++-- .../Apps/Shifter.Designer.cs | 9 +-- .../Controls/ProgressBarEX.cs | 8 +-- .../WindowsFormsApplication1/Engine/Lua_Interp.cs | 4 +- source/WindowsFormsApplication1/Program.cs | 72 ++++++++++++---------- 9 files changed, 80 insertions(+), 73 deletions(-) (limited to 'source/WindowsFormsApplication1/Apps/BitnoteWallet.cs') diff --git a/source/ShiftOS.sln b/source/ShiftOS.sln index ccf69a3..ef829cd 100644 --- a/source/ShiftOS.sln +++ b/source/ShiftOS.sln @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftUI", "ShiftUI\ShiftUI.csproj", "{C56E34D0-4749-4A73-9469-BCCD063569CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShiftUI Designer", "..\..\Project-Circle\ShiftUI Designer\ShiftUI Designer.csproj", "{20C1A600-B5C2-4226-B5B6-3F17716D2669}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {C56E34D0-4749-4A73-9469-BCCD063569CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {C56E34D0-4749-4A73-9469-BCCD063569CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {C56E34D0-4749-4A73-9469-BCCD063569CD}.Release|Any CPU.Build.0 = Release|Any CPU + {20C1A600-B5C2-4226-B5B6-3F17716D2669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20C1A600-B5C2-4226-B5B6-3F17716D2669}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20C1A600-B5C2-4226-B5B6-3F17716D2669}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20C1A600-B5C2-4226-B5B6-3F17716D2669}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/source/ShiftUI/Theming/ShiftOS.cs b/source/ShiftUI/Theming/ShiftOS.cs index 00e9b1a..7950c18 100644 --- a/source/ShiftUI/Theming/ShiftOS.cs +++ b/source/ShiftUI/Theming/ShiftOS.cs @@ -14,6 +14,7 @@ namespace ShiftUI.ShiftOS public Color ButtonBorderColor = Color.Black; public Color ButtonBackColor = Color.White; public Color ButtonBackColor_Pressed = Color.Gray; + public Color ButtonBackColor_Checked = Color.Black; #endregion #region Global @@ -55,6 +56,10 @@ namespace ShiftUI.ShiftOS #endregion + #region ListView + public Color ListViewBackground = Color.White; + #endregion + // No reason to have ShiftOS deal with window borders itself // when I can do it inside ShiftUI. #region Form diff --git a/source/ShiftUI/Theming/ThemeSkinnable.cs b/source/ShiftUI/Theming/ThemeSkinnable.cs index 6772251..5ea8a4d 100644 --- a/source/ShiftUI/Theming/ThemeSkinnable.cs +++ b/source/ShiftUI/Theming/ThemeSkinnable.cs @@ -2973,7 +2973,7 @@ namespace ShiftUI // border is drawn directly in the Paint method if (details && control.HeaderStyle != ColumnHeaderStyle.None) { - dc.FillRectangle(SystemBrushes.Control, + dc.FillRectangle(new SolidBrush(Application.CurrentSkin.ListViewBackground), 0, 0, control.TotalWidth, control.Font.Height + 5); if (control.Columns.Count > 0) { @@ -6923,67 +6923,64 @@ namespace ShiftUI private void CPDrawButtonInternal(Graphics dc, Rectangle rectangle, ButtonState state, Pen DarkPen, Pen NormalPen, Pen LightPen) { // sadly enough, the rectangle gets always filled with a hatchbrush - dc.FillRectangle(ResPool.GetHatchBrush(HatchStyle.Percent50, - Color.FromArgb(Clamp(ColorControl.R + 3, 0, 255), - ColorControl.G, ColorControl.B), - ColorControl), + dc.FillRectangle(new SolidBrush(Application.CurrentSkin.ButtonBackColor), rectangle.X + 1, rectangle.Y + 1, rectangle.Width - 2, rectangle.Height - 2); if ((state & ButtonState.All) == ButtonState.All || ((state & ButtonState.Checked) == ButtonState.Checked && (state & ButtonState.Flat) == ButtonState.Flat)) { - dc.FillRectangle(ResPool.GetHatchBrush(HatchStyle.Percent50, ColorControlLight, ColorControl), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4); + dc.FillRectangle(new SolidBrush(Application.CurrentSkin.ButtonBackColor_Checked), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4); - dc.DrawRectangle(SystemPens.ControlDark, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1); + dc.DrawRectangle(new Pen(new SolidBrush(Application.CurrentSkin.ButtonBorderColor), Application.CurrentSkin.ButtonBorderWidth), rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1); } else if ((state & ButtonState.Flat) == ButtonState.Flat) { - dc.DrawRectangle(SystemPens.ControlDark, rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1); + dc.DrawRectangle(new Pen(new SolidBrush(Application.CurrentSkin.ButtonBorderColor), Application.CurrentSkin.ButtonBorderWidth), rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1); } else if ((state & ButtonState.Checked) == ButtonState.Checked) { - dc.FillRectangle(ResPool.GetHatchBrush(HatchStyle.Percent50, ColorControlLight, ColorControl), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4); + dc.FillRectangle(new SolidBrush(Application.CurrentSkin.ButtonBackColor_Checked), rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4); - Pen pen = DarkPen; + Pen pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DTopLeftInner)); dc.DrawLine(pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2); dc.DrawLine(pen, rectangle.X + 1, rectangle.Y, rectangle.Right - 2, rectangle.Y); - pen = NormalPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRight)); dc.DrawLine(pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 3); dc.DrawLine(pen, rectangle.X + 2, rectangle.Y + 1, rectangle.Right - 3, rectangle.Y + 1); - pen = LightPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRightInner)); dc.DrawLine(pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 2, rectangle.Bottom - 1); dc.DrawLine(pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1); } else if (((state & ButtonState.Pushed) == ButtonState.Pushed) && ((state & ButtonState.Normal) == ButtonState.Normal)) { - Pen pen = DarkPen; + Pen pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DTopLeftInner)); dc.DrawLine(pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2); dc.DrawLine(pen, rectangle.X + 1, rectangle.Y, rectangle.Right - 2, rectangle.Y); - pen = NormalPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRight)); dc.DrawLine(pen, rectangle.X + 1, rectangle.Y + 1, rectangle.X + 1, rectangle.Bottom - 3); dc.DrawLine(pen, rectangle.X + 2, rectangle.Y + 1, rectangle.Right - 3, rectangle.Y + 1); - pen = LightPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRightInner)); dc.DrawLine(pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 2, rectangle.Bottom - 1); dc.DrawLine(pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 1); } else if (((state & ButtonState.Inactive) == ButtonState.Inactive) || ((state & ButtonState.Normal) == ButtonState.Normal)) { - Pen pen = LightPen; + Pen pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DTopLeftInner)); dc.DrawLine(pen, rectangle.X, rectangle.Y, rectangle.Right - 2, rectangle.Y); dc.DrawLine(pen, rectangle.X, rectangle.Y, rectangle.X, rectangle.Bottom - 2); - pen = NormalPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRight)); dc.DrawLine(pen, rectangle.X + 1, rectangle.Bottom - 2, rectangle.Right - 2, rectangle.Bottom - 2); dc.DrawLine(pen, rectangle.Right - 2, rectangle.Y + 1, rectangle.Right - 2, rectangle.Bottom - 3); - pen = DarkPen; + pen = new Pen(new SolidBrush(Application.CurrentSkin.Border3DBottomRightInner)); dc.DrawLine(pen, rectangle.X, rectangle.Bottom - 1, rectangle.Right - 1, rectangle.Bottom - 1); dc.DrawLine(pen, rectangle.Right - 1, rectangle.Y, rectangle.Right - 1, rectangle.Bottom - 2); } diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs index 4434fc7..ce0ad8c 100644 --- a/source/WindowsFormsApplication1/API.cs +++ b/source/WindowsFormsApplication1/API.cs @@ -1926,6 +1926,7 @@ namespace ShiftOS public static Color[] yellowmemory = new Color[16]; public static Color[] pinkmemory = new Color[16]; internal static Dictionary> LuaShifterRegistry = null; + public static bool ShouldLoadEngine = true; #endregion } diff --git a/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs b/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs index 7b19c70..3a7164e 100644 --- a/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs +++ b/source/WindowsFormsApplication1/Apps/BitnoteWallet.cs @@ -22,14 +22,17 @@ namespace ShiftOS public BitnoteWallet() { InitializeComponent(); - Clients = new List(); - foreach(var c in Package_Grabber.clients) + if (API.ShouldLoadEngine) { - if(c.Value.IsConnected) + Clients = new List(); + foreach (var c in Package_Grabber.clients) { - var client = new BitnoteClient(c.Key); - client.GetBank(); - Clients.Add(client); + if (c.Value.IsConnected) + { + var client = new BitnoteClient(c.Key); + client.GetBank(); + Clients.Add(client); + } } } } diff --git a/source/WindowsFormsApplication1/Apps/Shifter.Designer.cs b/source/WindowsFormsApplication1/Apps/Shifter.Designer.cs index 04a61d3..568822e 100644 --- a/source/WindowsFormsApplication1/Apps/Shifter.Designer.cs +++ b/source/WindowsFormsApplication1/Apps/Shifter.Designer.cs @@ -443,7 +443,6 @@ namespace ShiftOS this.pnlshifterintro.SuspendLayout(); this.pnldesktopoptions.SuspendLayout(); this.pnldesktoppaneloptions.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).BeginInit(); this.pnlapplauncheroptions.SuspendLayout(); this.pnldesktopintro.SuspendLayout(); this.pnlpanelbuttonsoptions.SuspendLayout(); @@ -453,7 +452,6 @@ namespace ShiftOS this.predesktoppanel.SuspendLayout(); this.prepnlpanelbuttonholder.SuspendLayout(); this.prepnlpanelbutton.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pretbicon)).BeginInit(); this.pretimepanel.SuspendLayout(); this.preapplaunchermenuholder.SuspendLayout(); this.predesktopappmenu.SuspendLayout(); @@ -472,7 +470,6 @@ namespace ShiftOS this.prepgleft.SuspendLayout(); this.prepgright.SuspendLayout(); this.pretitlebar.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.prepnlicon)).BeginInit(); this.pnlreset.SuspendLayout(); this.pgcontents.SuspendLayout(); this.pnldesktopcomposition.SuspendLayout(); @@ -5123,7 +5120,7 @@ namespace ShiftOS this.pnldesktopoptions.ResumeLayout(false); this.pnldesktoppaneloptions.ResumeLayout(false); this.pnldesktoppaneloptions.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).EndInit(); + //((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).EndInit(); this.pnlapplauncheroptions.ResumeLayout(false); this.pnlapplauncheroptions.PerformLayout(); this.pnldesktopintro.ResumeLayout(false); @@ -5139,7 +5136,7 @@ namespace ShiftOS this.prepnlpanelbuttonholder.ResumeLayout(false); this.prepnlpanelbutton.ResumeLayout(false); this.prepnlpanelbutton.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pretbicon)).EndInit(); + //((System.ComponentModel.ISupportInitialize)(this.pretbicon)).EndInit(); this.pretimepanel.ResumeLayout(false); this.pretimepanel.PerformLayout(); this.preapplaunchermenuholder.ResumeLayout(false); @@ -5169,7 +5166,7 @@ namespace ShiftOS this.prepgright.ResumeLayout(false); this.pretitlebar.ResumeLayout(false); this.pretitlebar.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.prepnlicon)).EndInit(); + //((System.ComponentModel.ISupportInitialize)(this.prepnlicon)).EndInit(); this.pnlreset.ResumeLayout(false); this.pgcontents.ResumeLayout(false); this.pgcontents.PerformLayout(); diff --git a/source/WindowsFormsApplication1/Controls/ProgressBarEX.cs b/source/WindowsFormsApplication1/Controls/ProgressBarEX.cs index d89969e..8febdcd 100644 --- a/source/WindowsFormsApplication1/Controls/ProgressBarEX.cs +++ b/source/WindowsFormsApplication1/Controls/ProgressBarEX.cs @@ -102,13 +102,7 @@ namespace ShiftOS get { return _MaxValue; } set { - if (value > this.MinValue) - { - _MaxValue = value; - } - else { - throw new ArgumentOutOfRangeException("The maximum value must be more than the minimum value."); - } + _MaxValue = value; } } diff --git a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs index fabc1be..d36b4d9 100644 --- a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs +++ b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs @@ -1466,9 +1466,7 @@ end"); /// The converted widget. public static Widget ToWidget(this System.Windows.Forms.Control ctrl) { - string json = JsonConvert.SerializeObject(ctrl); - json = json.Replace("Control", "Widget"); - return JsonConvert.DeserializeObject(json); + return new Controls.WinFormsHost(ctrl); } } } diff --git a/source/WindowsFormsApplication1/Program.cs b/source/WindowsFormsApplication1/Program.cs index 5f3f1ad..af294db 100644 --- a/source/WindowsFormsApplication1/Program.cs +++ b/source/WindowsFormsApplication1/Program.cs @@ -12,24 +12,24 @@ using Newtonsoft.Json; namespace ShiftOS { - static class Program + public static class Program { /// /// The main entry point for the application. /// [STAThread] - static void Main(string[] args) + public static void Main(string[] args) { - Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Extract all dependencies before starting the engine. ExtractDependencies(); - var poolThread = new Thread(new ThreadStart(new Action(() => { + var poolThread = new Thread(new ThreadStart(new Action(() => + { try { - //Download ShiftOS server startup-pool - string pool = new WebClient().DownloadString("http://playshiftos.ml/server/startup_pool"); + //Download ShiftOS server startup-pool + string pool = new WebClient().DownloadString("http://playshiftos.ml/server/startup_pool"); string[] splitter = pool.Split(';'); foreach (string address in splitter) { @@ -55,13 +55,14 @@ namespace ShiftOS //Start the Windows Forms backend Paths.RegisterPaths(); //Sets ShiftOS path variables based on the current OS. SaveSystem.Utilities.CheckForOlderSaves(); //Backs up C:\ShiftOS on Windows systems if it exists and doesn't contain a _engineInfo.txt file telling ShiftOS what engine created it. - //If there isn't a save folder at the directory specified by ShiftOS.Paths.SaveRoot, create a new save. - //If not, load that save. + //If there isn't a save folder at the directory specified by ShiftOS.Paths.SaveRoot, create a new save. + //If not, load that save. if (Directory.Exists(Paths.SaveRoot)) { API.Log("Loading ShiftOS save..."); SaveSystem.Utilities.loadGame(); - } else + } + else { SaveSystem.Utilities.NewGame(); } @@ -80,44 +81,48 @@ namespace ShiftOS Skinning.Utilities.loadskin(); SaveSystem.ShiftoriumRegistry.UpdateShiftorium(); //Lua bootscreen. - if(File.Exists(Paths.SaveRoot + "BOOT")) + if (File.Exists(Paths.SaveRoot + "BOOT")) { string lua = File.ReadAllText(Paths.SaveRoot + "BOOT"); var l = new LuaInterpreter(); l.mod(lua); } //Start recieving calls from the Modding API... - Application.Run(new ShiftOSDesktop()); - //By now, the API receiver has been loaded, - //and the desktop is shown. So, let's check - //for auto-start mods. - if(Directory.Exists(Paths.AutoStart)) + if (!args.Contains("nodisplay")) { - foreach(string file in Directory.GetFiles(Paths.AutoStart)) + Application.Run(new ShiftOSDesktop()); + //By now, the API receiver has been loaded, + //and the desktop is shown. So, let's check + //for auto-start mods. + if (Directory.Exists(Paths.AutoStart)) { - var inf = new FileInfo(file); - switch(inf.Extension) + foreach (string file in Directory.GetFiles(Paths.AutoStart)) { - case ".saa": - if (API.Upgrades["shiftnet"] == true) - { - API.Log("Starting start-up mod \"" + inf.FullName + "\"..."); - API.LaunchMod(inf.FullName); - } - break; - case ".trm": - var t = new Terminal(); - t.runterminalfile(inf.FullName); - API.Log("Started terminal file \"" + inf.FullName + "\"..."); - break; - } } + var inf = new FileInfo(file); + switch (inf.Extension) + { + case ".saa": + if (API.Upgrades["shiftnet"] == true) + { + API.Log("Starting start-up mod \"" + inf.FullName + "\"..."); + API.LaunchMod(inf.FullName); + } + break; + case ".trm": + var t = new Terminal(); + t.runterminalfile(inf.FullName); + API.Log("Started terminal file \"" + inf.FullName + "\"..."); + break; + } + } + } } //Now, for some ShiftOS launcher integration. try { - if(args[0] != null) + if (args[0] != null) { - if(args[0] != "") + if (args[0] != "") { API.CurrentSave.username = args[0]; //Username set. @@ -130,6 +135,7 @@ namespace ShiftOS } } + static void ExtractDependencies() { //Wow. This'll make it easy for people... -- cgit v1.2.3