public void SetupCommands(DirectoryTree dtree, DirectoryTreeViewModel rootModel)
        {

            #region RefreshCommand
            RefreshCommand = new SimpleRoutedCommand(NavigationCommands.Refresh)
            {
                CanExecuteDelegate = x => true,
                ExecuteDelegate = x => rootModel.SelectedDirectoryModel.Refresh()
            };
            #endregion

            #region RenamdCommand
            RenameCommand = new SimpleRoutedCommand(ApplicationCommands.SaveAs)
            {
                CanExecuteDelegate = x =>
                {
                    return rootModel.SelectedDirectoryModel != null &&
                        rootModel.SelectedDirectoryModel.EmbeddedModel.IsEditable;
                },
                ExecuteDelegate = x =>
                {
                    if (dtree._lastSelectedContainer != null)
                    {
                        DirectoryTree.SetIsEditing(dtree._lastSelectedContainer, true);
                    }
                }
            };
            #endregion RenamdCommand            
        }
예제 #2
0
        public void SetupCommands(DirectoryTree dtree, DirectoryTreeViewModel rootModel)
        {
            #region RefreshCommand
            RefreshCommand = new SimpleRoutedCommand(NavigationCommands.Refresh)
            {
                CanExecuteDelegate = x => true,
                ExecuteDelegate    = x => rootModel.SelectedDirectoryModel.Refresh()
            };
            #endregion

            #region RenamdCommand
            RenameCommand = new SimpleRoutedCommand(ApplicationCommands.SaveAs)
            {
                CanExecuteDelegate = x =>
                {
                    return(rootModel.SelectedDirectoryModel != null &&
                           rootModel.SelectedDirectoryModel.EmbeddedModel.IsEditable);
                },
                ExecuteDelegate = x =>
                {
                    if (dtree._lastSelectedContainer != null)
                    {
                        DirectoryTree.SetIsEditing(dtree._lastSelectedContainer, true);
                    }
                }
            };
            #endregion RenamdCommand
        }
예제 #3
0
        public DirectoryTreeCommands(DirectoryTree dtree, DirectoryTreeViewModel rootModel)
        {
            Func<ExModel[]> getSelectionFunc = new Func<ExModel[]>(() => { return new ExModel[] { rootModel.SelectedDirectoryModel.EmbeddedModel }; });
            Func<DirectoryModel> getCurrentFunc = new Func<DirectoryModel>(() => { return rootModel.SelectedDirectoryModel.EmbeddedDirectoryModel; });
            Func<System.Drawing.Point> getMousePositionFunc = new Func<System.Drawing.Point>(() =>
            { Point pt = dtree.PointToScreen(Mouse.GetPosition(dtree)); return new System.Drawing.Point((int)pt.X, (int)pt.Y); });
            SetupCommands(getSelectionFunc, getCurrentFunc, getMousePositionFunc);
            SetupCommands(dtree, rootModel);

            SimpleRoutedCommand.Register(typeof(DirectoryTree), RefreshCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), RenameCommand, new KeyGesture(Key.F2));
            SimpleRoutedCommand.Register(typeof(DirectoryTree), ContextMenuCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), PropertiesCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), CopyCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), PasteCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), DeleteCommand, new KeyGesture(Key.Delete));

            dtree.AddHandler(TreeViewItem.MouseRightButtonUpEvent, new MouseButtonEventHandler(
                (MouseButtonEventHandler)delegate(object sender, MouseButtonEventArgs args)
                {
                    ApplicationCommands.ContextMenu.Execute(null, dtree);
                }));
        }
예제 #4
0
        public DirectoryTreeCommands(DirectoryTree dtree, DirectoryTreeViewModel rootModel)
        {
            Func <ExModel[]>            getSelectionFunc     = new Func <ExModel[]>(() => { return(new ExModel[] { rootModel.SelectedDirectoryModel.EmbeddedModel }); });
            Func <DirectoryModel>       getCurrentFunc       = new Func <DirectoryModel>(() => { return(rootModel.SelectedDirectoryModel.EmbeddedDirectoryModel); });
            Func <System.Drawing.Point> getMousePositionFunc = new Func <System.Drawing.Point>(() =>
                                                                                               { Point pt = dtree.PointToScreen(Mouse.GetPosition(dtree)); return(new System.Drawing.Point((int)pt.X, (int)pt.Y)); });

            SetupCommands(getSelectionFunc, getCurrentFunc, getMousePositionFunc);
            SetupCommands(dtree, rootModel);

            SimpleRoutedCommand.Register(typeof(DirectoryTree), RefreshCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), RenameCommand, new KeyGesture(Key.F2));
            SimpleRoutedCommand.Register(typeof(DirectoryTree), ContextMenuCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), PropertiesCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), CopyCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), PasteCommand);
            SimpleRoutedCommand.Register(typeof(DirectoryTree), DeleteCommand, new KeyGesture(Key.Delete));

            dtree.AddHandler(TreeViewItem.MouseRightButtonUpEvent, new MouseButtonEventHandler(
                                 (MouseButtonEventHandler) delegate(object sender, MouseButtonEventArgs args)
            {
                ApplicationCommands.ContextMenu.Execute(null, dtree);
            }));
        }
        //public static void OnSelectedDirectoryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        //{
        //    DirectoryTree dt = (DirectoryTree)sender;
        //    dt.RootModel.SelectedDirectory = args.NewValue as DirectoryInfoEx;
        //}

        public static void OnRootDirectoryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            DirectoryTree dt = (DirectoryTree)sender;

            dt.RootModel.RootDirectory = args.NewValue as DirectoryInfoEx;
        }