示例#1
0
        /// <summary>
        /// Populates the current menu with items based on the actions collection
        /// </summary>
        /// <param name="actions">List of primary actions</param>
        /// <param name="actions2">List of view specific actions</param>
        protected virtual void PopulateToolbar(IHaveActions actions, IHaveActions actions2 = null)
        {
            Children.Clear();
            if (actions == null)
            {
                return;
            }

            var actionList = ViewActionHelper.GetConsolidatedActions(actions, actions2,
                                                                     actionsDisplayFilter: RootViewActionDisplayMode,
                                                                     actions2DisplayFilter: LocalViewActionDisplayMode,
                                                                     flagFirstSecondaryActionAsNewGroup: true);

            var actionCounter = 0;

            foreach (var action in actionList)
            {
                if (!IncludeAction(action))
                {
                    continue;
                }
                if (actionCounter > 0 && action.BeginGroup)
                {
                    Children.Add(new ViewActionToolbarSeparator());
                }
                Children.Add(new ViewActionToolbarButton(action));
                actionCounter++;
            }

            Visibility = Children.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
        }
示例#2
0
        /// <summary>
        /// Populates the current ribbon with items based on the actions collection
        /// </summary>
        protected virtual void PopulateStack()
        {
            var          actions    = Model as IHaveActions;
            var          viewResult = SelectedView as ViewResult;
            IHaveActions actions2   = null;

            if (viewResult != null)
            {
                actions2 = viewResult.Model as IHaveActions;
            }

            Children.Clear();
            if (actions == null)
            {
                Visibility = Visibility.Collapsed;
                return;
            }
            Visibility = Visibility.Visible;

            var actionList = ViewActionHelper.GetConsolidatedActions(actions, actions2);

            foreach (var action in actionList)
            {
                var button = new ViewActionStackPanelButton {
                    Command = action, ToolTip = action.Caption, DataContext = action
                };
                if (ActionFilter == ViewActionStackPanelActionFilter.ShowPinned)
                {
                    button.SetBinding(VisibilityProperty, new MultiBinding
                    {
                        Bindings =
                        {
                            new Binding("Visibility"),
                            new Binding("IsPinned")
                        },
                        Converter = new VisibilityAndPinnedConverter()
                    });
                }
                else
                {
                    button.SetBinding(VisibilityProperty, new Binding("Visibility"));
                }
                var action2 = action as ViewAction;
                if (action2 != null)
                {
                    var rectangle = new Rectangle {
                        Fill = action2.PopulatedBrush
                    };
                    button.Content = rectangle;
                }
                Children.Add(button);
            }
        }
示例#3
0
 /// <summary>
 /// Returns a list of consolidated actions from two different action lists.
 /// </summary>
 /// <param name="actions">The first set of actions.</param>
 /// <param name="actions2">The second set of actions.</param>
 /// <param name="defaultEmptyCategory">The default empty category.</param>
 /// <param name="actionsDisplayFilter">The actions display filter.</param>
 /// <param name="flagFirstSecondaryActionAsNewGroup">Defines whether the first secondary action is to be flagged as a new group.</param>
 /// <param name="actions2DisplayFilter">Display filter for the secondary set of actions</param>
 /// <param name="viewModel">Optional view model object</param>
 /// <returns>ObservableCollection&lt;IViewAction&gt;.</returns>
 public virtual ObservableCollection <IViewAction> GetConsolidatedActions(IHaveActions actions, IHaveActions actions2 = null, string defaultEmptyCategory = "", ViewActionDisplayMode actionsDisplayFilter = ViewActionDisplayMode.All, bool flagFirstSecondaryActionAsNewGroup = false, ViewActionDisplayMode actions2DisplayFilter = ViewActionDisplayMode.All, object viewModel = null) => ViewActionHelper.GetConsolidatedActions(actions, actions2, defaultEmptyCategory, actionsDisplayFilter, flagFirstSecondaryActionAsNewGroup, actions2DisplayFilter);
示例#4
0
        /// <summary>
        /// Populates the current menu with items based on the actions collection
        /// </summary>
        /// <param name="actions">List of primary actions</param>
        /// <param name="actions2">List of view specific actions</param>
        private void PopulateMenu(IHaveActions actions, IHaveActions actions2 = null)
        {
            RemoveAllMenuKeyBindings();
            Items.Clear();
            if (actions == null)
            {
                return;
            }

            var actionList = ViewActionPolicy != null?ViewActionPolicy.GetConsolidatedActions(actions, actions2, "File", viewModel : this) : ViewActionHelper.GetConsolidatedActions(actions, actions2, "File");

            var rootCategories = ViewActionPolicy != null?ViewActionPolicy.GetTopLevelActionCategories(actionList, "File", "File", this) : ViewActionHelper.GetTopLevelActionCategories(actionList, "File", "File");

            foreach (var category in rootCategories)
            {
                var menuItem = new TopLevelViewActionMenuItem {
                    Header = GetMenuTitle(category)
                };
                menuItem.SetBinding(VisibilityProperty, new Binding("Count")
                {
                    Source = menuItem.Items, Converter = new ItemsCollectionCountToVisibleConverter(menuItem.Items)
                });
                PopulateSubCategories(menuItem, category, actionList);
                Items.Add(menuItem);
            }

            CreateAllMenuKeyBindings();
        }