Пример #1
0
        private void CreateLargeButtonView()
        {
            // Create the background and border view
            _viewLarge = new ViewDrawRibbonGroupButtonBackBorder(_ribbon, GroupGallery,
                                                                 _ribbon.StateCommon.RibbonGroupButton.PaletteBack,
                                                                 _ribbon.StateCommon.RibbonGroupButton.PaletteBorder,
                                                                 false, _needPaint)
            {
                ButtonType = GroupButtonType.DropDown
            };
            _viewLarge.DropDown += OnLargeButtonDropDown;

            if (_ribbon.InDesignMode)
            {
                _viewLarge.ContextClick += OnContextClick;
            }

            // Create the layout docker for the contents of the button
            ViewLayoutDocker contentLayout = new ViewLayoutDocker();

            // Add the large button at the top
            _viewLargeImage = new ViewDrawRibbonGroupGalleryImage(_ribbon, GroupGallery);
            ViewLayoutRibbonCenterPadding largeImagePadding = new ViewLayoutRibbonCenterPadding(_largeImagePadding)
            {
                _viewLargeImage
            };

            contentLayout.Add(largeImagePadding, ViewDockStyle.Top);

            // Add the first line of text
            _viewLargeText1 = new ViewDrawRibbonGroupGalleryText(_ribbon, GroupGallery, true);
            contentLayout.Add(_viewLargeText1, ViewDockStyle.Bottom);

            // Add the second line of text
            _viewLargeCenter    = new ViewLayoutRibbonRowCenter();
            _viewLargeText2     = new ViewDrawRibbonGroupGalleryText(_ribbon, GroupGallery, false);
            _viewLargeDropArrow = new ViewDrawRibbonDropArrow(_ribbon);
            _viewLargeText2Sep1 = new ViewLayoutRibbonSeparator(4, false);
            _viewLargeText2Sep2 = new ViewLayoutRibbonSeparator(4, false);
            _viewLargeCenter.Add(_viewLargeText2);
            _viewLargeCenter.Add(_viewLargeText2Sep1);
            _viewLargeCenter.Add(_viewLargeDropArrow);
            _viewLargeCenter.Add(_viewLargeText2Sep2);
            contentLayout.Add(_viewLargeCenter, ViewDockStyle.Bottom);

            // Add a 1 pixel separator at bottom of button before the text
            contentLayout.Add(new ViewLayoutRibbonSeparator(1, false), ViewDockStyle.Bottom);

            // Add the content into the background and border
            _viewLarge.Add(contentLayout);

            // Create controller for intercepting events to determine tool tip handling
            _viewLarge.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager,
                                                               _viewLarge, _viewLarge.MouseController);

            // Add as a child view but as hidden, will become visible only in small mode
            _viewLarge.Visible = false;
            Add(_viewLarge);
        }
        private void CreateMediumSmallButtonView()
        {
            // Create the background and border view
            _viewMediumSmall = new ViewDrawRibbonGroupButtonBackBorder(_ribbon, GroupButton,
                                                                       _ribbon.StateCommon.RibbonGroupButton.PaletteBack,
                                                                       _ribbon.StateCommon.RibbonGroupButton.PaletteBorder,
                                                                       false, _needPaint)
            {
                SplitVertical = false
            };
            _viewMediumSmall.Click    += OnMediumSmallButtonClick;
            _viewMediumSmall.DropDown += OnMediumSmallButtonDropDown;

            if (_ribbon.InDesignMode)
            {
                _viewMediumSmall.ContextClick += OnContextClick;
            }

            // Create the layout docker for the contents of the button
            ViewLayoutDocker contentLayout = new ViewLayoutDocker();

            // Create the image and drop down content
            _viewMediumSmallImage     = new ViewDrawRibbonGroupButtonImage(_ribbon, GroupButton, false);
            _viewMediumSmallText1     = new ViewDrawRibbonGroupButtonText(_ribbon, GroupButton, true);
            _viewMediumSmallText2     = new ViewDrawRibbonGroupButtonText(_ribbon, GroupButton, false);
            _viewMediumSmallDropArrow = new ViewDrawRibbonDropArrow(_ribbon);
            _viewMediumSmallText2Sep2 = new ViewLayoutRibbonSeparator(3, false);
            _viewMediumSmallText2Sep3 = new ViewLayoutRibbonSeparator(3, false);
            ViewLayoutRibbonCenterPadding imagePadding = new ViewLayoutRibbonCenterPadding(_smallImagePadding)
            {
                _viewMediumSmallImage
            };

            // Layout the content in the center of a row
            _viewMediumSmallCenter = new ViewLayoutRibbonRowCenter
            {
                imagePadding,
                _viewMediumSmallText1,
                _viewMediumSmallText2,
                _viewMediumSmallText2Sep2,
                _viewMediumSmallDropArrow,
                _viewMediumSmallText2Sep3
            };

            // Use content as only fill item
            contentLayout.Add(_viewMediumSmallCenter, ViewDockStyle.Fill);

            // Add the content into the background and border
            _viewMediumSmall.Add(contentLayout);

            // Create controller for intercepting events to determine tool tip handling
            _viewMediumSmall.MouseController = new ToolTipController(_ribbon.TabsArea.ButtonSpecManager.ToolTipManager,
                                                                     _viewMediumSmall, _viewMediumSmall.MouseController);
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonAppButton class.
        /// </summary>
        /// <param name="ribbon">Owning control instance.</param>
        /// <param name="bottomHalf">Scroller orientation.</param>
        public ViewLayoutRibbonAppButton(KryptonRibbon ribbon,
                                         bool bottomHalf)
        {
            Debug.Assert(ribbon != null);
            _ribbon = ribbon;

            AppButton  = new ViewDrawRibbonAppButton(ribbon, bottomHalf);
            _separator = new ViewLayoutRibbonSeparator(APPBUTTON_GAP, true);

            // Dock it against the appropriate edge
            Add(AppButton, (bottomHalf ? ViewDockStyle.Top : ViewDockStyle.Bottom));

            // Place a separator between edge of control and start of the app button
            Add(_separator, ViewDockStyle.Left);

            // Use filler placeholder to force size to that required
            Add(new ViewLayoutRibbonSeparator(APPBUTTON_WIDTH, APPBUTTON_GAP, true), ViewDockStyle.Fill);
        }
Пример #4
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonScroller class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="orientation">Scroller orientation.</param>
        /// <param name="insetForTabs">Should scoller be inset for use in tabs area.</param>
        /// <param name="needPaintDelegate">Delegate for notifying paint/layout requests.</param>
        public ViewLayoutRibbonScroller(KryptonRibbon ribbon,
                                        VisualOrientation orientation,
                                        bool insetForTabs,
                                        NeedPaintHandler needPaintDelegate)
        {
            // Cache provided values
            _orientation  = orientation;
            _insetForTabs = insetForTabs;

            // Create the button and the separator
            _button    = new ViewDrawRibbonScrollButton(ribbon, orientation);
            _separator = new ViewLayoutRibbonSeparator(GAP_LENGTH, true);

            // Create button controller for clicking the button
            RepeatButtonController rbc = new RepeatButtonController(ribbon, _button, needPaintDelegate);

            rbc.Click += OnButtonClick;
            _button.MouseController = rbc;

            // Add as child elements
            Add(_button);
            Add(_separator);
        }
Пример #5
0
        private void CreateViewElements(PaletteRedirect redirect)
        {
            // Layout for individual tabs inside the header
            LayoutTabs = new ViewLayoutRibbonTabs(_ribbon, NeedPaintDelegate);

            // Put inside a viewport so scrollers are used when tabs cannot be shrunk to fill space
            _tabsViewport = new ViewLayoutRibbonScrollPort(_ribbon, System.Windows.Forms.Orientation.Horizontal, LayoutTabs, true, SCROLL_SPEED, NeedPaintDelegate)
            {
                TransparentBackground = true
            };
            _tabsViewport.PaintBackground += OnTabsPaintBackground;
            LayoutTabs.ParentControl       = _tabsViewport.ViewLayoutControl.ChildControl;
            LayoutTabs.NeedPaintDelegate   = _tabsViewport.ViewControlPaintDelegate;

            // We use a layout docker as a child to prevent buttons going to the left of the app button
            ViewLayoutDocker tabsDocker = new ViewLayoutDocker
            {
                // Place the tabs viewport as the fill inside ourself, the button specs will be placed
                // to the left and right of this fill element automatically by the button manager below
                { _tabsViewport, ViewDockStyle.Fill }
            };

            // We need to draw the bottom half of the application button or a full app tab
            LayoutAppButton = new ViewLayoutRibbonAppButton(_ribbon, true);
            LayoutAppTab    = new ViewLayoutRibbonAppTab(_ribbon);

            // Connect up the application button controller to the app button element
            _appButtonController.Target3        = LayoutAppButton.AppButton;
            _appButtonController.Click         += OnAppButtonClicked;
            _appButtonController.MouseReleased += OnAppButtonReleased;
            LayoutAppButton.MouseController     = _appButtonController;
            LayoutAppButton.SourceController    = _appButtonController;
            LayoutAppButton.KeyController       = _appButtonController;

            _appTabController.Target1        = LayoutAppTab.AppTab;
            _appTabController.Click         += OnAppButtonClicked;
            _appTabController.MouseReleased += OnAppButtonReleased;
            LayoutAppTab.MouseController     = _appTabController;
            LayoutAppTab.SourceController    = _appTabController;
            LayoutAppTab.KeyController       = _appTabController;

            // When the app button is not visible we need separator instead before start of first tab
            _layoutAppButtonSep = new ViewLayoutSeparator(5, 0)
            {
                Visible = false
            };

            // Used separators around the tabs and the edge elements
            _rightSeparator = new ViewLayoutRibbonSeparator(FAR_TAB_GAP, true);
            _leftSeparator  = new ViewLayoutRibbonSeparator(BUTTON_TAB_GAP_2007, true);

            // Place application button on left  and tabs as the filler (with some separators for neatness)
            Add(_rightSeparator, ViewDockStyle.Left);
            Add(_leftSeparator, ViewDockStyle.Left);
            Add(LayoutAppButton, ViewDockStyle.Left);
            Add(_layoutAppButtonSep, ViewDockStyle.Left);
            Add(LayoutAppTab, ViewDockStyle.Left);
            Add(tabsDocker, ViewDockStyle.Fill);

            // Create button specification collection manager
            PaletteRedirect aeroOverrideText = new PaletteRedirectRibbonAeroOverride(_ribbon, redirect);

            ButtonSpecManager = new ButtonSpecManagerLayoutRibbon(_ribbon, aeroOverrideText, _ribbon.ButtonSpecs, _buttonSpecsFixed,
                                                                  new ViewLayoutDocker[] { tabsDocker },
                                                                  new IPaletteMetric[] { _ribbon.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetPrimary },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.RibbonButtonPadding },
                                                                  _ribbon.CreateToolStripRenderer,
                                                                  NeedPaintDelegate);

            // Create the manager for handling tooltips
            ToolTipManager                   = new ToolTipManager();
            ToolTipManager.ShowToolTip      += OnShowToolTip;
            ToolTipManager.CancelToolTip    += OnCancelToolTip;
            ButtonSpecManager.ToolTipManager = ToolTipManager;
        }