AreFlagsSet() публичный Метод

Are all the provided flags set to true.
public AreFlagsSet ( KryptonPageFlags flags ) : bool
flags KryptonPageFlags Flags to test.
Результат bool
Пример #1
0
        /// <summary>
        /// Populate a context menu appropriate for a non-dockable workspace provided page.
        /// </summary>
        /// <param name="page">Reference to page.</param>
        /// <param name="kcm">Reference to context menu.</param>
        /// <returns>True if the context menu should be displayed; otherwise false.</returns>
        public virtual bool ShowPageContextMenuRequest(KryptonPage page, KryptonContextMenu kcm)
        {
            // Cannot action a null reference
            if (page == null) throw new ArgumentNullException("page");
            if (kcm == null) throw new ArgumentNullException("kcm");

            // By default there is nothing to display
            bool retDisplay = false;

            // If the page is not located in the hierarchy then there are no options we can provide
            DockingLocation location = FindPageLocation(page);
            if (location != DockingLocation.None)
            {
                // Reset the context menu with an items collection
                KryptonContextMenuItems options = new KryptonContextMenuItems();
                kcm.Items.Clear();
                kcm.Items.Add(options);

                // Can only make floating if we can find a floating element to target the action against
                if (FindDockingFloating(page.UniqueName) != null)
                {
                    // Add an option for floating the page
                    KryptonContextMenuItem floatingItem = new KryptonContextMenuItem(Strings.TextFloat);
                    floatingItem.Tag = page.UniqueName;
                    floatingItem.Click += new EventHandler(OnDropDownFloatingClicked);
                    floatingItem.Enabled = ((location != DockingLocation.Floating) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowFloating)));
                    options.Items.Add(floatingItem);
                    retDisplay = true;
                }

                // Can only make docked if we can find a docked edge to target the action against
                if (FindDockingEdgeDocked(page.UniqueName) != null)
                {
                    // Add an option for docked the page
                    KryptonContextMenuItem dockedItem = new KryptonContextMenuItem(Strings.TextDock);
                    dockedItem.Tag = page.UniqueName;
                    dockedItem.Click += new EventHandler(OnDropDownDockedClicked);
                    dockedItem.Enabled = ((location != DockingLocation.Docked) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked)));
                    options.Items.Add(dockedItem);
                    retDisplay = true;
                }

                // Can only make tabbed document if we can find a workspace to target the action against
                if (FindDockingWorkspace(page.UniqueName) != null)
                {
                    // Add an option for docked the page
                    KryptonContextMenuItem workspaceItem = new KryptonContextMenuItem(Strings.TextTabbedDocument);
                    workspaceItem.Tag = page.UniqueName;
                    workspaceItem.Click += new EventHandler(OnDropDownWorkspaceClicked);
                    workspaceItem.Enabled = ((location != DockingLocation.Workspace) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowWorkspace)));
                    options.Items.Add(workspaceItem);
                    retDisplay = true;
                }
                else
                {
                    // No workspace so look for a navigator instead
                    if (FindDockingNavigator(page.UniqueName) != null)
                    {
                        // Add an option for docked the page
                        KryptonContextMenuItem workspaceItem = new KryptonContextMenuItem(Strings.TextTabbedDocument);
                        workspaceItem.Tag = page.UniqueName;
                        workspaceItem.Click += new EventHandler(OnDropDownNavigatorClicked);
                        workspaceItem.Enabled = ((location != DockingLocation.Navigator) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowNavigator)));
                        options.Items.Add(workspaceItem);
                        retDisplay = true;
                    }
                }

                // Can only make auto hidden if we can find a auto hidden edge to target the action against
                if (FindDockingEdgeAutoHidden(page.UniqueName) != null)
                {
                    // Add an option for docked the page
                    KryptonContextMenuItem autoHiddenItem = new KryptonContextMenuItem(Strings.TextAutoHide);
                    autoHiddenItem.Tag = page.UniqueName;
                    autoHiddenItem.Click += new EventHandler(OnDropDownAutoHiddenClicked);
                    autoHiddenItem.Enabled = ((location != DockingLocation.AutoHidden) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowAutoHidden)));
                    options.Items.Add(autoHiddenItem);
                    retDisplay = true;
                }

                // Can only add the close menu option if we are allowed to close the page
                if (page.AreFlagsSet(KryptonPageFlags.DockingAllowClose))
                {
                    // Add an option for closing the page
                    KryptonContextMenuItem closeItem = new KryptonContextMenuItem(Strings.TextClose);
                    closeItem.Tag = page.UniqueName;
                    closeItem.Click += new EventHandler(OnDropDownCloseClicked);
                    options.Items.Add(closeItem);
                    retDisplay = true;
                }
            }

            // Let events customize the context menu
            ContextPageEventArgs args = new ContextPageEventArgs(page, kcm, !retDisplay);
            OnShowPageContextMenu(args);
            return !args.Cancel;
        }