/// <summary>
        /// Creates a command that navigates the current session to the specified page.
        /// </summary>
        /// <typeparam name="TPageView">The type of the page view.</typeparam>
        /// <typeparam name="TPageViewModel">The type of the page view model.</typeparam>
        /// <returns></returns>
        public ICommand New <TPageView, TPageViewModel>(Guid nodeId, params ActionContextEntry[] parameters)
            where TPageViewModel : ContentViewModel <TPageView, TPageViewModel>, new()
            where TPageView : ExtendedContentControl <TPageView, TPageViewModel>, new()
        {
            var viewModel      = _session.ViewModel;
            var createNextView = new Func <IView>(viewModel.Create <TPageView, TPageViewModel>);

            var next          = ActionContextEntry.Create(ActionContextConstants.CreateNextViewConstant, createNextView, false);
            var viewtype      = ActionContextEntry.Create(ActionContextConstants.ViewTypeConstant, typeof(TPageView), false);
            var viewModeltype = ActionContextEntry.Create(ActionContextConstants.ViewModelTypeConstant, typeof(TPageViewModel), false);


            var actionContextEntries = new List <ActionContextEntry>(parameters)
            {
                next,
                viewtype,
                viewModeltype
            };

            if (nodeId != Guid.Empty)
            {
                var id = ActionContextEntry.Create(ActionContextConstants.NodeId, nodeId, false);
                actionContextEntries.Add(id);
            }

            var command = RoutedAction.New <NavigationAction, SessionView, SessionViewModel>(_session, viewModel, actionContextEntries.ToArray());

            _navigatableActions.Add((IDisposable)command);

            return(command);
        }
Beispiel #2
0
        protected override void OnCreated()
        {
            View.Initialized         += OnViewInitialized;
            View.Loaded              += WindowLoaded;
            Application.Current.Exit += ApplicationClosing;

            _ExploreChanges = RoutedAction.New <ExploreChangesAction, MainWindow, MainViewModel>(View, this);

            SetKnownActionTypes(typeof(ChangeSettingsAction),
                                typeof(ClearChangesetsAction),
                                typeof(CloseAction),
                                typeof(CompleteSelectedAction),
                                typeof(CopyAction),
                                typeof(DeleteSelectedAction),
                                typeof(ExploreChangesAction),
                                typeof(FetchChangesetsAction),
                                typeof(LoadAction),
                                typeof(SaveAction),
                                typeof(ToggleCommitMessagesAction),
                                typeof(ToggleDeletedAction),
                                typeof(UndoSelectedAction),
                                typeof(ViewAboutAction),
                                typeof(LoadCollectionsAction),
                                typeof(LoadProjectsAction));

            _LoadProjectsAction = ActionManager.LoadProjects as ICommand;

            Guard.NotNull(_LoadProjectsAction);
        }