打开文件可视化窗口+CodeStudio代码高亮

This commit is contained in:
2026-03-02 21:42:44 +08:00
parent 5c952e7861
commit 29a68b4ca9
8 changed files with 550 additions and 47 deletions

View File

@@ -19,13 +19,13 @@ namespace CMLeonOS.Gui.Apps
AppWindow window;
WindowManager wm = ProcessManager.GetProcess<WindowManager>();
SettingsService settingsService = ProcessManager.GetProcess<SettingsService>();
TextBox textBox;
ShortcutBar shortcutBar;
FileBrowser fileBrowser;
private string? path = null;
private bool modified = false;
@@ -70,12 +70,6 @@ namespace CMLeonOS.Gui.Apps
{
if (newPath == null) return;
if (!FileSecurity.CanAccess(path))
{
MessageBox messageBox = new MessageBox(this, "Notepad", $"Access to '{Path.GetFileName(newPath)}' is unauthorised.");
messageBox.Show();
}
if (readFile && !File.Exists(newPath))
{
MessageBox messageBox = new MessageBox(this, "Notepad", $"No such file '{Path.GetFileName(newPath)}'.");
@@ -99,35 +93,27 @@ namespace CMLeonOS.Gui.Apps
private void OpenFilePrompt()
{
PromptBox prompt = new PromptBox(this, "Open File", "Enter the path to open.", "Path", (string newPath) =>
fileBrowser = new FileBrowser(this, wm, (string selectedPath) =>
{
if (!newPath.Contains(':'))
if (selectedPath != null)
{
newPath = $@"0:\{newPath}";
Open(selectedPath);
}
Open(newPath);
});
prompt.Show();
fileBrowser.Show();
}
private void SaveAsPrompt()
{
PromptBox prompt = new PromptBox(this, "Save As", "Enter the path to save to.", "Path", (string newPath) =>
fileBrowser = new FileBrowser(this, wm, (string selectedPath) =>
{
if (!newPath.Contains(':'))
{
newPath = $@"0:\{newPath}";
}
Open(newPath, readFile: false);
// Check if open succeeded.
if (path != null)
if (selectedPath != null)
{
path = selectedPath;
Save();
}
});
prompt.Show();
}, selectDirectoryOnly: true);
fileBrowser.Show();
}
private void Save()