From 57316e3557c1c3a566d1a24bd60675c02d1f8744 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Thu, 20 Mar 2025 18:51:21 -0400 Subject: [PATCH] reorganize --- .../src/lib/MBS.Desktop/CommandBar.cs | 48 +++++++++++++ .../src/lib/MBS.Desktop/DesktopApplication.cs | 71 ++++++++++++------- .../MBS.Desktop/{Controls => }/MainWindow.cs | 3 +- .../lib/MBS.Desktop/{Controls => }/Window.cs | 18 ++--- 4 files changed, 104 insertions(+), 36 deletions(-) create mode 100644 desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs rename desktop-framework-dotnet/src/lib/MBS.Desktop/{Controls => }/MainWindow.cs (74%) rename desktop-framework-dotnet/src/lib/MBS.Desktop/{Controls => }/Window.cs (81%) diff --git a/desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs b/desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs new file mode 100644 index 0000000..4cdbb48 --- /dev/null +++ b/desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs @@ -0,0 +1,48 @@ +// Copyright (C) 2024 Michael Becker +// +// This file is part of editor-dotnet. +// +// editor-dotnet is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// editor-dotnet is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with editor-dotnet. If not, see . + +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using MBS.Core; + +namespace MBS.Desktop; + +public class CommandBar +{ + public Union ID { get; } + public string Title { get; set; } + public ICollection Items { get; } + + public CommandBar(Union id, string title) + { + ID = id; + Title = title; + + ObservableCollection coll = new ObservableCollection(); + coll.CollectionChanged += coll_CollectionChanged; + + Items = coll; + } + + private void coll_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + + } + } +} \ No newline at end of file diff --git a/desktop-framework-dotnet/src/lib/MBS.Desktop/DesktopApplication.cs b/desktop-framework-dotnet/src/lib/MBS.Desktop/DesktopApplication.cs index caa859e..3a979ed 100644 --- a/desktop-framework-dotnet/src/lib/MBS.Desktop/DesktopApplication.cs +++ b/desktop-framework-dotnet/src/lib/MBS.Desktop/DesktopApplication.cs @@ -1,4 +1,5 @@ -using MBS.Desktop.Controls; +using MBS.Core; +using MBS.Desktop.Controls; namespace MBS.Desktop; @@ -6,33 +7,49 @@ public class DesktopApplication : MBS.Core.Application { public DesktopApplicationEngine Engine { get; private set; } - protected override int StartInternal() - { - Console.WriteLine("DesktopApplication::StartInternal"); + protected override int StartInternal() + { + Console.WriteLine("DesktopApplication::StartInternal"); - // find the appropriate DesktopApplicationEngine for this platform - DesktopApplicationEngine[] engines = MBS.Core.Reflection.TypeLoader.GetAvailableTypes(); - Console.WriteLine("DesktopApplicationEngine loader: found {0} engines", engines.Length); - if (engines.Length > 0) - { - DesktopApplicationEngine engine = engines[0]; - if (engine != null) - { - Engine = engine; + // find the appropriate DesktopApplicationEngine for this platform + DesktopApplicationEngine[] engines = MBS.Core.Reflection.TypeLoader.GetAvailableTypes(); + Console.WriteLine("DesktopApplicationEngine loader: found {0} engines", engines.Length); + if (engines.Length > 0) + { + DesktopApplicationEngine engine = engines[0]; + if (engine != null) + { + Engine = engine; - Console.WriteLine("Using engine '{0}'", engine.GetType().FullName); - return engine.Start(); - } - } - else - { - Console.Error.WriteLine("no engines were found or could be loaded"); - } - return 2; - } + Console.WriteLine("Using engine '{0}'", engine.GetType().FullName); + return engine.Start(); + } + } + else + { + Console.Error.WriteLine("no engines were found or could be loaded"); + } + return 2; + } - protected override void StopInternal(int exitCode = 0) - { - base.StopInternal(exitCode); - } + protected override void StopInternal(int exitCode = 0) + { + base.StopInternal(exitCode); + } + + protected override void OnStartup(EventArgs e) + { + base.OnStartup(e); + + Console.WriteLine("creating menu bars"); + + CommandBar menubar = new CommandBar(new Guid("{9a67ff4f-7532-4c5e-a2e8-772940863748}"), "Menu Bar"); + // ((DesktopApplication)Instance).CommandBars.Add(menubar); + + menubar.Items.Add(new CommandReferenceCommandItem("File")); + menubar.Items.Add(new CommandReferenceCommandItem("Edit")); + menubar.Items.Add(new CommandReferenceCommandItem("View")); + menubar.Items.Add(new CommandReferenceCommandItem("Window")); + menubar.Items.Add(new CommandReferenceCommandItem("Help")); + } } diff --git a/desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/MainWindow.cs b/desktop-framework-dotnet/src/lib/MBS.Desktop/MainWindow.cs similarity index 74% rename from desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/MainWindow.cs rename to desktop-framework-dotnet/src/lib/MBS.Desktop/MainWindow.cs index ce708af..a5d6b92 100644 --- a/desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/MainWindow.cs +++ b/desktop-framework-dotnet/src/lib/MBS.Desktop/MainWindow.cs @@ -1,7 +1,8 @@ using MBS.Core; using MBS.Desktop.Layouts; +using MBS.Desktop.Controls; -namespace MBS.Desktop.Controls; +namespace MBS.Desktop; public class MainWindow : Window { diff --git a/desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/Window.cs b/desktop-framework-dotnet/src/lib/MBS.Desktop/Window.cs similarity index 81% rename from desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/Window.cs rename to desktop-framework-dotnet/src/lib/MBS.Desktop/Window.cs index a282afe..53204e8 100644 --- a/desktop-framework-dotnet/src/lib/MBS.Desktop/Controls/Window.cs +++ b/desktop-framework-dotnet/src/lib/MBS.Desktop/Window.cs @@ -1,6 +1,8 @@ using MBS.Core.Drawing; -namespace MBS.Desktop.Controls; +namespace MBS.Desktop; + +using MBS.Desktop.Controls; public class Window : Container { @@ -24,15 +26,15 @@ public class Window : Container ((Window.IImplementation)Implementation).Show(); } - protected override void InitializeImplementedProperties() - { - base.InitializeImplementedProperties(); + protected override void InitializeImplementedProperties() + { + base.InitializeImplementedProperties(); Title = _Title; DefaultSize = _DefaultSize; - } + } - private string? _Title; + private string? _Title; public string? Title { get @@ -50,7 +52,7 @@ public class Window : Container } } - private Dimension2D _DefaultSize = new Dimension2D(-1, -1); + private Dimension2D _DefaultSize = new Dimension2D(-1, -1); public Dimension2D DefaultSize { get @@ -67,5 +69,5 @@ public class Window : Container (Implementation as Window.IImplementation)?.SetDefaultSize(value); } } - + } \ No newline at end of file