コード例 #1
0
        public void Handle(RootChangedEvent message)
        {
            Queue <IScriptCommand> cmds = new Queue <IScriptCommand>();

            cmds.Enqueue(Explorer.ChangeRoot(message.ChangeType, message.AppliedRootDirectories));

            if (message.Sender != null && message.Sender != this)
            {
                cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(CurrentDirectory.EntryModel));
            }
            else
            {
                switch (message.ChangeType)
                {
                case ChangeType.Changed:
                    cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(message.AppliedRootDirectories.First()));
                    break;

                case ChangeType.Deleted:
                    cmds.Enqueue(UIScriptCommands.ExplorerGoToValue(RootModels.FirstOrDefault()));
                    break;
                }
            }

            Commands.ExecuteAsync(cmds.ToArray());
        }
コード例 #2
0
        public override IScriptCommand Execute(ParameterDic pm)
        {
            var viewModel = new ExplorerViewModel(_initializer);

            pm["Explorer"] = viewModel;
            var view = new ExplorerView();

            Caliburn.Micro.Bind.SetModel(view, viewModel); //Set the ViewModel using this command.
            var mdiChild = new MdiChild
            {
                DataContext = viewModel,
                ShowIcon    = true,
                Content     = view,
                Width       = 500,
                Height      = 334,
                Position    = new Point(0, 0)
            };

            mdiChild.SetBinding(MdiChild.TitleProperty, new Binding("DisplayName")
            {
                Mode = BindingMode.OneWay
            });
            mdiChild.SetBinding(MdiChild.IconProperty, new Binding("CurrentDirectory.Icon")
            {
                Mode = BindingMode.OneWay
            });
            _container.Children.Add(mdiChild);

            var selection = _getSelectionFunc == null ? null : _getSelectionFunc(pm);

            if (selection != null && selection.Count() > 0)
            {
                return(UIScriptCommands.ExplorerGoToValue(selection.First()));
            }

            return(ResultCommand.NoError);
        }