Implement Toolbar
This commit is contained in:
parent
c30025f468
commit
a0b4a09742
@ -2,9 +2,9 @@
|
||||
<CommandBars LargeButtons="false" ScreenTips="true" ScreenTipShortcutKeys="true">
|
||||
<CommandBar ID="tbStandard" Title="Standard">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileNew" />
|
||||
<CommandReference CommandID="FileOpen" />
|
||||
<CommandReference CommandID="FileSave" />
|
||||
<CommandReference CommandID="FileNewDocument" />
|
||||
<CommandReference CommandID="FileOpenDocument" />
|
||||
<CommandReference CommandID="FileSaveDocument" />
|
||||
<CommandReference CommandID="FilePrint" />
|
||||
<Separator />
|
||||
<CommandReference CommandID="EditCut" />
|
||||
@ -19,4 +19,4 @@
|
||||
</Items>
|
||||
</CommandBar>
|
||||
</CommandBars>
|
||||
</ApplicationFramework>
|
||||
</ApplicationFramework>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<CommandReference CommandID="FileExit" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileNew" DefaultCommandID="FileNewDocument">
|
||||
<Command ID="FileNew" DefaultCommandID="FileNewDocument" StockType="New">
|
||||
<Items>
|
||||
<!--
|
||||
<CommandReference CommandID="FileNewDocumentFileSystem" />
|
||||
@ -28,7 +28,7 @@
|
||||
<CommandReference CommandID="FileNewProject" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileNewDocument">
|
||||
<Command ID="FileNewDocument" StockType="New">
|
||||
<Shortcut Modifiers="Control" Key="N" />
|
||||
<Parameters>
|
||||
<!-- This command takes one parameter which is not set by default -->
|
||||
@ -44,19 +44,19 @@
|
||||
<Command ID="FileNewProject">
|
||||
<Shortcut Modifiers="Control,Shift" Key="N" />
|
||||
</Command>
|
||||
<Command ID="FileOpen" DefaultCommandID="FileOpenDocument">
|
||||
<Command ID="FileOpen" DefaultCommandID="FileOpenDocument" StockType="Open">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileOpenDocument" />
|
||||
<CommandReference CommandID="FileOpenProject" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileOpenDocument">
|
||||
<Command ID="FileOpenDocument" StockType="Open">
|
||||
<Shortcut Modifiers="Control" Key="O" />
|
||||
</Command>
|
||||
<Command ID="FileOpenProject">
|
||||
<Shortcut Modifiers="Control,Shift" Key="O" />
|
||||
</Command>
|
||||
<Command ID="FileSave" DefaultCommandID="FileSaveDocument">
|
||||
<Command ID="FileSave" DefaultCommandID="FileSaveDocument" StockType="Save">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileSaveDocument" />
|
||||
<CommandReference CommandID="FileSaveDocumentAs" />
|
||||
@ -67,7 +67,7 @@
|
||||
<CommandReference CommandID="FileSaveAll" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileSaveDocument">
|
||||
<Command ID="FileSaveDocument" StockType="Save">
|
||||
<Shortcut Modifiers="Control" Key="S" />
|
||||
</Command>
|
||||
<Command ID="FileSaveDocumentAs" />
|
||||
@ -76,7 +76,7 @@
|
||||
<Command ID="FileSaveAll">
|
||||
<Shortcut Modifiers="Control,Shift" Key="S" />
|
||||
</Command>
|
||||
<Command ID="FileClose">
|
||||
<Command ID="FileClose" StockType="Close">
|
||||
<Items>
|
||||
<CommandReference CommandID="FileCloseDocument" />
|
||||
<CommandReference CommandID="FileCloseProject" />
|
||||
@ -84,7 +84,7 @@
|
||||
<CommandReference CommandID="FileCloseWindow" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileCloseDocument">
|
||||
<Command ID="FileCloseDocument" StockType="Close">
|
||||
<Shortcut Modifiers="Control" Key="W" />
|
||||
</Command>
|
||||
<Command ID="FileCloseProject">
|
||||
@ -93,7 +93,7 @@
|
||||
<Command ID="FileCloseWindow">
|
||||
<Shortcut Modifiers="Alt" Key="F4" />
|
||||
</Command>
|
||||
<Command ID="FilePrint">
|
||||
<Command ID="FilePrint" StockType="Print">
|
||||
<Shortcut Modifiers="Control" Key="P" />
|
||||
</Command>
|
||||
<Command ID="FileRecentFiles">
|
||||
@ -107,7 +107,7 @@
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="FileRestart" />
|
||||
<Command ID="FileExit">
|
||||
<Command ID="FileExit" StockType="Quit">
|
||||
<Shortcut Modifiers="Control" Key="Q" />
|
||||
</Command>
|
||||
|
||||
@ -129,34 +129,34 @@
|
||||
<CommandReference CommandID="EditGoTo" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="EditUndo">
|
||||
<Command ID="EditUndo" StockType="Undo">
|
||||
<Shortcut Modifiers="Control" Key="Z" />
|
||||
</Command>
|
||||
<Command ID="EditRedo">
|
||||
<Command ID="EditRedo" StockType="Redo">
|
||||
<Shortcut Modifiers="Control" Key="Y" />
|
||||
</Command>
|
||||
<Command ID="EditCut">
|
||||
<Command ID="EditCut" StockType="Cut">
|
||||
<Shortcut Modifiers="Control" Key="X" />
|
||||
</Command>
|
||||
<Command ID="EditCopy">
|
||||
<Command ID="EditCopy" StockType="Copy">
|
||||
<Shortcut Modifiers="Control" Key="C" />
|
||||
</Command>
|
||||
<Command ID="EditPaste">
|
||||
<Command ID="EditPaste" StockType="Paste">
|
||||
<Shortcut Modifiers="Control" Key="V" />
|
||||
</Command>
|
||||
<Command ID="EditDelete">
|
||||
<Command ID="EditDelete" StockType="Delete">
|
||||
<Shortcut Key="Delete" />
|
||||
</Command>
|
||||
<Command ID="EditSelectAll">
|
||||
<Command ID="EditSelectAll" StockType="SelectAll">
|
||||
<Shortcut Modifiers="Control" Key="A" />
|
||||
</Command>
|
||||
<Command ID="EditInvertSelection">
|
||||
<Command ID="EditInvertSelection" StockType="InvertSelection">
|
||||
<Shortcut Modifiers="Control,Shift" Key="A" />
|
||||
</Command>
|
||||
<Command ID="EditFindReplace">
|
||||
<Command ID="EditFindReplace" StockType="FindAndReplace">
|
||||
<Shortcut Modifiers="Control" Key="F" />
|
||||
</Command>
|
||||
<Command ID="EditGoTo">
|
||||
<Command ID="EditGoTo" StockType="GoTo">
|
||||
<Shortcut Modifiers="Control" Key="G" />
|
||||
</Command>
|
||||
|
||||
@ -331,7 +331,7 @@
|
||||
<Command ID="WindowResetWindowLayout" />
|
||||
<Command ID="WindowWindows" />
|
||||
|
||||
<Command ID="Help" DefaultCommandID="HelpViewHelp">
|
||||
<Command ID="Help" DefaultCommandID="HelpViewHelp" StockType="Help">
|
||||
<Items>
|
||||
<CommandReference CommandID="HelpViewHelp" />
|
||||
<Separator />
|
||||
@ -343,10 +343,10 @@
|
||||
<CommandReference CommandID="HelpAboutPlatform" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="HelpViewHelp" />
|
||||
<Command ID="HelpViewHelp" StockType="Help" />
|
||||
<Command ID="HelpCustomerFeedbackOptions" />
|
||||
<Command ID="HelpLicensingAndActivation" />
|
||||
<Command ID="HelpSoftwareManager" />
|
||||
<Command ID="HelpAboutPlatform" />
|
||||
</Commands>
|
||||
</ApplicationFramework>
|
||||
</ApplicationFramework>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using UniversalWidgetToolkit;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
{
|
||||
@ -47,11 +48,11 @@ namespace UniversalEditor.UserInterface
|
||||
private CommandShortcutKey mvarShortcutKey = new CommandShortcutKey();
|
||||
public CommandShortcutKey ShortcutKey { get { return mvarShortcutKey; } set { mvarShortcutKey = value; } }
|
||||
|
||||
private StockCommandType mvarStockCommandType = StockCommandType.None;
|
||||
private StockType mvarStockType = StockType.None;
|
||||
/// <summary>
|
||||
/// A <see cref="StockCommandType"/> that represents a predefined, platform-themed command.
|
||||
/// A <see cref="StockType"/> that represents a predefined, platform-themed command.
|
||||
/// </summary>
|
||||
public StockCommandType StockCommandType { get { return mvarStockCommandType; } set { mvarStockCommandType = value; } }
|
||||
public StockType StockType { get; set; }
|
||||
|
||||
private string mvarImageFileName = String.Empty;
|
||||
/// <summary>
|
||||
@ -85,6 +86,11 @@ namespace UniversalEditor.UserInterface
|
||||
{
|
||||
if (Executed != null) Executed(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -756,6 +756,23 @@ namespace UniversalEditor.UserInterface
|
||||
cmd.DefaultCommandID = attDefaultCommandID.Value;
|
||||
}
|
||||
|
||||
MarkupAttribute attCommandStockType = tagCommand.Attributes["StockType"];
|
||||
if (attCommandStockType != null)
|
||||
{
|
||||
StockType stockType = StockType.None;
|
||||
string[] names = Enum.GetNames(typeof(StockType));
|
||||
int[] values = (int[]) Enum.GetValues(typeof(StockType));
|
||||
for (int i = 0; i < names.Length; i++)
|
||||
{
|
||||
if (names[i].Equals(attCommandStockType.Value))
|
||||
{
|
||||
stockType = (StockType)values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
cmd.StockType = stockType;
|
||||
}
|
||||
|
||||
MarkupAttribute attTitle = tagCommand.Attributes["Title"];
|
||||
if (attTitle != null)
|
||||
{
|
||||
|
||||
@ -31,6 +31,38 @@ namespace UniversalEditor.UserInterface
|
||||
private ErrorListPanel pnlErrorList = new ErrorListPanel();
|
||||
private SolutionExplorerPanel pnlSolutionExplorer = new SolutionExplorerPanel();
|
||||
|
||||
private Toolbar LoadCommandBar(CommandBar cb)
|
||||
{
|
||||
Toolbar tb = new Toolbar();
|
||||
foreach (CommandItem ci in cb.Items)
|
||||
{
|
||||
if (ci is SeparatorCommandItem)
|
||||
{
|
||||
tb.Items.Add(new ToolbarItemSeparator());
|
||||
}
|
||||
else if (ci is CommandReferenceCommandItem)
|
||||
{
|
||||
CommandReferenceCommandItem crci = (ci as CommandReferenceCommandItem);
|
||||
Command cmd = Engine.CurrentEngine.Commands[crci.CommandID];
|
||||
if (cmd == null) continue;
|
||||
|
||||
ToolbarItemButton tsb = new ToolbarItemButton(cmd.ID, (StockType)cmd.StockType);
|
||||
tsb.SetExtraData<CommandReferenceCommandItem>("crci", crci);
|
||||
tsb.Click += tsbCommand_Click;
|
||||
tb.Items.Add(tsb);
|
||||
}
|
||||
}
|
||||
return tb;
|
||||
}
|
||||
|
||||
private void tsbCommand_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToolbarItemButton tsb = (sender as ToolbarItemButton);
|
||||
CommandReferenceCommandItem crci = tsb.GetExtraData<CommandReferenceCommandItem>("crci");
|
||||
Command cmd = Engine.CurrentEngine.Commands[crci.CommandID];
|
||||
cmd.Execute();
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
UniversalWidgetToolkit.Layouts.BoxLayout layout = new UniversalWidgetToolkit.Layouts.BoxLayout(Orientation.Vertical);
|
||||
@ -49,6 +81,13 @@ 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);
|
||||
}
|
||||
|
||||
dckContainer = new DockingContainer();
|
||||
tbsDocumentTabs = new TabContainer();
|
||||
|
||||
@ -36,9 +36,16 @@ namespace UniversalEditor.UserInterface.Panels
|
||||
{
|
||||
this.Layout = new BoxLayout(Orientation.Vertical);
|
||||
|
||||
tbErrorList.Items.Add(new ToolbarItemButton("tsbErrors", "Errors"));
|
||||
tbErrorList.Items.Add(new ToolbarItemButton("tsbWarnings", "Warnings"));
|
||||
tbErrorList.Items.Add(new ToolbarItemButton("tsbMessages", "Messages"));
|
||||
ToolbarItemButton tsbErrors = new ToolbarItemButton("tsbErrors", "Errors");
|
||||
tsbErrors.CheckOnClick = true;
|
||||
ToolbarItemButton tsbWarnings = new ToolbarItemButton("tsbWarnings", "Warnings");
|
||||
tsbWarnings.CheckOnClick = true;
|
||||
ToolbarItemButton tsbMessages = new ToolbarItemButton("tsbMessages", "Messages");
|
||||
tsbMessages.CheckOnClick = true;
|
||||
|
||||
tbErrorList.Items.Add(tsbErrors);
|
||||
tbErrorList.Items.Add(tsbWarnings);
|
||||
tbErrorList.Items.Add(tsbMessages);
|
||||
|
||||
this.Controls.Add(tbErrorList);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user