Example #1
0
        //protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        //{
        //    Rectangle rect = new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height);

        //    const int ItemSize = 71;
        //    Image image = ToolButtonBackImage.Image;

        //    int x = 0;
        //    if (e.Item.Pressed)
        //        x = 1 * ItemSize;
        //    else if (e.Item.Selected)
        //        x = 3 * ItemSize;

        //    if (e.Item is ToolStripButton)
        //    {
        //        if (((ToolStripButton)e.Item).Checked)
        //            x = 1 * ItemSize;
        //    }

        //    PaintHelper.ExpandImage(e.Graphics, image, 5, rect, new Rectangle(x, 0, ItemSize, image.Height));
        //}

        //protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        //{
        //    OnRenderButtonBackground(e);
        //}

        //protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
        //{
        //    Rectangle rect = new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height);

        //    if (e.Vertical)
        //    {
        //        rect.X += rect.Width/2;
        //        rect.Inflate(0, -2);
        //        e.Graphics.DrawLine(new Pen(SeparatorColor), rect.X, rect.Y, rect.X, rect.Bottom);
        //    }
        //    else
        //    {
        //        rect.Y += rect.Height / 2;
        //        rect.Inflate(-4, 0);
        //        if (e.ToolStrip is ToolStripDropDownMenu)
        //        {
        //            rect.X += 28;
        //            rect.Width -= 28;
        //        }
        //        e.Graphics.DrawLine(new Pen(SeparatorColor), rect.X, rect.Y, rect.Right, rect.Y);
        //    }

        //    //base.OnRenderSeparator(e);
        //}

        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            if (e.ToolStrip is StatusStrip)
            {
                if (!e.Item.Pressed && !e.Item.Selected)
                {
                    e.TextColor = PaintHelper.FarthestColor(ColorTheme.Workspace, ColorTheme.MediumLight, ColorTheme.MediumDark);
                }
            }
            else
            {
                if (e.Item is ToolStripMenuItem)
                {
                    if (e.ToolStrip is MenuStrip)
                    {
                        if (!e.Item.Pressed && !e.Item.Selected)
                        {
                            //e.TextColor = PaintHelper.FarthestColor(ColorTheme.Workspace, ColorTheme.MediumLight, ColorTheme.MediumDark);
                            e.TextColor = Colors.MenuStripItemForeColor;
                        }
                    }
                    else if (e.Item.Selected)
                    {
                        e.TextColor = Colors.MenuStripItemSelectedForeColor;//
                    }

                    e.TextRectangle = new Rectangle(e.TextRectangle.X,
                                                    e.TextRectangle.Y,
                                                    e.TextRectangle.Width,
                                                    e.TextRectangle.Height + e.Item.Padding.Vertical);

                    //e.Graphics.DrawRectangle(Pens.Red, e.TextRectangle.X, e.TextRectangle.Y, e.TextRectangle.Width - 1, e.TextRectangle.Height - 1);
                }
                else if (e.Item is ToolStripButton || e.Item is ToolStripDropDownButton || e.Item is ToolStripSplitButton)
                {
                    if (e.Item is ToolStripButton && ((ToolStripButton)e.Item).Checked)
                    {
                        e.TextColor = PaintHelper.FarthestColor(ColorTable.ButtonCheckedGradientMiddle, ColorTheme.Light, ColorTheme.Dark);//
                    }
                    else if (e.Item is ToolStripDropDownButton && e.Item.Pressed)
                    {
                        e.TextColor = PaintHelper.FarthestColor(ColorTable.ToolStripDropDownBackground, ColorTheme.Light, ColorTheme.Dark);//
                    }
                    else if (e.Item.Pressed || e.Item.Selected)
                    {
                        e.TextColor = PaintHelper.FarthestColor(ColorTable.ButtonSelectedGradientMiddle, ColorTheme.Light, ColorTheme.Dark);//
                    }
                    else
                    {
                        e.TextColor = PaintHelper.FarthestColor(ColorTable.ToolStripGradientMiddle, ColorTheme.Light, ColorTheme.Dark);//
                    }
                }
            }

            base.OnRenderItemText(e);
        }
Example #2
0
        public DefaultToolStripColors()
        {
            UIColorTheme theme = UITheme.Default.Colors;

            if (theme == null)
            {
                theme = UIColorThemeManage.Default;
            }

            _MenuStripGradientEnd           = theme.Workspace;
            _MenuStripGradientBegin         = theme.Workspace;   // PaintHelper.GetDarkColor(_MenuStripGradientEnd, 0.1);
            _MenuItemPressedGradientBegin   = PaintHelper.GetLightColor(theme.Light, 0.2f);
            _MenuItemSelected               = theme.MediumLight; // PaintHelper.GetDarkColor(theme.Sharp, 0.1f);
            MenuStripItemSelectedForeColor  = PaintHelper.FarthestColor(_MenuItemSelected, theme.Dark, theme.Light);
            _MenuItemSelectedGradientMiddle = _MenuItemSelected;
            _MenuItemSelectedGradientBegin  = PaintHelper.GetLightColor(_MenuItemSelectedGradientMiddle, 0.1f);
            _MenuItemSelectedGradientEnd    = PaintHelper.GetLightColor(_MenuItemSelectedGradientMiddle, 0.05f);
            _MenuItemSelectedBorder         = Color.Empty;// PaintHelper.AdjustColor(PaintHelper.GetDarkColor(theme.Sharp), 0, 50, 30, 40);
            _MenuBorder            = theme.MediumLight;
            MenuStripItemForeColor = PaintHelper.FarthestColor(theme.Workspace, theme.MediumLight, theme.MediumDark, 50);

            _GripDark  = PaintHelper.GetDarkColor(_MenuStripGradientBegin, 0.2);
            _GripLight = PaintHelper.GetLightColor(_MenuStripGradientBegin, 0.1);

            _ToolStripGradientBegin      = theme.MediumLight;
            _ToolStripGradientMiddle     = theme.MediumLight;
            _ToolStripGradientEnd        = theme.MediumLight;// PaintHelper.GetDarkColor(theme.MediumLight, 0.1);
            _ToolStripDropDownBackground = theme.Light;

            _ImageMarginGradientBegin  = theme.MenuImageMargin;
            _ImageMarginGradientMiddle = _ImageMarginGradientBegin;
            _ImageMarginGradientEnd    = _ImageMarginGradientBegin;

            _CheckBackground         = PaintHelper.GetLightColor(theme.MediumDark);
            _CheckSelectedBackground = PaintHelper.GetLightColor(_CheckBackground);

            //_SeparatorDark = _ToolStripGradientMiddle;
            _SeparatorDark  = PaintHelper.GetDarkColor(_ToolStripGradientMiddle, 0.1);
            _SeparatorLight = Color.Empty;                                                             // PaintHelper.GetLightColor(_ToolStripGradientMiddle, 0.1);

            _ButtonCheckedGradientMiddle  = PaintHelper.AdjustColor(theme.MediumLight, 0, 60, 40, 70); // .GetDarkColor(theme.MediumLight, 0.2);
            _ButtonCheckedGradientBegin   = PaintHelper.GetDarkColor(_ButtonCheckedGradientMiddle, 0.2);
            _ButtonCheckedGradientEnd     = PaintHelper.GetDarkColor(_ButtonCheckedGradientMiddle, 0.1);
            _ButtonSelectedBorder         = PaintHelper.AdjustColor(theme.MediumDark, 0, 0, 30, 40);
            _ButtonSelectedGradientMiddle = PaintHelper.AdjustColor(theme.Sharp, 0, 100, 70, 80);
            _ButtonSelectedGradientBegin  = PaintHelper.GetLightColor(_ButtonSelectedGradientMiddle, 0.2);
            _ButtonSelectedGradientEnd    = PaintHelper.GetLightColor(_ButtonSelectedGradientMiddle, 0.1);
        }
Example #3
0
        public override void ApplyTheme(UITheme theme)
        {
            base.ApplyTheme(theme);

            if (theme != null)
            {
                BackColor                     = theme.Colors.Workspace.IsEmpty ? theme.Colors.Dark : theme.Colors.Workspace;
                ForeColor                     = theme.Colors.Light;
                SelectedItemBackColor         = theme.Colors.MediumLight;                                                                //.Sharp;
                SelectedItemForeColor         = PaintHelper.FarthestColor(SelectedItemBackColor, theme.Colors.Dark, theme.Colors.Light); // theme.Colors.SharpText;
                InactiveSelectedItemBackColor = SelectedItemBackColor;
                InactiveSelectedItemForeColor = SelectedItemForeColor;
                //InactiveSelectedItemBackColor = theme.Colors.MediumDark;
                //InactiveSelectedItemForeColor = PaintHelper.FarthestColor(theme.Colors.MediumDark, theme.Colors.Light, theme.Colors.Dark);
                ItemBackColor      = theme.Colors.MediumDark;
                ItemForeColor      = PaintHelper.FarthestColor(ItemBackColor, theme.Colors.Dark, theme.Colors.Light);
                HoverItemBackColor = theme.Colors.Sharp;
                HoverItemForeColor = PaintHelper.FarthestColor(HoverItemBackColor, theme.Colors.Dark, theme.Colors.Light);
            }
        }
Example #4
0
        public override void ApplyTheme(UITheme theme)
        {
            base.ApplyTheme(theme);

            ForeColor = PaintHelper.FarthestColor(BackColor, theme.Colors.Sharp, theme.Colors.Dark);
        }