dynamic menu items are built-in to UWT now, yay!
This commit is contained in:
parent
9e7c774b15
commit
ae76749954
@ -17,6 +17,8 @@ namespace UniversalEditor.UserInterface
|
||||
/// </summary>
|
||||
public abstract class Editor : MBS.Framework.UserInterface.Container
|
||||
{
|
||||
public EditorContext Context { get; private set; } = null;
|
||||
|
||||
public EditorSelection.EditorSelectionCollection Selections { get; } = new EditorSelection.EditorSelectionCollection();
|
||||
public abstract void UpdateSelections();
|
||||
public EditorSelection[] GetSelections()
|
||||
@ -227,6 +229,9 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
public Editor()
|
||||
{
|
||||
EditorReference er = MakeReference();
|
||||
Context = new EditorContext(er.ID, er.Title, er);
|
||||
|
||||
// mvarLargeImageList.ColorDepth = ColorDepth.Depth32Bit;
|
||||
// mvarLargeImageList.ImageSize = new System.Drawing.Size(32, 32);
|
||||
// mvarLargeImageList.PopulateSystemIcons();
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
//
|
||||
// EditorContext.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019 Mike Becker
|
||||
//
|
||||
// This program 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.
|
||||
//
|
||||
// This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using MBS.Framework.UserInterface;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a <see cref="MBS.Framework.UserInterface.Context" /> associated with an <see cref="Editor" />.
|
||||
/// </summary>
|
||||
public class EditorContext : Context
|
||||
{
|
||||
public EditorReference Reference { get; private set; } = null;
|
||||
|
||||
public EditorContext(Guid id, string name, EditorReference reference)
|
||||
: base(id, name)
|
||||
{
|
||||
Reference = reference;
|
||||
|
||||
for (int i = 0; i < reference.Commands.Count; i++)
|
||||
{
|
||||
Commands.Add(reference.Commands[i]);
|
||||
}
|
||||
for (int i = 0; i < reference.MenuBar.Items.Count; i++)
|
||||
{
|
||||
MenuItems.Add(reference.MenuBar.Items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,39 +283,12 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
if (editor != _prevEditor)
|
||||
{
|
||||
foreach (MBS.Framework.UserInterface.MenuItem mi in _editorScopedMenuItems)
|
||||
{
|
||||
MenuBar.Items.Remove(mi);
|
||||
}
|
||||
_editorScopedMenuItems.Clear();
|
||||
if (_prevEditor != null)
|
||||
Application.Contexts.Remove(_prevEditor.Context);
|
||||
|
||||
foreach (Command cmd in _editorScopedCommands)
|
||||
if (editor != null)
|
||||
{
|
||||
Application.Commands.Remove(cmd);
|
||||
}
|
||||
_editorScopedCommands.Clear();
|
||||
|
||||
if (editor == null)
|
||||
{
|
||||
Console.WriteLine("Editor is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Editor is NOT null");
|
||||
|
||||
EditorReference er = editor.MakeReference();
|
||||
foreach (Command cmd in er.Commands)
|
||||
{
|
||||
Application.Commands.Add(cmd);
|
||||
_editorScopedCommands.Add(cmd);
|
||||
}
|
||||
|
||||
foreach (CommandItem ci in er.MenuBar.Items)
|
||||
{
|
||||
MBS.Framework.UserInterface.MenuItem mi = MBS.Framework.UserInterface.MenuItem.LoadMenuItem(ci, MainWindow_MenuBar_Item_Click);
|
||||
MenuBar.Items.Add(mi);
|
||||
_editorScopedMenuItems.Add(mi);
|
||||
}
|
||||
Application.Contexts.Add(editor.Context);
|
||||
}
|
||||
}
|
||||
_prevEditor = editor;
|
||||
|
||||
@ -126,6 +126,7 @@
|
||||
<Compile Include="EditorViewChangingEvent.cs" />
|
||||
<Compile Include="EditorViewChangedEvent.cs" />
|
||||
<Compile Include="ExtensionMethods.cs" />
|
||||
<Compile Include="EditorContext.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user