diff --git a/Directory.Packages.props b/Directory.Packages.props index 0db0bc9..fb4fc9e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,17 +6,19 @@ - + - - - - - - - + + + + + + + + + diff --git a/Progrart.Core/ProjectSystem/Project.cs b/Progrart.Core/ProjectSystem/Project.cs index 0edd368..4ca6034 100644 --- a/Progrart.Core/ProjectSystem/Project.cs +++ b/Progrart.Core/ProjectSystem/Project.cs @@ -7,11 +7,18 @@ namespace Progrart.Core.ProjectSystem [Serializable] public class Project { + public List Configurations = new List(); } [Serializable] public class BuildConfiguration { public string? Name; - + public List Items = new List(); + } + [Serializable] + public class BuildItem + { + public string? Source; + public string? Target; } } diff --git a/Progrart/App.axaml b/Progrart/App.axaml index 406ccf8..341395a 100644 --- a/Progrart/App.axaml +++ b/Progrart/App.axaml @@ -1,14 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Progrart/App.axaml.cs b/Progrart/App.axaml.cs index 953f5a1..4cabec6 100644 --- a/Progrart/App.axaml.cs +++ b/Progrart/App.axaml.cs @@ -23,6 +23,7 @@ public partial class App : Application IconProvider.Register(new DefaultIconProvider()); EditorProvider.Register("text", "Default Text Editor", typeof(EditorPage)); EditorProvider.Register("image", "Default Image Viewer", typeof(ImageViewPage)); + EditorProvider.Register("progrart", "Default Progrart Editor", typeof(ProgrartEditorPage)); EditorProvider.BindFileType("cs", "text"); EditorProvider.BindFileType("c", "text"); EditorProvider.BindFileType("cpp", "text"); @@ -33,7 +34,7 @@ public partial class App : Application EditorProvider.BindFileType("cpp", "text"); EditorProvider.BindFileType("json", "text"); EditorProvider.BindFileType("sh", "text"); - EditorProvider.BindFileType("progrart", "text"); + EditorProvider.BindFileType("progrart", "progrart"); EditorProvider.BindFileType("bashrc", "text"); EditorProvider.BindFileType("png", "image"); EditorProvider.BindFileType("bmp", "image"); diff --git a/Progrart/Controls/BaseEditor.axaml b/Progrart/Controls/BaseEditor.axaml new file mode 100644 index 0000000..666049a --- /dev/null +++ b/Progrart/Controls/BaseEditor.axaml @@ -0,0 +1,11 @@ + + + diff --git a/Progrart/Controls/BaseEditor.axaml.cs b/Progrart/Controls/BaseEditor.axaml.cs new file mode 100644 index 0000000..086b62e --- /dev/null +++ b/Progrart/Controls/BaseEditor.axaml.cs @@ -0,0 +1,37 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using AvaloniaEdit.TextMate; +using TextMateSharp.Grammars; + +namespace Progrart.Controls; + +public partial class BaseEditor : UserControl +{ + RegistryOptions _registryOptions; + TextMate.Installation _textMateInstallation; + public string Text + { + get => CodeEditBox.Text; + set => CodeEditBox.Text = value; + } + public BaseEditor() + { + InitializeComponent(); + { + var _textEditor = CodeEditBox; + _registryOptions = new RegistryOptions(ThemeName.DarkPlus); + _textMateInstallation = _textEditor.InstallTextMate(_registryOptions); + _textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(_registryOptions.GetLanguageByExtension(".js").Id)); + } + } + public void SetGrammerByExtension(string extension_name) + { + _textMateInstallation.SetGrammar( + _registryOptions.GetScopeByLanguageId( + _registryOptions.GetLanguageByExtension(extension_name).Id + ) + ); + + } +} \ No newline at end of file diff --git a/Progrart/Controls/FileItem.axaml b/Progrart/Controls/FileItem.axaml index 396d05f..89a3642 100644 --- a/Progrart/Controls/FileItem.axaml +++ b/Progrart/Controls/FileItem.axaml @@ -11,6 +11,15 @@ + + + + + + + + + diff --git a/Progrart/Controls/FileItem.axaml.cs b/Progrart/Controls/FileItem.axaml.cs index dfad962..b4cc44e 100644 --- a/Progrart/Controls/FileItem.axaml.cs +++ b/Progrart/Controls/FileItem.axaml.cs @@ -2,7 +2,10 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.Platform.Storage; +using Avalonia.Threading; +using DialogHostAvalonia; using Progrart.Controls.TabSystem; +using Progrart.Dialogs; using Progrart.Icons; using Progrart.Pages; using System.Threading.Tasks; @@ -26,6 +29,7 @@ public partial class FileItem : UserControl } else if (storageItem is IStorageFile file) { + NewFiles.IsVisible = false; FolderIcon.IsVisible = false; GenericFileIcon.IsVisible = true; IconContainer.Children.Clear(); @@ -44,14 +48,86 @@ public partial class FileItem : UserControl NameBlock.Text = storageItem.Name; MainButton.DoubleTapped += async (_, _) => { - await OpenItem(); + OpenItem(); }; OpenFileMenuItem.Click += async (a, b) => { - await OpenItem(); + OpenItem(); + }; + CreateFolderItem.Click += async (a, b) => + { + InputDialog content = new(); + content.SetDialogContent("Create New Folder", "Specify a name that is legal for your filesystem."); + content.onOK = async (v) => + { + if (currentItem is IStorageFolder folder) + { + try + { + var fldr = await folder.CreateFolderAsync(v); + if (fldr is not null) + { + if (isOpen) + Dispatcher.UIThread.Invoke(() => + { + var fitem = new FileItem(fldr); + ItemContainer.Children.Add(fitem); + }); + } + else + { + content.SetErrorMessage($"{v} is not a valid name for target filesystem."); + return true; + } + } + catch (System.Exception e) + { + content.SetErrorMessage($"{v} is not a valid name for target filesystem.\nMsg:{e.Message}"); + return true; + } + } + return false; + }; + await DialogHost.Show(content); + }; + CreateProgrartItem.Click += async (a, b) => + { + InputDialog content = new(); + content.SetDialogContent("Create A PROGRART Image", "Specify a name that is legal for your filesystem."); + content.onOK = async (v) => + { + if (currentItem is IStorageFolder folder) + { + try + { + var fldr = await folder.CreateFileAsync($"{v}.progrart"); + if (fldr is not null) + { + if (isOpen) + Dispatcher.UIThread.Invoke(() => + { + var fitem = new FileItem(fldr); + ItemContainer.Children.Add(fitem); + }); + } + else + { + content.SetErrorMessage($"{v} is not a valid name for target filesystem."); + return true; + } + } + catch (System.Exception e) + { + content.SetErrorMessage($"{v} is not a valid name for target filesystem.\nMsg:{e.Message}"); + return true; + } + } + return false; + }; + await DialogHost.Show(content); }; } - async Task OpenItem() + void OpenItem() { if (currentItem is IStorageFolder folder) @@ -64,7 +140,10 @@ public partial class FileItem : UserControl else { isOpen = true; - await LoadAll(folder); + Task.Run(async () => + { + await LoadAll(folder); + }); } } else @@ -88,7 +167,11 @@ public partial class FileItem : UserControl { await foreach (var item in folder.GetItemsAsync()) { - ItemContainer.Children.Add(new FileItem(item)); + Dispatcher.UIThread.Invoke(() => + { + var fitem = new FileItem(item); + ItemContainer.Children.Add(fitem); + }); } } void RemoveAll() diff --git a/Progrart/Controls/TabSystem/TabButton.axaml b/Progrart/Controls/TabSystem/TabButton.axaml index e90b4e4..a41e012 100644 --- a/Progrart/Controls/TabSystem/TabButton.axaml +++ b/Progrart/Controls/TabSystem/TabButton.axaml @@ -10,7 +10,9 @@ - + + + - - - - - - - - - - - - - - - - - - - - - - File Explorer - - - - - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - All - - - - - - + File Explorer + + + + - + + + + - + + + - - - - - - - - - - - - - - - - - Output - - - + + + + + + + + + + + + + All + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + Output + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/Progrart/Views/MainView.axaml.cs b/Progrart/Views/MainView.axaml.cs index 14272cd..9494dc9 100644 --- a/Progrart/Views/MainView.axaml.cs +++ b/Progrart/Views/MainView.axaml.cs @@ -1,5 +1,6 @@ using Avalonia.Controls; using Avalonia.Platform.Storage; +using Avalonia.Threading; using Progrart.Controls; using Progrart.Core.JSExecution; using Progrart.Pages; @@ -29,7 +30,7 @@ public partial class MainView : UserControl WriteLine(e.Message); } }; - Trace.Listeners.Add(new ConsoleLogger()); + //Trace.Listeners.Add(new ConsoleLogger()); EditorProvider.setHost(MainTabHost); BottomPanelToggle.IsCheckedChanged += (a, b) => { @@ -47,7 +48,6 @@ public partial class MainView : UserControl ContentGrid.RowDefinitions[2].MinHeight = 0; } }; - LeftPanelToggle.IsCheckedChanged += (a, b) => { bool v = LeftPanelToggle.IsChecked == true; @@ -92,11 +92,26 @@ public partial class MainView : UserControl } public void Write(string message) { - Output.Text += message; + //Dispatcher.UIThread.Invoke(() => + //Output.Text += message); + try + { + Output.Text += message; + } + catch (Exception) + { + } } public void WriteLine(string message) { - Output.Text += $"{message}\n"; + //Dispatcher.UIThread.Invoke(() =>); + try + { + Output.Text += $"{message}\n"; + } + catch (Exception) + { + } } private class ConsoleLogger : TraceListener {