Exemplo n.º 1
0
        /// <summary>
        ///  Initialize a new instance of the VisualContextMenu class.
        /// </summary>
        /// <param name="contextMenu">Originating context menu instance.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="items">Collection of context menu items to be displayed.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
        public VisualContextMenu(KryptonContextMenu contextMenu,
                                 IPalette palette,
                                 PaletteMode paletteMode,
                                 PaletteRedirect redirector,
                                 PaletteRedirectContextMenu redirectorImages,
                                 KryptonContextMenuCollection items,
                                 bool enabled,
                                 bool keyboardActivated)
            : base(true)
        {
            _contextMenu = contextMenu;
            Redirector   = redirector;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            SetPalette(palette ?? KryptonManager.GetPaletteForMode(paletteMode));

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns,
                                                palette, paletteMode, redirector, redirectorImages,
                                                NeedPaintDelegate, enabled);

            _provider.Closing += OnProviderClosing;
            _provider.Close   += OnProviderClose;
            _provider.Dispose += OnProviderClose;

            Construct(items, keyboardActivated);
        }
        private void RefreshPalette()
        {
            if (m_PaletteMode == PaletteMode.Global)
            {
                m_Palette = KryptonManager.CurrentGlobalPalette;
            }
            else
            {
                m_Palette = KryptonManager.GetPaletteForMode(m_PaletteMode);
            }

            m_Renderer = m_Palette.GetRenderer();

            m_ViewLayoutContext = new ViewLayoutContext(g_ViewLayoutContextControl, m_Renderer);
            g_TabFontBold       = new Font(m_Palette.GetContentShortTextFont(PaletteContentStyle.ButtonNavigatorStack, PaletteState.Normal), FontStyle.Bold);
            g_TabFontRegular    = new Font(g_TabFontBold, FontStyle.Regular);

            m_PaletteRedirect             = new PaletteRedirect(m_Palette);
            m_PaletteTabControlBackground = new PaletteBackInheritRedirect(m_PaletteRedirect);
            m_PaletteTabPageBorder        = new PaletteBorderInheritRedirect(m_PaletteRedirect);
            m_PaletteTabButtonBackground  = new PaletteBackInheritRedirect(m_PaletteRedirect);
            m_PaletteTabButtonBorder      = new PaletteBorderInheritRedirect(m_PaletteRedirect);

            m_PaletteTabControlBackground.Style = PaletteBackStyle.PanelClient;
            m_PaletteTabPageBorder.Style        = PaletteBorderStyle.ButtonNavigatorStack;
            m_PaletteTabButtonBackground.Style  = PaletteBackStyle.ButtonNavigatorStack;
            m_PaletteTabButtonBorder.Style      = PaletteBorderStyle.ButtonNavigatorMini;

            m_TabBrush = new SolidBrush(m_Palette.GetContentShortTextColor1(PaletteContentStyle.ButtonNavigatorStack, PaletteState.Normal));

            Refresh();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the color of the border.
        /// </summary>
        /// <returns>The color of the border.</returns>
        public static Color GetBorderColor()
        {
            var palette = GetCurrentPalette();
            var color   = KryptonManager.GetPaletteForMode(palette).GetBorderColor1(PaletteBorderStyle.HeaderPrimary, PaletteState.Normal);

            return(color);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the color of the panel.
        /// </summary>
        /// <param name="panelStyle">The panel style.</param>
        /// <returns>The color of the panel</returns>
        public static Color GetPanelColor(PanelStyle panelStyle)
        {
            var palette = GetCurrentPalette();

            var contentBackColour     = Color.WhiteSmoke;
            var backgroundBackColour  = Color.White;
            var buttonStripBackColour = SystemColors.ControlDark;

            if (palette == PaletteMode.Office2007Black ||
                palette == PaletteMode.Office2007Blue ||
                palette == PaletteMode.Office2007Silver)
            {
                contentBackColour    = Color.WhiteSmoke;
                backgroundBackColour = Color.White;
                if (palette == PaletteMode.Office2007Black)
                {
                    backgroundBackColour = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.PanelAlternate, PaletteState.Normal);
                }
                buttonStripBackColour = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.PanelClient, PaletteState.Normal);
            }
            else if (palette == PaletteMode.ProfessionalOffice2003 ||
                     palette == PaletteMode.ProfessionalSystem)
            {
                contentBackColour     = SystemColors.Control;
                backgroundBackColour  = Color.White;
                buttonStripBackColour = SystemColors.ControlDark;
            }
            else if (palette == PaletteMode.SparkleBlue ||
                     palette == PaletteMode.SparkleOrange ||
                     palette == PaletteMode.SparklePurple)
            {
                contentBackColour     = Color.Black;
                backgroundBackColour  = Color.FromArgb(24, 32, 48);
                buttonStripBackColour = Color.FromArgb(24, 32, 48);
            }
            else if (palette == PaletteMode.Office2010Black ||
                     palette == PaletteMode.Office2010Blue ||
                     palette == PaletteMode.Office2010Silver)
            {
                contentBackColour     = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.PanelClient, PaletteState.Normal);
                backgroundBackColour  = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.PanelAlternate, PaletteState.Normal);
                buttonStripBackColour = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.PanelAlternate, PaletteState.Normal);
            }

            if (panelStyle == PanelStyle.Content)
            {
                return(contentBackColour);
            }
            else if (panelStyle == PanelStyle.Background)
            {
                return(backgroundBackColour);
            }
            else if (panelStyle == PanelStyle.ButtonStrip)
            {
                return(buttonStripBackColour);
            }

            return(SystemColors.Control);
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Initialize a new instance of the VisualPopupAppMenu class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon instance.</param>
        /// <param name="appButton">Originating app button instance.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="rectAppButtonTopHalf">Screen location of the upper half of the app button.</param>
        /// <param name="rectAppButtonBottomHalf">Screen location of the lower half of the app button.</param>
        /// <param name="keyboardActivated">Was the context menu activated by a keyboard action.</param>
        public VisualPopupAppMenu(KryptonRibbon ribbon,
                                  RibbonAppButton appButton,
                                  IPalette palette,
                                  PaletteMode paletteMode,
                                  PaletteRedirect redirector,
                                  Rectangle rectAppButtonTopHalf,
                                  Rectangle rectAppButtonBottomHalf,
                                  bool keyboardActivated)
            : base(true)
        {
            // Remember incoming state
            _redirector              = redirector;
            _ribbon                  = ribbon;
            _rectAppButtonTopHalf    = rectAppButtonTopHalf;
            _rectAppButtonBottomHalf = rectAppButtonBottomHalf;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            if (palette != null)
            {
                SetPalette(palette);
            }
            else
            {
                SetPalette(KryptonManager.GetPaletteForMode(paletteMode));
            }

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider = new AppButtonMenuProvider((ViewContextMenuManager)ViewManager,
                                                  _ribbon.RibbonAppButton.AppButtonMenuItems,
                                                  _viewColumns, palette, paletteMode,
                                                  redirector, NeedPaintDelegate);

            _provider.Closing += new CancelEventHandler(OnProviderClosing);
            _provider.Close   += new EventHandler <CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            CreateAppButtonBottom();
            CreateButtonSpecView();
            CreateContextMenuView(appButton);
            CreateRecentDocumentsView();
            CreateInnerBacking(CreateInsideCanvas());
            CreateOuterBacking();
            CreateOutsideDocker();
            CreateButtonManager(appButton);

            ViewManager.Root = _drawOutsideDocker;

            // With keyboard activate we select the first valid item
            if (keyboardActivated)
            {
                ((ViewContextMenuManager)ViewManager).KeyDown();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the forecolor of the text.
        /// </summary>
        /// <returns>The fore color</returns>
        private Color GetForeColor()
        {
            if (this.Style == TitleStyle.Custom)
            {
                return(_foreColor);
            }

            var palette         = KryptonHelper.GetCurrentPalette();
            var headingColor    = Color.Black;
            var subheadingColor = Color.Black;

            if (palette == PaletteMode.Office2007Black ||
                palette == PaletteMode.Office2007Blue ||
                palette == PaletteMode.Office2007Silver)
            {
                headingColor    = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
                subheadingColor = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
            }
            else if (palette == PaletteMode.ProfessionalOffice2003 ||
                     palette == PaletteMode.ProfessionalSystem)
            {
                headingColor    = SystemColors.ControlText;
                subheadingColor = SystemColors.ControlText;
            }
            else if (palette == PaletteMode.SparkleBlue ||
                     palette == PaletteMode.SparkleOrange ||
                     palette == PaletteMode.SparklePurple)
            {
                headingColor    = Color.White;
                subheadingColor = Color.White;
            }
            else if (palette == PaletteMode.Office2010Black ||
                     palette == PaletteMode.Office2010Blue ||
                     palette == PaletteMode.Office2010Silver)
            {
                headingColor    = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
                subheadingColor = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
            }

            if (this.Style == TitleStyle.Subheading)
            {
                return(subheadingColor);
            }
            else if (this.Style == TitleStyle.Heading)
            {
                return(headingColor);
            }

            return(_foreColor);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Sets the state of the control based on the current theme.
        /// </summary>
        private void SetThemeState()
        {
            if (DesignMode)
            {
                return;
            }

            var palette = KryptonHelper.GetCurrentPalette();

            base.TrackProgressColor = KryptonManager.GetPaletteForMode(palette).GetBackColor1(PaletteBackStyle.ButtonStandalone, PaletteState.Pressed);
            base.TrackBorderColor   = KryptonHelper.GetBorderColor();
            base.ButtonBorderColor  = KryptonHelper.GetBorderColor();
            SetBackgroundColour();
            Invalidate();
        }
Exemplo n.º 8
0
        private void SetThemeColors()
        {
            var palette = KryptonHelper.GetCurrentPalette();

            if (palette == PaletteMode.SparkleBlue ||
                palette == PaletteMode.SparkleOrange ||
                palette == PaletteMode.SparklePurple)
            {
                _lightColor = SystemColors.ControlDark;
                _darkColor  = Color.FromArgb(24, 32, 48);
            }
            else
            {
                _lightColor = KryptonManager.GetPaletteForMode(palette).GetBackColor2(PaletteBackStyle.TabCustom3, PaletteState.Normal);
                _darkColor  = SystemColors.ControlDark;
            }
            this.Invalidate();
        }
Exemplo n.º 9
0
        private void RefreshPalette()
        {
            if (m_PaletteMode == PaletteMode.Global)
            {
                m_Palette = KryptonManager.CurrentGlobalPalette;
            }
            else
            {
                m_Palette = KryptonManager.GetPaletteForMode(m_PaletteMode);
            }

            m_Renderer        = m_Palette.GetRenderer();
            m_PaletteRedirect = new PaletteRedirect(m_Palette);

            m_PaletteTabPageBackground       = new PaletteBackInheritRedirect(m_PaletteRedirect);
            m_PaletteTabPageBackground.Style = PaletteBackStyle.PanelClient;

            Refresh();
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Sets the state of the control based on the current theme.
        /// </summary>
        private void SetThemeState()
        {
            if (DesignMode)
            {
                return;
            }

            var palette = KryptonHelper.GetCurrentPalette();
            var color   = KryptonManager.GetPaletteForMode(palette)
                          .GetBackColor2(PaletteBackStyle.PanelAlternate, PaletteState.Normal);

            BackColor           = color;
            pnlSlider.BackColor = color;
            pnlVolume.BackColor = color;
            slider.BackColor    = color;
            sldVolume.BackColor = color;

            _volumeColor1 = KryptonManager.GetPaletteForMode(palette)
                            .GetBackColor1(PaletteBackStyle.ButtonStandalone, PaletteState.Pressed);
            _volumeColor2 = KryptonManager.GetPaletteForMode(palette)
                            .GetBackColor2(PaletteBackStyle.ButtonStandalone, PaletteState.Pressed);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMenuItemSelect class.
        /// </summary>
        /// <param name="itemSelect">Reference to owning instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        public ViewLayoutMenuItemSelect(KryptonContextMenuImageSelect itemSelect,
                                        IContextMenuProvider provider)
        {
            Debug.Assert(itemSelect != null);
            Debug.Assert(provider != null);

            // Store incoming references
            _itemSelect = itemSelect;
            _provider   = provider;

            _itemSelect.TrackingIndex = -1;
            ItemEnabled  = provider.ProviderEnabled;
            _viewManager = provider.ProviderViewManager;

            // Cache the values to use when running
            _imageList       = _itemSelect.ImageList;
            _imageIndexStart = _itemSelect.ImageIndexStart;
            _imageIndexEnd   = _itemSelect.ImageIndexEnd;
            _lineItems       = _itemSelect.LineItems;
            _needPaint       = provider.ProviderNeedPaintDelegate;
            _padding         = _itemSelect.Padding;
            _imageCount      = _imageList == null ? 0 : _imageList.Images.Count;

            // Limit check the start and end values
            _imageIndexStart = Math.Max(0, _imageIndexStart);
            _imageIndexEnd   = Math.Min(_imageIndexEnd, _imageCount - 1);
            _imageIndexCount = Math.Max(0, _imageIndexEnd - _imageIndexStart + 1);

            IPalette palette = provider.ProviderPalette ?? KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode);

            // Create triple that can be used by the draw button
            _triple = new PaletteTripleToPalette(palette,
                                                 PaletteBackStyle.ButtonLowProfile,
                                                 PaletteBorderStyle.ButtonLowProfile,
                                                 PaletteContentStyle.ButtonLowProfile);

            // Update with current button style
            _triple.SetStyles(itemSelect.ButtonStyle);
        }
Exemplo n.º 12
0
        private void RefreshPalette()
        {
            if (this.paletteMode == PaletteMode.Global)
            {
                this.palette = KryptonManager.CurrentGlobalPalette;
            }
            else
            {
                this.palette = KryptonManager.GetPaletteForMode(this.paletteMode);
            }

            this.renderer            = this.palette.GetRenderer();
            this.paletteRedirect     = new PaletteRedirect(this.palette);
            this.paletteBorder       = new PaletteBorderInheritRedirect(this.paletteRedirect);
            this.paletteBack         = new PaletteBackInheritRedirect(this.paletteRedirect);
            this.paletteBorderButton = new PaletteBorderInheritRedirect(this.paletteRedirect);
            this.paletteBackButton   = new PaletteBackInheritRedirect(this.paletteRedirect);

            this.paletteBorder.Style       = PaletteBorderStyle.InputControlStandalone;
            this.paletteBack.Style         = PaletteBackStyle.InputControlStandalone;
            this.paletteBorderButton.Style = PaletteBorderStyle.ButtonInputControl;
            this.paletteBackButton.Style   = PaletteBackStyle.ButtonListItem;
        }
Exemplo n.º 13
0
        private void ResolvePaletteRenderer()
        {
            // Resolve the correct palette instance to use
            switch (_paletteMode)
            {
            case PaletteMode.Custom:
                _dragPalette = _localPalette;
                break;

            default:
                _dragPalette = KryptonManager.GetPaletteForMode(_paletteMode);
                break;
            }

            // Update redirector to point at the resolved palette
            _redirector.Target = _dragPalette;

            // Inherit the state common values from resolved palette
            _stateCommon.SetInherit(_dragPalette);

            // Get the renderer associated with the palette
            _dragRenderer = _dragPalette.GetRenderer();
        }
Exemplo n.º 14
0
        void RefreshPalette()
        {
            palette = paletteMode == PaletteMode.Global ? KryptonManager.CurrentGlobalPalette : KryptonManager.GetPaletteForMode(paletteMode);

            renderer = palette.GetRenderer();

            paletteRedirect     = new PaletteRedirect(palette);
            paletteBackground   = new PaletteBackInheritRedirect(paletteRedirect);
            paletteLines        = new PaletteBorderInheritRedirect(paletteRedirect);
            paletteBackButton   = new PaletteBackInheritRedirect(paletteRedirect);
            paletteBorderButton = new PaletteBorderInheritRedirect(paletteRedirect);

            paletteBackground.Style   = PaletteBackStyle.InputControlStandalone;
            paletteLines.Style        = PaletteBorderStyle.GridDataCellList;
            paletteBackButton.Style   = PaletteBackStyle.ButtonListItem;
            paletteBorderButton.Style = PaletteBorderStyle.ButtonListItem;

            Refresh();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Sets the background colour.
        /// </summary>
        private void SetForeColor()
        {
            if (this.Style == LabelStyle.Custom)
            {
                base.ForeColor = _foreColor;
                return;
            }

            var palette      = KryptonHelper.GetCurrentPalette();
            var textColor    = Color.Black;
            var captionColor = Color.Black;
            var headingColor = Color.Black;

            if (palette == PaletteMode.Office2007Black ||
                palette == PaletteMode.Office2007Blue ||
                palette == PaletteMode.Office2007Silver)
            {
                textColor    = Color.FromArgb(64, 64, 64);
                captionColor = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
                //headingColor = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
                headingColor = Color.Black;
            }
            else if (palette == PaletteMode.ProfessionalOffice2003 ||
                     palette == PaletteMode.ProfessionalSystem)
            {
                textColor    = SystemColors.ControlText;
                captionColor = SystemColors.ControlText;
                headingColor = SystemColors.ControlText;
            }
            else if (palette == PaletteMode.SparkleBlue ||
                     palette == PaletteMode.SparkleOrange ||
                     palette == PaletteMode.SparklePurple)
            {
                textColor    = Color.White;
                captionColor = Color.White;
                headingColor = Color.White;
            }
            else if (palette == PaletteMode.Office2010Black ||
                     palette == PaletteMode.Office2010Blue ||
                     palette == PaletteMode.Office2010Silver)
            {
                textColor = Color.FromArgb(64, 64, 64);
                if (palette == PaletteMode.Office2010Black)
                {
                    textColor = Color.White;
                }

                captionColor = KryptonManager.GetPaletteForMode(palette).GetContentShortTextColor1(PaletteContentStyle.ButtonStandalone, PaletteState.Normal);
                headingColor = headingColor = Color.Black;
            }

            if (this.Style == LabelStyle.Text)
            {
                base.ForeColor = textColor;
            }
            else if (this.Style == LabelStyle.Caption)
            {
                base.ForeColor = captionColor;
            }
            else if (this.Style == LabelStyle.Heading)
            {
                base.ForeColor = headingColor;
            }
        }
Exemplo n.º 16
0
        void RefreshPalette()
        {
            palette = paletteMode == PaletteMode.Global ? KryptonManager.CurrentGlobalPalette : KryptonManager.GetPaletteForMode(paletteMode);

            renderer = palette.GetRenderer();

            paletteRedirect   = new PaletteRedirect(palette);
            paletteBackground = new PaletteBackInheritRedirect(paletteRedirect);
            labelStyle        = new PaletteContentInheritRedirect(paletteRedirect);

            paletteBackground.Style = PaletteBackStyle.InputControlStandalone;
            labelStyle.Style        = PaletteContentStyle.LabelNormalControl;

            Refresh();
        }
Exemplo n.º 17
0
        void RefreshPalette()
        {
            palette = paletteMode == PaletteMode.Global ? KryptonManager.CurrentGlobalPalette : KryptonManager.GetPaletteForMode(paletteMode);

            renderer = palette.GetRenderer();

            paletteRedirect     = new PaletteRedirect(palette);
            paletteBackground   = new PaletteBackInheritRedirect(paletteRedirect);
            paletteBackButton   = new PaletteBackInheritRedirect(paletteRedirect);
            paletteBorderButton = new PaletteBorderInheritRedirect(paletteRedirect);

            paletteBackground.Style   = PaletteBackStyle.PanelClient;
            paletteBackButton.Style   = PaletteBackStyle.ButtonStandalone;
            paletteBorderButton.Style = PaletteBorderStyle.ButtonStandalone;

            Refresh();
        }