diff --git a/.vs/ShiftOS/v15/sqlite3/storage.ide b/.vs/ShiftOS/v15/sqlite3/storage.ide index 5166458..16112a5 100644 Binary files a/.vs/ShiftOS/v15/sqlite3/storage.ide and b/.vs/ShiftOS/v15/sqlite3/storage.ide differ diff --git a/ShiftOS.Engine/Misc/IniFile.cs b/ShiftOS.Engine/Misc/IniFile.cs new file mode 100644 index 0000000..e31583f --- /dev/null +++ b/ShiftOS.Engine/Misc/IniFile.cs @@ -0,0 +1,50 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace ShiftOS.Engine.Misc +{ + /// + /// Create a New INI file to store or load data + /// + public class IniFile + { + readonly string _path; + + public IniFile(string iniPath) => _path = iniPath; + + [DllImport("kernel32")] + static extern long WritePrivateProfileString( + string section, + string key, + string val, + string filePath); + + [DllImport("kernel32")] + static extern int GetPrivateProfileString( + string section, + string key, + string def, + StringBuilder retVal, + int size, + string filePath); + + public void WriteValue(string section, string key, string value) + { + WritePrivateProfileString(section, key, value, _path); + } + + public string ReadValue(string section, string key) + { + var temp = new StringBuilder(255); + GetPrivateProfileString( + section, + key, + "", + temp, + 255, + _path); + + return temp.ToString(); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/Tools.cs b/ShiftOS.Engine/Misc/Tools.cs similarity index 56% rename from ShiftOS.Engine/Tools.cs rename to ShiftOS.Engine/Misc/Tools.cs index 792ccef..6430084 100644 --- a/ShiftOS.Engine/Tools.cs +++ b/ShiftOS.Engine/Misc/Tools.cs @@ -1,26 +1,24 @@ using System; using System.Drawing; -using System.Drawing.Imaging; -using System.IO; using System.Runtime.InteropServices; -namespace ShiftOS.Engine +namespace ShiftOS.Engine.Misc { /// - /// Random class full of unassorted [but also uncategorizable] tools. + /// Random class full of unassorted [but also uncategorizable] tools. /// public static class Tools { public static Random Rnd = new Random(); [DllImport("user32.dll", CharSet = CharSet.Auto)] - public extern static bool DestroyIcon(IntPtr handle); + public static extern bool DestroyIcon(IntPtr handle); public static Icon ToIcon(this Bitmap bm) { - Icon tempicon = Icon.FromHandle(bm.GetHicon()); + var tempicon = Icon.FromHandle(bm.GetHicon()); - Icon newIcon = tempicon.Clone() as Icon; + var newIcon = tempicon.Clone() as Icon; //for some reason this exists DestroyIcon(tempicon.Handle); @@ -28,4 +26,4 @@ namespace ShiftOS.Engine return newIcon; } } -} +} \ No newline at end of file diff --git a/ShiftOS.Engine/Properties/AssemblyInfo.cs b/ShiftOS.Engine/Properties/AssemblyInfo.cs index 0a17339..51aee88 100644 --- a/ShiftOS.Engine/Properties/AssemblyInfo.cs +++ b/ShiftOS.Engine/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -33,4 +32,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs b/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs new file mode 100644 index 0000000..64ac4f2 --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs @@ -0,0 +1,50 @@ +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; + +namespace ShiftOS.Engine.ShiftFS +{ + public class ShiftDirectory : ShiftFsObject + { + public ShiftDirectory(string path) : base(path) + { + path = path.Replace(ShiftFs.SavePath, ""); + var dir = new DirectoryInfo(Path.Combine(ShiftFs.SavePath, path)); + Name = dir.Name; + FullDiskName = dir.FullName; + FullName = path; + + Children.CollectionChanged += (sender, e) => { }; + } + + public ShiftFsObject this[string name] => Children.First(f => f.Name == name); + public ShiftFsObject this[int index] => Children[index]; + + public new ShiftDirectory Parent => new ShiftDirectory(new DirectoryInfo(FullDiskName).Parent.FullName); + + public ObservableCollection Children + { + get + { + var collection = new ObservableCollection(); + + foreach (var dir in new DirectoryInfo(Path.Combine(ShiftFs.SavePath, FullName)).EnumerateDirectories()) + { + collection.Add(new ShiftDirectory(dir.FullName)); + } + + foreach (var file in new DirectoryInfo(Path.Combine(ShiftFs.SavePath, FullName)).EnumerateFiles()) + { + collection.Add(new ShiftFile(file.FullName.Replace(ShiftFs.SavePath, ""))); + } + + return collection; + } + } + + public ObservableCollection Files => new ObservableCollection(Children.OfType()); + + public ObservableCollection Directories + => new ObservableCollection(Children.OfType()); + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftFS/ShiftDrive.cs b/ShiftOS.Engine/ShiftFS/ShiftDrive.cs new file mode 100644 index 0000000..cde9e8d --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftDrive.cs @@ -0,0 +1,20 @@ +using System.IO; +using ShiftOS.Engine.Misc; + +namespace ShiftOS.Engine.ShiftFS +{ + public class ShiftDrive + { + internal ShiftDrive(DirectoryInfo dir) + { + Label = dir.Name; + var file = new IniFile(Path.Combine(dir.FullName, "driveinfo.ini")); + Letter = char.TryParse(file.ReadValue("", "DriveLetter"), out var letter) ? letter : '?'; + Contents = new ShiftDirectory(dir.FullName); + } + + public string Label { get; } + public char Letter { get; } + public ShiftDirectory Contents { get; } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftFS/ShiftFS.cs b/ShiftOS.Engine/ShiftFS/ShiftFS.cs new file mode 100644 index 0000000..d188bee --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftFS.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.ObjectModel; +using System.IO; + +namespace ShiftOS.Engine.ShiftFS +{ + public static class ShiftFs + { + internal static readonly string SavePath = Path.Combine(Environment.CurrentDirectory, "Save") + "\\"; + + public static ObservableCollection Drives = new ObservableCollection(); + + static ShiftFs() + { + if (Directory.Exists(SavePath)) + { + var info = new DirectoryInfo(SavePath); + foreach (var dir in info.EnumerateDirectories()) + { + Drives.Add(new ShiftDrive(dir)); + } + } + else + { + CreateSaveFile(); + } + } + + public static void CreateSaveFile() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftFS/ShiftFSObject.cs b/ShiftOS.Engine/ShiftFS/ShiftFSObject.cs new file mode 100644 index 0000000..69750fa --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftFSObject.cs @@ -0,0 +1,25 @@ +using System.IO; + +namespace ShiftOS.Engine.ShiftFS +{ + public abstract class ShiftFsObject + { + protected ShiftFsObject(string path) + { + if (!File.Exists(Path.Combine(ShiftFs.SavePath, path)) && !Directory.Exists(Path.Combine(ShiftFs.SavePath, path))) + { + throw new FileNotFoundException(); + } + } + + public string Name { get; set; } + public ShiftDirectory Parent { get; protected set; } + public string FullName { get; set; } + protected string FullDiskName { get; set; } + + public void Delete() + { + File.Delete(FullDiskName); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftFS/ShiftFile.cs b/ShiftOS.Engine/ShiftFS/ShiftFile.cs new file mode 100644 index 0000000..1a2413c --- /dev/null +++ b/ShiftOS.Engine/ShiftFS/ShiftFile.cs @@ -0,0 +1,48 @@ +using System; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; + +namespace ShiftOS.Engine.ShiftFS +{ + public class ShiftFile : ShiftFsObject + { + public ShiftFile(string path) : base(path) + { + path = path.Replace(ShiftFs.SavePath, ""); + + using (var fs = new FileStream(Path.Combine(ShiftFs.SavePath, path), FileMode.Open)) + { + Bytes = new MemoryStream(); + fs.CopyTo(Bytes); + } + + var file = new FileInfo(Path.Combine(ShiftFs.SavePath, path)); + + Name = file.Name; + FullDiskName = file.FullName; + FullName = path; + } + + public new ShiftDirectory Parent => new ShiftDirectory(new FileInfo(FullDiskName).Directory.FullName); + + public MemoryStream Bytes { get; set; } + public long Length => Bytes.Length; + } + + public class ShiftFile : ShiftFile // please C# gods let us constrain to attributes + { + public ShiftFile(string path) : base(path) + { + if (!typeof(T).IsSerializable) + { + throw new InvalidOperationException("Non-serializable types are not supported"); + } + } + + public T Object + { + get => (T) new BinaryFormatter().Deserialize(Bytes); + set => new BinaryFormatter().Serialize(Bytes, value); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/ShiftOS.Engine.csproj b/ShiftOS.Engine/ShiftOS.Engine.csproj index 3a505fb..ca3638e 100644 --- a/ShiftOS.Engine/ShiftOS.Engine.csproj +++ b/ShiftOS.Engine/ShiftOS.Engine.csproj @@ -46,16 +46,22 @@ + True True Resources.resx + + + + + - + UserControl diff --git a/ShiftOS.Engine/Terminal/Commands/Hello.cs b/ShiftOS.Engine/Terminal/Commands/Hello.cs index 531bd1f..7d4b82f 100644 --- a/ShiftOS.Engine/Terminal/Commands/Hello.cs +++ b/ShiftOS.Engine/Terminal/Commands/Hello.cs @@ -1,21 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Engine.Terminal.Commands +namespace ShiftOS.Engine.Terminal.Commands { - public class Hello : TerminalCommand - { - public override string GetName() - { - return "Hello"; - } + public class Hello : TerminalCommand + { + public override string GetName() => "Hello"; - public override string Run(params string[] parameters) - { - return "Oh, HELLO, " + String.Join(" ", parameters); - } - } -} + public override string Run(params string[] parameters) => "Oh, HELLO, " + string.Join(" ", parameters); + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/Terminal/TerminalBackend.cs b/ShiftOS.Engine/Terminal/TerminalBackend.cs index 7103238..793b748 100644 --- a/ShiftOS.Engine/Terminal/TerminalBackend.cs +++ b/ShiftOS.Engine/Terminal/TerminalBackend.cs @@ -2,45 +2,46 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace ShiftOS.Engine.Terminal { - public static class TerminalBackend - { - // The line below gets all the terminal commands in... well... the entire ShiftOS.Engine - public static IEnumerable instances = from t in Assembly.GetExecutingAssembly().GetTypes() - where t.IsSubclassOf(typeof(TerminalCommand)) - && t.GetConstructor(Type.EmptyTypes) != null - select Activator.CreateInstance(t) as TerminalCommand; + public static class TerminalBackend + { + // The line below gets all the terminal commands in... well... the entire ShiftOS.Engine + static readonly IEnumerable Instances = from t in Assembly.GetExecutingAssembly().GetTypes() + where t.IsSubclassOf(typeof(TerminalCommand)) && + t.GetConstructor(Type.EmptyTypes) != null + select (TerminalCommand) Activator.CreateInstance(t); - /// - /// Runs a terminal command. - /// - /// - /// Returns all the output from that command. - public static string RunCommand(string command) - { - string name; - try { name = command.Split(' ')[0]; } catch { name = command; } + /// + /// Runs a terminal command. + /// + /// + /// Returns all the output from that command. + public static string RunCommand(string command) + { + string name; + try + { + name = command.Split(' ')[0]; + } + catch + { + name = command; + } - var theParams = new string[command.Split(' ').Length - 1]; - Array.Copy(command.Split(' '), 1, theParams, 0, command.Split(' ').Length - 1); + var theParams = new string[command.Split(' ').Length - 1]; + Array.Copy(command.Split(' '), 1, theParams, 0, command.Split(' ').Length - 1); - foreach (TerminalCommand instance in instances) - { - if (instance.GetName() == name) - return instance.Run(theParams); - } + foreach (var instance in Instances) + { + if (instance.GetName() == name) + { + return instance.Run(theParams); + } + } - return "The command cannot be found."; - } - - // An extra function ;) - private static Type[] GetTypesInNamespace(Assembly assembly, string nameSpace) - { - return assembly.GetTypes().Where(t => String.Equals(t.Namespace, nameSpace, StringComparison.Ordinal)).ToArray(); - } - } -} + return "The command cannot be found."; + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/Terminal/TerminalCommand.cs b/ShiftOS.Engine/Terminal/TerminalCommand.cs index a344122..81a34b9 100644 --- a/ShiftOS.Engine/Terminal/TerminalCommand.cs +++ b/ShiftOS.Engine/Terminal/TerminalCommand.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Engine.Terminal +namespace ShiftOS.Engine.Terminal { - public abstract class TerminalCommand - { - public abstract string GetName(); + public abstract class TerminalCommand + { + public abstract string GetName(); - public abstract string Run(params string[] parameters); - } -} + public abstract string Run(params string[] parameters); + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs b/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs index 948df22..c2b45e0 100644 --- a/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs +++ b/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs @@ -1,94 +1,94 @@ using System; using System.Drawing; -using System.Windows.Forms; -using System.Media; using System.IO; +using System.Media; +using System.Windows.Forms; +using ShiftOS.Engine.Properties; namespace ShiftOS.Engine.WindowManager { - public partial class InfoboxTemplate : UserControl - { - Stream _str; - private int _buttonChoice; - private int _buttonSelected; - public InfoboxTemplate(ButtonType type) - { - InitializeComponent(); - - switch (type) - { - case ButtonType.Ok: - btnOpt1.Text = "OK"; - btnOpt2.Hide(); - btnOpt1.Location = new Point(109, 134); - _buttonChoice = 1; - break; - case ButtonType.OkCancel: - btnOpt1.Text = "OK"; - btnOpt2.Text = "Cancel"; - _buttonChoice = 2; - break; - case ButtonType.YesNo: - btnOpt1.Text = "Yes"; - btnOpt2.Text = "No"; - _buttonChoice = 3; - break; - } - } + public partial class InfoboxTemplate : UserControl + { + public enum ButtonType + { + YesNo, + OkCancel, + Ok + } - public enum ButtonType - { - YesNo, - OkCancel, - Ok - } + public enum DialogResult + { + Yes, + No, + Cancel, + Ok + } - public enum DialogResult - { - Yes, - No, - Cancel, - Ok - } + int _buttonChoice; + int _buttonSelected; + Stream _str; - private void btnOpt1_Click(object sender, EventArgs e) - { - switch (btnOpt1.Text) - { - case "OK": - ParentForm?.Close(); - break; - case "Yes": - _buttonSelected = 2; - ParentForm?.Close(); - break; - } - } + public InfoboxTemplate(ButtonType type) + { + InitializeComponent(); - private void btnOpt2_Click(object sender, EventArgs e) - { - switch (btnOpt2.Text) - { - case "No": - _buttonSelected = 3; - break; - case "Cancel": - _buttonSelected = 4; - break; - } - } + switch (type) + { + case ButtonType.Ok: + btnOpt1.Text = "OK"; + btnOpt2.Hide(); + btnOpt1.Location = new Point(109, 134); + _buttonChoice = 1; + break; + case ButtonType.OkCancel: + btnOpt1.Text = "OK"; + btnOpt2.Text = "Cancel"; + _buttonChoice = 2; + break; + case ButtonType.YesNo: + btnOpt1.Text = "Yes"; + btnOpt2.Text = "No"; + _buttonChoice = 3; + break; + } + } - public void Play() - { - _str = Properties.Resources.infobox; - SoundPlayer sp = new SoundPlayer(_str); - sp.Play(); - sp.Stream.Position = 0; - } + void btnOpt1_Click(object sender, EventArgs e) + { + switch (btnOpt1.Text) + { + case "OK": + ParentForm?.Close(); + break; + case "Yes": + _buttonSelected = 2; + ParentForm?.Close(); + break; + } + } - private void InfoboxTemplate_Load(object sender, EventArgs e) + void btnOpt2_Click(object sender, EventArgs e) + { + switch (btnOpt2.Text) + { + case "No": + _buttonSelected = 3; + break; + case "Cancel": + _buttonSelected = 4; + break; + } + } + + public void Play() + { + _str = Resources.infobox; + var sp = new SoundPlayer(_str); + sp.Play(); + sp.Stream.Position = 0; + } + + void InfoboxTemplate_Load(object sender, EventArgs e) => Play(); - - - } -} + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/WindowManager/ShiftSkinData.cs b/ShiftOS.Engine/WindowManager/ShiftSkinData.cs index 9f4bf45..2c8c4c8 100644 --- a/ShiftOS.Engine/WindowManager/ShiftSkinData.cs +++ b/ShiftOS.Engine/WindowManager/ShiftSkinData.cs @@ -2,22 +2,23 @@ namespace ShiftOS.Engine.WindowManager { - public abstract class ShiftSkinData - { - // ColorData - public static Color leftTopCornerColor = Color.Empty; - public static Color titleBarColor = Color.Empty; - public static Color rightTopCornerColor = Color.Empty; - public static Color btnCloseColor = Color.Empty; - public static Color btnMaxColor = Color.Empty; - public static Color btnMinColor = Color.Empty; - public static Color btnCloseHoverColor = Color.Empty; - public static Color btnMaxHoverColor = Color.Empty; - public static Color btnMinHoverColor = Color.Empty; - public static Color leftSideColor = Color.Empty; - public static Color rightSideColor = Color.Empty; - public static Color leftBottomCornerColor = Color.Empty; - public static Color bottomSideColor = Color.Empty; - public static Color rightBottomCornerColor = Color.Empty; - } -} + public abstract class ShiftSkinData + { + // ColorData + public static Color LeftTopCornerColor = Color.Empty; + + public static Color TitleBarColor = Color.Empty; + public static Color RightTopCornerColor = Color.Empty; + public static Color BtnCloseColor = Color.Empty; + public static Color BtnMaxColor = Color.Empty; + public static Color BtnMinColor = Color.Empty; + public static Color BtnCloseHoverColor = Color.Empty; + public static Color BtnMaxHoverColor = Color.Empty; + public static Color BtnMinHoverColor = Color.Empty; + public static Color LeftSideColor = Color.Empty; + public static Color RightSideColor = Color.Empty; + public static Color LeftBottomCornerColor = Color.Empty; + public static Color BottomSideColor = Color.Empty; + public static Color RightBottomCornerColor = Color.Empty; + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/WindowManager/ShiftWM.cs b/ShiftOS.Engine/WindowManager/ShiftWM.cs index 64b84f9..b6079bd 100644 --- a/ShiftOS.Engine/WindowManager/ShiftWM.cs +++ b/ShiftOS.Engine/WindowManager/ShiftWM.cs @@ -1,126 +1,129 @@ -using System; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Windows.Forms; +using ShiftOS.Engine.Misc; +using ShiftOS.Engine.Properties; using static ShiftOS.Engine.WindowManager.InfoboxTemplate; namespace ShiftOS.Engine.WindowManager { - public static class ShiftWM - { + public static class ShiftWm + { public static ObservableCollection Windows { get; } = new ObservableCollection(); - public static ShiftWindow GetShiftWindow(this UserControl control) - { - return Windows.First(p => (uint) control.Tag == p.Id); - } + public static ShiftWindow GetShiftWindow(this UserControl control) + { + return Windows.First(p => (uint) control.Tag == p.Id); + } - /// - /// Shows a new ShiftWindow based on a UserControl. - /// - /// The UserControl to use - /// The program's title - /// The icon to show - /// Checks if this is an infobox - /// Enables or disables resizing - /// - public static ShiftWindow Init(UserControl content, string title, Icon icon, bool showAsInfobox = false, bool resize = true) - { - // Setup Window - ShiftWindow app = new ShiftWindow - { - Text = title, - Title = {Text = title} - }; + /// + /// Shows a new ShiftWindow based on a UserControl. + /// + /// The UserControl to use + /// The program's title + /// The icon to show + /// Checks if this is an infobox + /// Enables or disables resizing + /// + public static ShiftWindow Init( + UserControl content, + string title, + Icon icon, + bool showAsInfobox = false, + bool resize = true) + { + // Setup Window + var app = new ShiftWindow + { + Text = title, + Title = { Text = title } + }; - app.Width = content.Width + app.leftSide.Width + app.rightSide.Width; - app.Height = content.Height + app.bottomSide.Height + app.titleBar.Height; + app.Width = content.Width + app.leftSide.Width + app.rightSide.Width; + app.Height = content.Height + app.bottomSide.Height + app.titleBar.Height; - if (ShiftSkinData.titleBarColor == Color.Empty) - { - Color borderColor = Color.FromArgb(64, 64, 64); - ShiftSkinData.btnCloseColor = Color.Black; - ShiftSkinData.btnMaxColor = Color.Black; - ShiftSkinData.btnMinColor = Color.Black; - ShiftSkinData.leftTopCornerColor = borderColor; - ShiftSkinData.titleBarColor = borderColor; - ShiftSkinData.rightTopCornerColor = borderColor; - ShiftSkinData.leftSideColor = borderColor; - ShiftSkinData.rightSideColor = borderColor; - ShiftSkinData.leftBottomCornerColor = borderColor; - ShiftSkinData.bottomSideColor = borderColor; - ShiftSkinData.rightBottomCornerColor = borderColor; - } + if (ShiftSkinData.TitleBarColor == Color.Empty) + { + var borderColor = Color.FromArgb(64, 64, 64); + ShiftSkinData.BtnCloseColor = Color.Black; + ShiftSkinData.BtnMaxColor = Color.Black; + ShiftSkinData.BtnMinColor = Color.Black; + ShiftSkinData.LeftTopCornerColor = borderColor; + ShiftSkinData.TitleBarColor = borderColor; + ShiftSkinData.RightTopCornerColor = borderColor; + ShiftSkinData.LeftSideColor = borderColor; + ShiftSkinData.RightSideColor = borderColor; + ShiftSkinData.LeftBottomCornerColor = borderColor; + ShiftSkinData.BottomSideColor = borderColor; + ShiftSkinData.RightBottomCornerColor = borderColor; + } - app.btnClose.BackColor = ShiftSkinData.btnCloseColor; - app.btnMax.BackColor = ShiftSkinData.btnMaxColor; - app.btnMin.BackColor = ShiftSkinData.btnMinColor; - app.leftTopCorner.BackColor = ShiftSkinData.leftTopCornerColor; - app.titleBar.BackColor = ShiftSkinData.titleBarColor; - app.rightTopCorner.BackColor = ShiftSkinData.rightTopCornerColor; - app.leftSide.BackColor = ShiftSkinData.leftSideColor; - app.rightSide.BackColor = ShiftSkinData.rightSideColor; - app.leftBottomCorner.BackColor = ShiftSkinData.leftBottomCornerColor; - app.bottomSide.BackColor = ShiftSkinData.bottomSideColor; - app.rightBottomCorner.BackColor = ShiftSkinData.rightBottomCornerColor; - + app.btnClose.BackColor = ShiftSkinData.BtnCloseColor; + app.btnMax.BackColor = ShiftSkinData.BtnMaxColor; + app.btnMin.BackColor = ShiftSkinData.BtnMinColor; + app.leftTopCorner.BackColor = ShiftSkinData.LeftTopCornerColor; + app.titleBar.BackColor = ShiftSkinData.TitleBarColor; + app.rightTopCorner.BackColor = ShiftSkinData.RightTopCornerColor; + app.leftSide.BackColor = ShiftSkinData.LeftSideColor; + app.rightSide.BackColor = ShiftSkinData.RightSideColor; + app.leftBottomCorner.BackColor = ShiftSkinData.LeftBottomCornerColor; + app.bottomSide.BackColor = ShiftSkinData.BottomSideColor; + app.rightBottomCorner.BackColor = ShiftSkinData.RightBottomCornerColor; - // Icon Setup - if (icon == null) - { - app.programIcon.Hide(); - app.programIcon.Image = Properties.Resources.nullIcon; - app.Title.Location = new Point(2, 7); - } - else - { - app.programIcon.Image = icon.ToBitmap(); - app.Icon = icon; - } + // Icon Setup + if (icon == null) + { + app.programIcon.Hide(); + app.programIcon.Image = Resources.nullIcon; + app.Title.Location = new Point(2, 7); + } + + else + { + app.programIcon.Image = icon.ToBitmap(); + app.Icon = icon; + } // Setup UC content.Parent = app.programContent; - content.BringToFront(); - content.Dock = DockStyle.Fill; - app.Show(); + content.BringToFront(); + content.Dock = DockStyle.Fill; + app.Show(); - content.Tag = app.SetId(); + content.Tag = app.SetId(); Debug.WriteLine($"usercontrol: {content.Tag} window: {app.Id}"); - app.Closed += (sender, args) => - { - Windows.Remove((ShiftWindow) sender); - }; + app.Closed += (sender, args) => { Windows.Remove((ShiftWindow) sender); }; Windows.Add(app); - if (content is IShiftWindowExtensions extensions) - { - extensions.OnLoaded(app); - } + if (content is IShiftWindowExtensions extensions) + { + extensions.OnLoaded(app); + } - return app; - } + return app; + } - /// - /// Shows a new infobox. - /// - /// The title of the infobox. - /// The infobox's content. - /// The ButtonType used for the infobox. - /// - public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type) - { - InfoboxTemplate info = new InfoboxTemplate(type) - { - label1 = { Text = body } - }; - Init(info, title, Properties.Resources.iconInfoBox_fw.ToIcon(), true, false); - return info; - } - } -} + /// + /// Shows a new infobox. + /// + /// The title of the infobox. + /// The infobox's content. + /// The ButtonType used for the infobox. + /// + public static InfoboxTemplate StartInfoboxSession(string title, string body, ButtonType type) + { + var info = new InfoboxTemplate(type) + { + label1 = { Text = body } + }; + Init(info, title, Resources.iconInfoBox_fw.ToIcon(), true, false); + return info; + } + } +} \ No newline at end of file diff --git a/ShiftOS.Engine/WindowManager/ShiftWindow.cs b/ShiftOS.Engine/WindowManager/ShiftWindow.cs index a8b9c79..aa327f1 100644 --- a/ShiftOS.Engine/WindowManager/ShiftWindow.cs +++ b/ShiftOS.Engine/WindowManager/ShiftWindow.cs @@ -1,74 +1,76 @@ using System; -using System.Drawing; using System.Linq; -using System.Windows.Forms; using System.Runtime.InteropServices; +using System.Windows.Forms; +using ShiftOS.Engine.Misc; namespace ShiftOS.Engine.WindowManager { - public partial class ShiftWindow : Form - { + public partial class ShiftWindow : Form + { + const int WmNclbuttondown = 0xA1; + const int HtCaption = 0x2; + + public ShiftWindow() + { + InitializeComponent(); + } + public uint Id { get; private set; } - public UserControl ChildControl { get; set; } + public UserControl ChildControl { get; set; } - public ShiftWindow() - { - InitializeComponent(); - } - - public uint SetId() - { + public uint SetId() + { do { - Id = (uint)Tools.Rnd.Next(100000, 999999); - } - while (ShiftWM.Windows.FirstOrDefault(w => w.Id == Id) != null); + Id = (uint) Tools.Rnd.Next(100000, 999999); + } while (ShiftWm.Windows.FirstOrDefault(w => w.Id == Id) != null); - return Id; - } + return Id; + } - private const int WM_NCLBUTTONDOWN = 0xA1; - private const int HT_CAPTION = 0x2; + [DllImport("user32.dll")] + static extern int SendMessage( + IntPtr hWnd, + int msg, + int wParam, + int lParam); - [DllImportAttribute("user32.dll")] - private static extern int SendMessage(IntPtr hWnd, - int Msg, int wParam, int lParam); + [DllImport("user32.dll")] + static extern bool ReleaseCapture(); - [DllImportAttribute("user32.dll")] - private static extern bool ReleaseCapture(); + void Programtopbar_drag(object sender, MouseEventArgs e) + { + if (e.Button != MouseButtons.Left) return; - private void Programtopbar_drag(object sender, MouseEventArgs e) - { - if (e.Button != MouseButtons.Left) return; + ReleaseCapture(); + SendMessage(Handle, WmNclbuttondown, HtCaption, 0); + } - ReleaseCapture(); - SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); - } + void closebutton_Click(object sender, EventArgs e) + => Close(); - private void closebutton_Click(object sender, EventArgs e) - => this.Close(); + void closebutton_MouseEnter(object sender, EventArgs e) + => btnClose.BackColor = ShiftSkinData.BtnCloseHoverColor; - private void closebutton_MouseEnter(object sender, EventArgs e) - => btnClose.BackColor = ShiftSkinData.btnCloseHoverColor; + void closebutton_MouseLeave(object sender, EventArgs e) + => btnClose.BackColor = ShiftSkinData.BtnCloseColor; - private void closebutton_MouseLeave(object sender, EventArgs e) - => btnClose.BackColor = ShiftSkinData.btnCloseColor; + void maximizebutton_MouseEnter(object sender, EventArgs e) + => btnMax.BackColor = ShiftSkinData.BtnMaxHoverColor; - private void maximizebutton_MouseEnter(object sender, EventArgs e) - => btnMax.BackColor = ShiftSkinData.btnMaxHoverColor; + void maximizebutton_MouseLeave(object sender, EventArgs e) + => btnMax.BackColor = ShiftSkinData.BtnMaxColor; - private void maximizebutton_MouseLeave(object sender, EventArgs e) - => btnMax.BackColor = ShiftSkinData.btnMaxColor; + void minimizebutton_MouseEnter(object sender, EventArgs e) + => btnMin.BackColor = ShiftSkinData.BtnMinHoverColor; - private void minimizebutton_MouseEnter(object sender, EventArgs e) - => btnMin.BackColor = ShiftSkinData.btnMinHoverColor; - - private void minimizebutton_MouseLeave(object sender, EventArgs e) - => btnMin.BackColor = ShiftSkinData.btnMinColor; + void minimizebutton_MouseLeave(object sender, EventArgs e) + => btnMin.BackColor = ShiftSkinData.BtnMinColor; - /* + /* private void closebutton_MouseDown(object sender, MouseEventArgs e) => btnClose.BackColor = Color.Black; @@ -77,12 +79,11 @@ namespace ShiftOS.Engine.WindowManager private void minimizebutton_MouseDown(object sender, MouseEventArgs e) => btnMin.BackColor = Color.Black; - */ - + */ } public interface IShiftWindowExtensions { void OnLoaded(ShiftWindow window); } -} +} \ No newline at end of file diff --git a/ShiftOS.Engine/packages.config b/ShiftOS.Engine/packages.config index ee51c23..a96650b 100644 --- a/ShiftOS.Engine/packages.config +++ b/ShiftOS.Engine/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/ShiftOS.Main/App.config b/ShiftOS.Main/App.config index 8e15646..5c73fc5 100644 --- a/ShiftOS.Main/App.config +++ b/ShiftOS.Main/App.config @@ -1,6 +1,7 @@ - + + - - - + + + \ No newline at end of file diff --git a/ShiftOS.Main/HijackScreen.Designer.cs b/ShiftOS.Main/HijackScreen.Designer.cs deleted file mode 100644 index fab31dc..0000000 --- a/ShiftOS.Main/HijackScreen.Designer.cs +++ /dev/null @@ -1,105 +0,0 @@ -namespace ShiftOS.Main -{ - partial class HijackScreen - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); - this.conversationtimer = new System.Windows.Forms.Timer(this.components); - this.hackeffecttimer = new System.Windows.Forms.Timer(this.components); - this.lblHijack = new System.Windows.Forms.Label(); - this.textgen = new System.Windows.Forms.Timer(this.components); - this.lblhackwords = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // conversationtimer - // - this.conversationtimer.Tick += new System.EventHandler(this.conversationtimer_Tick); - // - // hackeffecttimer - // - this.hackeffecttimer.Interval = 50; - this.hackeffecttimer.Tick += new System.EventHandler(this.hackeffecttimer_Tick); - // - // lblHijack - // - this.lblHijack.Anchor = System.Windows.Forms.AnchorStyles.None; - this.lblHijack.AutoSize = true; - this.lblHijack.BackColor = System.Drawing.Color.WhiteSmoke; - this.lblHijack.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F); - this.lblHijack.ForeColor = System.Drawing.Color.DimGray; - this.lblHijack.Location = new System.Drawing.Point(143, 193); - this.lblHijack.Name = "lblHijack"; - this.lblHijack.Size = new System.Drawing.Size(18, 25); - this.lblHijack.TabIndex = 0; - this.lblHijack.Text = "\\"; - // - // textgen - // - this.textgen.Interval = 20; - this.textgen.Tick += new System.EventHandler(this.textgen_Tick); - // - // lblhackwords - // - this.lblhackwords.AutoSize = true; - this.lblhackwords.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblhackwords.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblhackwords.ForeColor = System.Drawing.SystemColors.ButtonFace; - this.lblhackwords.Location = new System.Drawing.Point(0, 0); - this.lblhackwords.Name = "lblhackwords"; - this.lblhackwords.Size = new System.Drawing.Size(127, 18); - this.lblhackwords.TabIndex = 1; - this.lblhackwords.Text = "Hijack in progress"; - // - // HijackScreen - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Silver; - this.ClientSize = new System.Drawing.Size(636, 418); - this.Controls.Add(this.lblhackwords); - this.Controls.Add(this.lblHijack); - this.Name = "HijackScreen"; - this.Text = "ShiftOS"; - this.TransparencyKey = System.Drawing.Color.White; - this.Load += new System.EventHandler(this.HijackScreen_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.ComponentModel.BackgroundWorker backgroundWorker1; - private System.Windows.Forms.Timer conversationtimer; - private System.Windows.Forms.Timer hackeffecttimer; - private System.Windows.Forms.Label lblHijack; - private System.Windows.Forms.Timer textgen; - private System.Windows.Forms.Label lblhackwords; - } -} \ No newline at end of file diff --git a/ShiftOS.Main/HijackScreen.cs b/ShiftOS.Main/HijackScreen.cs deleted file mode 100644 index 721d49e..0000000 --- a/ShiftOS.Main/HijackScreen.cs +++ /dev/null @@ -1,612 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.IO; -using System.Media; -using System.Text.RegularExpressions; - -namespace ShiftOS.Main -{ - public partial class HijackScreen : Form - { - public string actualshiftversion = "0.0.1.1"; - string rtext; - string gtexttotype; - int charcount; - int currentletter; - int slashcount; - int conversationcount = 0; - Label textgeninput; - bool needtoclose = false; - string oldversion; - public bool upgraded = false; - SoundPlayer player = new SoundPlayer(); - - FileStream fs; - int hackeffect; - int percentcount; - - static DriveInfo[] cdrives = DriveInfo.GetDrives(); - DriveInfo cdrive = Array.Find(cdrives, c => "C:\\" == "C:\\"); - public HijackScreen() - { - InitializeComponent(); - } - private void PlaySound(Stream path) - { - player.Stream = path; - player.Play(); - player.Stream.Position = 0; - } - private void HijackScreen_Load(object sender, EventArgs e) - { - //extractdlls(); - Control.CheckForIllegalCrossThreadCalls = false; - - this.FormBorderStyle = FormBorderStyle.None; - this.WindowState = FormWindowState.Maximized; - if (Directory.Exists("C:\\ShiftOS-Rewind")) - { - if (File.ReadAllText("C:/ShiftOS-Rewind/Shiftum42/HDAccess.sft") == actualshiftversion) - { - //ShiftOSDesktop.Show(); - conversationtimer.Start(); - needtoclose = true; - } - else - { - if (MessageBox.Show("Your save file is not currently compatible with this version of ShiftOS. Would you like to upgrade your save file so you can continue to play the latest version of ShiftOS without losing your progress? If so click yes below. If you would like to start a new game and wipe all your progress please click no", "Warning: Update your save file", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes) - { - this.Hide(); - //ShiftOS_Save_File_Converter.Show(); - // ShiftOS_Save_File_Converter.BringToFront(); - } - else - { - oldversion = System.IO.File.ReadAllText("C:/ShiftOS-Rewind/Shiftum42/HDAccess.sft"); - upgraded = true; - System.IO.Directory.Delete("C:/ShiftOS-Rewind/", true); - backgroundWorker1.RunWorkerAsync(); - conversationtimer.Start(); - hackeffecttimer.Start(); - } - } - } - else - { - backgroundWorker1.RunWorkerAsync(); - conversationtimer.Start(); - hackeffecttimer.Start(); - } - } - - private void TextType(string texttotype) - { - conversationtimer.Stop(); - charcount = texttotype.Length; - gtexttotype = texttotype; - currentletter = 0; - slashcount = 1; - textgen.Start(); - } - - - private void textgen_Tick(object sender, EventArgs e) - { - switch (slashcount) - { - case 1: - if (currentletter < gtexttotype.Length) - { - textgeninput.Text = rtext + "\\"; - } - - break; - case 2: - if (currentletter < gtexttotype.Length) - { - textgeninput.Text = rtext + "|"; - } - - break; - case 3: - if (currentletter < gtexttotype.Length) - { - textgeninput.Text = rtext + "/"; - } - - break; - case 4: - if (currentletter < gtexttotype.Length) - { - rtext = rtext + Regex.Split(gtexttotype, string.Empty)[currentletter]; - currentletter = currentletter + 1; - textgeninput.Text = rtext; - - } - break; - } - - slashcount = slashcount + 1; - - if (slashcount == 5) - slashcount = 1; - if (currentletter == gtexttotype.Length) - { - gtexttotype = ""; - PlaySound(Properties.Resources.typesound); - conversationtimer.Start(); - textgen.Stop(); - } - - - } - - private void conversationtimer_Tick(object sender, EventArgs e) - { - switch (conversationcount) - { - case 0: - if (needtoclose == true) - this.Close(); - break; - case 1: - - textgeninput = lblHijack; - TextType("Your computer is now being Hijacked "); - conversationtimer.Interval = 1000; - - break; - case 3: - textgeninput = lblhackwords; - textgen.Interval = 10; - rtext = ""; - TextType("Congratulations, " + Environment.UserName + "you have been involuntarily selected to be an Alpha Tester for ShiftOS!" + Environment.NewLine + Environment.NewLine); - break; - case 4: - TextType("At this time, I do not wish to reveal any of my intentions and idenity." + Environment.NewLine + Environment.NewLine); - break; - case 5: - TextType("I just need to use you and your computer as an external test bed to evolve my experimental operating system." + Environment.NewLine + Environment.NewLine); - break; - case 6: - TextType("I need to expand the name of ShiftOS, so I'll work on it, and you'll have the chance to use ShiftOS!" + Environment.NewLine + Environment.NewLine); - break; - case 7: - TextType("Your hard drive will now be formatted in preparation for the installation of ShiftOS." + Environment.NewLine + Environment.NewLine); - break; - case 8: - TextType("Starting Format."); - conversationtimer.Interval = 500; - break; - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - TextType("."); - break; - case 19: - rtext = ""; - break; - case 20: - TextType("Scanning Drive C:\\..."); - break; - case 21: - - TextType(Environment.NewLine + Environment.NewLine + "Drive Label: " + cdrive.VolumeLabel); - break; - case 22: - TextType(Environment.NewLine + "Total Drive Size: " + String.Format((cdrive.TotalSize / 1024 / 1024 / 1024).ToString(), "0.00") + "GB. "); - break; - case 23: - TextType(Environment.NewLine + "Old File System: " + cdrive.DriveFormat + ". "); - break; - case 24: - TextType(Environment.NewLine + "New File System: ShiftFS. "); - break; - case 25: - TextType(Environment.NewLine + Environment.NewLine + "Formatting C:\\... - "); - conversationtimer.Interval = 100; - break; - case 26: // TODO: to 126 - textgeninput.Text = rtext + percentcount + "%"; - if (percentcount < 101) - { - percentcount = percentcount + 1; - PlaySound(Main.Properties.Resources.writesound); - } - break; - case 127: - rtext = rtext + "100%"; - conversationtimer.Interval = 1000; - break; - case 128: - TextType(Environment.NewLine + "Format Complete"); - break; - case 129: - rtext = ""; - percentcount = 0; - TextType("Installing ShiftOS Beta 0.0.1 - "); - conversationtimer.Interval = 200; - break; - case 130: // TODO: to 230 - textgeninput.Text = rtext + percentcount + "%" + Environment.NewLine + Environment.NewLine; - if (percentcount < 101) - { - percentcount = percentcount + 1; - PlaySound(Properties.Resources.writesound); - } - switch (percentcount) - { - case 1: - case 2: - textgeninput.Text = textgeninput.Text + "C:/Home"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Home"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Home"); - break; - case 3: - case 4: - textgeninput.Text = textgeninput.Text + "C:/Home/Documents"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Home/Documents"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Home/Documents"); - break; - case 5: - case 6: - case 7: - case 8: - case 9: - textgeninput.Text = textgeninput.Text + "C:/Home/Documents/ShiftOSInfo.txt"; - fs = File.Create("C:/ShiftOS-Rewind/Home/Documents/ShiftOSInfo.txt"); - fs.Close(); - break; - case 10: - case 11: - case 12: - textgeninput.Text = textgeninput.Text + "C:/Home/Music"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Home/Music"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Home/Music"); - break; - case 13: - case 14: - case 15: - textgeninput.Text = textgeninput.Text + "C:/Home/Pictures"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Home/Pictures"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Home/Pictures"); - break; - case 16: - case 17: - case 18: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Shiftum42"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Shiftum42"); - break; - case 19: - case 20: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Shiftum42/Drivers"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Shiftum42/Drivers"); - break; - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers/HDD.dri"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Drivers/HDD.dri"); - fs.Close(); - break; - case 28: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers/Keyboard.dri"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Drivers/Keyboard.dri"); - fs.Close(); - break; - case 36: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 43: - case 44: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers/Monitor.dri"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Drivers/Monitor.dri"); - fs.Close(); - break; - case 45: - case 46: - case 47: - case 48: - case 49: - case 50: - case 51: - case 52: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers/Mouse.dri"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Drivers/Mouse.dri"); - fs.Close(); - break; - case 53: - case 54: - case 55: - case 56: - case 57: - case 58: - case 59: - case 60: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Drivers/Printer.dri"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Drivers/Printer.dri"); - fs.Close(); - break; - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 68: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Languages/"; - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/Shiftum42/Languages/"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/Shiftum42/Languages/"); - break; - case 69: - case 70: - case 71: - case 72: - case 73: - case 74: - case 75: - case 76: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/Languages/English.lang"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/Languages/English.lang"); - fs.Close(); - break; - case 77: - case 78: - case 79: - case 80: - case 81: - case 82: - case 83: - case 84: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/HDAccess.sft"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/HDAccess.sft"); - fs.Close(); - System.IO.StreamWriter objWriter = new System.IO.StreamWriter("C:/ShiftOS-Rewind/Shiftum42/HDAccess.sft", false); - objWriter.Write(actualshiftversion); - objWriter.Close(); - break; - case 85: - case 86: - case 87: - case 88: - case 89: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/ShiftGUI.sft"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/ShiftGUI.sft"); - fs.Close(); - break; - case 90: - case 91: - case 92: - case 93: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/SKernal.sft"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/SKernal.sft"); - fs.Close(); - break; - case 94: - case 95: - case 96: - case 97: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/SRead.sft"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/SRead.sft"); - fs.Close(); - break; - case 98: - case 99: - case 100: - case 101: - textgeninput.Text = textgeninput.Text + "C:/Shiftum42/SWrite.sft"; - fs = File.Create("C:/ShiftOS-Rewind/Shiftum42/SWrite.sft"); - fs.Close(); - break; - } - - break; - - case 231: - textgeninput.Text = rtext + "100%" + Environment.NewLine + Environment.NewLine + "C:/Shiftum42/SWrite.sft"; - conversationtimer.Interval = 1000; - PlaySound(Properties.Resources.writesound); - break; - case 232: - textgeninput.Text = rtext + "100%" + Environment.NewLine + Environment.NewLine + "ShiftOS Installation Complete!"; - PlaySound(Properties.Resources.typesound); - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/SoftwareData/"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/SoftwareData/"); - if ((!System.IO.Directory.Exists("C:/ShiftOS-Rewind/SoftwareData/KnowledgeInput"))) - System.IO.Directory.CreateDirectory("C:/ShiftOS-Rewind/SoftwareData/KnowledgeInput"); - fs = File.Create("C:/ShiftOS-Rewind/SoftwareData/KnowledgeInput/Animals.lst"); - fs.Close(); - fs = File.Create("C:/ShiftOS-Rewind/SoftwareData/KnowledgeInput/Fruits.lst"); - fs.Close(); - fs = File.Create("C:/ShiftOS-Rewind/SoftwareData/KnowledgeInput/Countries.lst"); - fs.Close(); - break; - case 234: - //ShiftOSDesktop.newgame = true; - //ShiftOSDesktop.Show(); - //Terminal.Show(); - //Terminal.tmrfirstrun.Start(); - //this.Close(); - - break; - } - conversationcount = conversationcount + 1; - } - - private void hackeffecttimer_Tick(object sender, EventArgs e) - { - if (hackeffect < 101) - { - switch (hackeffect) - { - case 1: - case 3: - case 5: - case 7: - case 9: - case 11: - case 13: - case 15: - case 17: - case 19: - case 21: - case 23: - case 25: - case 27: - case 29: - case 31: - case 33: - case 35: - case 37: - case 39: - case 41: - case 43: - case 45: - case 47: - case 49: - case 51: - case 53: - case 55: - case 57: - case 59: - case 61: - case 63: - case 65: - case 67: - case 69: - case 71: - case 73: - case 75: - case 77: - case 79: - case 81: - case 83: - case 85: - case 87: - case 89: - case 91: - case 93: - case 95: - this.BackColor = Color.Black; - PlaySound(Properties.Resources.writesound); - break; - case 2: - case 4: - case 6: - case 8: - case 10: - case 12: - case 14: - case 16: - case 18: - case 20: - case 22: - case 24: - case 26: - case 28: - this.BackColor = Color.White; - PlaySound(Properties.Resources.typesound); - break; - case 30: - case 32: - case 34: - case 36: - case 38: - case 40: - case 42: - case 44: - case 46: - case 48: - case 50: - this.BackColor = Color.Gainsboro; - PlaySound(Properties.Resources.typesound); - break; - case 52: - case 54: - case 56: - case 58: - case 60: - case 62: - case 64: - case 66: - case 68: - case 70: - case 72: - case 74: - case 76: - this.BackColor = Color.Silver; - PlaySound(Properties.Resources.typesound); - break; - case 78: - case 80: - case 82: - case 84: - case 86: - case 88: - case 90: - case 92: - case 94: - this.BackColor = Color.DimGray; - PlaySound(Properties.Resources.typesound); - break; - case 96: - lblHijack.BackColor = Color.LightGray; - break; - case 97: - lblHijack.BackColor = Color.DarkGray; - break; - case 98: - lblHijack.BackColor = Color.DimGray; - break; - case 99: - lblHijack.BackColor = Color.Black; - lblHijack.ForeColor = Color.DimGray; - break; - case 100: - lblHijack.Hide(); - break; - } - } - else - { - hackeffecttimer.Stop(); - } - hackeffect = hackeffect + 1; - } - - } -} - - diff --git a/ShiftOS.Main/HijackScreen.resx b/ShiftOS.Main/HijackScreen.resx deleted file mode 100644 index 84970f0..0000000 --- a/ShiftOS.Main/HijackScreen.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 181, 17 - - - 331, 17 - - - 467, 17 - - \ No newline at end of file diff --git a/ShiftOS.Main/Program.cs b/ShiftOS.Main/Program.cs index 10277b0..99776dc 100644 --- a/ShiftOS.Main/Program.cs +++ b/ShiftOS.Main/Program.cs @@ -2,23 +2,24 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Main.ShiftOS; +using ShiftOS.Main.ShiftOS.Apps; namespace ShiftOS.Main { - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); Parallel.Invoke( () => Application.Run(new TestForm()), () => Application.Run(new Desktop())); - } - } -} + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/Properties/AssemblyInfo.cs b/ShiftOS.Main/Properties/AssemblyInfo.cs index 6f85581..bcab0d6 100644 --- a/ShiftOS.Main/Properties/AssemblyInfo.cs +++ b/ShiftOS.Main/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -33,4 +32,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/ShiftOS.Main/Properties/Settings.settings b/ShiftOS.Main/Properties/Settings.settings index 3964565..e04fc63 100644 --- a/ShiftOS.Main/Properties/Settings.settings +++ b/ShiftOS.Main/Properties/Settings.settings @@ -1,7 +1,8 @@  + - + \ No newline at end of file diff --git a/ShiftOS.Main/Resources/CatalystGrammar.xml b/ShiftOS.Main/Resources/CatalystGrammar.xml index b082a0d..90543d6 100644 --- a/ShiftOS.Main/Resources/CatalystGrammar.xml +++ b/ShiftOS.Main/Resources/CatalystGrammar.xml @@ -1,22 +1,23 @@ - + + - + - + How much Code Points do I have? - Can you run ? - Can you minimize ? - Can you close ? + Can you run ? + Can you minimize ? + Can you close ? diff --git a/ShiftOS.Main/ShiftOS.Main.csproj b/ShiftOS.Main/ShiftOS.Main.csproj index 93ece0f..7db2449 100644 --- a/ShiftOS.Main/ShiftOS.Main.csproj +++ b/ShiftOS.Main/ShiftOS.Main.csproj @@ -47,12 +47,6 @@ - - Form - - - HijackScreen.cs - @@ -97,9 +91,6 @@ Desktop.cs - - HijackScreen.cs - ResXFileCodeGenerator Resources.Designer.cs diff --git a/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.Designer.cs index 7fd37f0..f8ee8e3 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.Designer.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.Designer.cs @@ -1,4 +1,4 @@ -namespace ShiftOS.Main +namespace ShiftOS.Main.ShiftOS.Apps { partial class ShiftDemo { diff --git a/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.cs b/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.cs index 11fc160..ced10d2 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShiftDemo.cs @@ -1,26 +1,18 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using System.Windows.Forms; using ShiftOS.Engine.WindowManager; -namespace ShiftOS.Main +namespace ShiftOS.Main.ShiftOS.Apps { - public partial class ShiftDemo : UserControl, IShiftWindowExtensions - { - public ShiftDemo() - { - InitializeComponent(); - } + public partial class ShiftDemo : UserControl, IShiftWindowExtensions + { + public ShiftDemo() + { + InitializeComponent(); + } - public void OnLoaded(ShiftWindow window) - { - icon.Image = this.GetShiftWindow().Icon.ToBitmap(); - } + public void OnLoaded(ShiftWindow window) + { + icon.Image = this.GetShiftWindow().Icon.ToBitmap(); + } } -} +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.Designer.cs index a7473a0..5d50bc0 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.Designer.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.Designer.cs @@ -1,4 +1,4 @@ -namespace ShiftOS.Main.ShiftOS.Apps +namespace ShiftOS.Main.ShiftOS.Apps.ShifterStuff { partial class SelectColor { diff --git a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs index f26fe4d..543529a 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs @@ -1,50 +1,54 @@ using System; using System.Drawing; +using System.Globalization; using System.Windows.Forms; using ShiftOS.Engine.WindowManager; -namespace ShiftOS.Main.ShiftOS.Apps +namespace ShiftOS.Main.ShiftOS.Apps.ShifterStuff { - public partial class SelectColor : UserControl - { - Color _finalColor; - int _colorType1; - int _colorType2; - int _colorType3; - public SelectColor() - { - InitializeComponent(); + public partial class SelectColor : UserControl + { + int _colorType1; + int _colorType2; + int _colorType3; + Color _finalColor; - } + public SelectColor() + { + InitializeComponent(); + } - private Color setColor() - { - _colorType1 = Int32.Parse(redUpDown.Value.ToString()); - _colorType2 = Int32.Parse(greenUpDown.Value.ToString()); - _colorType3 = Int32.Parse(blueUpDown.Value.ToString()); - try - { - _finalColor = Color.FromArgb(_colorType1, _colorType2, _colorType3); - - - foreach (var window in ShiftWM.Windows) -{ - window.Invoke(new Action(() => window.titleBar.BackColor = _finalColor)); - } - - - ShiftWM.StartInfoboxSession("Success!", $"Changed color to:\r\n{_colorType1}, {_colorType2}, {_colorType3}.", InfoboxTemplate.ButtonType.Ok); - } - catch (Exception) - { - ShiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok); - } - return _finalColor; - } + Color SetColor() + { + _colorType1 = int.Parse(redUpDown.Value.ToString(CultureInfo.InvariantCulture)); + _colorType2 = int.Parse(greenUpDown.Value.ToString(CultureInfo.InvariantCulture)); + _colorType3 = int.Parse(blueUpDown.Value.ToString(CultureInfo.InvariantCulture)); + try + { + _finalColor = Color.FromArgb(_colorType1, _colorType2, _colorType3); - private void btnSetColor_Click(object sender, EventArgs e) - { - setColor(); - } - } -} + + foreach (var window in ShiftWm.Windows) + { + window.Invoke(new Action(() => window.titleBar.BackColor = _finalColor)); + } + + + ShiftWm.StartInfoboxSession( + "Success!", + $"Changed color to:\r\n{_colorType1}, {_colorType2}, {_colorType3}.", + InfoboxTemplate.ButtonType.Ok); + } + catch (Exception) + { + ShiftWm.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok); + } + return _finalColor; + } + + void btnSetColor_Click(object sender, EventArgs e) + { + SetColor(); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.Designer.cs index ac81a5c..2ed43b4 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.Designer.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.Designer.cs @@ -1,4 +1,4 @@ -namespace ShiftOS.Main.ShiftOS.Apps +namespace ShiftOS.Main.ShiftOS.Apps.ShifterStuff { partial class Shifter { @@ -94,7 +94,7 @@ this.button4.TabIndex = 4; this.button4.Text = "Set Random Skin"; this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.setRandomSkin); + this.button4.Click += new System.EventHandler(this.SetRandomSkin); // // button3 // @@ -106,7 +106,7 @@ this.button3.TabIndex = 3; this.button3.Text = "Set Default Skin"; this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.setDefaultSkin); + this.button3.Click += new System.EventHandler(this.SetDefaultSkin); // // button2 // @@ -118,7 +118,7 @@ this.button2.TabIndex = 2; this.button2.Text = "Set Colorful Skin"; this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.setColorSkin); + this.button2.Click += new System.EventHandler(this.SetColorSkin); // // groupBox1 // diff --git a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.cs b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.cs index 609b617..f7c9752 100644 --- a/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.cs +++ b/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/Shifter.cs @@ -1,113 +1,116 @@ using System; -using System.Windows.Forms; -using ShiftOS.Engine; -using ShiftOS.Engine.WindowManager; using System.Drawing; using System.IO; +using System.Windows.Forms; using Newtonsoft.Json; +using ShiftOS.Engine.Misc; +using ShiftOS.Engine.WindowManager; +using ShiftOS.Main.Properties; -namespace ShiftOS.Main.ShiftOS.Apps +namespace ShiftOS.Main.ShiftOS.Apps.ShifterStuff { - public partial class Shifter : UserControl - { - public int colorType; //This is a check to see what option was chosen. - public Shifter() - { - InitializeComponent(); - } + public partial class Shifter : UserControl + { + public int ColorType; //This is a check to see what option was chosen. - private void button1_Click(object sender, EventArgs e) - { - colorType = 1; - ShiftWM.Init(new SelectColor(), "Select a color", Properties.Resources.iconColourPicker_fw.ToIcon()); - } + public Shifter() + { + InitializeComponent(); + } - private void setDefaultSkin(object sender, EventArgs e) - { - setBorderColor(Color.FromArgb(64, 64, 64)); - ShiftSkinData.btnCloseColor = Color.Black; - ShiftSkinData.btnMaxColor = Color.Black; - ShiftSkinData.btnMinColor = Color.Black; - button5_Click(sender, e); - } + void button1_Click(object sender, EventArgs e) + { + ColorType = 1; + ShiftWm.Init(new SelectColor(), "Select a color", Resources.iconColourPicker_fw.ToIcon()); + } - private void setColorSkin(object sender, EventArgs e) - { - setBorderColor(Color.Blue); - ShiftSkinData.btnCloseColor = Color.Red; - ShiftSkinData.btnMaxColor = Color.Yellow; - ShiftSkinData.btnMinColor = Color.Green; - ShiftSkinData.btnCloseHoverColor = Color.FromArgb(255, 102, 102); - ShiftSkinData.btnMaxHoverColor = Color.FromArgb(255, 255, 153); - ShiftSkinData.btnMinColor = Color.FromArgb(102, 255, 102); - button5_Click(sender, e); - } + void SetDefaultSkin(object sender, EventArgs e) + { + SetBorderColor(Color.FromArgb(64, 64, 64)); + ShiftSkinData.BtnCloseColor = Color.Black; + ShiftSkinData.BtnMaxColor = Color.Black; + ShiftSkinData.BtnMinColor = Color.Black; + button5_Click(sender, e); + } - private void setRandomSkin(object sender, EventArgs e) - { - Random rnd = new Random(); - setBorderColor(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))); - ShiftSkinData.btnCloseColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - ShiftSkinData.btnMaxColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - ShiftSkinData.btnMinColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - ShiftSkinData.btnCloseHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - ShiftSkinData.btnMaxHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - ShiftSkinData.btnMinHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); - button5_Click(sender, e); - } + void SetColorSkin(object sender, EventArgs e) + { + SetBorderColor(Color.Blue); + ShiftSkinData.BtnCloseColor = Color.Red; + ShiftSkinData.BtnMaxColor = Color.Yellow; + ShiftSkinData.BtnMinColor = Color.Green; + ShiftSkinData.BtnCloseHoverColor = Color.FromArgb(255, 102, 102); + ShiftSkinData.BtnMaxHoverColor = Color.FromArgb(255, 255, 153); + ShiftSkinData.BtnMinColor = Color.FromArgb(102, 255, 102); + button5_Click(sender, e); + } - // SetBorderColor - public void setBorderColor(Color borderColor) - { - ShiftSkinData.leftTopCornerColor = borderColor; - ShiftSkinData.titleBarColor = borderColor; - ShiftSkinData.rightTopCornerColor = borderColor; - ShiftSkinData.leftSideColor = borderColor; - ShiftSkinData.rightSideColor = borderColor; - ShiftSkinData.leftBottomCornerColor = borderColor; - ShiftSkinData.bottomSideColor = borderColor; - ShiftSkinData.rightBottomCornerColor = borderColor; - } + void SetRandomSkin(object sender, EventArgs e) + { + var rnd = new Random(); + SetBorderColor(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))); + ShiftSkinData.BtnCloseColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + ShiftSkinData.BtnMaxColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + ShiftSkinData.BtnMinColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + ShiftSkinData.BtnCloseHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + ShiftSkinData.BtnMaxHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + ShiftSkinData.BtnMinHoverColor = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); + button5_Click(sender, e); + } - private void button5_Click(object sender, EventArgs e) - { + // SetBorderColor + public void SetBorderColor(Color borderColor) + { + ShiftSkinData.LeftTopCornerColor = borderColor; + ShiftSkinData.TitleBarColor = borderColor; + ShiftSkinData.RightTopCornerColor = borderColor; + ShiftSkinData.LeftSideColor = borderColor; + ShiftSkinData.RightSideColor = borderColor; + ShiftSkinData.LeftBottomCornerColor = borderColor; + ShiftSkinData.BottomSideColor = borderColor; + ShiftSkinData.RightBottomCornerColor = borderColor; + } - foreach (var window in ShiftWM.Windows) - { - window.Invoke(new Action(() => window.titleBar.BackColor = ShiftSkinData.titleBarColor)); - window.Invoke(new Action(() => window.leftTopCorner.BackColor = ShiftSkinData.leftTopCornerColor)); - window.Invoke(new Action(() => window.rightTopCorner.BackColor = ShiftSkinData.rightTopCornerColor)); - window.Invoke(new Action(() => window.leftSide.BackColor = ShiftSkinData.leftSideColor)); - window.Invoke(new Action(() => window.rightSide.BackColor = ShiftSkinData.rightSideColor)); - window.Invoke(new Action(() => window.leftBottomCorner.BackColor = ShiftSkinData.leftBottomCornerColor)); - window.Invoke(new Action(() => window.bottomSide.BackColor = ShiftSkinData.bottomSideColor)); - window.Invoke(new Action(() => window.rightBottomCorner.BackColor = ShiftSkinData.rightBottomCornerColor)); - window.Invoke(new Action(() => window.btnClose.BackColor = ShiftSkinData.btnCloseColor)); - window.Invoke(new Action(() => window.btnMax.BackColor = ShiftSkinData.btnMaxColor)); - window.Invoke(new Action(() => window.btnMin.BackColor = ShiftSkinData.btnMinColor)); - - } - } + void button5_Click(object sender, EventArgs e) + { + foreach (var window in ShiftWm.Windows) + { + window.Invoke(new Action(() => window.titleBar.BackColor = ShiftSkinData.TitleBarColor)); + window.Invoke(new Action(() => window.leftTopCorner.BackColor = ShiftSkinData.LeftTopCornerColor)); + window.Invoke(new Action(() => window.rightTopCorner.BackColor = ShiftSkinData.RightTopCornerColor)); + window.Invoke(new Action(() => window.leftSide.BackColor = ShiftSkinData.LeftSideColor)); + window.Invoke(new Action(() => window.rightSide.BackColor = ShiftSkinData.RightSideColor)); + window.Invoke(new Action(() => window.leftBottomCorner.BackColor = ShiftSkinData.LeftBottomCornerColor)); + window.Invoke(new Action(() => window.bottomSide.BackColor = ShiftSkinData.BottomSideColor)); + window.Invoke(new Action(() => window.rightBottomCorner.BackColor = ShiftSkinData.RightBottomCornerColor)); + window.Invoke(new Action(() => window.btnClose.BackColor = ShiftSkinData.BtnCloseColor)); + window.Invoke(new Action(() => window.btnMax.BackColor = ShiftSkinData.BtnMaxColor)); + window.Invoke(new Action(() => window.btnMin.BackColor = ShiftSkinData.BtnMinColor)); + } + } - private void btnSave_Click(object sender, EventArgs e) - { - Color[] shiftColors = new Color[14]; - shiftColors[0] = ShiftSkinData.leftTopCornerColor; - shiftColors[1] = ShiftSkinData.titleBarColor; - shiftColors[2] = ShiftSkinData.rightTopCornerColor; - shiftColors[3] = ShiftSkinData.leftSideColor; - shiftColors[4] = ShiftSkinData.rightSideColor; - shiftColors[5] = ShiftSkinData.leftBottomCornerColor; - shiftColors[6] = ShiftSkinData.bottomSideColor; - shiftColors[7] = ShiftSkinData.rightBottomCornerColor; - shiftColors[8] = ShiftSkinData.btnCloseColor; - shiftColors[9] = ShiftSkinData.btnMaxColor; - shiftColors[10] = ShiftSkinData.btnMinColor; - shiftColors[11] = ShiftSkinData.btnCloseHoverColor; - shiftColors[12] = ShiftSkinData.btnMaxHoverColor; - shiftColors[13] = ShiftSkinData.btnMinHoverColor; - File.WriteAllText(@"C:\Users\Public\Documents\Skin.json", JsonConvert.SerializeObject(shiftColors)); - ShiftWM.StartInfoboxSession("Saved Skin", "Saved Skin to C:\\Users\\Public\\Documents\\Skin.json", InfoboxTemplate.ButtonType.Ok); - } - } -} + void btnSave_Click(object sender, EventArgs e) + { + var shiftColors = new Color[14]; + shiftColors[0] = ShiftSkinData.LeftTopCornerColor; + shiftColors[1] = ShiftSkinData.TitleBarColor; + shiftColors[2] = ShiftSkinData.RightTopCornerColor; + shiftColors[3] = ShiftSkinData.LeftSideColor; + shiftColors[4] = ShiftSkinData.RightSideColor; + shiftColors[5] = ShiftSkinData.LeftBottomCornerColor; + shiftColors[6] = ShiftSkinData.BottomSideColor; + shiftColors[7] = ShiftSkinData.RightBottomCornerColor; + shiftColors[8] = ShiftSkinData.BtnCloseColor; + shiftColors[9] = ShiftSkinData.BtnMaxColor; + shiftColors[10] = ShiftSkinData.BtnMinColor; + shiftColors[11] = ShiftSkinData.BtnCloseHoverColor; + shiftColors[12] = ShiftSkinData.BtnMaxHoverColor; + shiftColors[13] = ShiftSkinData.BtnMinHoverColor; + File.WriteAllText(@"C:\Users\Public\Documents\Skin.json", JsonConvert.SerializeObject(shiftColors)); + ShiftWm.StartInfoboxSession( + "Saved Skin", + "Saved Skin to C:\\Users\\Public\\Documents\\Skin.json", + InfoboxTemplate.ButtonType.Ok); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs index a9bd093..4c11136 100644 --- a/ShiftOS.Main/ShiftOS/Apps/Terminal.cs +++ b/ShiftOS.Main/ShiftOS/Apps/Terminal.cs @@ -1,95 +1,80 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using ShiftOS.Engine; using ShiftOS.Engine.Terminal; namespace ShiftOS.Main.ShiftOS.Apps { - public partial class Terminal : UserControl - { - public string defaulttextBefore = "user> "; - public string defaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!! - public bool doClear = false; + public partial class Terminal : UserControl + { + public string DefaulttextBefore = "user> "; + string DefaulttextResult = "user@shiftos> "; // NOT YET IMPLEMENTED!!! + bool DoClear = false; - // The below variables makes the terminal... a terminal! - public string OldText = ""; - public int TrackingPosition = 0; + // The below variables makes the terminal... a terminal! + string OldText = ""; - public Terminal() - { - InitializeComponent(); + int TrackingPosition; - termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! - } + public Terminal() + { + InitializeComponent(); - public void Print(string text) - { - termmain.AppendText($"\n {text} \n {defaulttextResult}"); - TrackingPosition = termmain.Text.Length; - } + termmain.ContextMenuStrip = new ContextMenuStrip(); // Disables the right click of a richtextbox! + } - private void termmain_KeyDown(object sender, KeyEventArgs e) - { - // The below code disables the ability to paste anything other then text... + void Print(string text) + { + termmain.AppendText($"\n {text} \n {DefaulttextResult}"); + TrackingPosition = termmain.Text.Length; + } - if (e.Control && e.KeyCode == Keys.V) - { - //if (Clipboard.ContainsText()) - // termmain.Paste(DataFormats.GetFormat(DataFormats.Text)); - e.Handled = true; - } else if (e.KeyCode == Keys.Enter) { - Print(TerminalBackend.RunCommand(termmain.Text.Substring(TrackingPosition, termmain.Text.Length - TrackingPosition))); // The most horrific line in the entire application! - e.Handled = true; - } - } + void termmain_KeyDown(object sender, KeyEventArgs e) + { + // The below code disables the ability to paste anything other then text... - private void termmain_TextChanged(object sender, EventArgs e) - { - if (termmain.SelectionStart < TrackingPosition) - { - if (doClear == false) // If it's not clearing the terminal - { - termmain.Text = OldText; - termmain.Select(termmain.Text.Length, 0); - } - } - else - { - OldText = termmain.Text; - } - } + if (e.Control && e.KeyCode == Keys.V) + { + //if (Clipboard.ContainsText()) + // termmain.Paste(DataFormats.GetFormat(DataFormats.Text)); + e.Handled = true; + } + else if (e.KeyCode == Keys.Enter) + { + Print( + TerminalBackend.RunCommand( + termmain.Text.Substring( + TrackingPosition, + termmain.Text.Length - TrackingPosition))); // The most horrific line in the entire application! + e.Handled = true; + } + } - private void termmain_SelectionChanged(object sender, EventArgs e) - { - if (termmain.SelectionStart < TrackingPosition) - { - termmain.Text = OldText; - termmain.Select(termmain.Text.Length, 0); - } - } + void termmain_TextChanged(object sender, EventArgs e) + { + if (termmain.SelectionStart < TrackingPosition) + { + if (DoClear) return; + + termmain.Text = OldText; + termmain.Select(termmain.Text.Length, 0); + } + else + { + OldText = termmain.Text; + } + } - private void Terminal_Load(object sender, EventArgs e) - { - Print("\n"); - } + void termmain_SelectionChanged(object sender, EventArgs e) + { + if (termmain.SelectionStart >= TrackingPosition) return; + + termmain.Text = OldText; + termmain.Select(termmain.Text.Length, 0); + } - public string RunCommand(string command) - { - string ToReturn = ""; - - if (command == "hi") - { - ToReturn = $"{ToReturn} \n Hi!"; - MessageBox.Show("HI!"); - } - return ToReturn; - } - } -} + void Terminal_Load(object sender, EventArgs e) + { + Print("\n"); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs b/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs index 50bcb58..b49924e 100644 --- a/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs +++ b/ShiftOS.Main/ShiftOS/Apps/TestForm.Designer.cs @@ -1,4 +1,4 @@ -namespace ShiftOS.Main +namespace ShiftOS.Main.ShiftOS.Apps { partial class TestForm { diff --git a/ShiftOS.Main/ShiftOS/Apps/TestForm.cs b/ShiftOS.Main/ShiftOS/Apps/TestForm.cs index 389f8d1..5929a66 100644 --- a/ShiftOS.Main/ShiftOS/Apps/TestForm.cs +++ b/ShiftOS.Main/ShiftOS/Apps/TestForm.cs @@ -1,28 +1,27 @@ using System; -using System.Drawing; -using System.Linq; using System.Windows.Forms; -using ShiftOS.Engine; +using ShiftOS.Engine.Misc; using ShiftOS.Engine.WindowManager; -using ShiftOS.Main.ShiftOS.Apps; +using ShiftOS.Main.Properties; +using ShiftOS.Main.ShiftOS.Apps.ShifterStuff; -namespace ShiftOS.Main +namespace ShiftOS.Main.ShiftOS.Apps { - public partial class TestForm : Form - { - public TestForm() - { - InitializeComponent(); - } + public partial class TestForm : Form + { + public TestForm() + { + InitializeComponent(); + } - private void Button1_Click(object sender, EventArgs e) - { - ShiftDemo demo = new ShiftDemo(); - ShiftWM.Init(demo, textBox1.Text, null); - ShiftWM.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.ButtonType.Ok); - } + void Button1_Click(object sender, EventArgs e) + { + var demo = new ShiftDemo(); + ShiftWm.Init(demo, textBox1.Text, null); + ShiftWm.StartInfoboxSession(textBox1.Text, textBox2.Text, InfoboxTemplate.ButtonType.Ok); + } - private void button2_Click(object sender, EventArgs e) - => ShiftWM.Init(new Shifter(), "Shifter", Properties.Resources.iconShifter.ToIcon()); - } -} + void button2_Click(object sender, EventArgs e) + => ShiftWm.Init(new Shifter(), "Shifter", Resources.iconShifter.ToIcon()); + } +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Apps/TextPad.cs b/ShiftOS.Main/ShiftOS/Apps/TextPad.cs index 6c091df..e86b1be 100644 --- a/ShiftOS.Main/ShiftOS/Apps/TextPad.cs +++ b/ShiftOS.Main/ShiftOS/Apps/TextPad.cs @@ -1,54 +1,36 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; using System.IO; -using ShiftOS.Engine; +using System.Windows.Forms; namespace ShiftOS.Main.ShiftOS.Apps { - public partial class TextPad : UserControl - { - string editedText; - public TextPad() - { - InitializeComponent(); - editedText = textBox.Text; - } - private bool isEdited(string editedString) - { - editedString = editedText; - if(editedString != textBox.Text) - { - return true; - } - else - { - return false; - } - } + public partial class TextPad : UserControl + { + readonly string _editedText; - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - if (openFileDialog1.ShowDialog() == DialogResult.OK) - { - var sr = new StreamReader(openFileDialog1.FileName); - textBox.Text = sr.ReadToEnd(); - sr.Close(); - } - } + public TextPad() + { + InitializeComponent(); + _editedText = textBox.Text; + } - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - if (isEdited(textBox.Text)) - { - MessageBox.Show("yay it works"); - } - } - } -} + bool IsEdited() => _editedText != textBox.Text; + + void openToolStripMenuItem_Click(object sender, EventArgs e) + { + if (openFileDialog1.ShowDialog() != DialogResult.OK) return; + + var sr = new StreamReader(openFileDialog1.FileName); + textBox.Text = sr.ReadToEnd(); + sr.Close(); + } + + void newToolStripMenuItem_Click(object sender, EventArgs e) + { + if (IsEdited()) + { + MessageBox.Show("yay it works"); + } + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/ShiftOS/Desktop.cs b/ShiftOS.Main/ShiftOS/Desktop.cs index 66392a7..9bfcb0f 100644 --- a/ShiftOS.Main/ShiftOS/Desktop.cs +++ b/ShiftOS.Main/ShiftOS/Desktop.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using ShiftOS.Engine.Misc; using ShiftOS.Engine.WindowManager; -using ShiftOS.Engine; +using ShiftOS.Main.Properties; +using ShiftOS.Main.ShiftOS.Apps; namespace ShiftOS.Main.ShiftOS { @@ -20,56 +16,64 @@ namespace ShiftOS.Main.ShiftOS timer1.Start(); - this.Closed += (sender, args) => - { - Application.Exit(); - }; + Closed += (sender, args) => { Application.Exit(); }; #region Disgusting taskbar code - ShiftWM.Windows.CollectionChanged += (sender, args) => + ShiftWm.Windows.CollectionChanged += (sender, args) => { - args.NewItems?.OfType().ToList().ForEach(window => - { - taskbar.Invoke(new Action(() => - { - taskbar.Items.Add(new ToolStripButton - { - Text = window.Title.Text, - Image = window.Icon.ToBitmap(), - Tag = window.Id - }); - })); - }); - - args.OldItems?.OfType().ToList().ForEach(window => - { - taskbar.Invoke(new Action(() => - { - var tbRemovalList = taskbar.Items.OfType().Where(i => (uint) i.Tag == window.Id); + args.NewItems?.OfType() + .ToList() + .ForEach( + window => + { + taskbar.Invoke( + new Action( + () => + { + taskbar.Items.Add( + new ToolStripButton + { + Text = window.Title.Text, + Image = window.Icon.ToBitmap(), + Tag = window.Id + }); + })); + }); - tbRemovalList.ToList().ForEach(p => taskbar.Items.Remove(p)); - })); - }); + args.OldItems?.OfType() + .ToList() + .ForEach( + window => + { + taskbar.Invoke( + new Action( + () => + { + var tbRemovalList = taskbar.Items.OfType().Where(i => (uint) i.Tag == window.Id); + + tbRemovalList.ToList().ForEach(p => taskbar.Items.Remove(p)); + })); + }); }; #endregion } - private void timer1_Tick(object sender, EventArgs e) => + void timer1_Tick(object sender, EventArgs e) => taskbarClock.Text = $"{DateTime.Now:t}"; - private void terminalToolStripMenuItem_Click(object sender, EventArgs e) - { - Apps.Terminal trm = new Apps.Terminal(); + void terminalToolStripMenuItem_Click(object sender, EventArgs e) + { + var trm = new Terminal(); - ShiftWM.Init(trm, "Terminal", null, false, true); - } + ShiftWm.Init(trm, "Terminal", null); + } - private void textPadToolStripMenuItem_Click(object sender, EventArgs e) - { - var tp = new Apps.TextPad(); - ShiftWM.Init(tp, "TextPad", Properties.Resources.iconTextPad.ToIcon()); - } - } -} + void textPadToolStripMenuItem_Click(object sender, EventArgs e) + { + var tp = new TextPad(); + ShiftWm.Init(tp, "TextPad", Resources.iconTextPad.ToIcon()); + } + } +} \ No newline at end of file diff --git a/ShiftOS.Main/packages.config b/ShiftOS.Main/packages.config index ee51c23..a96650b 100644 --- a/ShiftOS.Main/packages.config +++ b/ShiftOS.Main/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file