Esempio n. 1
0
        private void CreateViewElements()
        {
            // Create redirector for the accessing the background palette
            _redirectCaption = new PaletteDoubleRedirect(_redirect, PaletteBackStyle.HeaderForm, PaletteBorderStyle.HeaderForm, NeedPaintDelegate);

            // Create a top half for use in KryptonForm and another for use inside this caption area
            _captionAppButton = new ViewLayoutRibbonAppButton(_ribbon, false);
            _otherAppButton   = new ViewLayoutRibbonAppButton(_ribbon, false);

            // Connect up the application button controller to the two button elements
            _appButtonController              = new AppButtonController(_ribbon);
            _appButtonController.Target1      = _captionAppButton.AppButton;
            _appButtonController.Target2      = _otherAppButton.AppButton;
            _appButtonController.NeedPaint   += new NeedPaintHandler(OnAppButtonNeedPaint);
            _captionAppButton.MouseController = _appButtonController;
            _otherAppButton.MouseController   = _appButtonController;
            _appTabController            = new AppTabController(_ribbon);
            _appTabController.NeedPaint += new NeedPaintHandler(OnAppButtonNeedPaint);

            // When not showing the app button we show this spacer instead
            _spaceInsteadOfAppButton         = new ViewLayoutSeparator(0);
            _spaceInsteadOfAppButton.Visible = false;

            // Quick access toolbar, minibar versions
            _captionQAT    = new ViewLayoutRibbonQATMini(_ribbon, _needIntegratedDelegate);
            _nonCaptionQAT = new ViewLayoutRibbonQATMini(_ribbon, NeedPaintDelegate);

            // Layout needed to position and draw the context titles
            _contextTiles = new ViewLayoutRibbonContextTitles(_ribbon, this);
            _contextTiles.ReverseRenderOrder = true;

            // Create composition right border and attach to composition area
            _compRightBorder = new ViewDrawRibbonCompoRightBorder();
            _compositionArea.CompRightBorder = _compRightBorder;

            // Place app button on left side and fill remainder with context titles
            Add(_contextTiles, ViewDockStyle.Fill);
            Add(_nonCaptionQAT, ViewDockStyle.Left);
            Add(_otherAppButton, ViewDockStyle.Left);

            // Update base class to use correct palette interface
            base.SetPalettes(_redirectCaption.PaletteBack, _redirectCaption.PaletteBorder);
        }
        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;
        }