diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj index 1a64a0b..ba40c12 100644 --- a/CMLeonOS.csproj +++ b/CMLeonOS.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -33,26 +33,32 @@ 8 + 1603,1701;1702,8632 8 + 1603,1701;1702,8632 8 + 1603,1701;1702,8632 8 + 1603,1701;1702,8632 8 + 1603,1701;1702,8632 8 + 1603,1701;1702,8632 diff --git a/GitCommit.txt b/GitCommit.txt index 48a9dcc..4286705 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -a01dd4e \ No newline at end of file +d7b60fa \ No newline at end of file diff --git a/Kernel.cs b/Kernel.cs index 03ba138..7581ed0 100644 --- a/Kernel.cs +++ b/Kernel.cs @@ -364,8 +364,8 @@ namespace CMLeonOS Console.WriteLine("If this screen appears again, follow these steps:"); Console.WriteLine("1. Check the system logs to ensure all kernel modules are loaded correctly."); Console.WriteLine("2. Record the system version and steps to reproduce the error."); - Console.WriteLine("3. Send an email to the CMLeonOS developer team (the email address is below)."); - Console.WriteLine("Contact us via email at leonmmcoset@outlook.com, including the error information for support."); + Console.WriteLine("3. Send an post to the CMLeonOS official forum."); + Console.WriteLine("Contact us via https://lbbs.ecuil.com/#/thread/category/10, including the error information for support."); Console.WriteLine("Please include the system build version, runtime environment, and operation steps before the crash."); Console.WriteLine("Warning: Unsaved data in memory will be lost due to the emergency system shutdown."); Console.WriteLine("Press any key to restart."); diff --git a/System/FileSystem.cs b/System/FileSystem.cs index 132d2d5..025a2bb 100644 --- a/System/FileSystem.cs +++ b/System/FileSystem.cs @@ -30,10 +30,10 @@ namespace CMLeonOS { get { - if (currentDirectory == @"0:\") - { - return "."; - } + // if (currentDirectory == @"0:\apps") + // { + // return ":"; + // } return currentDirectory; } } diff --git a/System/UserSystem.cs b/System/UserSystem.cs index 69c5736..d0bab31 100644 --- a/System/UserSystem.cs +++ b/System/UserSystem.cs @@ -333,11 +333,11 @@ namespace CMLeonOS global::System.Console.SetCursorPosition(7, 14); global::System.Console.WriteLine("8. No liability for data loss or corruption"); global::System.Console.SetCursorPosition(7, 15); - global::System.Console.WriteLine("9. Support available at: leonmmcoset@outlook.com"); + global::System.Console.WriteLine("9. Support available at: https://lbbs.ecuil.com/#/thread/category/10"); global::System.Console.SetCursorPosition(7, 16); global::System.Console.WriteLine("10. This license is for personal use only"); global::System.Console.SetCursorPosition(7, 17); - global::System.Console.WriteLine("11. Use of this OS requires recognition of the one-China principle."); + global::System.Console.WriteLine("11. Use of this OS requires recognition of the one-China principle"); bool termsAccepted = false; while (!termsAccepted) diff --git a/shell/CommandList.cs b/shell/CommandList.cs index 6e5b004..62a322c 100644 --- a/shell/CommandList.cs +++ b/shell/CommandList.cs @@ -34,6 +34,9 @@ namespace CMLeonOS.shell case "calc": shell.Calculate(args); break; + case "calcgui": + shell.ShowCalculatorGUI(); + break; case "history": shell.ShowHistory(); break; diff --git a/shell/Commands/Utility/CalcGuiCommand.cs b/shell/Commands/Utility/CalcGuiCommand.cs new file mode 100644 index 0000000..c4de615 --- /dev/null +++ b/shell/Commands/Utility/CalcGuiCommand.cs @@ -0,0 +1,335 @@ +using System; +using System.Collections.Generic; +using CMLeonOS.UI; + +namespace CMLeonOS.Commands.Utility +{ + public static class CalcGUICommand + { + private static string currentInput = "0"; + private static string previousInput = ""; + private static string currentOperation = ""; + private static bool newInput = true; + private static int selectedButton = 0; + + private static readonly List buttons = new List + { + "7", "8", "9", "/", + "4", "5", "6", "*", + "1", "2", "3", "-", + "C", "0", "=", "+" + }; + + public static void ShowCalculator() + { + Console.Clear(); + + var window = new Window( + new Rect(5, 2, 40, 20), + "Calculator", + () => { }, + true + ); + window.Render(); + + bool running = true; + while (running) + { + RenderCalculator(); + + var key = Console.ReadKey(true); + + switch (key.Key) + { + case ConsoleKey.D0: + case ConsoleKey.NumPad0: + PressButton("0"); + break; + case ConsoleKey.D1: + case ConsoleKey.NumPad1: + PressButton("1"); + break; + case ConsoleKey.D2: + case ConsoleKey.NumPad2: + PressButton("2"); + break; + case ConsoleKey.D3: + case ConsoleKey.NumPad3: + PressButton("3"); + break; + case ConsoleKey.D4: + case ConsoleKey.NumPad4: + PressButton("4"); + break; + case ConsoleKey.D5: + case ConsoleKey.NumPad5: + PressButton("5"); + break; + case ConsoleKey.D6: + case ConsoleKey.NumPad6: + PressButton("6"); + break; + case ConsoleKey.D7: + case ConsoleKey.NumPad7: + PressButton("7"); + break; + case ConsoleKey.D8: + case ConsoleKey.NumPad8: + PressButton("8"); + break; + case ConsoleKey.D9: + case ConsoleKey.NumPad9: + PressButton("9"); + break; + case ConsoleKey.Add: + PressButton("+"); + break; + case ConsoleKey.Subtract: + PressButton("-"); + break; + case ConsoleKey.Multiply: + PressButton("*"); + break; + case ConsoleKey.Divide: + PressButton("/"); + break; + case ConsoleKey.Enter: + PressButton("="); + break; + case ConsoleKey.Escape: + case ConsoleKey.Q: + running = false; + break; + case ConsoleKey.Backspace: + if (currentInput.Length > 1) + { + currentInput = currentInput.Substring(0, currentInput.Length - 1); + } + else if (currentInput.Length == 1) + { + currentInput = "0"; + } + else + { + currentInput = "0"; + } + break; + case ConsoleKey.C: + PressButton("C"); + break; + case ConsoleKey.UpArrow: + selectedButton = Math.Max(0, selectedButton - 4); + break; + case ConsoleKey.DownArrow: + selectedButton = Math.Min(15, selectedButton + 4); + break; + case ConsoleKey.LeftArrow: + selectedButton = Math.Max(0, selectedButton - 1); + break; + case ConsoleKey.RightArrow: + selectedButton = Math.Min(15, selectedButton + 1); + break; + } + } + + Console.Clear(); + } + + private static void RenderCalculator() + { + var window = new Window( + new Rect(5, 2, 40, 20), + "Calculator", + () => { }, + true + ); + window.Render(); + + TUIHelper.SetColors(ConsoleColor.White, ConsoleColor.DarkBlue); + + Console.SetCursorPosition(7, 4); + Console.Write(new string(' ', 36)); + Console.SetCursorPosition(7, 4); + Console.Write(currentInput); + + int startX = 7; + int startY = 7; + int buttonWidth = 8; + int buttonHeight = 3; + + for (int i = 0; i < buttons.Count; i++) + { + int row = i / 4; + int col = i % 4; + + int x = startX + col * (buttonWidth + 1); + int y = startY + row * (buttonHeight + 1); + + bool isSelected = (i == selectedButton); + ConsoleColor bgColor = isSelected ? ConsoleColor.Yellow : ConsoleColor.DarkGray; + ConsoleColor fgColor = isSelected ? ConsoleColor.Black : ConsoleColor.White; + + TUIHelper.SetColors(fgColor, bgColor); + + for (int py = 0; py < buttonHeight; py++) + { + Console.SetCursorPosition(x, y + py); + for (int px = 0; px < buttonWidth; px++) + { + if (py == 0 || py == buttonHeight - 1 || px == 0 || px == buttonWidth - 1) + { + Console.Write(isSelected ? " " : "+"); + } + else + { + Console.Write(" "); + } + } + } + + string buttonText = buttons[i]; + int textX = x + (buttonWidth - buttonText.Length) / 2; + int textY = y + buttonHeight / 2; + Console.SetCursorPosition(textX, textY); + Console.Write(buttonText); + } + + TUIHelper.SetColors(ConsoleColor.Gray, ConsoleColor.DarkBlue); + Console.SetCursorPosition(7, 18); + Console.Write("Arrow keys to navigate, Enter to select"); + Console.SetCursorPosition(7, 19); + Console.Write("Esc or Q to exit"); + } + + private static void PressButton(string button) + { + switch (button) + { + case "C": + currentInput = "0"; + previousInput = ""; + currentOperation = ""; + newInput = true; + break; + + case "=": + if (!string.IsNullOrEmpty(currentOperation) && !string.IsNullOrEmpty(previousInput)) + { + try + { + double num1 = double.Parse(previousInput); + double num2 = double.Parse(currentInput); + double result = 0; + + switch (currentOperation) + { + case "+": + result = num1 + num2; + break; + case "-": + result = num1 - num2; + break; + case "*": + result = num1 * num2; + break; + case "/": + if (num2 != 0) + { + result = num1 / num2; + } + else + { + currentInput = "Error"; + return; + } + break; + } + + currentInput = result.ToString(); + previousInput = ""; + currentOperation = ""; + newInput = true; + } + catch + { + currentInput = "Error"; + } + } + break; + + case "+": + case "-": + case "*": + case "/": + if (string.IsNullOrEmpty(currentInput)) + { + currentInput = "0"; + } + + if (string.IsNullOrEmpty(previousInput) || string.IsNullOrEmpty(currentOperation)) + { + previousInput = currentInput; + currentOperation = button; + newInput = true; + } + else + { + try + { + double num1 = double.Parse(previousInput); + double num2 = double.Parse(currentInput); + double result = 0; + + switch (currentOperation) + { + case "+": + result = num1 + num2; + break; + case "-": + result = num1 - num2; + break; + case "*": + result = num1 * num2; + break; + case "/": + if (num2 != 0) + { + result = num1 / num2; + } + else + { + currentInput = "Error"; + return; + } + break; + } + + previousInput = result.ToString(); + currentOperation = button; + newInput = false; + } + catch + { + currentInput = "Error"; + } + } + break; + + default: + if (newInput || currentInput == "0" || currentInput == "Error") + { + currentInput = button; + newInput = false; + } + else + { + if (currentInput.Length < 10) + { + currentInput += button; + } + } + break; + } + } + } +} \ No newline at end of file diff --git a/shell/Shell.cs b/shell/Shell.cs index 3dcaa48..dcdfcc9 100644 --- a/shell/Shell.cs +++ b/shell/Shell.cs @@ -556,6 +556,11 @@ namespace CMLeonOS Commands.Utility.CalcCommand.Calculate(expression, ShowError); } + public void ShowCalculatorGUI() + { + Commands.Utility.CalcGUICommand.ShowCalculator(); + } + public void ShowHistory() { Commands.Utility.HistoryCommand.ShowHistory(commandHistory);