take advantage of FINALLY! keyboard and mouse binding support in UWT and some other aesthetic improvements
This commit is contained in:
parent
1b93e21699
commit
0185e4ab32
@ -1,7 +1,21 @@
|
||||
<UniversalEditor Version="5.0">
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<UniversalEditor Version="5.0">
|
||||
<Editors>
|
||||
<Editor ID="{1B5B1E8D-442A-4AC0-8EFD-03AADFF3CAD2}" TypeName="UniversalEditor.Editors.FileSystem.FileSystemEditor">
|
||||
<Editor ID="{1B5B1E8D-442A-4AC0-8EFD-03AADFF3CAD2}" TypeName="UniversalEditor.Editors.FileSystem.FileSystemEditor" Title="File System Editor">
|
||||
<Contexts>
|
||||
<Context ID="{ce094932-77fb-418f-bd98-e3734a670fad}" Name="Tree View - File System Editor" />
|
||||
</Contexts>
|
||||
<CommandBindings>
|
||||
<!-- set up the default command bindings for this editor context -->
|
||||
<CommandBinding Key="F5" CommandID="FileSystemContextMenu_CopyTo" />
|
||||
<CommandBinding Key="F6" CommandID="FileSystemContextMenu_Rename" />
|
||||
<CommandBinding Key="F7" CommandID="FileSystemContextMenu_New_Folder" />
|
||||
<CommandBinding Key="F8" CommandID="EditDelete" />
|
||||
</CommandBindings>
|
||||
<Commands>
|
||||
<Command ID="FileSystemEditor_GoUp" Title="Go Up" />
|
||||
<Command ID="FileSystemEditor_OpenSelection" Title="Open Selection in Current Tab" />
|
||||
|
||||
<Command ID="FileSystemContextMenu_View_Thumbnails" Title="T_humbnails" />
|
||||
<Command ID="FileSystemContextMenu_View_Tiles" Title="Tile_s" />
|
||||
<Command ID="FileSystemContextMenu_View_Icons" Title="Ico_ns" />
|
||||
|
||||
@ -162,6 +162,12 @@ namespace UniversalEditor.UserInterface.Common
|
||||
er.Configuration.Combine(tagEditor);
|
||||
}
|
||||
|
||||
MarkupAttribute attTitle = tagEditor.Attributes["Title"];
|
||||
if (attTitle != null)
|
||||
{
|
||||
er.Title = attTitle.Value;
|
||||
}
|
||||
|
||||
MarkupTagElement tagCommands = (tagEditor.Elements["Commands"] as MarkupTagElement);
|
||||
if (tagCommands != null)
|
||||
{
|
||||
@ -195,6 +201,43 @@ namespace UniversalEditor.UserInterface.Common
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MarkupTagElement tagCommandBindings = (tagEditor.Elements["CommandBindings"] as MarkupTagElement);
|
||||
if (tagCommandBindings != null)
|
||||
{
|
||||
foreach (MarkupElement elCommandBinding in tagCommandBindings.Elements)
|
||||
{
|
||||
CommandBinding cb = CommandBinding.FromXML(elCommandBinding as MarkupTagElement);
|
||||
if (cb == null) continue;
|
||||
|
||||
(Application.Instance as UIApplication).CommandBindings.Add(cb);
|
||||
}
|
||||
}
|
||||
|
||||
MarkupTagElement tagContexts = (tagEditor.Elements["Contexts"] as MarkupTagElement);
|
||||
if (tagContexts != null)
|
||||
{
|
||||
// load the contexts defined by this editor
|
||||
// these are NOT contexts that will automatically be added to the application when the editor is focused!
|
||||
|
||||
// these are for advertising Editor-specific contexts that aren't loaded by the rest of the application
|
||||
// so that we can associate settings with them
|
||||
|
||||
foreach (MarkupElement elContext in tagContexts.Elements)
|
||||
{
|
||||
MarkupTagElement tagContext = elContext as MarkupTagElement;
|
||||
if (tagContext == null) continue;
|
||||
if (tagContext.FullName != "Context") continue;
|
||||
|
||||
MarkupAttribute attContextID = tagContext.Attributes["ID"];
|
||||
MarkupAttribute attContextName = tagContext.Attributes["Name"];
|
||||
if (attContextID == null || attContextName == null) continue;
|
||||
|
||||
Context ctx = new Context(new Guid(attContextID.Value), attContextName.Value);
|
||||
er.Contexts.Add(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
MarkupTagElement tagMenuBar = (tagEditor.Elements["MenuBar"] as MarkupTagElement);
|
||||
if (tagMenuBar != null)
|
||||
{
|
||||
|
||||
@ -28,6 +28,7 @@ using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Input.Keyboard;
|
||||
using MBS.Framework.UserInterface.Dialogs;
|
||||
using MBS.Framework;
|
||||
using MBS.Framework.UserInterface.Input.Mouse;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
{
|
||||
@ -709,19 +710,23 @@ namespace UniversalEditor.UserInterface
|
||||
return base.ProcessKeyPreview(ref m);
|
||||
}
|
||||
*/
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
// look at this editor's configuration to see if we have any registered keybindings
|
||||
foreach (Command cmd in Commands)
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
// FIXME: this should be sorted by contextID
|
||||
foreach (CommandBinding binding in (Application.Instance as UIApplication).CommandBindings)
|
||||
{
|
||||
/*
|
||||
if (cmd.Shortcut.CompareTo(e.KeyData))
|
||||
if (binding.Match(e))
|
||||
{
|
||||
cmd.Execute();
|
||||
if (binding.ContextID == null || Application.Instance.Contexts.Contains(binding.ContextID.Value))
|
||||
{
|
||||
Application.Instance.ExecuteCommand(binding.CommandID);
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -875,5 +880,9 @@ namespace UniversalEditor.UserInterface
|
||||
MessageDialog.ShowDialog(String.Format("TODO: Implement Document Properties dialog for '{0}'!", GetType().Name), "Not Implemented", MessageDialogButtons.OK, MessageDialogIcon.Error);
|
||||
}
|
||||
}
|
||||
public bool HasDocumentProperties
|
||||
{
|
||||
get { return GetDocumentPropertiesSettingsProviders().Length > 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
|
||||
using System;
|
||||
using MBS.Framework;
|
||||
using MBS.Framework.UserInterface;
|
||||
|
||||
namespace UniversalEditor.UserInterface
|
||||
@ -17,5 +19,26 @@ namespace UniversalEditor.UserInterface
|
||||
/// A collection of messages to display in the Error List panel.
|
||||
/// </summary>
|
||||
public HostApplicationMessage.HostApplicationMessageCollection Messages { get; } = new HostApplicationMessage.HostApplicationMessageCollection();
|
||||
|
||||
protected override Command FindCommandInternal(string commandID)
|
||||
{
|
||||
EditorReference[] editors = Common.Reflection.GetAvailableEditors();
|
||||
foreach (EditorReference er in editors)
|
||||
{
|
||||
Command cmd = er.Commands[commandID];
|
||||
if (cmd != null) return cmd;
|
||||
}
|
||||
return base.FindCommandInternal(commandID);
|
||||
}
|
||||
protected override Context FindContextInternal(Guid contextID)
|
||||
{
|
||||
EditorReference[] editors = Common.Reflection.GetAvailableEditors();
|
||||
foreach (EditorReference er in editors)
|
||||
{
|
||||
Context ctx = er.Contexts[contextID];
|
||||
if (ctx != null) return ctx;
|
||||
}
|
||||
return base.FindContextInternal(contextID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,11 @@ namespace UniversalEditor.UserInterface
|
||||
{
|
||||
public EditorReference Reference { get; private set; } = null;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("[Editor] {0}", Name);
|
||||
}
|
||||
|
||||
public EditorContext(Guid id, string name, EditorReference reference)
|
||||
: base(id, name)
|
||||
{
|
||||
@ -43,10 +48,6 @@ namespace UniversalEditor.UserInterface
|
||||
{
|
||||
MenuItems.Add(reference.MenuBar.Items[i]);
|
||||
}
|
||||
for (int i = 0; i < reference.KeyBindings.Count; i++)
|
||||
{
|
||||
KeyBindings.Add(reference.KeyBindings[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@ namespace UniversalEditor.UserInterface
|
||||
private string mvarTitle = String.Empty;
|
||||
public string Title { get { return mvarTitle; } set { mvarTitle = value; } }
|
||||
|
||||
public Context.ContextCollection Contexts { get; } = new Context.ContextCollection();
|
||||
|
||||
private Type mvarEditorType = null;
|
||||
public Type EditorType { get { return mvarEditorType; } set { mvarEditorType = value; } }
|
||||
|
||||
@ -29,7 +31,6 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
public CommandBar MenuBar { get; } = new CommandBar();
|
||||
public Command.CommandCollection Commands { get; } = new Command.CommandCollection();
|
||||
public KeyBinding.KeyBindingCollection KeyBindings { get; } = new KeyBinding.KeyBindingCollection();
|
||||
|
||||
public EditorView.EditorViewCollection Views { get; } = new EditorView.EditorViewCollection();
|
||||
public Variable.VariableCollection Variables { get; } = new Variable.VariableCollection();
|
||||
|
||||
@ -94,6 +94,24 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
private Context ctxTreeView = null;
|
||||
protected override void OnCreating(EventArgs e)
|
||||
{
|
||||
base.OnCreating(e);
|
||||
ctxTreeView = MakeReference().Contexts[new Guid("{ce094932-77fb-418f-bd98-e3734a670fad}")];
|
||||
}
|
||||
|
||||
[EventHandler(nameof(tv), nameof(ListViewControl.GotFocus))]
|
||||
private void tv_GotFocus(object sender, EventArgs e)
|
||||
{
|
||||
Application.Instance.Contexts.Add(ctxTreeView);
|
||||
}
|
||||
[EventHandler(nameof(tv), nameof(ListViewControl.LostFocus))]
|
||||
private void tv_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
Application.Instance.Contexts.Remove(ctxTreeView);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigates to the specified <see cref="IFileSystemObject" />.
|
||||
/// </summary>
|
||||
@ -175,6 +193,8 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
Context.AttachCommandEventHandler("FileSystemContextMenu_CopyTo", ContextMenuCopyTo_Click);
|
||||
// Application.AttachCommandEventHandler("FileProperties", ContextMenuProperties_Click);
|
||||
|
||||
Context.AttachCommandEventHandler("FileSystemEditor_GoUp", FileSystemEditor_GoUp);
|
||||
|
||||
// FIXME: this is GTK-specific...
|
||||
this.tv.RegisterDragSource(new DragDropTarget[]
|
||||
{
|
||||
@ -188,16 +208,6 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
txtPath.Text = GetPath(CurrentFolder);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (e.Buttons == MouseButtons.XButton1)
|
||||
{
|
||||
GoUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void tv_DragDropDataRequest(object sender, DragDropDataRequestEventArgs e)
|
||||
{
|
||||
if (tv.SelectedRows.Count == 0) return;
|
||||
@ -321,7 +331,7 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
}
|
||||
else
|
||||
{
|
||||
AddFolderToItem(f, null);
|
||||
AddFolderToItem(f, fsom);
|
||||
tm.Rows.Add(row);
|
||||
}
|
||||
return f;
|
||||
@ -705,11 +715,7 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
if (_er == null)
|
||||
{
|
||||
_er = base.MakeReference();
|
||||
_er.KeyBindings.Add(new KeyBinding("FileSystemContextMenu_CopyTo", KeyboardKey.F5, KeyboardModifierKey.None));
|
||||
_er.KeyBindings.Add(new KeyBinding("FileSystemContextMenu_Rename", KeyboardKey.F6, KeyboardModifierKey.None));
|
||||
_er.KeyBindings.Add(new KeyBinding("FileSystemContextMenu_New_Folder", KeyboardKey.F7, KeyboardModifierKey.None));
|
||||
_er.KeyBindings.Add(new KeyBinding("EditDelete", KeyboardKey.F8, KeyboardModifierKey.None));
|
||||
|
||||
_er.ID = new Guid("{1B5B1E8D-442A-4AC0-8EFD-03AADFF3CAD2}");
|
||||
_er.SupportedObjectModels.Add(typeof(FileSystemObjectModel));
|
||||
}
|
||||
return _er;
|
||||
@ -1009,17 +1015,7 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
[EventHandler(nameof(tv), nameof(ListViewControl.KeyDown))]
|
||||
private void tv_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == KeyboardKey.Back)
|
||||
{
|
||||
// FIXME: this should be a keyboard key binding in UWT Settings
|
||||
GoUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void GoUp()
|
||||
private void FileSystemEditor_GoUp(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrentFolder == null)
|
||||
{
|
||||
|
||||
@ -109,6 +109,9 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
/*
|
||||
// we have to process key shortcuts manually if we do not use a traditional menu bar
|
||||
foreach (Command cmd in ((UIApplication)Application.Instance).Commands)
|
||||
{
|
||||
@ -127,6 +130,7 @@ namespace UniversalEditor.UserInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
UpdateSuperDuperButtonBar(e.KeyAsModifier);
|
||||
}
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
@ -425,7 +429,7 @@ namespace UniversalEditor.UserInterface
|
||||
Application.Instance.Commands["BookmarksAddAll"].Enabled = GetEditorPages().Length > 0;
|
||||
if (editor != null)
|
||||
{
|
||||
Application.Instance.Commands["FileProperties"].Enabled = editor.Selections.Count > 0;
|
||||
Application.Instance.Commands["FileProperties"].Enabled = editor.Selections.Count > 0 || editor.HasDocumentProperties;
|
||||
|
||||
Application.Instance.Commands["EditUndo"].Enabled = editor.UndoItemCount > 0;
|
||||
Application.Instance.Commands["EditRedo"].Enabled = editor.RedoItemCount > 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user