コード例 #1
0
        /// <summary>
        /// Populate Sub menus from parent menu
        /// </summary>
        /// <param name="menu">
        /// <see cref="Menu"/>
        /// </param>
        /// <param name="organizer">
        /// <see cref="UPMAdvancedSearchOrganizer"/>
        /// </param>
        private void PopulateSubMenusFromMenu(Menu menu, UPMAdvancedSearchOrganizer organizer)
        {
            var searchTypes = new List <UPMDetailSearch>();

            for (var index = 0; index < menu.NumberOfSubMenus; index++)
            {
                var menuItem = menu.SubMenuAtIndex(index);
                if (menuItem?.ViewReference != null)
                {
                    if (menuItem.UnitName == MenuItemHistorySearch)
                    {
                        var modelController = PageForViewReference(menuItem.ViewReference);
                        AddPageModelController(modelController);
                        organizer.AddPage(modelController.Page);
                        QuickHistorySearchModelController = (UPHistorySearchPageModelController)modelController;
                    }
                    else if (menuItem.ViewReference.ViewName == ViewRecordListView || menuItem.ViewReference.ViewName == ViewCalendarView ||
                             menuItem.ViewReference.ViewName == ViewDocumentView)
                    {
                        if (menuItem.UnitName == MenuItemGlobalSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickGlobalSearchModelController = (GlobalSearchPageModelController)modelController;
                        }
                        else if (menuItem.UnitName == MenuItemFavoriteSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickFavoriteSearchModelController = (UPMultiSearchPageModelController)modelController;
                        }
                        else
                        {
                            var itemViewReference = menuItem.ViewReference;
                            var infoArea          = itemViewReference.ContextValueForKey(KeyInfoArea);
                            if (menuItem.ViewReference.ViewName == ViewDocumentView && infoArea == null)
                            {
                                infoArea = InfoAreaD1;
                            }

                            var identifier       = StringIdentifier.IdentifierWithStringId(menu.UnitName);
                            var detailSearchType = new UPMDetailSearch(identifier)
                            {
                                TileField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{menuItem.UnitName}{IdentifierSuffixTitle}"))
                            };
                            detailSearchType.TileField.StringValue = menuItem.DisplayName;
                            detailSearchType.Color = ColorForInfoAreaWithId(infoArea);
                            searchTypes.Add(detailSearchType);
                            var action = new UPMAction(StringIdentifier.IdentifierWithStringId($"{IdentifierPrefixDetailAction} {menuItem.UnitName}"));
                            action.SetTargetAction(this, PerformDetailAction);
                            detailSearchType.SwitchToDetailSearchAction = action;
                            viewReferenceDict[action.Identifier]        = itemViewReference;
                        }
                    }
                }
            }

            organizer.DetailSearches = searchTypes;
        }
コード例 #2
0
        /// <summary>
        /// Populate Sub menus
        /// </summary>
        /// <param name="organizer">
        /// <see cref="UPMAdvancedSearchOrganizer"/> object
        /// </param>
        /// <param name="store">
        /// <see cref="IConfigurationUnitStore"/> config store
        /// </param>
        /// <param name="startMenuName">
        /// starting menu
        /// </param>
        private void PopulateSubMenus(UPMAdvancedSearchOrganizer organizer, IConfigurationUnitStore store, string startMenuName)
        {
            var searchTypes = new List <UPMDetailSearch>();
            var menu        = Menu.MainMenu();

            for (var index = 0; index < menu.NumberOfSubMenus; index++)
            {
                var menuItem = menu.SubMenuAtIndex(index);
                if (menuItem?.ViewReference != null)
                {
                    if (startMenu == null)
                    {
                        startMenu = menuItem;
                    }

                    if (!string.IsNullOrWhiteSpace(startMenuName))
                    {
                        var startMenuItem = store.MenuByName(startMenuName);
                        if (startMenuItem != null && startMenuItem == menuItem)
                        {
                            startMenu = menuItem;
                        }
                    }

                    if (menuItem.ViewReference.ViewName == ViewHistoryListView)
                    {
                        var modelController = PageForViewReference(menuItem.ViewReference);
                        AddPageModelController(modelController);
                        organizer.AddPage(modelController.Page);
                        QuickHistorySearchModelController = (UPHistorySearchPageModelController)modelController;
                    }
                    else if (menuItem.ViewReference.ViewName == ViewRecordListView || menuItem.ViewReference.ViewName == ViewCalendarView ||
                             menuItem.ViewReference.ViewName == ViewDocumentView)
                    {
                        if (menuItem.ViewReference.ContextValueForKey(KeyModus) == KeyGlobalSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickGlobalSearchModelController = (GlobalSearchPageModelController)modelController;
                        }
                        else if (menuItem.ViewReference.ContextValueForKey(KeyModus) == KeyMultiSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickFavoriteSearchModelController = (UPMultiSearchPageModelController)modelController;
                        }
                        else
                        {
                            var itemViewReference = menuItem.ViewReference;
                            var infoArea          = itemViewReference.ContextValueForKey(KeyInfoArea);
                            if (menuItem.ViewReference.ViewName == ViewDocumentView && infoArea == null)
                            {
                                infoArea = InfoAreaD1;
                            }

                            var detailSearchType = new UPMDetailSearch(StringIdentifier.IdentifierWithStringId(menu.UnitName))
                            {
                                TileField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{menuItem.UnitName}{IdentifierSuffixTitle}"))
                                {
                                    StringValue = menuItem.DisplayName
                                },
                                Color = ColorForInfoAreaWithId(infoArea)
                            };
                            searchTypes.Add(detailSearchType);
                            var action = new UPMAction(StringIdentifier.IdentifierWithStringId($"{IdentifierPrefixDetailAction} {menuItem.UnitName}"));
                            action.SetTargetAction(this, PerformDetailAction);
                            detailSearchType.SwitchToDetailSearchAction = action;
                            viewReferenceDict[action.Identifier]        = itemViewReference;
                        }
                    }
                }
            }

            organizer.DetailSearches = searchTypes;
        }