mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
更新一堆
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@@ -33,26 +33,32 @@
|
|||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fixed_Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fixed_Release|AnyCPU'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fixed_Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Fixed_Release|x64'">
|
||||||
<WarningLevel>8</WarningLevel>
|
<WarningLevel>8</WarningLevel>
|
||||||
|
<NoWarn>1603,1701;1702,8632</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
a01dd4e
|
d7b60fa
|
||||||
@@ -364,8 +364,8 @@ namespace CMLeonOS
|
|||||||
Console.WriteLine("If this screen appears again, follow these steps:");
|
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("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("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("3. Send an post to the CMLeonOS official forum.");
|
||||||
Console.WriteLine("Contact us via email at leonmmcoset@outlook.com, including the error information for support.");
|
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("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("Warning: Unsaved data in memory will be lost due to the emergency system shutdown.");
|
||||||
Console.WriteLine("Press any key to restart.");
|
Console.WriteLine("Press any key to restart.");
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ namespace CMLeonOS
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (currentDirectory == @"0:\")
|
// if (currentDirectory == @"0:\apps")
|
||||||
{
|
// {
|
||||||
return ".";
|
// return ":";
|
||||||
}
|
// }
|
||||||
return currentDirectory;
|
return currentDirectory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,11 +333,11 @@ namespace CMLeonOS
|
|||||||
global::System.Console.SetCursorPosition(7, 14);
|
global::System.Console.SetCursorPosition(7, 14);
|
||||||
global::System.Console.WriteLine("8. No liability for data loss or corruption");
|
global::System.Console.WriteLine("8. No liability for data loss or corruption");
|
||||||
global::System.Console.SetCursorPosition(7, 15);
|
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.SetCursorPosition(7, 16);
|
||||||
global::System.Console.WriteLine("10. This license is for personal use only");
|
global::System.Console.WriteLine("10. This license is for personal use only");
|
||||||
global::System.Console.SetCursorPosition(7, 17);
|
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;
|
bool termsAccepted = false;
|
||||||
while (!termsAccepted)
|
while (!termsAccepted)
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace CMLeonOS.shell
|
|||||||
case "calc":
|
case "calc":
|
||||||
shell.Calculate(args);
|
shell.Calculate(args);
|
||||||
break;
|
break;
|
||||||
|
case "calcgui":
|
||||||
|
shell.ShowCalculatorGUI();
|
||||||
|
break;
|
||||||
case "history":
|
case "history":
|
||||||
shell.ShowHistory();
|
shell.ShowHistory();
|
||||||
break;
|
break;
|
||||||
|
|||||||
335
shell/Commands/Utility/CalcGuiCommand.cs
Normal file
335
shell/Commands/Utility/CalcGuiCommand.cs
Normal file
@@ -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<string> buttons = new List<string>
|
||||||
|
{
|
||||||
|
"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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -556,6 +556,11 @@ namespace CMLeonOS
|
|||||||
Commands.Utility.CalcCommand.Calculate(expression, ShowError);
|
Commands.Utility.CalcCommand.Calculate(expression, ShowError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowCalculatorGUI()
|
||||||
|
{
|
||||||
|
Commands.Utility.CalcGUICommand.ShowCalculator();
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowHistory()
|
public void ShowHistory()
|
||||||
{
|
{
|
||||||
Commands.Utility.HistoryCommand.ShowHistory(commandHistory);
|
Commands.Utility.HistoryCommand.ShowHistory(commandHistory);
|
||||||
|
|||||||
Reference in New Issue
Block a user