예제 #1
0
        private void PaintElement(Graphics g, VisualStyleElement element, Rectangle rect, int state)
        {
            VisualStyleElement  e        = VisualStyleElement.CreateElement(element.ClassName, element.Part, state);
            VisualStyleRenderer renderer = new VisualStyleRenderer(e);

            renderer.DrawBackground(g, rect);
        }
예제 #2
0
        /// <summary>
        /// Handles the item drawing of a selected item.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.DrawItemEventArgs"/> that contains the event data.</param>
        /// <param name="hover">Determines whether the cursor is currently hovering over the item.</param>
        protected virtual void DrawItemSelected(DrawItemEventArgs e, bool hover)
        {
            if (VisualStyleRenderer.IsSupported)
            {
                VisualStyleElement elementToDraw = hover
          ? VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewState.HotSelected)
          : VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewState.Selected);

                if (VisualStyleRenderer.IsElementDefined(elementToDraw))
                {
                    new VisualStyleRenderer(elementToDraw).DrawBackground(e.Graphics, e.Bounds);
                    return;
                }
            }

            using (Pen backPen = new Pen(Color.FromArgb(50, SystemColors.Highlight)))
            {
                e.Graphics.FillRectangle(
                    backPen.Brush
                    , 0
                    , e.Bounds.Top
                    , e.Bounds.Width - 0
                    , e.Bounds.Height - 0);

                using (Pen highlightPen = new Pen(Color.FromArgb(200, backPen.Color)))
                {
                    e.Graphics.DrawRectangle(
                        highlightPen
                        , 0
                        , e.Bounds.Top
                        , e.Bounds.Width - 1
                        , e.Bounds.Height - 1);
                }
            }
        }
        protected override void OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs e)
        {
            //Draw the background using Rebar & RP_BACKGROUND (or, if that is not available, fall back to
            //Rebar.Band.Normal)
            if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(RebarClass, RP_BACKGROUND, 0)))
            {
                renderer.SetParameters(RebarClass, RP_BACKGROUND, 0);
            }
            else
            {
                renderer.SetParameters(RebarClass, 0, 0);
                //renderer.SetParameters(VisualStyleElement.Taskbar.BackgroundBottom.Normal);
                //renderer.SetParameters(Subclass(VisualStyleElement.Rebar.Band.Normal));
            }

            if (renderer.IsBackgroundPartiallyTransparent())
            {
                renderer.DrawParentBackground(e.Graphics, e.ToolStripPanel.ClientRectangle, e.ToolStripPanel);
            }

            renderer.DrawBackground(e.Graphics, e.ToolStripPanel.ClientRectangle);

            //Draw the etched edges of each row.
            //renderer.SetParameters(Subclass(VisualStyleElement.Rebar.Band.Normal));
            //foreach (ToolStripPanelRow row in e.ToolStripPanel.Rows) {
            //    Rectangle rowBounds = row.Bounds;
            //    rowBounds.Offset(0, -1);
            //    renderer.DrawEdge(e.Graphics, rowBounds, Edges.Top, EdgeStyle.Etched, EdgeEffects.None);
            //}

            e.Handled = true;
        }
예제 #4
0
        protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
        {
            var rect = e.Item.ContentRectangle;

            rect.Inflate(1, 1);
            rect.X    += 2;
            rect.Width = rect.Height;
            var element = VisualStyleElement.CreateElement("menu", 12, !e.Item.Enabled ? 1 : 2);

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e.Graphics, rect);
            }
            // FIXME: This should cope with radios, if we can have them. Add 2 to state.
            element = VisualStyleElement.CreateElement("menu", 11, e.Item.Enabled ? 1 : 2);
            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e.Graphics, rect);
            }
            else
            {
                base.OnRenderItemCheck(e);
            }
        }
        private void DrawBackground()
        {
            if (_backgroundOverlay == null)
            {
                _backgroundOverlay = Utilities.ResourceHelper.GetStandardResourceBitmap("shell32.dll", "#632");
            }

            using (Graphics g = Graphics.FromImage(_background)) {
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleElement  cpGradient = VisualStyleElement.CreateElement("CONTROLPANEL", 1, 0);
                    VisualStyleRenderer renderer   = new VisualStyleRenderer(cpGradient);
                    Rectangle           rect       = new Rectangle(0, 0, this.Width, this.Height);

                    renderer.DrawBackground(g, rect);
                }
                else
                {
                    g.FillRectangle(SystemBrushes.Control, 0, 0, _backgroundOverlay.Width, _backgroundOverlay.Height);
                }

                if (_backgroundOverlay != null)
                {
                    g.DrawImage(_backgroundOverlay, 0, 0, _backgroundOverlay.Width, _backgroundOverlay.Height);
                }
            }
        }
예제 #6
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            var rect = !e.Item.IsOnDropDown ? new Rectangle(new Point(), e.Item.Bounds.Size) : e.Item.ContentRectangle;

            if (e.Item.IsOnDropDown)
            {
                rect.Inflate(0, 1);
            }
            var element = VisualStyleElement.CreateElement("menu", !e.Item.IsOnDropDown ? 8 : 14, (e.Item.Enabled ? 0 : !e.Item.IsOnDropDown ? 3 : 2) + (!e.Item.Pressed || e.Item.IsOnDropDown ? !e.Item.Selected ? 1 : 2 : 3));

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                if (!e.Item.IsOnDropDown)
                {
                    rect.Height--;
                }
                else
                {
                    rect.X++;
                    rect.Width--;
                }
                renderer.DrawBackground(e.Graphics, rect);
            }
            else
            {
                base.OnRenderMenuItemBackground(e);
            }
        }
예제 #7
0
 protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
 {
     if (EnsureRenderer())
     {
         if (e.ToolStrip.IsDropDown)
         {
             renderer.SetParameters(MenuClass, 9, 0);
         }
         else
         {
             if (e.ToolStrip.Parent is ToolStripPanel)
             {
                 return;
             }
             if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(RebarClass, RebarBackground, 0)))
             {
                 renderer.SetParameters(RebarClass, RebarBackground, 0);
             }
             else
             {
                 renderer.SetParameters(RebarClass, 0, 0);
             }
         }
         if (renderer.IsBackgroundPartiallyTransparent())
         {
             renderer.DrawParentBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.ToolStrip);
         }
         renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds);
     }
     else
     {
         base.OnRenderToolStripBackground(e);
     }
 }
        /// <summary>
        /// Returns the Visual Style Element of a popup menu item with the appropriate state.
        /// </summary>
        /// <param name="selected"></param>
        /// <param name="enabled"></param>
        /// <returns></returns>
        private VisualStyleElement GetPopUpItemVSElement(bool selected, bool enabled)
        {
            int state;

            if (selected)
            {
                if (enabled)
                {
                    //Hot
                    state = 2;
                }
                else
                {
                    //DisabledHot
                    state = 4;
                }
            }
            else
            {
                if (enabled)
                {
                    //Normal
                    state = 1;
                }
                else
                {
                    //Disabled
                    state = 3;
                }
            }

            return(VisualStyleElement.CreateElement(vsClass, 14, state));
        }
        protected override void OnRenderToolStripPanelBackground(ToolStripPanelRenderEventArgs e)
        {
            if (EnsureRenderer())
            {
                // Draw the background using Rebar & RP_BACKGROUND (or, if that is not available, fall back to
                // Rebar.Band.Normal)
                if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(RebarClass, RebarBackground, 0)))
                {
                    renderer.SetParameters(RebarClass, RebarBackground, 0);
                }
                else
                {
                    renderer.SetParameters(RebarClass, 0, 0);
                }

                if (renderer.IsBackgroundPartiallyTransparent())
                {
                    renderer.DrawParentBackground(e.Graphics, e.ToolStripPanel.ClientRectangle, e.ToolStripPanel);
                }

                renderer.DrawBackground(e.Graphics, e.ToolStripPanel.ClientRectangle);

                e.Handled = true;
            }
            else
            {
                base.OnRenderToolStripPanelBackground(e);
            }
        }
예제 #10
0
            private VisualStyleElement DecideVisualElement(bool isExpanded)
            {
                string klass = this.UseTriangles ? "Explorer::TreeView" : "TREEVIEW";
                int    part  = this.UseTriangles && this.IsExpansionHot ? 4 : 2;
                int    state = isExpanded ? 2 : 1;

                return(VisualStyleElement.CreateElement(klass, part, state));
            }
예제 #11
0
 static BrowserRenderer()
 {
     if (Utils.IsVistaOrLater && VisualStyleRenderer.IsSupported)
     {
         ClosedGlyphRenderer =
             new VisualStyleRenderer(VisualStyleElement.CreateElement("Explorer::TreeView", 2, 1));
         OpenedGlyphRenderer =
             new VisualStyleRenderer(VisualStyleElement.CreateElement("Explorer::TreeView", 2, 2));
     }
 }
예제 #12
0
        /// <summary>
        /// Gives the correct <see cref="VisualStyleElement"/> to use for
        /// a give tab.
        /// </summary>
        /// <param name="page">The tab to return the element for.</param>
        /// <returns>The element to use when rendering the tab.</returns>
        internal VisualStyleElement GetElement(BpTabPage page)
        {
            string className = "TAB";
            int    part;
            int    state;

            if (page == selectedTab)
            {
                state = 3;
            }
            else if (page.Disabled)
            {
                state = 4;
            }
            else if (page == hoverTab)
            {
                state = 2;
            }
            else
            {
                state = 1;
            }

            TabPosition position = positions[page];
            int         toprow   = rows - 1;

            if ((rows > 1) && (toprow == selectedRow))
            {
                toprow--;
            }

            if (rowCounts[position.Row] == 1)
            {
                part = 1;
            }
            else if (position.Pos == rowCounts[position.Row] - 1)
            {
                part = 2;
            }
            else if (position.Pos == 0)
            {
                part = 3;
            }
            else
            {
                part = 4;
            }

            if (position.Row == toprow)
            {
                part += 4;
            }

            return(VisualStyleElement.CreateElement(className, part, state));
        }
예제 #13
0
        public Toast(Account account)
        {
            InitializeComponent();

            this.Account = account;

            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.UpdateStyles();

            int enabled  = 0;
            int response = DwmIsCompositionEnabled(ref enabled);

            _aeroEnabled = enabled == 1;

            this.Opacity = 0;

            _closeTimer.Tick += delegate(object sender, EventArgs e) {
                this.Close();
            };

            _elementClose = VisualStyleElement.Window.SmallCloseButton.Normal;
            _elementPrev  = VisualStyleElement.CreateElement("TaskbandExtendedUI", LeftControl, 1);
            _elementInbox = VisualStyleElement.CreateElement("TaskbandExtendedUI", CenterControl, 1);
            _elementNext  = VisualStyleElement.CreateElement("TaskbandExtendedUI", RightControl, 1);

            _iconPrev   = ResourceHelper.GetIcon("Previous.ico");
            _iconInbox  = ResourceHelper.GetIcon("Inbox.ico");
            _iconNext   = ResourceHelper.GetIcon("Next.ico");
            _iconWindow = ResourceHelper.GetIcon("gmail-classic.ico", 16);

            ToolTip openTip = new ToolTip();

            openTip.SetToolTip(_PictureOpen, Locale.Current.Tooltips.OpenMail);

            _PictureOpen.Cursor = Cursors.Hand;
            _PictureOpen.Click += OpenEmail;

            using (Icon icon = ResourceHelper.GetIcon("Open.ico")) {
                _PictureOpen.Image = icon.ToBitmap();
            }

            if (this.Account.Emails.Count > 1)
            {
                _stateNext = State.Normal;
            }

            // show the last (newest) email
            _mailIndex = this.Account.Emails.Count - 1;

            UpdateBody();
        }
예제 #14
0
        public mainInstructionsLabel()
        {
            ForeColor = Color.FromArgb(0, 51, 153);
            Font      = new Font(SystemFonts.MessageBoxFont.FontFamily.Name, 12f, GraphicsUnit.Point);
            _isVisualStyleSupported = (Environment.OSVersion.Version.Major >= 6 && VisualStyleRenderer.IsSupported);

            if (_isVisualStyleSupported)
            {
                _vseMainInstruction = VisualStyleElement.CreateElement("TEXTSTYLE", 1, 0);
            }
        }
예제 #15
0
        public static IEnumerable <object[]> Ctor_InvalidElement_TestData()
        {
            yield return(new object[] { VisualStyleElement.CreateElement("", 0, 0) });

            yield return(new object[] { VisualStyleElement.CreateElement("NoSuchClassName", 0, 0) });

            yield return(new object[] { VisualStyleElement.CreateElement("BUTTON", -1, 0) });

            yield return(new object[] { VisualStyleElement.CreateElement("BUTTON", int.MinValue, 0) });

            yield return(new object[] { VisualStyleElement.CreateElement("BUTTON", int.MaxValue, 0) });
        }
        protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
        {
            Rectangle bounds;

            if (colorTable.PopupForeColor != ToolStripSystemColorTable.DefaultPopupForeColor)
            {
                bounds = new Rectangle(Point.Empty, e.Item.Size);
                //We should probably use the PopupBorderColor for the separator, but in the specific
                //context of the dark skin, that color is not contrasty enough, so to keep things simple,
                //we just blend the fore color and the back color.
                DrawClassicSeparatorInternal(
                    e.Graphics,
                    Core.Utilities.ColorUtils.BlendColors(colorTable.PopupForeColor, 1, colorTable.PopupBackColor, 3),
                    bounds);
            }
            else if (ToolStripManager.VisualStylesEnabled)
            {
                VisualStyleElement vsElement = VisualStyleElement.CreateElement(vsClass, 15, 0);
                if (VisualStyleRenderer.IsElementDefined(vsElement))
                {
                    VisualStyleRenderer vsRenderer = GetVisualStyleRenderer(vsElement);
                    int partHeight = vsRenderer.GetPartSize(e.Graphics, ThemeSizeType.True).Height;
                    int y          = (e.Item.Height - partHeight) / 2;      //Vertical center
                    bounds = new Rectangle(0, y, e.Item.Width, partHeight); //here, the rect is full width, and we shrink it when we check for RightToLeft.
                    ToolStripDropDownMenu dropDownMenu = e.Item.GetCurrentParent() as ToolStripDropDownMenu;

                    if (dropDownMenu != null)
                    {
                        if (dropDownMenu.RightToLeft == RightToLeft.No)
                        {
                            bounds.X    += dropDownMenu.ImageScalingSize.Width + 6;
                            bounds.Width = dropDownMenu.Width - bounds.X;
                        }
                        else
                        {
                            bounds.X    -= 6;
                            bounds.Width = dropDownMenu.Width - bounds.X - dropDownMenu.ImageScalingSize.Width;
                        }
                    }

                    vsRenderer.DrawBackground(e.Graphics, bounds);
                }
                else
                {
                    base.OnRenderSeparator(e);
                }
            }
            else
            {
                base.OnRenderSeparator(e);
            }
        }
예제 #17
0
 private bool EnsureRenderer()
 {
     if (!VisualStyleRenderer.IsSupported)
     {
         return(false);
     }
     if (!VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(MenuClass, (int)MenuParts.BarBackground, (int)MenuBarStates.Active)))
     {
         return(false);
     }
     _renderer ??= new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
     return(true);
 }
예제 #18
0
        public void VisualStyleElement_CreateElement()
        {
            var className = "a";
            var part      = 1;
            var state     = 2;

            var vse = VisualStyleElement.CreateElement(className, part, state);

            Assert.NotNull(vse);
            Assert.Equal(className, vse.ClassName);
            Assert.Equal(part, vse.Part);
            Assert.Equal(state, vse.State);
        }
예제 #19
0
        // Render the background of an actual menu bar, dropdown menu or toolbar.
        protected override void OnRenderToolStripBackground(System.Windows.Forms.ToolStripRenderEventArgs e)
        {
            if (EnsureRenderer())
            {
                if (e.ToolStrip.IsDropDown)
                {
                    renderer.SetParameters(MenuClass, (int)MenuParts.PopupBackground, 0);
                }
                else
                {
                    // It's a MenuStrip or a ToolStrip. If it's contained inside a larger panel, it should have a
                    // transparent background, showing the panel's background.

                    if (e.ToolStrip.Parent is ToolStripPanel)
                    {
                        // The background should be transparent, because the ToolStripPanel's background will be visible.
                        // (Of course, we assume the ToolStripPanel is drawn using the same theme, but it's not my fault
                        // if someone does that.)
                        return;
                    }
                    else
                    {
                        // A lone toolbar/menubar should act like it's inside a toolbox, I guess.
                        // Maybe I should use the MenuClass in the case of a MenuStrip, although that would break
                        // the other themes...
                        if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement(RebarClass, RebarBackground, 0)))
                        {
                            renderer.SetParameters(RebarClass, RebarBackground, 0);
                        }
                        else
                        {
                            renderer.SetParameters(RebarClass, 0, 0);
                        }
                    }
                }

                if (renderer.IsBackgroundPartiallyTransparent())
                {
                    renderer.DrawParentBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.ToolStrip);
                }
                if (DrawBackground)
                {
                    renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds);
                }
            }
            else
            {
                base.OnRenderToolStripBackground(e);
            }
        }
예제 #20
0
        /// <summary>
        ///     Raises the <see cref="E:Paint" /> event.
        /// </summary>
        /// <param name="e">The <see cref="PaintEventArgs" /> instance containing the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Application.RenderWithVisualStyles &&
                VisualStyleRenderer.IsElementDefined(VisualStyleElement.CreateElement("TaskDialog", 8, 0)))
            {
                PaintWithVisualStyles(e.Graphics);
            }
            else
            {
                PaintManually(e.Graphics);
            }

            base.OnPaint(e);
        }
예제 #21
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            var element = VisualStyleElement.CreateElement("menu", !e.Item.IsOnDropDown ? 8 : 14, (e.Item.Enabled ? 0 : !e.Item.IsOnDropDown ? 3 : 2) + (!e.Item.Pressed || e.Item.IsOnDropDown ? !e.Item.Selected ? 1 : 2 : 3));

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                e.TextColor = renderer.GetColor(ColorProperty.TextColor);
                base.OnRenderItemText(e);
            }
            else
            {
                base.OnRenderItemText(e);
            }
        }
예제 #22
0
        protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
        {
            var rect    = e.ArrowRectangle;
            var element = VisualStyleElement.CreateElement("menu", 16, e.Item.Enabled ? 1 : 2);

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e.Graphics, rect);
            }
            else
            {
                base.OnRenderArrow(e);
            }
        }
예제 #23
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            var rect    = e.ToolStrip.ClientRectangle;
            var element = VisualStyleElement.CreateElement("menu", !e.ToolStrip.IsDropDown ? 7 : 9, 0);

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e.Graphics, rect, e.AffectedBounds);
            }
            else
            {
                base.OnRenderToolStripBackground(e);
            }
        }
 /// <param name="bitmap">Set to true if the associated foreground image is not a standard glyph. (I think)</param>
 private VisualStyleElement GetMenuGlyphBackgroundVSElement(bool enabled, bool bitmap)
 {
     if (!enabled)
     {
         return(VisualStyleElement.CreateElement(vsClass, 12, 1));
     }
     else if (bitmap)
     {
         return(VisualStyleElement.CreateElement(vsClass, 12, 3));
     }
     else
     {
         return(VisualStyleElement.CreateElement(vsClass, 12, 2));
     }
 }
예제 #25
0
        /// <summary>
        /// Returns the Visual Style Element of a popup menu item with the appropriate state.
        /// </summary>
        /// <param name="selected"></param>
        /// <param name="enabled"></param>
        /// <returns></returns>
        private VisualStyleElement GetPopUpItemVsElement(bool selected, bool enabled)
        {
            int state;

            if (selected)
            {
                state = enabled ? 2 : 4;
            }
            else
            {
                state = enabled ? 1 : 3;
            }

            return(VisualStyleElement.CreateElement(_vsClass, 14, state));
        }
        private void DrawBackground()
        {
            if (_backgroundOverlay == null)
            {
                _backgroundOverlay = Utilities.ResourceHelper.GetResourcePNG("shell32.dll", "632");
            }

            VisualStyleElement  cpGradient = VisualStyleElement.CreateElement("CONTROLPANEL", 1, 0);
            VisualStyleRenderer renderer   = new VisualStyleRenderer(cpGradient);
            Rectangle           rect       = new Rectangle(0, 0, this.Width, this.Height);

            using (Graphics g = Graphics.FromImage(_background)) {
                renderer.DrawBackground(g, rect);
                g.DrawImage(_backgroundOverlay, 0, 0, _backgroundOverlay.Width, _backgroundOverlay.Height);
            }
        }
예제 #27
0
        private VisualStyleElement GetMenuGlyphVsElement(MenuGlyph glyph, bool enabled)
        {
            switch (glyph)
            {
            case MenuGlyph.Arrow:
                return(VisualStyleElement.CreateElement(_vsClass, 16, enabled ? 1 : 2));

            case MenuGlyph.Bullet:
                return(VisualStyleElement.CreateElement(_vsClass, 11, enabled ? 3 : 4));

            case MenuGlyph.Checkmark:
                return(VisualStyleElement.CreateElement(_vsClass, 11, enabled ? 1 : 2));

            default:
                throw new ArgumentException("Supported value.", nameof(glyph));
            }
        }
        private VisualStyleElement GetMenuBarItemVSElement(bool selected, bool enabled, bool pushed)
        {
            int state;

            if (pushed)
            {
                if (enabled)
                {
                    //Pushed
                    state = 3;
                }
                else
                {
                    //DisabledPushed
                    state = 6;
                }
            }
            else if (selected)
            {
                if (enabled)
                {
                    //Hot
                    state = 2;
                }
                else
                {
                    //DisabledHot
                    state = 5;
                }
            }
            else
            {
                if (enabled)
                {
                    //Normal
                    state = 1;
                }
                else
                {
                    //Disabled
                    state = 4;
                }
            }

            return(VisualStyleElement.CreateElement(vsClass, 8, state));
        }
예제 #29
0
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            var rect = e.ToolStrip.ClientRectangle;

            rect.Width = e.ToolStrip.Width - e.ToolStrip.DisplayRectangle.Width - 2;
            var element = VisualStyleElement.CreateElement("menu", 13, 0);

            if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(element))
            {
                var renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e.Graphics, rect);
            }
            else
            {
                base.OnRenderImageMargin(e);
            }
        }
예제 #30
0
        static ListItemRenderer()
        {
            if (!VisualStyleRenderer.IsSupported)
            {
                isSupported = false;
                return;
            }

            VisualStyleElement
                normal           = VisualStyleElement.ListView.Item.Normal,
                hot              = VisualStyleElement.ListView.Item.Hot,
                selected         = VisualStyleElement.ListView.Item.Selected,
                disabled         = VisualStyleElement.ListView.Item.Disabled,
                selectedNotFocus = VisualStyleElement.ListView.Item.SelectedNotFocus;

            isSupported = VisualStyleRenderer.IsElementDefined(normal) &&
                          VisualStyleRenderer.IsElementDefined(hot) &&
                          VisualStyleRenderer.IsElementDefined(selected) &&
                          VisualStyleRenderer.IsElementDefined(disabled) &&
                          VisualStyleRenderer.IsElementDefined(selectedNotFocus);

            if (isSupported)
            {
                baseElement = normal;
                return;
            }

            normal           = VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewItemState.Normal);
            hot              = VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewItemState.Hot);
            selected         = VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewItemState.Selected);
            disabled         = VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewItemState.Disabled);
            selectedNotFocus = VisualStyleElement.CreateElement("Explorer::ListView", 1, (int)ListViewItemState.SelectedNotFocus);

            isSupported = VisualStyleRenderer.IsElementDefined(normal) &&
                          VisualStyleRenderer.IsElementDefined(hot) &&
                          VisualStyleRenderer.IsElementDefined(selected) &&
                          VisualStyleRenderer.IsElementDefined(disabled) &&
                          VisualStyleRenderer.IsElementDefined(selectedNotFocus);

            if (isSupported)
            {
                baseElement = normal;
                return;
            }
        }