mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Work on UI (commands)
This commit is contained in:
		@@ -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>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,29 +24,24 @@ 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)
 | 
			
		||||
            {
 | 
			
		||||
                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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user