Preliminary (hardcoded) support for Ribbon

This commit is contained in:
Michael Becker 2019-07-26 01:16:27 -04:00
parent ed5c7ea701
commit dbe8dbc84a
9 changed files with 145 additions and 563 deletions

View File

@ -1,96 +0,0 @@
using System;
using UniversalWidgetToolkit;
namespace UniversalEditor.UserInterface
{
public class Command
{
public class CommandCollection
: System.Collections.ObjectModel.Collection<Command>
{
public Command this[string ID]
{
get
{
foreach (Command command in this)
{
if (command.ID == ID) return command;
}
return null;
}
}
}
private bool mvarEnableTearoff = false;
public bool EnableTearoff { get { return mvarEnableTearoff; } set { mvarEnableTearoff = value; } }
private bool mvarChecked = false;
/// <summary>
/// Determines whether this command displays as checked.
/// </summary>
public bool Checked { get { return mvarChecked; } set { mvarChecked = value; } }
private string mvarID = String.Empty;
/// <summary>
/// The ID of the command, used to reference it in <see cref="CommandReferenceCommandItem"/>.
/// </summary>
public string ID { get { return mvarID; } set { mvarID = value; } }
private string mvarTitle = String.Empty;
/// <summary>
/// The title of the command (including mnemonic prefix, if applicable).
/// </summary>
public string Title { get { return mvarTitle; } set { mvarTitle = value; } }
private string mvarDefaultCommandID = String.Empty;
public string DefaultCommandID { get { return mvarDefaultCommandID; } set { mvarDefaultCommandID = value; } }
private CommandShortcutKey mvarShortcutKey = new CommandShortcutKey();
public CommandShortcutKey ShortcutKey { get { return mvarShortcutKey; } set { mvarShortcutKey = value; } }
private StockType mvarStockType = StockType.None;
/// <summary>
/// A <see cref="StockType"/> that represents a predefined, platform-themed command.
/// </summary>
public StockType StockType { get; set; }
private string mvarImageFileName = String.Empty;
/// <summary>
/// The file name of the image to be displayed on the command.
/// </summary>
public string ImageFileName { get { return mvarImageFileName; } set { mvarImageFileName = value; } }
private CommandItem.CommandItemCollection mvarItems = new CommandItem.CommandItemCollection();
/// <summary>
/// The child <see cref="CommandItem"/>s that are contained within this <see cref="Command"/>.
/// </summary>
public CommandItem.CommandItemCollection Items { get { return mvarItems; } }
/// <summary>
/// The event that is fired when the command is executed.
/// </summary>
public event EventHandler Executed;
/// <summary>
/// Determines whether this <see cref="Command" /> is visible in all <see cref="CommandBar" />s and <see cref="MenuBar" />s
/// that reference it.
/// </summary>
/// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
public bool Visible { get; set; }
/// <summary>
/// Executes this <see cref="Command"/>.
/// </summary>
public void Execute()
{
if (Executed != null) Executed(this, EventArgs.Empty);
}
public override string ToString()
{
return this.ID;
}
}
}

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversalWidgetToolkit;
namespace UniversalEditor.UserInterface
{
public class CommandBar

View File

@ -1,35 +0,0 @@
using System;
namespace UniversalEditor.UserInterface
{
public abstract class CommandItem
{
public class CommandItemCollection
: System.Collections.ObjectModel.Collection<CommandItem>
{
}
}
public class CommandReferenceCommandItem : CommandItem
{
private string mvarCommandID = String.Empty;
public string CommandID { get { return mvarCommandID; } set { mvarCommandID = value; } }
public CommandReferenceCommandItem(string commandID)
{
mvarCommandID = commandID;
}
}
public class CommandPlaceholderCommandItem : CommandItem
{
private string mvarPlaceholderID = String.Empty;
public string PlaceholderID { get { return mvarPlaceholderID; } set { mvarPlaceholderID = value; } }
public CommandPlaceholderCommandItem(string placeholderID)
{
mvarPlaceholderID = placeholderID;
}
}
public class SeparatorCommandItem : CommandItem
{
}
}

View File

@ -1,186 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniversalWidgetToolkit.Input.Keyboard;
namespace UniversalEditor.UserInterface
{
[Flags()]
public enum CommandShortcutKeyModifiers
{
None = 0,
Control = 1,
Shift = 2,
Alt = 4,
Meta = 8,
Super = 16,
Hyper = 32
}
public enum CommandShortcutKeyValue
{
None = 0,
//
// Summary:
// The SPACEBAR key.
Space = 32,
//
// Summary:
// The PAGE UP key.
Prior = 33,
//
// Summary:
// The PAGE UP key.
PageUp = 33,
//
// Summary:
// The PAGE DOWN key.
Next = 34,
//
// Summary:
// The PAGE DOWN key.
PageDown = 34,
//
// Summary:
// The END key.
End = 35,
//
// Summary:
// The HOME key.
Home = 36,
//
// Summary:
// The LEFT ARROW key.
Left = 37,
//
// Summary:
// The UP ARROW key.
Up = 38,
//
// Summary:
// The RIGHT ARROW key.
Right = 39,
//
// Summary:
// The DOWN ARROW key.
Down = 40,
//
// Summary:
// The SELECT key.
Select = 41,
//
// Summary:
// The PRINT key.
Print = 42,
//
// Summary:
// The EXECUTE key.
Execute = 43,
//
// Summary:
// The PRINT SCREEN key.
PrintScreen = 44,
//
// Summary:
// The INS key.
Insert = 45,
//
// Summary:
// The DEL key.
Delete = 46,
//
// Summary:
// The HELP key.
Help = 47,
TopRow0 = 48,
TopRow1,
TopRow2,
TopRow3,
TopRow4,
TopRow5,
TopRow6,
TopRow7,
TopRow8,
TopRow9,
A = 65,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
NumPad0 = 96,
NumPad1,
NumPad2,
NumPad3,
NumPad4,
NumPad5,
NumPad6,
NumPad7,
NumPad8,
NumPad9,
F1 = 112,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12
}
public class CommandShortcutKey
{
private CommandShortcutKeyModifiers mvarModifiers = CommandShortcutKeyModifiers.None;
public CommandShortcutKeyModifiers Modifiers { get { return mvarModifiers; } set { mvarModifiers = value; } }
private CommandShortcutKeyValue mvarValue = CommandShortcutKeyValue.None;
public CommandShortcutKeyValue Value { get { return mvarValue; } set { mvarValue = value; } }
public bool CompareTo(KeyboardKey keyData)
{
// first look at modifier keys
// if (!(((value.Modifiers & CommandShortcutKeyModifiers.Alt) == CommandShortcutKeyModifiers.Alt)
// && ((keyData & KeyboardModifierKey.Alt) == KeyboardModifierKey.Alt))) return false;
return true;
}
public CommandShortcutKey()
: this(CommandShortcutKeyValue.None, CommandShortcutKeyModifiers.None)
{
}
public CommandShortcutKey(CommandShortcutKeyValue value, CommandShortcutKeyModifiers modifiers = CommandShortcutKeyModifiers.None)
{
mvarValue = value;
mvarModifiers = modifiers;
}
}
}

View File

@ -482,10 +482,12 @@ namespace UniversalEditor.UserInterface
// look at this editor's configuration to see if we have any registered keybindings
foreach (Command cmd in mvarCommands)
{
if (cmd.ShortcutKey.CompareTo(e.KeyData))
/*
if (cmd.Shortcut.CompareTo(e.KeyData))
{
cmd.Execute();
}
*/
}
}

View File

@ -17,6 +17,7 @@ using UniversalWidgetToolkit.Dialogs;
using UniversalWidgetToolkit.Drawing;
using UniversalEditor.UserInterface.Dialogs;
using UniversalWidgetToolkit;
using UniversalWidgetToolkit.Input.Keyboard;
using MBS.Framework.Drawing;
namespace UniversalEditor.UserInterface
@ -200,18 +201,6 @@ namespace UniversalEditor.UserInterface
return new Engine[] { _TheEngine };
}
public bool AttachCommandEventHandler(string commandID, EventHandler handler)
{
Command cmd = Commands[commandID];
if (cmd != null)
{
cmd.Executed += handler;
return true;
}
Console.WriteLine("attempted to attach handler for unknown command '" + commandID + "'");
return false;
}
protected virtual void AfterInitialization()
{
}
@ -220,93 +209,93 @@ namespace UniversalEditor.UserInterface
{
// Initialize all the commands that are common to UniversalEditor
#region File
AttachCommandEventHandler("FileNewDocument", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileNewDocument", delegate(object sender, EventArgs e)
{
LastWindow.NewFile();
});
AttachCommandEventHandler("FileNewProject", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileNewProject", delegate(object sender, EventArgs e)
{
LastWindow.NewProject();
});
AttachCommandEventHandler("FileOpenDocument", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileOpenDocument", delegate(object sender, EventArgs e)
{
LastWindow.OpenFile();
});
AttachCommandEventHandler("FileOpenProject", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileOpenProject", delegate(object sender, EventArgs e)
{
LastWindow.OpenProject();
});
AttachCommandEventHandler("FileSaveDocument", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileSaveDocument", delegate(object sender, EventArgs e)
{
LastWindow.SaveFile();
});
AttachCommandEventHandler("FileSaveDocumentAs", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileSaveDocumentAs", delegate(object sender, EventArgs e)
{
LastWindow.SaveFileAs();
});
AttachCommandEventHandler("FileSaveProject", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileSaveProject", delegate(object sender, EventArgs e)
{
LastWindow.SaveProject();
});
AttachCommandEventHandler("FileSaveProjectAs", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileSaveProjectAs", delegate(object sender, EventArgs e)
{
LastWindow.SaveProjectAs();
});
AttachCommandEventHandler("FileSaveAll", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileSaveAll", delegate(object sender, EventArgs e)
{
LastWindow.SaveAll();
});
AttachCommandEventHandler("FileCloseDocument", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileCloseDocument", delegate(object sender, EventArgs e)
{
LastWindow.CloseFile();
});
AttachCommandEventHandler("FileCloseProject", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileCloseProject", delegate(object sender, EventArgs e)
{
LastWindow.CloseProject();
});
AttachCommandEventHandler("FileRestart", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileRestart", delegate(object sender, EventArgs e)
{
RestartApplication();
});
AttachCommandEventHandler("FileExit", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("FileExit", delegate(object sender, EventArgs e)
{
StopApplication();
});
#endregion
#region Edit
AttachCommandEventHandler("EditCut", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditCut", delegate(object sender, EventArgs e)
{
Command cmdCopy = mvarCommands["EditCopy"];
Command cmdDelete = mvarCommands["EditDelete"];
Command cmdCopy = Application.Commands["EditCopy"];
Command cmdDelete = Application.Commands["EditDelete"];
cmdCopy.Execute ();
cmdDelete.Execute ();
});
AttachCommandEventHandler("EditCopy", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditCopy", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
editor.Copy();
});
AttachCommandEventHandler("EditPaste", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditPaste", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
editor.Paste();
});
AttachCommandEventHandler("EditDelete", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditDelete", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
editor.Delete();
});
AttachCommandEventHandler("EditUndo", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditUndo", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
editor.Undo();
});
AttachCommandEventHandler("EditRedo", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("EditRedo", delegate(object sender, EventArgs e)
{
Editor editor = LastWindow.GetCurrentEditor();
if (editor == null) return;
@ -314,52 +303,52 @@ namespace UniversalEditor.UserInterface
});
#endregion
#region View
AttachCommandEventHandler("ViewFullScreen", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewFullScreen", delegate(object sender, EventArgs e)
{
Command cmd = (sender as Command);
LastWindow.FullScreen = !LastWindow.FullScreen;
cmd.Checked = LastWindow.FullScreen;
});
#region Perspective
AttachCommandEventHandler("ViewPerspective1", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective1", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(1);
});
AttachCommandEventHandler("ViewPerspective2", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective2", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(2);
});
AttachCommandEventHandler("ViewPerspective3", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective3", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(3);
});
AttachCommandEventHandler("ViewPerspective4", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective4", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(4);
});
AttachCommandEventHandler("ViewPerspective5", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective5", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(5);
});
AttachCommandEventHandler("ViewPerspective6", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective6", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(6);
});
AttachCommandEventHandler("ViewPerspective7", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective7", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(7);
});
AttachCommandEventHandler("ViewPerspective8", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective8", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(8);
});
AttachCommandEventHandler("ViewPerspective9", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewPerspective9", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.SwitchPerspective(9);
});
#endregion
AttachCommandEventHandler("ViewStartPage", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ViewStartPage", delegate(object sender, EventArgs e)
{
HostApplication.CurrentWindow.ShowStartPage();
});
@ -367,27 +356,27 @@ namespace UniversalEditor.UserInterface
#endregion
#region Tools
// ToolsOptions should actually be under the Edit menu as "Preferences" on Linux systems
AttachCommandEventHandler("ToolsOptions", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("ToolsOptions", delegate(object sender, EventArgs e)
{
LastWindow.ShowOptionsDialog();
});
#endregion
#region Window
AttachCommandEventHandler("WindowNewWindow", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("WindowNewWindow", delegate(object sender, EventArgs e)
{
OpenWindow();
});
AttachCommandEventHandler("WindowWindows", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("WindowWindows", delegate(object sender, EventArgs e)
{
LastWindow.SetWindowListVisible(true, true);
});
#endregion
#region Help
AttachCommandEventHandler("HelpLicensingAndActivation", delegate (object sender, EventArgs e)
Application.AttachCommandEventHandler("HelpLicensingAndActivation", delegate (object sender, EventArgs e)
{
MessageDialog.ShowDialog("This product has already been activated.", "Licensing and Activation", MessageDialogButtons.OK, MessageDialogIcon.Information);
});
AttachCommandEventHandler("HelpAboutPlatform", delegate(object sender, EventArgs e)
Application.AttachCommandEventHandler("HelpAboutPlatform", delegate(object sender, EventArgs e)
{
ShowAboutDialog();
});
@ -403,17 +392,17 @@ namespace UniversalEditor.UserInterface
cmdViewToolbarsToolbar.ID = "ViewToolbars" + i.ToString();
cmdViewToolbarsToolbar.Title = mvarCommandBars[i].Title;
cmdViewToolbarsToolbar.Executed += cmdViewToolbarsToolbar_Executed;
mvarCommands.Add(cmdViewToolbarsToolbar);
mvarCommands["ViewToolbars"].Items.Insert(0, new CommandReferenceCommandItem(cmdViewToolbarsToolbar.ID));
Application.Commands.Add(cmdViewToolbarsToolbar);
Application.Commands["ViewToolbars"].Items.Insert(0, new CommandReferenceCommandItem(cmdViewToolbarsToolbar.ID));
}
#endregion
#region Panels
if (mvarCommands["ViewPanels"] != null)
if (Application.Commands["ViewPanels"] != null)
{
Command cmdViewPanels1 = new Command();
cmdViewPanels1.ID = "ViewPanels1";
mvarCommands.Add(cmdViewPanels1);
mvarCommands["ViewPanels"].Items.Add(new CommandReferenceCommandItem("ViewPanels1"));
Application.Commands.Add(cmdViewPanels1);
Application.Commands["ViewPanels"].Items.Add(new CommandReferenceCommandItem("ViewPanels1"));
}
#endregion
#endregion
@ -421,13 +410,13 @@ namespace UniversalEditor.UserInterface
#region Language Strings
#region Help
Command helpAboutPlatform = mvarCommands["HelpAboutPlatform"];
Command helpAboutPlatform = Application.Commands["HelpAboutPlatform"];
if (helpAboutPlatform != null)
{
helpAboutPlatform.Title = String.Format(helpAboutPlatform.Title, mvarDefaultLanguage.GetStringTableEntry("ApplicationTitle", "Universal Editor"));
}
Command helpLanguage = mvarCommands["HelpLanguage"];
Command helpLanguage = Application.Commands["HelpLanguage"];
if (helpLanguage != null)
{
foreach (Language lang in mvarLanguages)
@ -439,7 +428,7 @@ namespace UniversalEditor.UserInterface
{
HostApplication.Messages.Add(HostApplicationMessageSeverity.Notice, "Clicked language " + lang.ID);
};
mvarCommands.Add(cmdLanguage);
Application.Commands.Add(cmdLanguage);
helpLanguage.Items.Add(new CommandReferenceCommandItem("HelpLanguage_" + lang.ID));
}
@ -495,12 +484,6 @@ namespace UniversalEditor.UserInterface
return true;
}
private Command.CommandCollection mvarCommands = new Command.CommandCollection();
/// <summary>
/// The commands defined for this application.
/// </summary>
public Command.CommandCollection Commands { get { return mvarCommands; } }
private Language mvarDefaultLanguage = null;
/// <summary>
/// The default <see cref="Language"/> used to display translatable text in this application.
@ -790,7 +773,7 @@ namespace UniversalEditor.UserInterface
MarkupAttribute attKey = tagShortcut.Attributes["Key"];
if (attKey != null)
{
CommandShortcutKeyModifiers modifiers = CommandShortcutKeyModifiers.None;
KeyboardModifierKey modifiers = KeyboardModifierKey.None;
if (attModifiers != null)
{
string[] strModifiers = attModifiers.Value.Split(new char[] { ',' });
@ -800,37 +783,40 @@ namespace UniversalEditor.UserInterface
{
case "alt":
{
modifiers |= CommandShortcutKeyModifiers.Alt;
modifiers |= KeyboardModifierKey.Alt;
break;
}
case "control":
{
modifiers |= CommandShortcutKeyModifiers.Control;
modifiers |= KeyboardModifierKey.Control;
break;
}
case "meta":
{
modifiers |= CommandShortcutKeyModifiers.Meta;
modifiers |= KeyboardModifierKey.Meta;
break;
}
case "shift":
{
modifiers |= CommandShortcutKeyModifiers.Shift;
modifiers |= KeyboardModifierKey.Shift;
break;
}
case "super":
{
modifiers |= CommandShortcutKeyModifiers.Super;
modifiers |= KeyboardModifierKey.Super;
break;
}
}
}
}
CommandShortcutKeyValue value = CommandShortcutKeyValue.None;
value = (CommandShortcutKeyValue)Enum.Parse(typeof(CommandShortcutKeyValue), attKey.Value);
KeyboardKey value = KeyboardKey.None;
if (!Enum.TryParse<KeyboardKey>(attKey.Value, out value))
{
Console.WriteLine("ue: ui: unable to parse keyboard key '{0}'", attKey.Value);
}
cmd.ShortcutKey = new CommandShortcutKey(value, modifiers);
cmd.Shortcut = new Shortcut(value, modifiers);
}
}
@ -846,7 +832,7 @@ namespace UniversalEditor.UserInterface
}
}
mvarCommands.Add(cmd);
Application.Commands.Add(cmd);
}
}
#endregion
@ -907,7 +893,7 @@ namespace UniversalEditor.UserInterface
}
else
{
foreach (Command cmd in mvarCommands)
foreach (Command cmd in Application.Commands)
{
cmd.Title = mvarDefaultLanguage.GetCommandTitle(cmd.ID, cmd.ID);
}

View File

@ -1,4 +1,7 @@
using System;
using UniversalWidgetToolkit;
namespace UniversalEditor.UserInterface
{
public class EngineMainMenu

View File

@ -20,6 +20,8 @@ using UniversalWidgetToolkit.Drawing;
using MBS.Framework.Drawing;
// TODO: We need to work on UWT signaling to native objects...
using UniversalWidgetToolkit.Layouts;
using UniversalWidgetToolkit.Controls.Ribbon;
namespace UniversalEditor.UserInterface
{
@ -31,6 +33,43 @@ namespace UniversalEditor.UserInterface
private ErrorListPanel pnlErrorList = new ErrorListPanel();
private SolutionExplorerPanel pnlSolutionExplorer = new SolutionExplorerPanel();
private RibbonTab LoadRibbonBar(CommandBar cb)
{
RibbonTab tab = new RibbonTab ();
RibbonTabGroup rtgClipboard = new RibbonTabGroup ();
rtgClipboard.Title = "Clipboard";
rtgClipboard.Items.Add (new RibbonCommandItemButton ("EditPaste"));
(rtgClipboard.Items[0] as RibbonCommandItemButton).IsImportant = true;
rtgClipboard.Items.Add (new RibbonCommandItemButton ("EditCut"));
rtgClipboard.Items.Add (new RibbonCommandItemButton ("EditCopy"));
rtgClipboard.Items.Add (new RibbonCommandItemButton ("EditDelete"));
tab.Groups.Add (rtgClipboard);
/*
Container ctFont = new Container ();
ctFont.Layout = new BoxLayout (Orientation.Vertical);
Container ctFontFace = new Container ();
ctFontFace.Layout = new BoxLayout (Orientation.Horizontal);
TextBox txtFontFace = new TextBox ();
txtFontFace.Text = "Calibri (Body)";
ctFontFace.Controls.Add (txtFontFace);
ctFont.Controls.Add (ctFontFace);
RibbonTabGroup rtgFont = LoadRibbonTabGroup ("Font", ctFont);
tab.Groups.Add (rtgFont);
Toolbar tb = LoadCommandBar (cb);
RibbonTabGroup rtg2 = LoadRibbonTabGroup ("General", tb);
tab.Groups.Add (rtg2);
*/
return tab;
}
private Toolbar LoadCommandBar(CommandBar cb)
{
Toolbar tb = new Toolbar();
@ -43,7 +82,7 @@ namespace UniversalEditor.UserInterface
else if (ci is CommandReferenceCommandItem)
{
CommandReferenceCommandItem crci = (ci as CommandReferenceCommandItem);
Command cmd = Engine.CurrentEngine.Commands[crci.CommandID];
Command cmd = Application.Commands[crci.CommandID];
if (cmd == null) continue;
ToolbarItemButton tsb = new ToolbarItemButton(cmd.ID, (StockType)cmd.StockType);
@ -59,16 +98,32 @@ namespace UniversalEditor.UserInterface
{
ToolbarItemButton tsb = (sender as ToolbarItemButton);
CommandReferenceCommandItem crci = tsb.GetExtraData<CommandReferenceCommandItem>("crci");
Command cmd = Engine.CurrentEngine.Commands[crci.CommandID];
Command cmd = Application.Commands[crci.CommandID];
cmd.Execute();
}
protected override void OnKeyDown(KeyEventArgs e)
{
// we have to process key shortcuts manually if we do not use a traditional menu bar
if ((e.ModifierKeys & KeyboardModifierKey.Control) == KeyboardModifierKey.Control) {
switch (e.Key) {
case KeyboardKey.Q:
{
Application.Stop (0);
break;
}
}
}
}
public MainWindow()
{
UniversalWidgetToolkit.Layouts.BoxLayout layout = new UniversalWidgetToolkit.Layouts.BoxLayout(Orientation.Vertical);
this.Layout = layout;
this.IconName = "universal-editor";
this.CommandDisplayMode = CommandDisplayMode.Ribbon;
foreach (CommandItem ci in Engine.CurrentEngine.MainMenu.Items)
{
UniversalWidgetToolkit.MenuItem mi = LoadMenuItem(ci);
@ -81,14 +136,18 @@ namespace UniversalEditor.UserInterface
}
this.MenuBar.Items.Add(mi);
}
foreach (CommandBar cb in Engine.CurrentEngine.CommandBars)
{
Toolbar tb = LoadCommandBar(cb);
if (tb == null) continue;
Controls.Add(tb);
}
if (this.CommandDisplayMode == CommandDisplayMode.Ribbon || this.CommandDisplayMode == CommandDisplayMode.Both) {
foreach (CommandBar cb in Engine.CurrentEngine.CommandBars) {
RibbonTab ribbonTabHome = LoadRibbonBar (cb);
ribbonTabHome.Title = "Home";
this.Ribbon.Tabs.Add (ribbonTabHome);
}
} else {
foreach (CommandBar cb in Engine.CurrentEngine.CommandBars) {
this.Controls.Add (LoadCommandBar(cb));
}
}
dckContainer = new DockingContainer();
tbsDocumentTabs = new TabContainer();
@ -137,9 +196,10 @@ namespace UniversalEditor.UserInterface
public void NewFile()
{
/*
NewDialog2 dlg2 = new NewDialog2();
dlg2.ShowDialog();
*/
NewDialog dlg = new NewDialog();
dlg.Mode = NewDialogMode.File;
@ -316,7 +376,7 @@ namespace UniversalEditor.UserInterface
if (mi == null)
return;
Command cmd = UniversalEditor.UserInterface.Engine.CurrentEngine.Commands[mi.Name];
Command cmd = Application.Commands[mi.Name];
if (cmd == null)
{
Console.WriteLine("unknown cmd '" + mi.Name + "'");
@ -338,167 +398,18 @@ namespace UniversalEditor.UserInterface
}, DragDropEffect.Copy, MouseButtons.Primary | MouseButtons.Secondary, KeyboardModifierKey.None);
}
private Shortcut CommandShortcutKeyToUWTShortcut(CommandShortcutKey shortcutKey)
{
KeyboardKey key = KeyboardKey.None;
switch (shortcutKey.Value)
{
case CommandShortcutKeyValue.A:
{
key = KeyboardKey.A;
break;
}
case CommandShortcutKeyValue.B:
{
key = KeyboardKey.B;
break;
}
case CommandShortcutKeyValue.C:
{
key = KeyboardKey.C;
break;
}
case CommandShortcutKeyValue.D:
{
key = KeyboardKey.D;
break;
}
case CommandShortcutKeyValue.E:
{
key = KeyboardKey.E;
break;
}
case CommandShortcutKeyValue.F:
{
key = KeyboardKey.F;
break;
}
case CommandShortcutKeyValue.G:
{
key = KeyboardKey.G;
break;
}
case CommandShortcutKeyValue.H:
{
key = KeyboardKey.H;
break;
}
case CommandShortcutKeyValue.I:
{
key = KeyboardKey.I;
break;
}
case CommandShortcutKeyValue.J:
{
key = KeyboardKey.J;
break;
}
case CommandShortcutKeyValue.K:
{
key = KeyboardKey.K;
break;
}
case CommandShortcutKeyValue.L:
{
key = KeyboardKey.L;
break;
}
case CommandShortcutKeyValue.M:
{
key = KeyboardKey.M;
break;
}
case CommandShortcutKeyValue.N:
{
key = KeyboardKey.N;
break;
}
case CommandShortcutKeyValue.O:
{
key = KeyboardKey.O;
break;
}
case CommandShortcutKeyValue.P:
{
key = KeyboardKey.P;
break;
}
case CommandShortcutKeyValue.Q:
{
key = KeyboardKey.Q;
break;
}
case CommandShortcutKeyValue.R:
{
key = KeyboardKey.R;
break;
}
case CommandShortcutKeyValue.S:
{
key = KeyboardKey.S;
break;
}
case CommandShortcutKeyValue.T:
{
key = KeyboardKey.T;
break;
}
case CommandShortcutKeyValue.U:
{
key = KeyboardKey.U;
break;
}
case CommandShortcutKeyValue.V:
{
key = KeyboardKey.V;
break;
}
case CommandShortcutKeyValue.W:
{
key = KeyboardKey.W;
break;
}
case CommandShortcutKeyValue.X:
{
key = KeyboardKey.X;
break;
}
case CommandShortcutKeyValue.Y:
{
key = KeyboardKey.Y;
break;
}
case CommandShortcutKeyValue.Z:
{
key = KeyboardKey.Z;
break;
}
}
KeyboardModifierKey modifierKeys = KeyboardModifierKey.None;
if ((shortcutKey.Modifiers & CommandShortcutKeyModifiers.Alt) == CommandShortcutKeyModifiers.Alt) modifierKeys |= KeyboardModifierKey.Alt;
if ((shortcutKey.Modifiers & CommandShortcutKeyModifiers.Control) == CommandShortcutKeyModifiers.Control) modifierKeys |= KeyboardModifierKey.Control;
if ((shortcutKey.Modifiers & CommandShortcutKeyModifiers.Hyper) == CommandShortcutKeyModifiers.Hyper) modifierKeys |= KeyboardModifierKey.Hyper;
if ((shortcutKey.Modifiers & CommandShortcutKeyModifiers.Shift) == CommandShortcutKeyModifiers.Shift) modifierKeys |= KeyboardModifierKey.Shift;
if ((shortcutKey.Modifiers & CommandShortcutKeyModifiers.Super) == CommandShortcutKeyModifiers.Super) modifierKeys |= KeyboardModifierKey.Super;
return new Shortcut(key, modifierKeys);
}
private UniversalWidgetToolkit.MenuItem LoadMenuItem(CommandItem ci)
{
if (ci is CommandReferenceCommandItem)
{
CommandReferenceCommandItem crci = (ci as CommandReferenceCommandItem);
Command cmd = UniversalEditor.UserInterface.Engine.CurrentEngine.Commands[crci.CommandID];
Command cmd = Application.Commands[crci.CommandID];
if (cmd != null)
{
CommandMenuItem mi = new CommandMenuItem(cmd.Title);
mi.Name = cmd.ID;
mi.Shortcut = CommandShortcutKeyToUWTShortcut(cmd.ShortcutKey);
mi.Shortcut = cmd.Shortcut;
if (cmd.Items.Count > 0)
{
foreach (CommandItem ci1 in cmd.Items)
@ -685,27 +596,27 @@ namespace UniversalEditor.UserInterface
private void AddRecentMenuItem(string FileName)
{
Command mnuFileRecentFiles = Engine.CurrentEngine.Commands["FileRecentFiles"];
Command mnuFileRecentFiles = Application.Commands["FileRecentFiles"];
Command mnuFileRecentFile = new Command();
mnuFileRecentFile.ID = "FileRecentFile_" + FileName;
mnuFileRecentFile.Title = System.IO.Path.GetFileName(FileName);
// mnuFileRecentFile.ToolTipText = FileName;
Engine.CurrentEngine.Commands.Add(mnuFileRecentFile);
Application.Commands.Add(mnuFileRecentFile);
CommandReferenceCommandItem tsmi = new CommandReferenceCommandItem("FileRecentFile_" + FileName);
mnuFileRecentFiles.Items.Add(tsmi);
}
private void RefreshRecentFilesList()
{
Command mnuFileRecentFiles = Engine.CurrentEngine.Commands["FileRecentFiles"];
Command mnuFileRecentFiles = Application.Commands["FileRecentFiles"];
mnuFileRecentFiles.Items.Clear();
foreach (string fileName in Engine.CurrentEngine.RecentFileManager.FileNames)
{
AddRecentMenuItem(fileName);
}
Command mnuFileRecentProjects = Engine.CurrentEngine.Commands["FileRecentProjects"];
Command mnuFileRecentProjects = Application.Commands["FileRecentProjects"];
mnuFileRecentFiles.Visible = (mnuFileRecentFiles.Items.Count > 0);
mnuFileRecentProjects.Visible = (mnuFileRecentProjects.Items.Count > 0);

View File

@ -3,8 +3,6 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8622EBC4-8E20-476E-B284-33D472081F5C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
@ -60,7 +58,6 @@
<Compile Include="BookmarksManager.cs" />
<Compile Include="CommandBar.cs" />
<Compile Include="CommandDisplayStyle.cs" />
<Compile Include="CommandShortcutKey.cs" />
<Compile Include="Common\Reflection.cs" />
<Compile Include="ConfigurationManager.cs" />
<Compile Include="CustomOptionDialogType.cs" />
@ -85,8 +82,6 @@
<Compile Include="Toolbox.cs" />
<Compile Include="UnsavedDocumentOption.cs" />
<Compile Include="WindowState.cs" />
<Compile Include="CommandItem.cs" />
<Compile Include="Command.cs" />
<Compile Include="StockCommandType.cs" />
<Compile Include="EngineMainMenu.cs" />
<Compile Include="MainWindow.cs" />