Beispiel #1
0
        public MdiWindow(IWindowManager wm, IEventAggregator events, IEntryModel[] rootModels)
        {
            InitializeComponent();

            _rootDirectories = rootModels;

            _initializer = new ScriptCommandInitializer()
            {
                WindowManager     = wm,
                Events            = events,
                OnModelCreated    = IOInitializeHelpers.Explorer_Initialize_Default,
                OnViewAttached    = UIScriptCommands.ExplorerGotoStartupPathOrFirstRoot(),
                RootModels        = rootModels,
                StartupParameters = new ParameterDic()
                {
                    { "MdiWindow", this }
                }
            };

            //_initializer = AppViewModel.getInitializer(_windowManager, _events,  _root,
            //    new ColumnInitializers(),
            //    new ScriptCommandsInitializers(_windowManager, _events),
            //    new ToolbarCommandsInitializers(_windowManager));

            //_initializer.Initializers.Add(new MdiWindowInitializers(_initializer, Container));
        }
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IWindowManager   wm     = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
            IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator();

            IExplorerInitializer initializer = new ScriptCommandInitializer()
            {
                StartupParameters = pm,
                WindowManager     = wm,
                Events            = events,
                OnModelCreated    = ScriptCommands.Run(OnModelCreatedKey),
                OnViewAttached    = ScriptCommands.Run(OnViewAttachedKey)
            };

            ExplorerViewModel evm = null;

            switch (ExplorerMode)
            {
            case Script.ExplorerMode.Normal:
                evm = new ExplorerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            case Script.ExplorerMode.FileOpen:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Open
                };
                break;

            case Script.ExplorerMode.FileSave:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Save
                };
                break;

            case Script.ExplorerMode.DirectoryOpen:
                evm = new DirectoryPickerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            default:
                return(ResultCommand.Error(new NotSupportedException(ExplorerMode.ToString())));
            }

            logger.Info(String.Format("Creating {0}", evm));
            pm.SetValue(DestinationKey, evm, false);

            return(NextCommand);
        }