mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 11:37:01 +00:00
修复GUI的一些bug
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-03-01 17:02:21
|
2026-03-01 19:12:06
|
||||||
@@ -1 +1 @@
|
|||||||
545f40c
|
f0a9223
|
||||||
@@ -75,7 +75,6 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
("CMLeonOS (0:)", @"0:\"),
|
("CMLeonOS (0:)", @"0:\"),
|
||||||
("My Home", @$"0:\user\{UserSystem.CurrentLoggedInUser.Username}"),
|
("My Home", @$"0:\user\{UserSystem.CurrentLoggedInUser.Username}"),
|
||||||
("Users", @"0:\user"),
|
("Users", @"0:\user"),
|
||||||
("etc", @"0:\etc"),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private Bitmap GetFileIcon(string path)
|
private Bitmap GetFileIcon(string path)
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
window.DrawString($"Memory: {Cosmos.Core.CPU.GetAmountOfRAM()} MB", Color.Black, 12, 80);
|
window.DrawString($"Memory: {Cosmos.Core.CPU.GetAmountOfRAM()} MB", Color.Black, 12, 80);
|
||||||
|
|
||||||
window.DrawString("Credits", Color.DarkBlue, 12, 108);
|
window.DrawString("Credits", Color.DarkBlue, 12, 108);
|
||||||
window.DrawString("Cosmos Team - OS tooling", Color.Black, 12, 132);
|
window.DrawString("Microsoft - .NET Runtime", Color.Black, 12, 132);
|
||||||
window.DrawString("Microsoft - .NET Runtime", Color.Black, 12, 156);
|
window.DrawString("Google Fonts - Font", Color.Black, 12, 156);
|
||||||
window.DrawString("Google Fonts - Font", Color.Black, 12, 180);
|
|
||||||
|
|
||||||
Button button = new Button(window, window.Width - 80 - 12, window.Height - 20 - 12, 80, 20);
|
Button button = new Button(window, window.Width - 80 - 12, window.Height - 20 - 12, 80, 20);
|
||||||
button.Text = "OK";
|
button.Text = "OK";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Cosmos.System.Graphics;
|
using Cosmos.System.Graphics;
|
||||||
using CMLeonOS;
|
using CMLeonOS;
|
||||||
using CMLeonOS.Gui.UILib;
|
using CMLeonOS.Gui.UILib;
|
||||||
|
using CMLeonOS.Settings;
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
@@ -16,8 +17,6 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
WindowManager wm = ProcessManager.GetProcess<WindowManager>();
|
WindowManager wm = ProcessManager.GetProcess<WindowManager>();
|
||||||
|
|
||||||
SettingsService settingsService = ProcessManager.GetProcess<SettingsService>();
|
|
||||||
|
|
||||||
private static class Icons
|
private static class Icons
|
||||||
{
|
{
|
||||||
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.Gui.Resources.Settings.User.bmp")]
|
[IL2CPU.API.Attribs.ManifestResourceStream(ResourceName = "CMLeonOS.Gui.Resources.Settings.User.bmp")]
|
||||||
@@ -59,22 +58,22 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
private void LeftStartButtonChanged(bool @checked)
|
private void LeftStartButtonChanged(bool @checked)
|
||||||
{
|
{
|
||||||
settingsService.LeftHandStartButton = @checked;
|
SettingsManager.GUI_LeftHandStartButton = @checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TwelveHourClockChanged(bool @checked)
|
private void TwelveHourClockChanged(bool @checked)
|
||||||
{
|
{
|
||||||
settingsService.TwelveHourClock = @checked;
|
SettingsManager.GUI_TwelveHourClock = @checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowFpsChanged(bool @checked)
|
private void ShowFpsChanged(bool @checked)
|
||||||
{
|
{
|
||||||
settingsService.ShowFps = @checked;
|
SettingsManager.GUI_ShowFps = @checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MouseSensitivityChanged(float value)
|
private void MouseSensitivityChanged(float value)
|
||||||
{
|
{
|
||||||
settingsService.MouseSensitivity = value;
|
SettingsManager.GUI_MouseSensitivity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowAppearanceCategory()
|
private void ShowAppearanceCategory()
|
||||||
@@ -90,13 +89,13 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
Switch leftStartButton = new Switch(appearance, 12, 40, 244, 16);
|
Switch leftStartButton = new Switch(appearance, 12, 40, 244, 16);
|
||||||
leftStartButton.Text = "Left-hand start button";
|
leftStartButton.Text = "Left-hand start button";
|
||||||
leftStartButton.Checked = settingsService.LeftHandStartButton;
|
leftStartButton.Checked = SettingsManager.GUI_LeftHandStartButton;
|
||||||
leftStartButton.CheckBoxChanged = LeftStartButtonChanged;
|
leftStartButton.CheckBoxChanged = LeftStartButtonChanged;
|
||||||
wm.AddWindow(leftStartButton);
|
wm.AddWindow(leftStartButton);
|
||||||
|
|
||||||
Switch showFps = new Switch(appearance, 12, 68, 244, 16);
|
Switch showFps = new Switch(appearance, 12, 68, 244, 16);
|
||||||
showFps.Text = "Show frames per second";
|
showFps.Text = "Show frames per second";
|
||||||
showFps.Checked = settingsService.ShowFps;
|
showFps.Checked = SettingsManager.GUI_ShowFps;
|
||||||
showFps.CheckBoxChanged = ShowFpsChanged;
|
showFps.CheckBoxChanged = ShowFpsChanged;
|
||||||
wm.AddWindow(showFps);
|
wm.AddWindow(showFps);
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
Switch twelveHourClock = new Switch(dateTime, 12, 40, 244, 16);
|
Switch twelveHourClock = new Switch(dateTime, 12, 40, 244, 16);
|
||||||
twelveHourClock.Text = "12-hour clock";
|
twelveHourClock.Text = "12-hour clock";
|
||||||
twelveHourClock.Checked = settingsService.TwelveHourClock;
|
twelveHourClock.Checked = SettingsManager.GUI_TwelveHourClock;
|
||||||
twelveHourClock.CheckBoxChanged = TwelveHourClockChanged;
|
twelveHourClock.CheckBoxChanged = TwelveHourClockChanged;
|
||||||
wm.AddWindow(twelveHourClock);
|
wm.AddWindow(twelveHourClock);
|
||||||
|
|
||||||
@@ -152,7 +151,7 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
{
|
{
|
||||||
Mode mode = wm.AvailableModes[i];
|
Mode mode = wm.AvailableModes[i];
|
||||||
resolutionsTable.Cells.Add(new TableCell($"{mode.Width}x{mode.Height}"));
|
resolutionsTable.Cells.Add(new TableCell($"{mode.Width}x{mode.Height}"));
|
||||||
if (mode.Equals(settingsService.Mode))
|
if (mode.Width == SettingsManager.GUI_ScreenWidth && mode.Height == SettingsManager.GUI_ScreenHeight)
|
||||||
{
|
{
|
||||||
resolutionsTable.SelectedCellIndex = i;
|
resolutionsTable.SelectedCellIndex = i;
|
||||||
}
|
}
|
||||||
@@ -161,8 +160,8 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
resolutionsTable.TableCellSelected = (int index) =>
|
resolutionsTable.TableCellSelected = (int index) =>
|
||||||
{
|
{
|
||||||
Mode mode = wm.AvailableModes[index];
|
Mode mode = wm.AvailableModes[index];
|
||||||
settingsService.Mode = mode;
|
SettingsManager.GUI_ScreenWidth = (int)mode.Width;
|
||||||
settingsService.Flush();
|
SettingsManager.GUI_ScreenHeight = (int)mode.Height;
|
||||||
|
|
||||||
MessageBox messageBox = new MessageBox(this, "Restart Required", "Restart your PC to apply changes.");
|
MessageBox messageBox = new MessageBox(this, "Restart Required", "Restart your PC to apply changes.");
|
||||||
messageBox.Show();
|
messageBox.Show();
|
||||||
@@ -242,7 +241,7 @@ namespace CMLeonOS.Gui.Apps
|
|||||||
|
|
||||||
mouse.DrawString("Mouse sensitivity", Color.Gray, 12, 40);
|
mouse.DrawString("Mouse sensitivity", Color.Gray, 12, 40);
|
||||||
|
|
||||||
RangeSlider mouseSensitivity = new RangeSlider(mouse, 12, 68, 244, 30, min: 0.25f, value: settingsService.MouseSensitivity, max: 2f);
|
RangeSlider mouseSensitivity = new RangeSlider(mouse, 12, 68, 244, 30, min: 0.25f, value: SettingsManager.GUI_MouseSensitivity, max: 2f);
|
||||||
mouseSensitivity.Changed = MouseSensitivityChanged;
|
mouseSensitivity.Changed = MouseSensitivityChanged;
|
||||||
wm.AddWindow(mouseSensitivity);
|
wm.AddWindow(mouseSensitivity);
|
||||||
|
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ namespace CMLeonOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 我他妈居然成功了,我在没有任何文档的情况下研究出来了
|
// 我居然成功了,我在没有任何文档的情况下研究出来了
|
||||||
private void CreateMBRandPartitionTable(Disk disk)
|
private void CreateMBRandPartitionTable(Disk disk)
|
||||||
{
|
{
|
||||||
disk.Clear();
|
disk.Clear();
|
||||||
|
|||||||
@@ -12,7 +12,14 @@ namespace CMLeonOS.Settings
|
|||||||
private static Dictionary<string, string> defaultSettings = new Dictionary<string, string>
|
private static Dictionary<string, string> defaultSettings = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "LoggerEnabled", "true" },
|
{ "LoggerEnabled", "true" },
|
||||||
{ "MaxLoginAttempts", "3" }
|
{ "MaxLoginAttempts", "3" },
|
||||||
|
{ "GUI_LeftHandStartButton", "false" },
|
||||||
|
{ "GUI_ShowFps", "true" },
|
||||||
|
{ "GUI_TwelveHourClock", "false" },
|
||||||
|
{ "GUI_MouseSensitivity", "1.0" },
|
||||||
|
{ "GUI_ScreenWidth", "1280" },
|
||||||
|
{ "GUI_ScreenHeight", "800" },
|
||||||
|
{ "GUI_DarkNotepad", "false" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool LoggerEnabled
|
public static bool LoggerEnabled
|
||||||
@@ -52,6 +59,134 @@ namespace CMLeonOS.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool GUI_LeftHandStartButton
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_LeftHandStartButton", out string value))
|
||||||
|
{
|
||||||
|
return value.ToLower() == "true";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_LeftHandStartButton"] = value ? "true" : "false";
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool GUI_ShowFps
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_ShowFps", out string value))
|
||||||
|
{
|
||||||
|
return value.ToLower() == "true";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_ShowFps"] = value ? "true" : "false";
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool GUI_TwelveHourClock
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_TwelveHourClock", out string value))
|
||||||
|
{
|
||||||
|
return value.ToLower() == "true";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_TwelveHourClock"] = value ? "true" : "false";
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float GUI_MouseSensitivity
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_MouseSensitivity", out string value))
|
||||||
|
{
|
||||||
|
if (float.TryParse(value, out float result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_MouseSensitivity"] = value.ToString();
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GUI_ScreenWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_ScreenWidth", out string value))
|
||||||
|
{
|
||||||
|
if (int.TryParse(value, out int result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1280;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_ScreenWidth"] = value.ToString();
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GUI_ScreenHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_ScreenHeight", out string value))
|
||||||
|
{
|
||||||
|
if (int.TryParse(value, out int result))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 800;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_ScreenHeight"] = value.ToString();
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool GUI_DarkNotepad
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (settings.TryGetValue("GUI_DarkNotepad", out string value))
|
||||||
|
{
|
||||||
|
return value.ToLower() == "true";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
settings["GUI_DarkNotepad"] = value ? "true" : "false";
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void LoadSettings()
|
public static void LoadSettings()
|
||||||
{
|
{
|
||||||
settings.Clear();
|
settings.Clear();
|
||||||
|
|||||||
@@ -15,18 +15,26 @@ namespace CMLeonOS.Utils
|
|||||||
|
|
||||||
string sanitized = path;
|
string sanitized = path;
|
||||||
|
|
||||||
sanitized = sanitized.Replace('\\', '/');
|
// 保留驱动器字母和冒号(如 0:)
|
||||||
sanitized = sanitized.Replace(':', '_');
|
// 检查格式:X:\ 其中 X 是单个字符(字母或数字)
|
||||||
sanitized = sanitized.Replace('*', '_');
|
bool hasDrive = sanitized.Length >= 2 && sanitized[1] == ':';
|
||||||
sanitized = sanitized.Replace('?', '_');
|
string drive = hasDrive ? sanitized.Substring(0, 2) : "";
|
||||||
sanitized = sanitized.Replace('"', '_');
|
string rest = hasDrive ? sanitized.Substring(2) : sanitized;
|
||||||
sanitized = sanitized.Replace('<', '_');
|
|
||||||
sanitized = sanitized.Replace('>', '_');
|
|
||||||
sanitized = sanitized.Replace('|', '_');
|
|
||||||
|
|
||||||
sanitized = sanitized.Trim('/', '\\');
|
// 不替换反斜杠,因为 Cosmos 文件系统需要反斜杠
|
||||||
|
rest = rest.Replace(':', '_');
|
||||||
|
rest = rest.Replace('*', '_');
|
||||||
|
rest = rest.Replace('?', '_');
|
||||||
|
rest = rest.Replace('"', '_');
|
||||||
|
rest = rest.Replace('<', '_');
|
||||||
|
rest = rest.Replace('>', '_');
|
||||||
|
rest = rest.Replace('|', '_');
|
||||||
|
|
||||||
return sanitized;
|
// 只移除结尾的斜杠,保留开头的斜杠(因为驱动器后面需要斜杠)
|
||||||
|
rest = rest.TrimEnd('/');
|
||||||
|
rest = rest.TrimEnd('\\');
|
||||||
|
|
||||||
|
return drive + rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Combine(string path1, string path2)
|
public static string Combine(string path1, string path2)
|
||||||
|
|||||||
Reference in New Issue
Block a user