From 3d0a028920a9cb5daa0867c51f885e827efaa133 Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Fri, 25 Jul 2014 14:05:41 +0300 Subject: [PATCH] Work on UI (commands) --- RainmeterEditor/Resources/Strings.Designer.cs | 2 +- RainmeterEditor/Resources/Strings.resx | 2 +- RainmeterEditor/UI/MainWindow.xaml | 15 ++++++------ RainmeterEditor/UI/MainWindow.xaml.cs | 23 ++++++++----------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/RainmeterEditor/Resources/Strings.Designer.cs b/RainmeterEditor/Resources/Strings.Designer.cs index 986ee145..ea6d64cd 100644 --- a/RainmeterEditor/Resources/Strings.Designer.cs +++ b/RainmeterEditor/Resources/Strings.Designer.cs @@ -70,7 +70,7 @@ namespace RainmeterEditor.Resources { } /// - /// Looks up a localized string similar to New file.... + /// Looks up a localized string similar to _File.... /// internal static string DocumentCreateCommand_DisplayText { get { diff --git a/RainmeterEditor/Resources/Strings.resx b/RainmeterEditor/Resources/Strings.resx index ca250b3d..e2d125c1 100644 --- a/RainmeterEditor/Resources/Strings.resx +++ b/RainmeterEditor/Resources/Strings.resx @@ -121,7 +121,7 @@ Utility - New file... + _File... Creates a new file diff --git a/RainmeterEditor/UI/MainWindow.xaml b/RainmeterEditor/UI/MainWindow.xaml index 8f1b80c6..e5601ce8 100644 --- a/RainmeterEditor/UI/MainWindow.xaml +++ b/RainmeterEditor/UI/MainWindow.xaml @@ -27,17 +27,14 @@ - - + - + @@ -62,6 +59,10 @@ + diff --git a/RainmeterEditor/UI/MainWindow.xaml.cs b/RainmeterEditor/UI/MainWindow.xaml.cs index bb318c4f..67c34f81 100644 --- a/RainmeterEditor/UI/MainWindow.xaml.cs +++ b/RainmeterEditor/UI/MainWindow.xaml.cs @@ -24,29 +24,24 @@ namespace RainmeterEditor.UI { private DocumentController documentController; - private IEnumerable Commands - { - get - { - yield return documentController.DocumentCreateCommand; - } - } + public Command DocumentCreateCommand { get { return documentController.DocumentCreateCommand; } } public MainWindow() { InitializeComponent(); + this.DataContext = this; + documentController = new DocumentController(); documentController.OwnerWindow = this; documentController.DocumentOpened += documentController_DocumentOpened; + AddKeyBinding(documentController.DocumentCreateCommand); + } - foreach (var c in Commands) - { - Resources.Add(c.Name, c); - - if (c.Shortcut != null) - InputBindings.Add(new KeyBinding(c, c.Shortcut)); - } + private void AddKeyBinding(Command c) + { + if (c.Shortcut != null) + InputBindings.Add(new KeyBinding(c, c.Shortcut)); } void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e)