reorganize
This commit is contained in:
parent
2a25e02514
commit
57316e3557
48
desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs
Normal file
48
desktop-framework-dotnet/src/lib/MBS.Desktop/CommandBar.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
||||||
|
//
|
||||||
|
// 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using MBS.Core;
|
||||||
|
|
||||||
|
namespace MBS.Desktop;
|
||||||
|
|
||||||
|
public class CommandBar
|
||||||
|
{
|
||||||
|
public Union<Guid, string> ID { get; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public ICollection<CommandItem> Items { get; }
|
||||||
|
|
||||||
|
public CommandBar(Union<Guid, string> id, string title)
|
||||||
|
{
|
||||||
|
ID = id;
|
||||||
|
Title = title;
|
||||||
|
|
||||||
|
ObservableCollection<CommandItem> coll = new ObservableCollection<CommandItem>();
|
||||||
|
coll.CollectionChanged += coll_CollectionChanged;
|
||||||
|
|
||||||
|
Items = coll;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void coll_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using MBS.Desktop.Controls;
|
using MBS.Core;
|
||||||
|
using MBS.Desktop.Controls;
|
||||||
|
|
||||||
namespace MBS.Desktop;
|
namespace MBS.Desktop;
|
||||||
|
|
||||||
@ -6,33 +7,49 @@ public class DesktopApplication : MBS.Core.Application
|
|||||||
{
|
{
|
||||||
public DesktopApplicationEngine Engine { get; private set; }
|
public DesktopApplicationEngine Engine { get; private set; }
|
||||||
|
|
||||||
protected override int StartInternal()
|
protected override int StartInternal()
|
||||||
{
|
{
|
||||||
Console.WriteLine("DesktopApplication::StartInternal");
|
Console.WriteLine("DesktopApplication::StartInternal");
|
||||||
|
|
||||||
// find the appropriate DesktopApplicationEngine for this platform
|
// find the appropriate DesktopApplicationEngine for this platform
|
||||||
DesktopApplicationEngine[] engines = MBS.Core.Reflection.TypeLoader.GetAvailableTypes<DesktopApplicationEngine>();
|
DesktopApplicationEngine[] engines = MBS.Core.Reflection.TypeLoader.GetAvailableTypes<DesktopApplicationEngine>();
|
||||||
Console.WriteLine("DesktopApplicationEngine loader: found {0} engines", engines.Length);
|
Console.WriteLine("DesktopApplicationEngine loader: found {0} engines", engines.Length);
|
||||||
if (engines.Length > 0)
|
if (engines.Length > 0)
|
||||||
{
|
{
|
||||||
DesktopApplicationEngine engine = engines[0];
|
DesktopApplicationEngine engine = engines[0];
|
||||||
if (engine != null)
|
if (engine != null)
|
||||||
{
|
{
|
||||||
Engine = engine;
|
Engine = engine;
|
||||||
|
|
||||||
Console.WriteLine("Using engine '{0}'", engine.GetType().FullName);
|
Console.WriteLine("Using engine '{0}'", engine.GetType().FullName);
|
||||||
return engine.Start();
|
return engine.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("no engines were found or could be loaded");
|
Console.Error.WriteLine("no engines were found or could be loaded");
|
||||||
}
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void StopInternal(int exitCode = 0)
|
protected override void StopInternal(int exitCode = 0)
|
||||||
{
|
{
|
||||||
base.StopInternal(exitCode);
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
using MBS.Core;
|
using MBS.Core;
|
||||||
using MBS.Desktop.Layouts;
|
using MBS.Desktop.Layouts;
|
||||||
|
using MBS.Desktop.Controls;
|
||||||
|
|
||||||
namespace MBS.Desktop.Controls;
|
namespace MBS.Desktop;
|
||||||
|
|
||||||
public class MainWindow : Window
|
public class MainWindow : Window
|
||||||
{
|
{
|
||||||
@ -1,6 +1,8 @@
|
|||||||
using MBS.Core.Drawing;
|
using MBS.Core.Drawing;
|
||||||
|
|
||||||
namespace MBS.Desktop.Controls;
|
namespace MBS.Desktop;
|
||||||
|
|
||||||
|
using MBS.Desktop.Controls;
|
||||||
|
|
||||||
public class Window : Container
|
public class Window : Container
|
||||||
{
|
{
|
||||||
@ -24,15 +26,15 @@ public class Window : Container
|
|||||||
((Window.IImplementation)Implementation).Show();
|
((Window.IImplementation)Implementation).Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitializeImplementedProperties()
|
protected override void InitializeImplementedProperties()
|
||||||
{
|
{
|
||||||
base.InitializeImplementedProperties();
|
base.InitializeImplementedProperties();
|
||||||
|
|
||||||
Title = _Title;
|
Title = _Title;
|
||||||
DefaultSize = _DefaultSize;
|
DefaultSize = _DefaultSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string? _Title;
|
private string? _Title;
|
||||||
public string? Title
|
public string? Title
|
||||||
{
|
{
|
||||||
get
|
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
|
public Dimension2D DefaultSize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
Loading…
x
Reference in New Issue
Block a user