Work on UI (commands)

This commit is contained in:
Tiberiu Chibici 2014-07-25 14:05:41 +03:00
parent 1d44d69b94
commit 3d0a028920
4 changed files with 19 additions and 23 deletions

View File

@ -70,7 +70,7 @@ namespace RainmeterEditor.Resources {
}
/// <summary>
/// Looks up a localized string similar to New file....
/// Looks up a localized string similar to _File....
/// </summary>
internal static string DocumentCreateCommand_DisplayText {
get {

View File

@ -121,7 +121,7 @@
<value>Utility</value>
</data>
<data name="DocumentCreateCommand_DisplayText" xml:space="preserve">
<value>New file...</value>
<value>_File...</value>
</data>
<data name="DocumentCreateCommand_ToolTip" xml:space="preserve">
<value>Creates a new file</value>

View File

@ -27,17 +27,14 @@
<Menu Grid.Row="0" Grid.ColumnSpan="10">
<MenuItem Header="_File">
<MenuItem Header="_New">
<MenuItem Header="_File..."
DataContext="{DynamicResource DocumentCreateCommand}"
Command="{Binding}"
ToolTip="{Binding Tooltip}"
<MenuItem DataContext="{Binding DocumentCreateCommand}"
Command="{Binding}" Header="{Binding DisplayText}" ToolTip="{Binding Tooltip}"
InputGestureText="{Binding ShortcutText}">
<MenuItem.Icon>
<Image DataContext="{DynamicResource DocumentCreateCommand}"
Source="{Binding Icon}" />
<Image Source="{Binding Icon}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="_Project..." Command="{DynamicResource CreateFileCommand}">
<MenuItem Header="_Project..." Command="{Binding DocumentCreateCommand}">
<MenuItem.Icon>
<Image Source="/Resources/Icons/project_star_16.png" />
</MenuItem.Icon>
@ -62,6 +59,10 @@
<Image Width="16" Height="16" Source="/Resources/Icons/arrow_forward_16.png" />
</Button>
<Separator />
<Button DataContext="{Binding DocumentCreateCommand}"
Command="{Binding}" ToolTip="{Binding Tooltip}">
<Image Source="{Binding Icon}" />
</Button>
</ToolBar>
</ToolBarTray>

View File

@ -24,30 +24,25 @@ namespace RainmeterEditor.UI
{
private DocumentController documentController;
private IEnumerable<Command> 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)
private void AddKeyBinding(Command c)
{
Resources.Add(c.Name, c);
if (c.Shortcut != null)
InputBindings.Add(new KeyBinding(c, c.Shortcut));
}
}
void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e)
{