Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            PaintBackground(e);

            PaintHelper.SetHighQualityRender(e.Graphics);

            if (Pages == null)
            {
                BeginInvoke(new MethodInvoker(CalculatePageInfo));
            }
            else if (Pages.Length == 0 || ExceptionPrinting)
            {
                SolidBrush brushText = new SolidBrush(ForeColor);

                string msg;
                if (this.ExceptionPrinting)
                {
                    msg = Lang._("Exception Occurs");
                }
                else
                {
                    msg = Lang._("No Pages");
                }

                e.Graphics.DrawString(msg, Font, brushText, ClientRectangle, PaintHelper.SFCenter);

                brushText.Dispose();
            }
            else
            {
                PaintPages(e);
            }
        }
Example #2
0
        protected override void DrawCloseButton(TabItemPaintEventArgs e, Rectangle rect)
        {
            //Skin.Instance.DrawTaskBarItemCloseButton(new SkinPaintEventArgs(this, e), rect, tis, Alignment, item == SelectedItem);
            Image image = Properties.Resources.close_button; // Images.close_button;

            Rectangle rectS = new Rectangle(0, 0, image.Width / 4, image.Height);

            if (!e.Selected)
            {
                rectS.X = rectS.Width * 3;
            }

            switch (e.CloseButtonStatus)
            {
            case UIControlStatus.Hover:
                rectS.X = rectS.Width * 1;
                break;

            case UIControlStatus.Selected:
                rectS.X = rectS.Width * 2;
                break;

            case UIControlStatus.Disabled:
                rectS.X = rectS.Width * 3;
                break;
            }

            PaintHelper.DrawImageInRange(e.Graphics, image, rect, rectS);
        }
Example #3
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            e.Graphics.Clear(e.BackColor);

            if (e.ToolStrip is ToolStripDropDownMenu)
            {
                //base.OnRenderToolStripBackground(e);
                Rectangle rect = e.AffectedBounds;
                //Image image = MenuBackImage.Image;
                //PT.ExpandImage(e.Graphics, image, 10, rect, new Rectangle(0, 0, image.Width, image.Height));
                //e.ToolStrip.Region = new Region(PT.GetRoundRectangle(new Rectangle(rect.Left, rect.Top, rect.Width + 1, rect.Height + 1), 2));

                e.Graphics.FillRectangle(new SolidBrush(UITheme.Default.Colors.MediumLight), rect);

                GraphicsPath path = PaintHelper.GetRoundRectangle(rect, 2);
                e.Graphics.DrawPath(Pens.Gray, path);

                e.Graphics.FillRectangle(Brushes.Silver, new Rectangle(rect.Right - 1, rect.Bottom - 1, 1, 1));
            }
            else
            {
                int def = 0;
                if (e.ToolStrip is ToolStripPro && ((ToolStripPro)e.ToolStrip).HalfRenderBackground)
                {
                    def = 2;
                }

                Image image = BarBackImage.Image;
                PaintHelper.ExpandImage(e.Graphics, image, 5, e.AffectedBounds, new Rectangle(0, def, image.Width, image.Height - def));
            }
            //base.OnRenderToolStripBackground(e);
        }
Example #4
0
        void DrawButton(PaintEventArgs e, ButtonInfo button, int iconX, int textX)
        {
            Color backColor = ButtonBackColor;
            Color foreColor = ButtonForeColor;

            if (button == PressedObject || button == HoverObject)
            {
                backColor = ButtonHoverBackColor;
                foreColor = ButtonHoverForeColor;
            }

            var rect = button.Bounds;
            var font = Font;

            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);

            if (button.Image != null)
            {
                var rectIcon = new Rectangle(iconX, rect.Y, IconSize.Width, rect.Height);
                PaintHelper.DrawImageInRange(e.Graphics, button.Image, rectIcon);
            }

            if (!string.IsNullOrEmpty(button.Text))
            {
                var rectText = new Rectangle(textX, rect.Y, rect.Right - textX, rect.Height);

                var sf = PaintHelper.SFLeft;
                sf.FormatFlags |= StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;

                e.Graphics.DrawString(button.Text, Font, new SolidBrush(foreColor), rectText, sf);
            }
        }
Example #5
0
        public override void Initialize(PaintEventArgs e)
        {
            base.Initialize(e);

            PaintHelper.SetHighQualityRender(e.Graphics);
            e.Graphics.SmoothingMode = SmoothingMode.Default;
        }
Example #6
0
            protected virtual void DrawItemBackground(PaintEventArgs e, bool hover, bool pressed)
            {
                Color color;

                //UIControlStatus us = UIControlStatus.Normal;
                if (pressed)
                {
                    color = SystemColors.ControlDark;
                }
                //us = UIControlStatus.Selected;
                else if (hover)
                {
                    color = SystemColors.ControlLight;
                }
                //us = UIControlStatus.Hover;
                else if (BackColor.HasValue)
                {
                    color = BackColor.Value;
                }
                else
                {
                    return;
                }

                e.Graphics.FillRectangle(new SolidBrush(color), Bounds);
                e.Graphics.DrawRectangle(new Pen(PaintHelper.GetDarkColor(color)), 0, 0, Bounds.Width, Bounds.Height);

                //Skin.DrawToolButtonBackground(new SkinPaintEventArgs(this, e), item.Bounds, us);
            }
Example #7
0
        void DrawButtonImageAndText(PaintEventArgs e, TabBarButton button, UIControlStatus ucs)
        {
            if (button.Icon != null && string.IsNullOrEmpty(button.Text))
            {
                PaintHelper.DrawImageInRange(e.Graphics, button.Icon, button.Bounds);
            }
            else if (button.Icon == null && string.IsNullOrEmpty(button.Text))
            {
                DrawButtonText(e, button, ucs);
            }
            else
            {
                Size size = Size.Ceiling(e.Graphics.MeasureString(button.Text, Bar.Font));
                size.Width += button.Icon.Width;
                Rectangle rect = new Rectangle(
                    button.Bounds.X + (button.Bounds.Width - size.Width) / 2,
                    button.Bounds.Y + (button.Bounds.Height - size.Height) / 2,
                    size.Width,
                    size.Height);

                e.Graphics.DrawImage(button.Icon,
                                     new Rectangle(rect.Left, rect.Top + (rect.Height - button.Icon.Height) / 2, button.Icon.Width, button.Icon.Height),
                                     0, 0, button.Icon.Width, button.Icon.Height, GraphicsUnit.Pixel);

                rect.X     += button.Icon.Width;
                rect.Width -= button.Icon.Width;

                e.Graphics.DrawString(button.Text, Bar.Font, new SolidBrush(Bar.ForeColor), rect, PaintHelper.SFCenter);
            }
        }
Example #8
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));
        }
Example #9
0
        protected virtual bool OnPaint(ThumbViewPaintEventArgs e)
        {
            e.PaintBackground();

            // text
            var textHeight = e.Font.Height + 6;
            var rectText   = new Rectangle(Left, Bottom - textHeight, Width, textHeight);

            if (!string.IsNullOrEmpty(Text))
            {
                var sf = PaintHelper.SFCenter;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                sf.FormatFlags |= StringFormatFlags.NoWrap;

                e.Graphics.DrawString(Text,
                                      e.Font,
                                      Selected ? new SolidBrush(e.View.ActiveCellForeColor) : new SolidBrush(e.View.CellForeColor),
                                      rectText,
                                      sf);
            }

            // image
            if (Image != null)
            {
                var rectImg = new Rectangle(Left, Top, Width, Height - textHeight - 4);
                PaintHelper.DrawImageInRange(e.Graphics, Image, rectImg);
            }

            return(true);
        }
Example #10
0
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(e.ToolStrip.ToString());
            if (e.ToolStrip is ToolStripDropDownMenu)
            {
                Color color;
                if (e.Item.Selected)
                {
                    if (e.Item.Enabled)
                    {
                        color = PaintHelper.AdjustColor(UITheme.Default.Colors.Sharp, 40, 50, 85, 90);
                    }
                    else
                    {
                        color = Color.WhiteSmoke;
                    }
                }
                else
                {
                    return;
                }
                Rectangle rect = new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height);
                rect.Inflate(-2, 0);

                PaintHelper.DrawHoverBackground(e.Graphics, rect, color);
                return;
            }

            base.OnRenderMenuItemBackground(e);
        }
Example #11
0
        protected override void DrawItemBackground(TabItemPaintEventArgs e)
        {
            //base.DrawItemBackground(e);

            TaskBar taskBar   = e.GetBar <TaskBar>();
            Color   backColor = e.Bar.ItemBackColor;

            switch (e.Status)
            {
            case UIControlStatus.Selected:
            case UIControlStatus.Focused:
                if (taskBar.IsActive)
                {
                    backColor = taskBar.SelectedItemBackColor;
                }
                else
                {
                    backColor = taskBar.InactiveSelectedItemBackColor;
                }
                break;

            case UIControlStatus.Hover:
                backColor = taskBar.HoverItemBackColor;
                break;
            }

            if (!backColor.IsEmpty)
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(e.Bounds, taskBar.TabRounded, taskBar.TabRounded, 0, 0);
                //if (e.Status == UIControlStatus.Hover)
                //{
                //    LinearGradientBrush backBrush = new LinearGradientBrush(e.Bounds, backColor, backColor, 90.0f);
                //    ColorBlend cb = new ColorBlend(3);
                //    cb.Colors = new Color[] { PaintHelper.GetLightColor(backColor), backColor, backColor };
                //    cb.Positions = new float[] { 0.0f, 0.5f, 1.0f };
                //    backBrush.InterpolationColors = cb;
                //    e.Graphics.FillPath(backBrush, path);
                //}
                //else
                //{
                SolidBrush backBrush = new SolidBrush(backColor);
                e.Graphics.FillPath(backBrush, path);
                //}

                //
                if ((e.Status == UIControlStatus.Normal || e.Status == UIControlStatus.Hover) &&
                    e.Bounds.Height > 10)
                {
                    Rectangle rectShadow = e.Bounds;
                    rectShadow.Y      = rectShadow.Bottom - 6;
                    rectShadow.Height = 5;
                    var brush = new LinearGradientBrush(rectShadow, Color.Transparent,
                                                        PaintHelper.AdjustColorSLess(PaintHelper.GetDarkColor(backColor), 20), 90.0f);
                    rectShadow.Y++;//规避一个Gdi+错误, 会导致第一行有一个很深的线
                    //e.Graphics.FillRectangle(Brushes.Red, rectShadow);
                    e.Graphics.FillRectangle(brush, rectShadow);
                }
            }
        }
Example #12
0
        public override void DrawBaseLine(PaintEventArgs e)
        {
            Rectangle    rect  = new Rectangle(0, Bar.Height - Bar.BaseLineSize, Bar.Width, Bar.BaseLineSize);
            GraphicsPath path  = PaintHelper.GetRoundRectangle(rect, Bar.BaseLineSize, Bar.BaseLineSize, 0, 0);
            Color        color = TaskBar.IsActive ? TaskBar.SelectedItemBackColor : TaskBar.InactiveSelectedItemBackColor;

            e.Graphics.FillPath(new SolidBrush(color), path);
        }
Example #13
0
        void PaintBackground(PaintEventArgs e)
        {
            //e.Graphics.Clear(BackColor);

            LinearGradientBrush brush = new LinearGradientBrush(ClientRectangle, PaintHelper.GetDarkColor(BackColor), BackColor, 45.0f);

            e.Graphics.FillRectangle(brush, ClientRectangle);
        }
Example #14
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Image == null)
            {
                base.OnPaint(e);
            }
            else
            {
                InvokePaintBackground(this, e);
                PaintBackground(e);

                Size         textSize = Size.Empty;
                Image        image    = (IsMouseHover && HoverImage != null) ? HoverImage : Image;
                StringFormat sf       = new StringFormat();
                sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide;
                if (!string.IsNullOrEmpty(Text))
                {
                    textSize = Size.Ceiling(e.Graphics.MeasureString(Text, Font, Width - image.Width, sf));
                }

                Size clientSize = ClientSize;

                // Draw Image
                int totalWidth = image.Width + textSize.Width;
                //int totalHeight = Math.Max(Image.Height, textSize.Height);

                var rectImage = new Rectangle((clientSize.Width - totalWidth) / 2, (clientSize.Height - image.Height) / 2, image.Width, image.Height);

                if (!Enabled)
                {
                    PaintHelper.DrawImageDisabled(e.Graphics,
                                                  image,
                                                  rectImage,
                                                  new Rectangle(0, 0, image.Width, image.Height),
                                                  BackColor);
                }
                else
                {
                    e.Graphics.DrawImage(image
                                         , rectImage
                                         , 0, 0, image.Width, image.Height
                                         , GraphicsUnit.Pixel);
                }

                // Draw Text
                if (!string.IsNullOrEmpty(Text))
                {
                    e.Graphics.DrawString(Text
                                          , Font
                                          , new SolidBrush(ForeColor)
                                          , (clientSize.Width - totalWidth) / 2 + image.Width
                                          , (clientSize.Height - textSize.Height) / 2 + 2
                                          , sf);
                }
            }
        }
Example #15
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 #16
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (ExternalMode)
            {
                var image = Properties.Resources.external;
                var rect  = ClientRectangle;
                PaintHelper.DrawImageInRange(e.Graphics, image, rect);
            }
        }
Example #17
0
        protected virtual void DrawHover(Rectangle rectCell, PaintEventArgs e)
        {
            Color color = PaintHelper.AdjustColor(SystemColors.Highlight, 40, 50, 85, 90);

            PaintHelper.DrawHoverBackgroundFlat(e.Graphics, rectCell, color);


            //LinearGradientBrush brush = new LinearGradientBrush(rectCell, PT.GetLightColor(SystemColors.Highlight), SystemColors.Highlight, 90.0f);
            //e.Graphics.FillRectangle(brush, rectCell);
            //e.Graphics.DrawRectangle(SystemPens.Highlight, rectCell.X, rectCell.Y, rectCell.Width - 1, rectCell.Height - 1);
        }
Example #18
0
        protected override void DrawCell(int index, Rectangle rect, PaintEventArgs e)
        {
            Image image = Items[index];

            if (image == null)
            {
                return;
            }

            PaintHelper.DrawImageInRange(e.Graphics, image, rect);
        }
Example #19
0
        protected override void DrawCell(int index, Rectangle rect, PaintEventArgs e)
        {
            Picture picture = Items[index];

            if (picture == null || picture.Data == null)
            {
                return;
            }

            PaintHelper.DrawImageInRange(e.Graphics, picture.Data, rect);
        }
Example #20
0
            protected override void OnPaint(PaintEventArgs e)
            {
                Rectangle           rect  = ClientRectangle;
                Graphics            grf   = e.Graphics;
                LinearGradientBrush brush = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 90.0f);

                grf.FillRectangle(brush, rect);

                if (!string.IsNullOrEmpty(Text))
                {
                    grf.DrawString(Text, Font, new SolidBrush(ForeColor), rect, PaintHelper.SFCenter);
                }

                grf.DrawRectangle(new Pen(PaintHelper.GetDarkColor(BackColor)), rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
            }
Example #21
0
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            //base.OnRenderImageMargin(e);
            Rectangle rect = e.AffectedBounds;

            rect.X      += 2;
            rect.Width  -= 2;
            rect.Y      += 2;
            rect.Height -= 4;

            Color color = UITheme.Default.Colors.MediumDark;// PaintHelper.AdjustColor(Blumind.Core.Settings.Options.Default.Appearance.WindowBackColor, 15, 25, 90, 90);

            e.Graphics.FillRectangle(new SolidBrush(color), rect);
            e.Graphics.DrawLine(new Pen(PaintHelper.GetDarkColor(color, .1f)), rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1);
        }
Example #22
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 #23
0
        protected virtual void ShowForm(BaseForm form, bool showTab, bool canClose)
        {
            if (form == null)
            {
                throw new ArgumentNullException();
            }

            if (MdiClient != null)
            {
                MdiClient.ShowMdiForm(form);
            }
            else if (IsMdiContainer)
            {
                form.MdiParent   = this;
                form.WindowState = FormWindowState.Maximized;
                //form.FormBorderStyle = FormBorderStyle.None;
                form.ControlBox = false;
                form.Show();
            }

            form.TextChanged += Form_TextChanged;
            form.Activated   += Form_Activated;
            form.FormClosed  += Form_FormClosed;

            if (showTab && TaskBar != null)
            {
                var ti = new TabItem();
                ti.Text     = form.Text;
                ti.CanClose = canClose;
                ti.Tag      = form;
                if (form is BaseForm)
                {
                    ti.Icon = ((BaseForm)form).IconImage;
                }
                else
                {
                    ti.Icon = PaintHelper.IconToImage(form.Icon);
                }
                TaskBar.Items.Add(ti);

                TaskBar.SelectedItem = ti;
            }

            if (!Forms.Contains(form))
            {
                Forms.Add(form);
            }
        }
Example #24
0
        public bool DrawExpand(Graphics graphics, UIControlStatus status, Rectangle targetRectangle, Padding padding)
        {
            if (this.Image == null)
            {
                return(false);
            }

            var rectSource = GetBounds(status);

            if (rectSource.Width <= 0 || rectSource.Height <= 0)
            {
                return(false);
            }

            return(PaintHelper.ExpandImage(graphics, Image, padding, targetRectangle, rectSource));
        }
Example #25
0
            public virtual void OnPaint(PaintEventArgs e, Color backColor, Color foreColor, Font font, bool hover, bool pressed)
            {
                DrawItemBackground(e, hover, pressed);

                if (Image != null)
                {
                    if (Enabled && this.Enabled)
                    {
                        PaintHelper.DrawImageInRange(e.Graphics, Image, Bounds);
                    }
                    else
                    {
                        PaintHelper.DrawImageDisabledInRect(e.Graphics, Image, Bounds, backColor);
                    }
                }
            }
Example #26
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            InvokePaintBackground(this, e);

            Rectangle rectTitle = ClientRectangle;

            rectTitle.Height = FoldingButtonRect.Height;

            Size sizeText = Size.Ceiling(e.Graphics.MeasureString(Text, Font));

            rectTitle.Height = Math.Max(rectTitle.Height, sizeText.Height);

            Image image = Folded ? Properties.Resources.folding_expand : Properties.Resources.folding_collapse;

            PaintHelper.DrawImageInRange(e.Graphics, image, FoldingButtonRect);
            rectTitle.X     += FoldingButtonRect.Width;
            rectTitle.Width -= FoldingButtonRect.Width;

            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rectTitle, PaintHelper.SFLeft);
            rectTitle.X     += sizeText.Width;
            rectTitle.Width -= sizeText.Width;

            PaintHelper.SetHighQualityRender(e.Graphics);
            e.Graphics.ExcludeClip(new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - rectTitle.Width, rectTitle.Height));
            Rectangle rectBorder = new Rectangle(0, rectTitle.Y + rectTitle.Height / 2, ClientSize.Width, ClientSize.Height - rectTitle.Height / 2);
            Pen       penLine    = new Pen(PaintHelper.GetDarkColor(BackColor));

            if (Folded)
            {
                e.Graphics.DrawLine(penLine, rectBorder.X, rectBorder.Y, rectBorder.Right, rectBorder.Y);
            }
            else
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(rectBorder, 6);
                e.Graphics.DrawPath(penLine, path);
                path.Dispose();
            }

            if (Focused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));
            }
        }
Example #27
0
        protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
        {
            Rectangle rect = new Rectangle(0, 0, e.Item.Bounds.Width, e.Item.Bounds.Height);

            if (e.Vertical)
            {
                PaintHelper.DrawImageTiled(e.Graphics, SplitterVBackImage.Image, rect, PaintHelper.DrawImageMethod.RepeatY);
            }
            else
            {
                rect.X     += 27;
                rect.Width -= 27;
                int y = rect.Y + rect.Height / 2;
                e.Graphics.DrawLine(Pens.LightGray, rect.X, y, rect.Right, y);
                //PT.DrawImageTiled(e.Graphics, SplitterHBackImage.Image, rect, PT.DrawImageMethod.RepeatX);
            }

            //base.OnRenderSeparator(e);
        }
Example #28
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index < 0 || e.Index >= Items.Count)
            {
                base.OnDrawItem(e);
                return;
            }

            e.DrawBackground();

            Rectangle rect = GetItemRectangle(e.Index);
            Brush     brushFore;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                //Color color = PaintHelper.AdjustColor(SystemColors.Highlight, 40, 50, 85, 90); //SystemColors.Highlight;
                //LinearGradientBrush brushBack = new LinearGradientBrush(rect, PT.GetLightColor(color, .2), color, 90.0f);
                //e.Graphics.FillRectangle(brushBack, rect.Left, rect.Top, rect.Width, rect.Height);
                PaintHelper.DrawHoverBackgroundFlat(e.Graphics, rect, UITheme.Default.Colors.Sharp);
                brushFore = new SolidBrush(UITheme.Default.Colors.SharpText);
                //brushFore = Brushes.Black;
            }
            else
            {
                //e.Graphics.FillRectangle(new LinearGradientBrush(rect, Color.White, Color.GhostWhite, 90.0f)
                //    , rect.Left, rect.Top, rect.Width, rect.Height);

                //e.Graphics.DrawLine(new Pen(Color.FromArgb(100, Color.Silver)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                brushFore = Brushes.Black;
            }
            e.Graphics.DrawLine(new Pen(Color.FromArgb(100, Color.Silver)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);

            object obj = Items[e.Index];

            if (obj != null)
            {
                rect.Inflate(-1, -1);
                StringFormat sf = PaintHelper.SFLeft;
                sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
                e.Graphics.DrawString(obj.ToString(), Font, brushFore, rect, sf);
            }
        }
Example #29
0
        private void PaintSplitButton(PaintEventArgs e, Rectangle rect, bool hover, bool toLeftTop)
        {
            Brush brushBack = null;

            if (!hover)
            {
                brushBack = new SolidBrush(BackColor);
            }
            else
            {
                if (Orientation == Orientation.Horizontal)
                {
                    brushBack = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 90.0f);
                }
                else
                {
                    brushBack = new LinearGradientBrush(rect, PaintHelper.GetLightColor(BackColor), BackColor, 0.0f);
                }
            }
            e.Graphics.FillRectangle(brushBack, rect);

            Pen       penLine = new Pen(PaintHelper.GetDarkColor(BackColor));
            const int iw      = 5;
            const int ih      = 3;

            if (Orientation == Orientation.Horizontal)
            {
                Image image = Properties.Resources.split_btn_h;
                int   x     = toLeftTop ? 0 : iw;
                e.Graphics.DrawImage(image,
                                     new Rectangle(rect.Left + (rect.Width - iw) / 2, rect.Top + (rect.Height - ih) / 2, iw, ih),
                                     x, 0, iw, ih, GraphicsUnit.Pixel);
            }
            else
            {
                Image image = Properties.Resources.split_btn_v;
                int   y     = toLeftTop ? 0 : iw;
                e.Graphics.DrawImage(image,
                                     new Rectangle(rect.Left + (rect.Width - iw) / 2, rect.Top + (rect.Height - ih) / 2, ih, iw),
                                     0, y, ih, iw, GraphicsUnit.Pixel);
            }
        }
Example #30
0
        bool CalcaluteImageViewSize()
        {
            if (Image != null)
            {
                var size       = Image.Size;
                var clientSize = ClientSize;
                var zoom       = Zoom;
                switch (ZoomType)
                {
                case ZoomType.FitHeight:
                    zoom = (float)clientSize.Height / size.Height;
                    if (zoom * size.Width > clientSize.Width)
                    {
                        zoom = (float)(clientSize.Height - SystemInformation.HorizontalScrollBarHeight) / size.Height;
                    }
                    break;

                case ZoomType.FitWidth:
                    zoom = (float)clientSize.Width / size.Width;
                    if (zoom * size.Height > clientSize.Height)
                    {
                        zoom = (float)(clientSize.Width - SystemInformation.VerticalScrollBarWidth) / size.Width;
                    }
                    break;

                case ZoomType.FitPage:
                    zoom = Math.Min((float)clientSize.Width / size.Width, (float)clientSize.Height / size.Height);
                    break;
                }

                ZoomValue = zoom;
                size      = PaintHelper.Zoom(size, zoom);
                if (ImageViewSize != size)
                {
                    ImageViewSize     = size;
                    AutoScrollMinSize = ImageViewSize;
                    return(true);
                }
            }

            return(false);
        }