Esempio n. 1
0
        private void CreateView()
        {
            // Override the palette provided values
            _backForced   = new PaletteBackInheritForced(_ribbon.StateCommon.RibbonGroupClusterButton.PaletteBack);
            _borderForced = new PaletteBorderInheritForced(_ribbon.StateCommon.RibbonGroupClusterButton.PaletteBorder);

            // Create the background and border view
            _viewMediumSmall = new ViewDrawRibbonGroupButtonBackBorder(_ribbon, _ribbonColorButton, _backForced, _borderForced, true, _needPaint);
            _viewMediumSmall.SplitVertical = false;
            _viewMediumSmall.Click        += new EventHandler(OnSmallButtonClick);
            _viewMediumSmall.DropDown     += new EventHandler(OnSmallButtonDropDown);

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

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

            // Create the image and drop down content
            _viewMediumSmallImage         = new ViewDrawRibbonGroupClusterColorButtonImage(_ribbon, _ribbonColorButton);
            _viewMediumSmallText1         = new ViewDrawRibbonGroupClusterColorButtonText(_ribbon, _ribbonColorButton);
            _viewMediumSmallText1.Visible = (_currentSize != GroupItemSize.Small);
            _viewMediumSmallDropArrow     = new ViewDrawRibbonDropArrow(_ribbon);
            _viewMediumSmallText2Sep1     = new ViewLayoutRibbonSeparator(3, false);
            _viewMediumSmallText2Sep2     = new ViewLayoutRibbonSeparator(3, false);
            ViewLayoutRibbonCenterPadding imagePadding = new ViewLayoutRibbonCenterPadding(_smallImagePadding);

            imagePadding.Add(_viewMediumSmallImage);

            // Layout the content in the center of a row
            _viewMediumSmallCenter = new ViewLayoutRibbonRowCenter();
            _viewMediumSmallCenter.Add(imagePadding);
            _viewMediumSmallCenter.Add(_viewMediumSmallText1);
            _viewMediumSmallCenter.Add(_viewMediumSmallText2Sep1);
            _viewMediumSmallCenter.Add(_viewMediumSmallDropArrow);
            _viewMediumSmallCenter.Add(_viewMediumSmallText2Sep2);

            // 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);

            // Provide back reference to the button definition
            _ribbonColorButton.ClusterColorButtonView = _viewMediumSmall;

            // Define the actual view
            Add(_viewMediumSmall);
        }
Esempio n. 2
0
        private void CreateLargeButtonView()
        {
            // Create the background and border view
            _viewLarge = new ViewDrawRibbonGroupButtonBackBorder(_ribbon, _ribbonGallery,
                                                                 _ribbon.StateCommon.RibbonGroupButton.PaletteBack,
                                                                 _ribbon.StateCommon.RibbonGroupButton.PaletteBorder,
                                                                 false, _needPaint);
            _viewLarge.ButtonType = GroupButtonType.DropDown;
            _viewLarge.DropDown  += new EventHandler(OnLargeButtonDropDown);

            if (_ribbon.InDesignMode)
            {
                _viewLarge.ContextClick += new MouseEventHandler(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, _ribbonGallery);
            ViewLayoutRibbonCenterPadding largeImagePadding = new ViewLayoutRibbonCenterPadding(_largeImagePadding);

            largeImagePadding.Add(_viewLargeImage);
            contentLayout.Add(largeImagePadding, ViewDockStyle.Top);

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

            // Add the second line of text
            _viewLargeCenter    = new ViewLayoutRibbonRowCenter();
            _viewLargeText2     = new ViewDrawRibbonGroupGalleryText(_ribbon, _ribbonGallery, 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);
        }
Esempio n. 3
0
        private void CreateMediumSmallButtonView()
        {
            // Create the background and border view
            _viewMediumSmall = new ViewDrawRibbonGroupButtonBackBorder(_ribbon, _ribbonColorButton,
                                                                       _ribbon.StateCommon.RibbonGroupButton.PaletteBack,
                                                                       _ribbon.StateCommon.RibbonGroupButton.PaletteBorder,
                                                                       false, _needPaint);
            _viewMediumSmall.SplitVertical = false;
            _viewMediumSmall.Click        += new EventHandler(OnMediumSmallButtonClick);
            _viewMediumSmall.DropDown     += new EventHandler(OnMediumSmallButtonDropDown);

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

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

            // Create the image and drop down content
            _viewMediumSmallImage     = new ViewDrawRibbonGroupColorButtonImage(_ribbon, _ribbonColorButton, false);
            _viewMediumSmallText1     = new ViewDrawRibbonGroupColorButtonText(_ribbon, _ribbonColorButton, true);
            _viewMediumSmallText2     = new ViewDrawRibbonGroupColorButtonText(_ribbon, _ribbonColorButton, false);
            _viewMediumSmallDropArrow = new ViewDrawRibbonDropArrow(_ribbon);
            _viewMediumSmallText2Sep2 = new ViewLayoutRibbonSeparator(3, false);
            _viewMediumSmallText2Sep3 = new ViewLayoutRibbonSeparator(3, false);
            ViewLayoutRibbonCenterPadding imagePadding = new ViewLayoutRibbonCenterPadding(_smallImagePadding);

            imagePadding.Add(_viewMediumSmallImage);

            // Layout the content in the center of a row
            _viewMediumSmallCenter = new ViewLayoutRibbonRowCenter();
            _viewMediumSmallCenter.Add(imagePadding);
            _viewMediumSmallCenter.Add(_viewMediumSmallText1);
            _viewMediumSmallCenter.Add(_viewMediumSmallText2);
            _viewMediumSmallCenter.Add(_viewMediumSmallText2Sep2);
            _viewMediumSmallCenter.Add(_viewMediumSmallDropArrow);
            _viewMediumSmallCenter.Add(_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);
        }
        private void CreateNormalView()
        {
            // Create a layout for the main area
            _layoutNormalMain = new ViewLayoutRibbonTitle();

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the group
                ContextClickController controller = new ContextClickController();
                controller.ContextClick          += new MouseEventHandler(OnContextClick);
                _layoutNormalMain.MouseController = controller;
            }

            // Create layout elements
            _layoutNormalTitle    = new ViewLayoutDocker();
            _layoutNormalContent  = new ViewLayoutRibbonGroupContent(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalSepTop   = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepLeft  = new ViewLayoutRibbonSeparator(NORMAL_BORDER_TOPLEFT2007, true);
            _layoutNormalSepRight = new ViewLayoutRibbonSeparator(NORMAL_BORDER_RIGHT2007, true);

            // Add layout elements to correct areas of the normal group
            _layoutNormalMain.Add(_layoutNormalTitle, ViewDockStyle.Bottom);
            _layoutNormalMain.Add(_layoutNormalSepTop, ViewDockStyle.Top);
            _layoutNormalMain.Add(_layoutNormalSepLeft, ViewDockStyle.Left);
            _layoutNormalMain.Add(_layoutNormalSepRight, ViewDockStyle.Right);
            _layoutNormalMain.Add(_layoutNormalContent, ViewDockStyle.Fill);

            // Create and add the title string that fills remainder title area
            _viewNormalTitle = new ViewDrawRibbonGroupTitle(_ribbon, _ribbonGroup);
            _layoutNormalTitle.Add(_viewNormalTitle, ViewDockStyle.Fill);

            // Add the dialog box launcher button to the right side of title area
            _viewNormalDialog = new ViewLayoutRibbonGroupButton(_ribbon, _ribbonGroup, _needPaint);
            _layoutNormalContent.DialogView = _viewNormalDialog;
            _layoutNormalTitle.Add(_viewNormalDialog, ViewDockStyle.Right);

            // Use this class to return the context color for any null values
            _paletteContextBack = new PaletteRibbonContextBack(_ribbon);

            // All values are equal to a default of Office 2007 shape
            _lastRibbonShape = PaletteRibbonShape.Office2007;
            _totalBorders    = TOTAL_LEFT_RIGHT_BORDERS_2007;
        }
Esempio n. 6
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 += new MouseEventHandler(OnButtonClick);
            _button.MouseController = rbc;

            // Add as child elements
            Add(_button);
            Add(_separator);
        }
        private void CreateViewElements(PaletteRedirect redirect)
        {
            // Layout for individual tabs inside the header
            _layoutRibbonTabs = 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, _layoutRibbonTabs, true, SCROLL_SPEED, NeedPaintDelegate);
            _tabsViewport.TransparentBackground = true;
            _tabsViewport.PaintBackground      += new PaintEventHandler(OnTabsPaintBackground);
            _layoutRibbonTabs.ParentControl     = _tabsViewport.ViewLayoutControl.ChildControl;
            _layoutRibbonTabs.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
            tabsDocker.Add(_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         += new EventHandler(OnAppButtonClicked);
            _appButtonController.MouseReleased += new EventHandler(OnAppButtonReleased);
            _layoutAppButton.MouseController    = _appButtonController;
            _layoutAppButton.SourceController   = _appButtonController;
            _layoutAppButton.KeyController      = _appButtonController;

            _appTabController.Target1        = _layoutAppTab.AppTab;
            _appTabController.Click         += new EventHandler(OnAppButtonClicked);
            _appTabController.MouseReleased += new EventHandler(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);
            _layoutAppButtonSep.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);

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

            // Create the manager for handling tooltips
            _toolTipManager                = new ToolTipManager();
            _toolTipManager.ShowToolTip   += new EventHandler <ToolTipEventArgs>(OnShowToolTip);
            _toolTipManager.CancelToolTip += new EventHandler(OnCancelToolTip);
            _buttonManager.ToolTipManager  = _toolTipManager;
        }