Example #1
0
        /// <summary>
        /// Called by the app when the app is suspending
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnSuspending_Fired(object sender, SuspendingEventArgs e)
        {
            // Setup a ref deferral for everyone to hold. We also need to setup a clean up action to save the setting
            // when the deferral is done.
            RefCountedDeferral refDeferral = new RefCountedDeferral(e.SuspendingOperation.GetDeferral(), () =>
            {
                // We need to flush the settings here just before we complete the deferal. We need to block this function
                // until the settings are flushed.
                using (AutoResetEvent are = new AutoResetEvent(false))
                {
                    Task.Run(async() =>
                    {
                        // Flush out the local settings
                        await SettingsMan.FlushLocalSettings();
                        are.Set();
                    });
                    are.WaitOne();
                }
            });

            // Add a ref to cover anyone down this call stack.
            refDeferral.AddRef();

            // Make the
            OnSuspendingArgs args = new OnSuspendingArgs()
            {
                RefDeferral = refDeferral
            };

            // Fire the event
            m_onSuspending.Raise(this, args);

            // Release our ref to the deferral
            refDeferral.ReleaseRef();
        }
Example #2
0
        protected override void BeforeRun()
        {
            Encoding.RegisterProvider(CosmosEncodingProvider.Instance);
            Console.InputEncoding  = Encoding.GetEncoding(437);
            Console.OutputEncoding = Encoding.GetEncoding(437);

            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Loading virtual FS...");
            VFSManager.RegisterVFS(Reference.FAT);

            if (Reference.FAT.GetVolumes().Count != 0)
            {
                ColorConsole.WriteLine(ConsoleColor.Green, "Sucessfully loaded the virtual FS!");
            }
            else
            {
                ColorConsole.WriteLine(ConsoleColor.Red, "Uh-oh, couldn't load the virtual FS...");
            }

            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Initializing SSE...");
            Global.CPU.InitSSE();
            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Initializing Float...");
            Global.CPU.InitFloat();

            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Initializing settings...");
            if (!File.Exists(Reference.Settings))
            {
                File.Create(Reference.Settings);
            }
            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Loading settings...");

            string layout = SettingsMan.Get("keyboard_layout");

            if (layout == "fr")
            {
                Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.FR_Standard());
            }
            else if (layout == "en")
            {
                Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.US_Standard());
            }
            else if (layout == "de")
            {
                Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.DE_Standard());
            }

            ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Creating live account...");
            Acc acc = new Acc("Sartox", "123");

            acc.Create();

            Reference.Installed = File.Exists(Reference.RootPath + "Installed.txt");
            if (!Reference.Installed)
            {
                ColorConsole.WriteLine(ConsoleColor.Yellow, "=> Loading setup...");
                Setup.Init();
            }

            Console.Clear();
            ColorConsole.WriteLine(ConsoleColor.Green, $"Welcome to Sartox OS v{Reference.Version}!");
        }
Example #3
0
        private void OnShowOptions(SettingsMan settings)
        {
            using (OptionsForm optionsForm = new OptionsForm(settings))
            {
                DialogResult result = optionsForm.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    optionsForm.UpdateSettings();
                }
            }
        }
Example #4
0
        public OptionsForm(SettingsMan settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            InitializeComponent();

            m_Settings = settings;

            OptionsABTA.UpdateCtrlWithCfg(m_Settings.Cfg.Options.ABTA);
            OptionsABHC.UpdateCtrlWithCfg(m_Settings.Cfg.Options.ABHC);
            OptionsABSE.UpdateCtrlWithCfg(m_Settings.Cfg.Options.ABSE);
        }
Example #5
0
        public static void Init()
        {
            try
            {
                ColorConsole.WriteLine(ConsoleColor.Cyan, "Classic Shell v1.1");
                commands : ColorConsole.Write(ConsoleColor.Cyan, Reference.UserAccount.GetUsername());
                ColorConsole.Write(ConsoleColor.White, Reference.UserAccess);
                ColorConsole.Write(ConsoleColor.Yellow, Reference.CurrentDir);
                ColorConsole.Write(ConsoleColor.White, " => ");
                string cmd = Console.ReadLine();

                if (cmd == Reference.Commands[0])
                {
                    string all = string.Empty;
                    foreach (string comnd in Reference.Commands)
                    {
                        all += $"{comnd} - ";
                    }
                    ColorConsole.WriteLine(ConsoleColor.White, all.Remove(all.Length - 3));
                    goto commands;
                }
                else if (cmd == Reference.Commands[1])
                {
                    SimpleGui.Init();
                }
                else if (cmd == Reference.Commands[2])
                {
                    ColorConsole.WriteLine(ConsoleColor.White, $"{UnixTime.Now()} (day/month/year hour:minute:second)");
                    goto commands;
                }
                else if (cmd == Reference.Commands[3])
                {
                    ColorConsole.WriteLine(ConsoleColor.White, $"{MemoryManager.UsedMemory()} MB / {MemoryManager.TotalMemory()} MB (used / total)");
                    goto commands;
                }
                else if (cmd == Reference.Commands[4])
                {
                    Textpad.Run();
                    Console.ReadKey();
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[4]} "))
                {
                    Textpad.Run(cmd.Split(" ")[1]);
                    Console.ReadKey();
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[5]} "))
                {
                    string lang    = cmd.Split(" ")[1];
                    string setName = "keyboard_layout";
                    if (lang == "fr")
                    {
                        Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.FR_Standard());
                        SettingsMan.Add(setName, "fr");
                    }
                    else if (lang == "us")
                    {
                        Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.US_Standard());
                        SettingsMan.Add(setName, "en");
                    }
                    else if (lang == "de")
                    {
                        Sys.KeyboardManager.SetKeyLayout(new Sys.ScanMaps.DE_Standard());
                        SettingsMan.Add(setName, "de");
                    }
                    else
                    {
                        ColorConsole.WriteLine(ConsoleColor.Red, "Unknown keyboard layout.");
                    }
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[6]} "))
                {
                    string newDir = cmd.Split(" ")[1];
                    if (Directory.Exists(newDir))
                    {
                        if (newDir.Contains(Reference.RootPath))
                        {
                            Reference.CurrentDir = newDir;
                        }
                        else
                        {
                            Reference.CurrentDir += newDir;
                        }
                    }
                    else
                    {
                        ColorConsole.WriteLine(ConsoleColor.Red, "Directory not found.");
                    }
                    goto commands;
                }
                else if (cmd == Reference.Commands[7])
                {
                    List <string[]> fad = new List <string[]>
                    {
                        Directory.GetDirectories(Reference.CurrentDir),
                        Directory.GetFiles(Reference.CurrentDir)
                    };

                    for (int i = 0; i < fad.Count; i++)
                    {
                        string[] list = fad[i];
                        for (int y = 0; y < list.Length; y++)
                        {
                            ColorConsole.WriteLine(ConsoleColor.Cyan, list[y]);
                        }
                    }
                    goto commands;
                }
                else if (cmd == Reference.Commands[8])
                {
                    Console.Clear();
                    LoginMan.Init();
                }
                else if (cmd == Reference.Commands[9])
                {
                    Console.Clear();
                    goto commands;
                }
                else if (cmd == Reference.Commands[10])
                {
                    ColorConsole.WriteLine(ConsoleColor.White, $"Sartox OS ver {Reference.Version}, kernel ver {Reference.KernelVersion} made by ShiningLea.\n\nSartox OS is an operating system made in C# with the COSMOS kit. The goal here is to provide a minimal but working operating system for any purpose. Currently made by only one developer, it's highly maintained and will continue to be as long as the dev wants to (oh wait, I'm literally writing this message...)");
                    goto commands;
                }
                else if (cmd == Reference.Commands[11])
                {
                    Power.Shutdown();
                }
                else if (cmd.StartsWith($"{Reference.Commands[12]} "))
                {
                    Directory.CreateDirectory(cmd.Split(" ")[1]);
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[13]} "))
                {
                    File.Create(cmd.Split(" ")[1]);
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[14]} "))
                {
                    File.WriteAllText(cmd.Split(" ")[1], string.Empty);
                    goto commands;
                }
                else if (cmd == Reference.Commands[14])
                {
                    ColorConsole.WriteLine(ConsoleColor.White, "Touch what?");
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[15]} "))
                {
                    File.WriteAllText(cmd.Split(" ")[1], cmd.Split(" ")[2]);
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[16]} "))
                {
                    string file = cmd.Split(" ")[1];
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                    else
                    {
                        ColorConsole.WriteLine(ConsoleColor.Red, "The specified file doesn't exist.");
                    }
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[17]} "))
                {
                    string dir = cmd.Split(" ")[1];
                    if (Directory.Exists(dir))
                    {
                        Directory.Delete(dir, true);
                    }
                    else
                    {
                        ColorConsole.WriteLine(ConsoleColor.Red, "The specified directory doesn't exist.");
                    }
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[18]} "))
                {
                    string move = cmd.Split(" ")[1];
                    if (Directory.Exists(move) || File.Exists(move))
                    {
                        Directory.Move(move, cmd.Split(" ")[2]);
                    }
                    else
                    {
                        ColorConsole.WriteLine(ConsoleColor.Red, "The source directory/file doesn't exist.");
                    }
                    goto commands;
                }
                else if (cmd.StartsWith($"{Reference.Commands[19]} "))
                {
                    File.Copy(cmd.Split(" ")[1], cmd.Split(" ")[2], true);
                    goto commands;
                }
                else if (cmd == Reference.Commands[20])
                {
                    Power.Restart();
                }
                else if (cmd == Reference.Commands[21])
                {
                    throw new Exception("Crash initialized by user.");
                }
                else if (cmd == Reference.Commands[22])
                {
                    SartoxShell.Init();
                }
                else
                {
                    ColorConsole.WriteLine(ConsoleColor.Red, "Invalid command.");
                    goto commands;
                }
            }
            catch (Exception e)
            {
                Global.mDebugger.Send("ERROR : " + e.Message + e.HResult.ToString());
                ErrorScreen.Init(e.Message, e.HResult);
            }
        }