示例#1
0
        private void SaveLayoutSettings()
        {
            // Avoid saving changes when constructing new instances.
            if (_initializing)
            {
                return;
            }

            ViewSettings viewSettings = ServiceRegistration.Get <ISettingsManager>().Load <ViewSettings>();

            viewSettings.ScreenConfigs[CurrentScreenData.GetType().ToString()] = new ScreenConfig
            {
                Sorting    = CurrentSorting.GetType().ToString(),
                LayoutSize = LayoutSize,
                LayoutType = LayoutType
            };
            ServiceRegistration.Get <ISettingsManager>().Save(viewSettings);
        }
        /// <summary>
        /// Enters a new media navigation context by modifying the list of available screens. This is used for
        /// presenting the result of a filter, where the menu must be changed.
        /// </summary>
        /// <param name="subViewSpecification">Specification for the sub view to be shown in the new navigation context.</param>
        /// <param name="currentMenuItemLabel">Current menu item label needed for distinction of available screens.</param>
        /// <param name="navbarDisplayLabel">Display label to be shown in the navigation bar for the new navigation context.</param>
        /// <returns>Newly created navigation data.</returns>
        public NavigationData StackAutonomousNavigationContext(ViewSpecification subViewSpecification, string currentMenuItemLabel, string navbarDisplayLabel)
        {
            AbstractScreenData currentScreen = AvailableScreens.FirstOrDefault(screen => screen.MenuItemLabel == currentMenuItemLabel);
            ICollection <AbstractScreenData> remainingScreens = new List <AbstractScreenData>(AvailableScreens.Where(screen => screen != currentScreen));

            WorkflowState newState = WorkflowState.CreateTransientState(
                "View: " + subViewSpecification.ViewDisplayName, subViewSpecification.ViewDisplayName,
                false, null, false, WorkflowType.Workflow, null);

            string             nextScreenName;
            AbstractScreenData nextScreen = null;

            // Try to load the prefered next screen from settings.
            if (LoadScreenHierarchy(CurrentScreenData.GetType().ToString(), out nextScreenName))
            {
                nextScreen = remainingScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName);
            }

            // Default way: always take the first of the available screens.
            if (nextScreen == null)
            {
                nextScreen = remainingScreens.First(s => s != currentScreen);
            }

            ScreenConfig nextScreenConfig;

            LoadLayoutSettings(nextScreen.GetType().ToString(), out nextScreenConfig);

            Sorting.Sorting nextSortingMode = AvailableSortings.FirstOrDefault(
                sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting && sorting.IsAvailable(nextScreen)) ?? _currentSorting;
            Sorting.Sorting nextGroupingMode = String.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : AvailableGroupings.FirstOrDefault(
                grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping && grouping.IsAvailable(nextScreen)) ?? _currentGrouping;

            NavigationData newNavigationData = new NavigationData(this, subViewSpecification.ViewDisplayName,
                                                                  newState.StateId, newState.StateId, subViewSpecification, nextScreen, remainingScreens,
                                                                  nextSortingMode, nextGroupingMode)
            {
                LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize
            };

            PushNewNavigationWorkflowState(newState, navbarDisplayLabel, newNavigationData);
            return(newNavigationData);
        }