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/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/WindowsFormsApplication1/Program.cs') diff --git a/source/WindowsFormsApplication1/Program.cs b/source/WindowsFormsApplication1/Program.cs index 0cb9096..5f3f1ad 100644 --- a/source/WindowsFormsApplication1/Program.cs +++ b/source/WindowsFormsApplication1/Program.cs @@ -3,7 +3,7 @@ using System.IO; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using System.Windows.Forms; +using ShiftUI; using System.Net; using System.IO.Compression; using System.ComponentModel; @@ -178,7 +178,7 @@ namespace ShiftOS } catch { - MessageBox.Show("Sorry to break the immersion, but we're currently downloading ShiftOS dependencies that'll make the game run MUCH better, such as the Lua engine and Gecko web renderer. Give us a moment. ShiftOS will continue to run while this happens but some things won't work right until we're finished."); + MessageBox.Show("Sorry to break the immersion, but we're currently downloading ShiftOS dependencies that'll make the game run MUCH better, such as the Lua engine and Gecko web renderer. Give us a moment. ShiftOS will continue to run while this happens but some things won't work right until we're finished.", "Dependency download"); wc.DownloadFileAsync(new Uri("http://playshiftos.ml/shiftos/dependencies/ShiftOS_Dependencies.zip"), zippath); } -- 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/Program.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 From bf7a488011c09be39bdb4980c2bb020cb1fdb71a Mon Sep 17 00:00:00 2001 From: Carver Harrison Date: Sun, 24 Jul 2016 11:17:36 -0700 Subject: Added Hashing API and Fixed Bugs --- source/ShiftUI Designer/Program.cs | 8 +- source/WindowsFormsApplication1/API.cs | 720 +++++++++++---------- .../Desktop/ShiftOSDesktop.cs | 332 +++++----- source/WindowsFormsApplication1/Program.cs | 16 +- 4 files changed, 566 insertions(+), 510 deletions(-) (limited to 'source/WindowsFormsApplication1/Program.cs') diff --git a/source/ShiftUI Designer/Program.cs b/source/ShiftUI Designer/Program.cs index 7e4be98..4ca9e98 100644 --- a/source/ShiftUI Designer/Program.cs +++ b/source/ShiftUI Designer/Program.cs @@ -1423,10 +1423,10 @@ namespace ShiftUI_DesignerGenerated { forms.Add(type.Name, Activator.CreateInstance(type) as Form); } } - catch - { - - } + catch (Exception catcherror) + { + Console.WriteLine(catcherror); + } } foreach(var item in forms) { diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs index e81788d..157f373 100644 --- a/source/WindowsFormsApplication1/API.cs +++ b/source/WindowsFormsApplication1/API.cs @@ -80,341 +80,391 @@ namespace ShiftOS } - public class API - { - public static Dictionary OpenGUIDs = new Dictionary(); - public static Dictionary DEF_PanelGUIDs = new Dictionary(); - - - /// - /// Settings file. - /// - public static Settings LoadedSettings = null; - - /// - /// Whether or not dev commands like '05tray' are available. - /// Typically, this is set to true if the release is classified as - /// an alpha, beta, or release candidate. - /// - /// Turn it off if the release is the final RC, or the stable release! - /// - /// Enabling developer mode will cause the save engine to not encrypt the save file - /// or Shiftorium Registry on save, enabling you to easily modify your save - /// to test new features or to bring in lots of codepoints. This is why - /// Developer mode should ALWAYS be off in non-dev releases, to prevent cheating. - /// - public static bool DeveloperMode = true; - - /// - /// If this is true, only certain applications will open and only - /// certain features will work. - /// - /// This is useful for story plots like the End Game where you don't - /// want the user being distracted by novelty features when they should - /// be focusing on what's happening. - /// - /// Think of it like the opposite of what Developer Mode would do. - /// - public static bool LimitedMode = false; - - public static bool InfoboxesPlaySounds = true; - - public static void SkinWidget(Widget c) - { - if(c is Button) - { - var b = c as Button; - b.FlatStyle = FlatStyle.Standard; - } - if(c is Panel || c is FlowLayoutPanel) - { - foreach(Widget child in c.Widgets) - { - SkinWidget(child); - } - } - } - - public static List RunningModProcesses = new List(); - public static Dictionary CommandAliases = new Dictionary(); - public static Terminal LoggerTerminal = null; - - // Alternate Names for True and False - public static bool yes = true; - public static bool no = false; - - /// - /// Logs an exception to the log. - /// - /// The text to log. - /// Is it a fatal crash? - public static void LogException(string Message, bool fatal) - { - if(!File.Exists(Paths.SystemDir + "_Log.txt")) - { - if (fatal == true) - { - File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " [ExWatch/WARNING] ShiftOS has encountered an UNHANDLED exception with message \"" + Message + "\". Report this to Michael as well as what you were doing when it happened ASAP."); - } - else - { - File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " ShiftOS encountered a handled exception with message \"" + Message + "\" and was able to keep going. Ignore this."); - } - } - else - { - List Entries = new List(); - foreach(string entry in File.ReadAllLines(Paths.SystemDir + "_Log.txt")) { - Entries.Add(entry); - } - if (fatal == true) - { - Entries.Add(GetLogTime() + " [ExWatch/WARNING] ShiftOS has encountered an UNHANDLED exception with message \"" + Message + "\". Report this to Michael as well as what you were doing when it happened ASAP."); - } - else - { - Entries.Add(GetLogTime() + " ShiftOS encountered a handled exception with message \"" + Message + "\" and was able to keep going. Ignore this."); - } - File.WriteAllLines(Paths.SystemDir + "_Log.txt", Entries.ToArray()); - } - } - - /// - /// Logs text to the log file. - /// - /// The text to log. - public static void Log(string Message) - { - if (!File.Exists(Paths.SystemDir + "_Log.txt")) - { - File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " " + Message); - } - else - { - List Entries = new List(); - foreach (string entry in File.ReadAllLines(Paths.SystemDir + "_Log.txt")) - { - Entries.Add(entry); - } - Entries.Add(GetLogTime() + " " + Message); - File.WriteAllLines(Paths.SystemDir + "_Log.txt", Entries.ToArray()); - } - } - - /// - /// Gets a proper-formatted date/time string for the log. - /// - /// - public static string GetLogTime() - { - return "[" + DateTime.Now.ToLongDateString() + "\\" + DateTime.Now.ToLongTimeString() + "]"; - } - - /// - /// Property representing the currently loaded name pack. - /// - public static Skinning.NamePack LoadedNames - { - get - { - if (Skinning.Utilities.LoadedNames != null) - { - return Skinning.Utilities.LoadedNames; - } - else - { - Skinning.Utilities.LoadedNames = new Skinning.NamePack(); - Skinning.Utilities.loadedSkin.EmbeddedNamePackPath = "names.npk"; - Skinning.Utilities.SaveEmbeddedNamePack(); - Log("[Name Changer] Couldn't locate loaded name pack, using default name pack."); - return Skinning.Utilities.LoadedNames; - } - } - } - - /// - /// Adds a command line alias. - /// - /// Alias name - /// Command to run. - /// - public static bool AddAlias(string key, string value) - { - if(!AliasExists(key)) - { - CommandAliases.Add(key, value); - return true; - } - else - { - return false; - } - } - - /// - /// Saves alias list to save game. - /// - public static void SaveAliases() - { - string json = JsonConvert.SerializeObject(CommandAliases); - File.WriteAllText(Paths.SystemDir + "_aliases.json", json); - } - - /// - /// Loads alias list from the save game. - /// - public static void LoadAliases() - { - if (File.Exists(Paths.SystemDir + "_aliases.json")) { - string json = File.ReadAllText(Paths.SystemDir + "_aliases.json"); - CommandAliases = JsonConvert.DeserializeObject>(json); - } - else - { - CommandAliases = new Dictionary(); - } - - } - - /// - /// Removes an alias from the list. - /// - /// Alias to remove. - /// Whether the alias could be removed. - public static bool RemoveAlias(string key) - { - if(AliasExists(key)) - { - CommandAliases.Remove(key); - return true; - } - else - { - return false; - } - } - - /// - /// Checks if the provided alias exists. - /// - /// The alias to check. - /// Whether the alias exists. - public static bool AliasExists(string key) - { - bool no = false; - foreach(KeyValuePair kv in CommandAliases) - { - if(kv.Key == key) - { - no = true; - } - } - return no; - } - - /// - /// I have no idea what this does - Michael - /// - /// - public static void CreateNewLoggerTerminal(string AppName) - { - CreateForm(new Terminal(true), AppName, Properties.Resources.iconTerminal); - } - - public const string HiddenAPMCommand = "0Ifm0DcBBy10VZo/p4r1Jg=="; - public const string HiddenBTNConvertCommand = "js2qrls5kvZnutMbfH46sUKzKVrBtjzPlWn/wIIe/3g="; - public const string HiddenDodgeCommand = "mpL4WPUoDcZrsXnNUJ5RWQ=="; - public const string HiddenLabyrinthCommand = "NbNzpplGKaS5D/RdwrQMXw=="; - public const string HiddenQuickChatCommand = "iQm+/qDqgkHT/zgPiYRlZQ=="; - public const string HiddenShiftnetCommand = "NCM++hbZox7B+m9tXRXGnw=="; - public const string HiddenBWalletCommand = "1nLiZELFcaxkXDufrLuyfw=="; - public const string HiddenBDiggerCommand = "g/efSjsaglt//dr3XHnPOw=="; - public const string HiddenDecryptorCommand = "CYPXaweggfWAuS7ONt/OPQ=="; - - /// - /// Launches an saa file, hooks it up to the Lua API, and runs it. - /// - /// File to run. - public static void LaunchMod(string modSAA) - { - if (!LimitedMode) - { - if (Upgrades["shiftnet"] == true) - { - if (File.Exists(modSAA)) - { - if (File.ReadAllText(modSAA) == HiddenAPMCommand) - { - CreateForm(new Appscape(), "Appscape Package Manager", Properties.Resources.iconAppscape); - } - else if (File.ReadAllText(modSAA) == HiddenDecryptorCommand) - { - CreateForm(new ShiftnetDecryptor(), "Shiftnet Decryptor", Properties.Resources.iconShiftnet); - } - else if (File.ReadAllText(modSAA) == HiddenBDiggerCommand) - { - CreateForm(new BitnoteDigger(), "Bitnote Digger", Properties.Resources.iconBitnoteDigger); - } - else if (File.ReadAllText(modSAA) == HiddenBWalletCommand) - { - CreateForm(new BitnoteWallet(), "Bitnote Wallet", Properties.Resources.iconBitnoteWallet); - } - else if (File.ReadAllText(modSAA) == HiddenShiftnetCommand) - { - CreateForm(new Shiftnet(), "Shiftnet", Properties.Resources.iconShiftnet); - } - else if (File.ReadAllText(modSAA) == HiddenBTNConvertCommand) - { - CreateForm(new BitnoteConverter(), "Bitnote Converter", Properties.Resources.iconBitnoteWallet); - } - else if (File.ReadAllText(modSAA) == HiddenDodgeCommand) - { - CreateForm(new Dodge(), "Dodge", Properties.Resources.iconDodge); - } - else if (File.ReadAllText(modSAA) == HiddenLabyrinthCommand) - { - CreateForm(new Labyrinth(), "Labyrinth", null); - } - else - { - try - { - ExtractFile(modSAA, Paths.Mod_Temp, true); - var l = new LuaInterpreter(Paths.Mod_Temp + "main.lua"); - } - catch (Exception ex) - { - LogException("Error launching mod file (.saa): " + ex.Message, false); - CreateInfoboxSession("Error", "Could not launch the .saa file you specified. It is unsupported by this version of ShiftOS.", infobox.InfoboxMode.Info); - } - } - var story_rnd = new Random(); - int story_chance = story_rnd.Next(0, 3); - switch (story_chance) { - case 2: - if(API.Upgrades["holochat"] == false) - { - var t = new Terminal(); - API.CreateForm(t, API.LoadedNames.TerminalName, API.GetIcon("Terminal")); - t.StartDevXFuriousStory(); - t.BringToFront(); - } - break; - } - - } - else - { - throw new ModNotFoundException(); - } - } - } - else - { - CreateInfoboxSession("Limited mode", "ShiftOS is in limited mode and cannot perform this action. Please complete the current Mission first.", infobox.InfoboxMode.Info); - } - } - + public class API + { + public static Dictionary OpenGUIDs = new Dictionary(); + public static Dictionary DEF_PanelGUIDs = new Dictionary(); + + + /// + /// Settings file. + /// + public static Settings LoadedSettings = null; + + /// + /// Whether or not dev commands like '05tray' are available. + /// Typically, this is set to true if the release is classified as + /// an alpha, beta, or release candidate. + /// + /// Turn it off if the release is the final RC, or the stable release! + /// + /// Enabling developer mode will cause the save engine to not encrypt the save file + /// or Shiftorium Registry on save, enabling you to easily modify your save + /// to test new features or to bring in lots of codepoints. This is why + /// Developer mode should ALWAYS be off in non-dev releases, to prevent cheating. + /// + public static bool DeveloperMode = true; + + /// + /// If this is true, only certain applications will open and only + /// certain features will work. + /// + /// This is useful for story plots like the End Game where you don't + /// want the user being distracted by novelty features when they should + /// be focusing on what's happening. + /// + /// Think of it like the opposite of what Developer Mode would do. + /// + public static bool LimitedMode = false; + + public static bool InfoboxesPlaySounds = true; + + public static void SkinWidget(Widget c) + { + if (c is Button) + { + var b = c as Button; + b.FlatStyle = FlatStyle.Standard; + } + if (c is Panel || c is FlowLayoutPanel) + { + foreach (Widget child in c.Widgets) + { + SkinWidget(child); + } + } + } + + public static List RunningModProcesses = new List(); + public static Dictionary CommandAliases = new Dictionary(); + public static Terminal LoggerTerminal = null; + + // Alternate Names for True and False + public static bool yes = true; + public static bool no = false; + + /// + /// Logs an exception to the log. + /// + /// The text to log. + /// Is it a fatal crash? + public static void LogException(string Message, bool fatal) + { + if (!File.Exists(Paths.SystemDir + "_Log.txt")) + { + if (fatal == true) + { + File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " [ExWatch/WARNING] ShiftOS has encountered an UNHANDLED exception with message \"" + Message + "\". Report this to Michael as well as what you were doing when it happened ASAP."); + } + else + { + File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " ShiftOS encountered a handled exception with message \"" + Message + "\" and was able to keep going. Ignore this."); + } + } + else + { + List Entries = new List(); + foreach (string entry in File.ReadAllLines(Paths.SystemDir + "_Log.txt")) + { + Entries.Add(entry); + } + if (fatal == true) + { + Entries.Add(GetLogTime() + " [ExWatch/WARNING] ShiftOS has encountered an UNHANDLED exception with message \"" + Message + "\". Report this to Michael as well as what you were doing when it happened ASAP."); + } + else + { + Entries.Add(GetLogTime() + " ShiftOS encountered a handled exception with message \"" + Message + "\" and was able to keep going. Ignore this."); + } + File.WriteAllLines(Paths.SystemDir + "_Log.txt", Entries.ToArray()); + } + } + + /// + /// Logs text to the log file. + /// + /// The text to log. + public static void Log(string Message) + { + if (!File.Exists(Paths.SystemDir + "_Log.txt")) + { + File.WriteAllText(Paths.SystemDir + "_Log.txt", GetLogTime() + " " + Message); + } + else + { + List Entries = new List(); + foreach (string entry in File.ReadAllLines(Paths.SystemDir + "_Log.txt")) + { + Entries.Add(entry); + } + Entries.Add(GetLogTime() + " " + Message); + File.WriteAllLines(Paths.SystemDir + "_Log.txt", Entries.ToArray()); + } + } + + /// + /// Gets a proper-formatted date/time string for the log. + /// + /// + public static string GetLogTime() + { + return "[" + DateTime.Now.ToLongDateString() + "\\" + DateTime.Now.ToLongTimeString() + "]"; + } + + /// + /// Property representing the currently loaded name pack. + /// + public static Skinning.NamePack LoadedNames + { + get + { + if (Skinning.Utilities.LoadedNames != null) + { + return Skinning.Utilities.LoadedNames; + } + else + { + Skinning.Utilities.LoadedNames = new Skinning.NamePack(); + Skinning.Utilities.loadedSkin.EmbeddedNamePackPath = "names.npk"; + Skinning.Utilities.SaveEmbeddedNamePack(); + Log("[Name Changer] Couldn't locate loaded name pack, using default name pack."); + return Skinning.Utilities.LoadedNames; + } + } + } + + /// + /// Adds a command line alias. + /// + /// Alias name + /// Command to run. + /// + public static bool AddAlias(string key, string value) + { + if (!AliasExists(key)) + { + CommandAliases.Add(key, value); + return true; + } + else + { + return false; + } + } + + /// + /// Saves alias list to save game. + /// + public static void SaveAliases() + { + string json = JsonConvert.SerializeObject(CommandAliases); + File.WriteAllText(Paths.SystemDir + "_aliases.json", json); + } + + /// + /// Loads alias list from the save game. + /// + public static void LoadAliases() + { + if (File.Exists(Paths.SystemDir + "_aliases.json")) + { + string json = File.ReadAllText(Paths.SystemDir + "_aliases.json"); + CommandAliases = JsonConvert.DeserializeObject>(json); + } + else + { + CommandAliases = new Dictionary(); + } + + } + + /// + /// Removes an alias from the list. + /// + /// Alias to remove. + /// Whether the alias could be removed. + public static bool RemoveAlias(string key) + { + if (AliasExists(key)) + { + CommandAliases.Remove(key); + return true; + } + else + { + return false; + } + } + + /// + /// Checks if the provided alias exists. + /// + /// The alias to check. + /// Whether the alias exists. + public static bool AliasExists(string key) + { + bool nay = false; + foreach (KeyValuePair kv in CommandAliases) + { + if (kv.Key == key) + { + nay = true; + } + } + return nay; + } + + /// + /// I have no idea what this does - Michael + /// + /// + public static void CreateNewLoggerTerminal(string AppName) + { + CreateForm(new Terminal(true), AppName, Properties.Resources.iconTerminal); + } + + public const string HiddenAPMCommand = "0Ifm0DcBBy10VZo/p4r1Jg=="; + public const string HiddenBTNConvertCommand = "js2qrls5kvZnutMbfH46sUKzKVrBtjzPlWn/wIIe/3g="; + public const string HiddenDodgeCommand = "mpL4WPUoDcZrsXnNUJ5RWQ=="; + public const string HiddenLabyrinthCommand = "NbNzpplGKaS5D/RdwrQMXw=="; + public const string HiddenQuickChatCommand = "iQm+/qDqgkHT/zgPiYRlZQ=="; + public const string HiddenShiftnetCommand = "NCM++hbZox7B+m9tXRXGnw=="; + public const string HiddenBWalletCommand = "1nLiZELFcaxkXDufrLuyfw=="; + public const string HiddenBDiggerCommand = "g/efSjsaglt//dr3XHnPOw=="; + public const string HiddenDecryptorCommand = "CYPXaweggfWAuS7ONt/OPQ=="; + + /// + /// Launches an saa file, hooks it up to the Lua API, and runs it. + /// + /// File to run. + public static void LaunchMod(string modSAA) + { + if (!LimitedMode) + { + if (Upgrades["shiftnet"] == true) + { + if (File.Exists(modSAA)) + { + if (File.ReadAllText(modSAA) == HiddenAPMCommand) + { + CreateForm(new Appscape(), "Appscape Package Manager", Properties.Resources.iconAppscape); + } + else if (File.ReadAllText(modSAA) == HiddenDecryptorCommand) + { + CreateForm(new ShiftnetDecryptor(), "Shiftnet Decryptor", Properties.Resources.iconShiftnet); + } + else if (File.ReadAllText(modSAA) == HiddenBDiggerCommand) + { + CreateForm(new BitnoteDigger(), "Bitnote Digger", Properties.Resources.iconBitnoteDigger); + } + else if (File.ReadAllText(modSAA) == HiddenBWalletCommand) + { + CreateForm(new BitnoteWallet(), "Bitnote Wallet", Properties.Resources.iconBitnoteWallet); + } + else if (File.ReadAllText(modSAA) == HiddenShiftnetCommand) + { + CreateForm(new Shiftnet(), "Shiftnet", Properties.Resources.iconShiftnet); + } + else if (File.ReadAllText(modSAA) == HiddenBTNConvertCommand) + { + CreateForm(new BitnoteConverter(), "Bitnote Converter", Properties.Resources.iconBitnoteWallet); + } + else if (File.ReadAllText(modSAA) == HiddenDodgeCommand) + { + CreateForm(new Dodge(), "Dodge", Properties.Resources.iconDodge); + } + else if (File.ReadAllText(modSAA) == HiddenLabyrinthCommand) + { + CreateForm(new Labyrinth(), "Labyrinth", null); + } + else + { + try + { + ExtractFile(modSAA, Paths.Mod_Temp, true); + var l = new LuaInterpreter(Paths.Mod_Temp + "main.lua"); + } + catch (Exception ex) + { + LogException("Error launching mod file (.saa): " + ex.Message, false); + CreateInfoboxSession("Error", "Could not launch the .saa file you specified. It is unsupported by this version of ShiftOS.", infobox.InfoboxMode.Info); + } + } + var story_rnd = new Random(); + int story_chance = story_rnd.Next(0, 3); + switch (story_chance) + { + case 2: + if (API.Upgrades["holochat"] == false) + { + var t = new Terminal(); + API.CreateForm(t, API.LoadedNames.TerminalName, API.GetIcon("Terminal")); + t.StartDevXFuriousStory(); + t.BringToFront(); + } + break; + } + + } + else + { + throw new ModNotFoundException(); + } + } + } + else + { + CreateInfoboxSession("Limited mode", "ShiftOS is in limited mode and cannot perform this action. Please complete the current Mission first.", infobox.InfoboxMode.Info); + } + } + + /// + /// Base64 Function + /// + public static class Base64 + { + public static string Encrypt(string text) + { + return Convert.ToBase64String(Encoding.UTF8.GetBytes(text)); + } + + public static string Decrypt(string text) + { + return Encoding.UTF8.GetString(Convert.FromBase64String(text)); + } + } + + /// + /// Hashing API + /// By Carver Harrison (@carverh) + /// + public static class Hash + { + public static string MD5(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.MD5.Create(text).Hash); + } + public static string SHA1(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.SHA1.Create(text).Hash); + } + public static string SHA256(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.SHA256.Create(text).Hash); + } + public static string SHA384(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.SHA384.Create(text).Hash); + } + public static string SHA512(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.SHA512.Create(text).Hash); + } + public static string DSA(string text) + { + return Encoding.UTF8.GetString(System.Security.Cryptography.DSA.Create().CreateSignature(Encoding.UTF8.GetBytes(text))); + } + } /// /// Source: http://stackoverflow.com/questions/10168240/encrypting-decrypting-a-string-in-c-sharp diff --git a/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs b/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs index 6d8af77..85659c2 100644 --- a/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs +++ b/source/WindowsFormsApplication1/Desktop/ShiftOSDesktop.cs @@ -327,45 +327,53 @@ namespace ShiftOS public void SetupDesktop() { - SetupRenderers(); - SetupDesktopPanel(); - SetupAppLauncher(); - SetupDesktopIcons(); - SetupGNOME2Elements(); - SetupPanelClock(); - SetupPanelButtons(); - CheckUnity(); - SetupWidgets(); - CheckForChristmas(); - //Set up the context menus. - addDesktopPanelToolStripMenuItem.Visible = API.Upgrades["advanceddesktop"]; - widgetManagerToolStripMenuItem.Visible = API.Upgrades["advanceddesktop"]; - if (API.Upgrades["advanceddesktop"]) - { - AppLauncherPanel.ContextMenuStrip = cbwidget; - Clock.ContextMenuStrip = cbwidget; - PanelButtonHolder.ContextMenuStrip = cbwidget; - } - else - { - AppLauncherPanel.ContextMenuStrip = null; - Clock.ContextMenuStrip = null; - PanelButtonHolder.ContextMenuStrip = null; - } - if (DesktopPanels != null) { - foreach (var dp in DesktopPanels) - { - if (API.Upgrades["advanceddesktop"]) - { - dp.ContextMenuStrip = cbdpanel; - } - else - { - dp.ContextMenuStrip = cbdpanel; - } - } - } - OnDesktopReload?.Invoke(); + try + { + SetupRenderers(); + SetupDesktopPanel(); + SetupAppLauncher(); + SetupDesktopIcons(); + SetupGNOME2Elements(); + SetupPanelClock(); + SetupPanelButtons(); + CheckUnity(); + SetupWidgets(); + CheckForChristmas(); + //Set up the context menus. + addDesktopPanelToolStripMenuItem.Visible = API.Upgrades["advanceddesktop"]; + widgetManagerToolStripMenuItem.Visible = API.Upgrades["advanceddesktop"]; + if (API.Upgrades["advanceddesktop"]) + { + AppLauncherPanel.ContextMenuStrip = cbwidget; + Clock.ContextMenuStrip = cbwidget; + PanelButtonHolder.ContextMenuStrip = cbwidget; + } + else + { + AppLauncherPanel.ContextMenuStrip = null; + Clock.ContextMenuStrip = null; + PanelButtonHolder.ContextMenuStrip = null; + } + if (DesktopPanels != null) + { + foreach (var dp in DesktopPanels) + { + if (API.Upgrades["advanceddesktop"]) + { + dp.ContextMenuStrip = cbdpanel; + } + else + { + dp.ContextMenuStrip = cbdpanel; + } + } + } + OnDesktopReload?.Invoke(); + } + catch (Exception catcherror) + { + Console.WriteLine(catcherror); + } } public void SetupWidgets() @@ -1072,23 +1080,23 @@ namespace ShiftOS if (API.Upgrades["usefulpanelbuttons"]) { Widget ctrl = (Widget)sender; - try - { - PanelButton pbtn = (PanelButton)ctrl.Tag; - var frm = pbtn.FormToManage; - if(frm.Left < Screen.PrimaryScreen.Bounds.Width) - { - API.MinimizeForm(frm); - } - else - { - API.ToggleMinimized(frm); - } - } - catch - { - - } + try + { + PanelButton pbtn = (PanelButton)ctrl.Tag; + var frm = pbtn.FormToManage; + if (frm.Left < Screen.PrimaryScreen.Bounds.Width) + { + API.MinimizeForm(frm); + } + else + { + API.ToggleMinimized(frm); + } + } + catch (Exception catcherror) + { + Console.WriteLine(catcherror); + } } } @@ -1315,113 +1323,111 @@ namespace ShiftOS public static List Icons = null; public static List Models = null; - public static void GetIcons() - { - Icons = new List(); - Models = new List(); - API.GetAppLauncherItems(); - if (!Directory.Exists(Paths.Desktop)) - { - Directory.CreateDirectory(Paths.Desktop); - } - else - { - foreach (string dir in Directory.GetDirectories(Paths.Desktop)) - { - //Get dir info - var dinf = new DirectoryInfo(dir); - //Create new IconModel - var m = new IconModel(); - //Set name to dir name - m.Name = dinf.Name; - //Set type to Directory - m.Type = IconType.Directory; - //Set lua to open directory in File Skimmer - m.Lua = $"fileskimmer('/Home/Desktop/{dinf.Name}')"; - Models.Add(m); - } - foreach (string file in Directory.GetFiles(Paths.Desktop)) - { - //Get file info - var finf = new FileInfo(file); - //Create new IconModel - var icm = new IconModel(); - //Set IconModel name to filename - icm.Name = finf.Name; - //Set IconModel's type based on file extension - switch (finf.Extension.ToLower()) //Make the string lower-case for ease of use. - { - case ".desktop": - //Desktop script. - icm.Type = IconType.Script; - icm.Lua = File.ReadAllText(finf.FullName); //The Lua that is to be ran by this script is in the file. - break; - case ".sct": - //Desktop Shortcut - NYI - break; - default: - //File. - icm.Type = IconType.File; - icm.Lua = $"fopen('/Home/Desktop/{finf.Name}')"; - break; - } - Models.Add(icm); - } - } - - foreach(IconModel m in Models) - { - var d = new DesktopIcon(); - d.IconName = m.Name; - d.LuaAction = m.Lua; - switch(m.Type) - { - case IconType.Directory: - d.Icon = API.GetIcon("Folder"); - break; - default: - var finf = new FileInfo(Paths.Desktop + d.IconName); - switch(finf.Extension) - { - case ".txt": - case ".doc": - case ".owd": - case ".docx": - d.Icon = API.GetIcon("TextFile"); - break; - case ".skn": - case ".spk": - d.Icon = API.GetIcon("SkinFile"); - break; - case ".saa": - d.Icon = API.GetIcon("SAAFile"); - break; - case ".pkg": - case ".stp": - d.Icon = API.GetIcon("SetupPackage"); - break; - default: - d.Icon = API.GetIcon("UnrecognizedFile"); - break; - } - break; - } - Icons.Add(d); - } - foreach (ApplauncherItem al in API.AppLauncherItems) - { - if (al.Display == true) - { - var dl = new DesktopIcon(); - dl.Icon = al.Icon; - dl.IconName = al.Name; - dl.LuaAction = al.Lua; - Icons.Add(dl); - } - } - - } - + public static void GetIcons() + { + Icons = new List(); + Models = new List(); + API.GetAppLauncherItems(); + if (!Directory.Exists(Paths.Desktop)) + { + Directory.CreateDirectory(Paths.Desktop); + } + else + { + foreach (string dir in Directory.GetDirectories(Paths.Desktop)) + { + //Get dir info + var dinf = new DirectoryInfo(dir); + //Create new IconModel + var m = new IconModel(); + //Set name to dir name + m.Name = dinf.Name; + //Set type to Directory + m.Type = IconType.Directory; + //Set lua to open directory in File Skimmer + m.Lua = $"fileskimmer('/Home/Desktop/{dinf.Name}')"; + Models.Add(m); + } + foreach (string file in Directory.GetFiles(Paths.Desktop)) + { + //Get file info + var finf = new FileInfo(file); + //Create new IconModel + var icm = new IconModel(); + //Set IconModel name to filename + icm.Name = finf.Name; + //Set IconModel's type based on file extension + switch (finf.Extension.ToLower()) //Make the string lower-case for ease of use. + { + case ".desktop": + //Desktop script. + icm.Type = IconType.Script; + icm.Lua = File.ReadAllText(finf.FullName); //The Lua that is to be ran by this script is in the file. + break; + case ".sct": + //Desktop Shortcut - NYI + break; + default: + //File. + icm.Type = IconType.File; + icm.Lua = $"fopen('/Home/Desktop/{finf.Name}')"; + break; + } + Models.Add(icm); + } + } + + foreach (IconModel m in Models) + { + var d = new DesktopIcon(); + d.IconName = m.Name; + d.LuaAction = m.Lua; + switch (m.Type) + { + case IconType.Directory: + d.Icon = API.GetIcon("Folder"); + break; + default: + var finf = new FileInfo(Paths.Desktop + d.IconName); + switch (finf.Extension) + { + case ".txt": + case ".doc": + case ".owd": + case ".docx": + d.Icon = API.GetIcon("TextFile"); + break; + case ".skn": + case ".spk": + d.Icon = API.GetIcon("SkinFile"); + break; + case ".saa": + d.Icon = API.GetIcon("SAAFile"); + break; + case ".pkg": + case ".stp": + d.Icon = API.GetIcon("SetupPackage"); + break; + default: + d.Icon = API.GetIcon("UnrecognizedFile"); + break; + } + break; + } + Icons.Add(d); + } + foreach (ApplauncherItem al in API.AppLauncherItems) + { + if (al.Display == true) + { + var dl = new DesktopIcon(); + dl.Icon = al.Icon; + dl.IconName = al.Name; + dl.LuaAction = al.Lua; + Icons.Add(dl); + } + } + } public class IconModel { public string Name { get; set; } diff --git a/source/WindowsFormsApplication1/Program.cs b/source/WindowsFormsApplication1/Program.cs index af294db..e6c4c23 100644 --- a/source/WindowsFormsApplication1/Program.cs +++ b/source/WindowsFormsApplication1/Program.cs @@ -40,10 +40,10 @@ namespace ShiftOS int port = Convert.ToInt32(addSplitter[1]); Package_Grabber.ConnectToServer(host, port); } - catch - { - - } + catch (Exception catcherror) + { + Console.WriteLine(catcherror); + } } } catch @@ -129,10 +129,10 @@ namespace ShiftOS } } } - catch - { - - } + catch (Exception e) + { + Console.WriteLine(e); + } } -- cgit v1.2.3