예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var rec = WideRendering ?
                      new Rectangle(0, 0, ClientSize.Width - Dpi.ScaleX(1), ClientSize.Height - Dpi.ScaleX(1)) :
                      new Rectangle(Dpi.ScaleX(1), 0, ClientSize.Width - Dpi.ScaleX(2), ClientSize.Height - Dpi.ScaleX(2));

            using (var b = new SolidBrush(UserColors.Window))
                e.Graphics.FillRectangle(b, rec);

            e.Graphics.DrawRectangle(UserPens.Border, rec);
            base.OnPaint(e);
        }
예제 #2
0
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item.Selected)
     {
         var rect = new Rectangle(Dpi.ScaleX(1), Dpi.ScaleY(1), e.Item.Bounds.Width - Dpi.ScaleX(2), e.Item.Bounds.Height);
         e.Graphics.FillRectangle(UserBrushes.Selection, rect);
     }
     else if (e.Item is ToolStripMenuItem && ((ToolStripMenuItem)e.Item).DropDown.Visible)
     {
         var rect = new Rectangle(Dpi.ScaleX(1), Dpi.ScaleY(1), e.Item.Bounds.Width - Dpi.ScaleX(2), e.Item.Bounds.Height);
         e.Graphics.FillRectangle(UserBrushes.Selection, rect);
     }
 }
예제 #3
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            var g     = e.Graphics;
            var color = UserColors.Text;

            if (e.Item.Selected)
            {
                color = UserColors.HighlightText;
            }

            e.TextRectangle = new Rectangle(Dpi.ScaleX(15), e.TextRectangle.Y, Width - Dpi.ScaleX(18), Dpi.ScaleY(16));
            TextRenderer.DrawText(e.Graphics, e.Text, Fonts.Menu, e.TextRectangle, color, TextFormatFlags.Left | TextFormatFlags.EndEllipsis);
        }
예제 #4
0
        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            if (IsItemVisible(e.Index))
            {
                e.ItemWidth  = ClientSize.Width;
                e.ItemHeight = Dpi.ScaleY(18);
            }
            else
            {
                e.ItemHeight = 0;
            }

            base.OnMeasureItem(e);
        }
예제 #5
0
파일: ToolWindow.cs 프로젝트: ngoffee/ela
        public ToolWindow()
        {
            InitializeComponent();
            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);

            panel.BackColor = Color.White;
            panel.Paint    += (o, e) =>
            {
                var g = e.Graphics;
                g.DrawLine(UserPens.Border, 0, 0, 0, panel.ClientSize.Height);
                g.DrawLine(UserPens.Border, 0, panel.ClientSize.Height - Dpi.ScaleY(1), panel.ClientSize.Width, panel.ClientSize.Height - Dpi.ScaleY(1));
                g.DrawLine(UserPens.Border, panel.ClientSize.Width - Dpi.ScaleX(1), 0, panel.ClientSize.Width - Dpi.ScaleX(1), panel.ClientSize.Height);
            };
            switchBar.SelectedIndexChanged += SwitchBarSelectedIndexChanged;
            switchBar.CloseRequested       += SwitchBarCloseRequested;
            panel.SetPadding(new Padding(Dpi.ScaleX(1), Dpi.ScaleY(5), Dpi.ScaleX(1), Dpi.ScaleX(2)));
        }
예제 #6
0
        private int DrawItem(Graphics g, ToolbarItem item, int pos, bool sel)
        {
            var text = item.NewContent && !String.IsNullOrEmpty(item.ContentDescription) ?
                       String.Format("{0} ({1})", item.Text, item.ContentDescription) : item.Text;
            var color = sel ? UserColors.HighlightText : UserColors.Text;
            var font  = item.NewContent ? boldFont : Fonts.Menu;
            var tsize = TextRenderer.MeasureText(text, font);
            var width = tsize.Width;

            if (sel)
            {
                g.FillRectangle(UserBrushes.Selection, new Rectangle(pos - Dpi.ScaleX(5), Dpi.ScaleY(3), width + Dpi.ScaleX(10), tsize.Height + Dpi.ScaleY(2)));
            }

            TextRenderer.DrawText(g, text, font, new Rectangle(pos, Dpi.ScaleY(3), width, ClientSize.Height), color, TextFormatFlags.Left);
            return(width);
        }
예제 #7
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (Items.Count > 1 && e.X <= Dpi.ScaleX(16) + lastWidth && e.Y < Dpi.ScaleY(HEIGHT))
            {
                if (hoverItem != 0)
                {
                    hoverItem = 0;
                    using (var g = CreateGraphics())
                        PaintMain(g, fast: true);
                }
            }
            else if (hoverItem != -1)
            {
                hoverItem = -1;
                using (var g = CreateGraphics())
                    PaintMain(g, fast: true);
            }

            base.OnMouseMove(e);
        }
예제 #8
0
        private void DrawNormalItem(ListItem item, DrawItemEventArgs e)
        {
            var caption = item.Text;
            var brush   = default(Brush);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                brush = UserBrushes.HighlightText;
                e.Graphics.FillRectangle(UserBrushes.Selection, e.Bounds);
            }
            else
            {
                brush = UserBrushes.Text;
                e.Graphics.FillRectangle(UserBrushes.Window, e.Bounds);
            }

            var captionSize = e.Graphics.MeasureString(caption, Font);

            e.Graphics.DrawString(caption, e.Font, brush, e.Bounds.X + Dpi.ScaleX(15), e.Bounds.Y + (e.Bounds.Height - captionSize.Height) / 2);
        }
예제 #9
0
파일: SwitchBar.cs 프로젝트: ngoffee/ela
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.FillRectangle(UserBrushes.Window, ClientRectangle);
            var width     = 0;
            var textColor = UserColors.Text;
            var corner    = "Corner";
            var cross     = "Cross";

            if (SelectedItem != null)
            {
                currentWidth = width = (Int32)g.MeasureString(SelectedItem.Caption, Fonts.Caption).Width;
            }

            if (hoverItem == 0 || contextMenu.Visible)
            {
                g.FillRectangle(UserBrushes.Selection, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(12) + width, Dpi.ScaleY(14)));
                textColor = UserColors.HighlightText;
                corner    = "CornerWhite";
            }
            else if (hoverItem == 1)
            {
                g.FillRectangle(UserBrushes.Selection, new Rectangle(ClientSize.Width - Dpi.ScaleX(17), Dpi.ScaleY(4), Dpi.ScaleX(14), Dpi.ScaleY(14)));
                cross = "CrossWhite";
            }

            using (var bmp = Bitmaps.Load(corner))
                g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(5), Dpi.ScaleY(9), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));

            using (var bmp = Bitmaps.Load(cross))
                g.DrawImage(bmp, new Rectangle(ClientSize.Width - Dpi.ScaleX(15), Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));

            g.DrawRectangle(UserPens.Border, new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - Dpi.ScaleX(1), ClientRectangle.Height));

            if (SelectedItem != null)
            {
                TextRenderer.DrawText(g, SelectedItem.Caption, Fonts.Caption, new Rectangle(Dpi.ScaleX(14), 0, width + Dpi.ScaleY(20), ClientSize.Height), textColor,
                                      TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.EndEllipsis);
            }
        }
예제 #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawLine(UserPens.Border, new Point(0, 0), new Point(ClientSize.Width, 0));

            if (BottomBorder)
            {
                e.Graphics.DrawLine(UserPens.Border, new Point(0, ClientSize.Height - Dpi.ScaleY(1)), new Point(ClientSize.Width, ClientSize.Height - Dpi.ScaleY(1)));
            }

            if (LeftBorder)
            {
                e.Graphics.DrawLine(UserPens.Border, new Point(0, 0), new Point(0, ClientSize.Height - Dpi.ScaleY(1)));
            }

            if (RightBorder)
            {
                e.Graphics.DrawLine(UserPens.Border, new Point(ClientSize.Width - Dpi.ScaleX(1), 0), new Point(ClientSize.Width - Dpi.ScaleX(1), ClientSize.Height - Dpi.ScaleY(1)));
            }

            base.OnPaint(e);
        }
예제 #11
0
        private void DrawHeader(ListGroup group, DrawItemEventArgs e)
        {
            var caption = group.Title;

            e.Graphics.FillRectangle(UserBrushes.Window, e.Bounds);

            using (var font = new Font(e.Font, FontStyle.Bold))
            {
                if (group.Expanded)
                {
                    e.Graphics.DrawImage(Bitmaps.Load("ArrowDownGray"), e.Bounds.X + Dpi.ScaleX(5), e.Bounds.Y + Dpi.ScaleY(7));
                }
                else
                {
                    e.Graphics.DrawImage(Bitmaps.Load("ArrowGray"), e.Bounds.X + Dpi.ScaleX(7), e.Bounds.Y + Dpi.ScaleY(5));
                }

                var captionSize = e.Graphics.MeasureString(caption, font);
                e.Graphics.DrawString(caption, font, SystemBrushes.ControlText,
                                      e.Bounds.X + Dpi.ScaleX(14), e.Bounds.Y + (e.Bounds.Height - captionSize.Height) / 2);
            }
        }
예제 #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.FillRectangle(UserBrushes.Menu, ClientRectangle);
            var shift = Dpi.ScaleX(11);

            foreach (var i in items)
            {
                var w = DrawItem(g, i, shift, i == selItem || i == hoverItem);
                i.Left  = shift;
                i.Right = shift + w;
                shift  += w + Dpi.ScaleX(10);
            }

            g.DrawLine(UserPens.Border, new Point(0, 0), new Point(ClientSize.Width, 0));
            g.DrawLine(UserPens.Border, new Point(shift, 0), new Point(shift, ClientSize.Height));

            var extraShift = Dpi.ScaleX(10);

            if (HighlightStatusString)
            {
                g.FillRectangle(UserBrushes.Window, new Rectangle(shift + Dpi.ScaleX(1), Dpi.ScaleY(1), ClientSize.Width - shift, ClientSize.Height));

                if (StatusImage != null)
                {
                    g.DrawImage(StatusImage, new Rectangle(shift + Dpi.ScaleX(10), Dpi.ScaleY(4), Dpi.ScaleX(StatusImage.Width), Dpi.ScaleY(StatusImage.Height)));
                }

                extraShift += Dpi.ScaleX(15);
            }

            var c = HighlightStatusString ? UserColors.Text : UserColors.Disabled;

            TextRenderer.DrawText(g, StatusString, Fonts.Text, new Rectangle(shift + extraShift, Dpi.ScaleY(3), ClientSize.Width - shift - Dpi.ScaleX(20), ClientSize.Height - Dpi.ScaleY(2)),
                                  c, TextFormatFlags.EndEllipsis);
        }
예제 #13
0
        protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
        {
            var g  = e.Graphics;
            var cm = e.ToolStrip is ContextMenuStrip;

            var x = IsTopLevel(e.Item) && !cm?Dpi.ScaleX(2) : Dpi.ScaleX(15);

            var y = IsTopLevel(e.Item) && !cm?Dpi.ScaleX(1) : e.TextRectangle.Y;

            var tsize = TextRenderer.MeasureText(e.Text, e.TextFont);

            if (e.Item.Text != e.Text)
            {
                x = e.ToolStrip.Width - tsize.Width - Dpi.ScaleX(2);
            }

            e.TextRectangle = new Rectangle(x, y, e.Item.Width - x, Dpi.ScaleY(16));
            var flag  = IsTopLevel(e.Item) && !cm ? TextFormatFlags.Top | TextFormatFlags.HorizontalCenter : TextFormatFlags.Default;
            var color = !e.Item.Enabled ? UserColors.Disabled :
                        (e.Item.Selected || e.Item.Pressed ? UserColors.HighlightText : UserColors.Text);

            TextRenderer.DrawText(e.Graphics, e.Text, e.TextFont, e.TextRectangle, color,
                                  TextFormatFlags.Left | TextFormatFlags.EndEllipsis | flag);
        }
예제 #14
0
 protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
 {
     if (e.Item.Selected)
     {
         var g    = e.Graphics;
         var rect = new Rectangle(Dpi.ScaleX(1), Dpi.ScaleY(1), e.Item.Bounds.Width - Dpi.ScaleX(2), e.Item.Bounds.Height);
         g.FillRectangle(UserBrushes.Selection, rect);
     }
 }
예제 #15
0
 protected override void OnResize(EventArgs e)
 {
     Height = Dpi.ScaleY(HEIGHT);
     base.OnResize(e);
 }
예제 #16
0
        protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
        {
            var g = e.Graphics;

            g.FillRectangle(UserBrushes.Menu, e.AffectedBounds);

            if (!(e.ToolStrip is MenuStrip))
            {
                g.DrawRectangle(UserPens.Border, new Rectangle(0, 0,
                                                               e.AffectedBounds.Width - Dpi.ScaleX(1), e.AffectedBounds.Height - Dpi.ScaleY(1)));
            }
        }
예제 #17
0
 public FlatPanel()
 {
     SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);
     base.Padding = new Padding(Dpi.ScaleX(2), Dpi.ScaleY(2), Dpi.ScaleX(2), Dpi.ScaleY(2));
 }
예제 #18
0
 protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
 {
     e.Graphics.DrawLine(UserPens.Border, 0, Dpi.ScaleY(1), e.Item.Bounds.Width, Dpi.ScaleY(1));
 }
예제 #19
0
 protected override void Initialize(ToolStrip toolStrip)
 {
     toolStrip.AutoSize = false;
     toolStrip.Height   = Dpi.ScaleY(MENUHEIGHT);
     InitializeSubMenus(toolStrip.Items, true);
 }
예제 #20
0
 protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
 {
     using (var bmp = Bitmaps.Load("Arrow"))
         e.Graphics.DrawImage(bmp, new Rectangle(e.Item.Bounds.Width - Dpi.ScaleX(10),
                                                 e.ArrowRectangle.Y + Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
 }
예제 #21
0
 public SingleBorderPanel()
 {
     SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);
     base.Padding = new Padding(0, Dpi.ScaleY(1), 0, 0);
 }
예제 #22
0
파일: IntPicker.cs 프로젝트: ngoffee/ela
 protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e)
 {
     e.ItemHeight = Dpi.ScaleY(16);
 }
예제 #23
0
 protected override void InitializeItem(ToolStripItem item)
 {
     item.AutoSize = false;
     item.Height   = Dpi.ScaleY(HEIGHT);
     item.Width    = Width;
 }
예제 #24
0
 protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
 {
     using (var bmp = Bitmaps.Load("Check"))
         e.Graphics.DrawImage(bmp, new Rectangle(e.ImageRectangle.X + Dpi.ScaleX(1),
                                                 e.ImageRectangle.Y + Dpi.ScaleY(5), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
 }
예제 #25
0
        private void PaintMain(Graphics g, bool fast = false)
        {
            var textColor = UserColors.Text;
            var corner    = "Corner";

            var rect = new Rectangle(0, 0, ClientSize.Width - Dpi.ScaleX(1), Dpi.ScaleY(HEIGHT));

            if (!fast)
            {
                var fullRect = new Rectangle(0, 0, ClientSize.Width - Dpi.ScaleX(1), ClientSize.Height - Dpi.ScaleY(1));
                g.FillRectangle(UserBrushes.Window, rect);
                g.DrawRectangle(UserPens.Border, rect);
                g.DrawRectangle(UserPens.Border, fullRect);
            }

            var text        = SelectedDocument != null ? SelectedDocument.Caption : String.Empty;
            var captionRect = new Rectangle(Dpi.ScaleX(15), 0, ClientSize.Width - Dpi.ScaleY(LABELS_WIDTH), Dpi.ScaleY(HEIGHT));
            var flags       = TextFormatFlags.Left | TextFormatFlags.PathEllipsis | TextFormatFlags.VerticalCenter;

            lastWidth = (Int32)g.MeasureString(text, Fonts.Header).Width;

            if (lastWidth > captionRect.Width)
            {
                lastWidth = captionRect.Width;
            }

            if (hoverItem == 0 || contextMenu.Visible)
            {
                textColor = UserColors.HighlightText;
                corner    = "CornerWhite";
                g.FillRectangle(UserBrushes.Selection, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(16) + lastWidth, Dpi.ScaleY(14)));
            }
            else if (hoverItem == -1 && fast)
            {
                g.FillRectangle(UserBrushes.Window, new Rectangle(Dpi.ScaleX(3), Dpi.ScaleY(4), Dpi.ScaleX(16) + lastWidth, Dpi.ScaleY(14)));
            }

            TextRenderer.DrawText(g, text, Fonts.Header, captionRect, textColor, flags);

            if (Items.Count > 1)
            {
                using (var bmp = Bitmaps.Load(corner))
                    g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(5), Dpi.ScaleY(9), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }
            else if (Items.Count == 1)
            {
                using (var bmp = Bitmaps.Load("CornerDisabled"))
                    g.DrawImage(bmp, new Rectangle(Dpi.ScaleX(7), Dpi.ScaleY(7), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }

            if (InfoBarVisible && !fast)
            {
                TextRenderer.DrawText(g, Overtype ? "OVR" : "INS", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(32), 0, Dpi.ScaleX(30), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, Column.ToString(), Fonts.Menu, new Rectangle(ClientSize.Width - Dpi.ScaleX(68), 0, Dpi.ScaleX(25), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, "Col", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(90), 0, Dpi.ScaleX(25), Dpi.ScaleY(20)), UserColors.Text, flags);
                TextRenderer.DrawText(g, Line.ToString(), Fonts.Menu, new Rectangle(ClientSize.Width - Dpi.ScaleX(123), 0, Dpi.ScaleX(35), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);
                TextRenderer.DrawText(g, "Line", Fonts.Header, new Rectangle(ClientSize.Width - Dpi.ScaleX(150), 0, Dpi.ScaleX(30), Dpi.ScaleY(HEIGHT)), UserColors.Text, flags);

                using (var bmp = Bitmaps.Load("Bounds"))
                    g.DrawImage(bmp, new Rectangle(ClientSize.Width - Dpi.ScaleX(167), Dpi.ScaleY(5), Dpi.ScaleX(bmp.Width), Dpi.ScaleY(bmp.Height)));
            }
        }
예제 #26
0
파일: ColorPicker.cs 프로젝트: ngoffee/ela
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            if (e.Index == -1 || DesignMode)
            {
                return;
            }

            var colorRect = new Rectangle(e.Bounds.X + Dpi.ScaleX(2), e.Bounds.Y + Dpi.ScaleY(3), Dpi.ScaleX(12), Dpi.ScaleY(10));
            var textBrush = Enabled ? UserBrushes.Text : UserBrushes.Disabled;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(UserBrushes.Selection, e.Bounds);
                textBrush = UserBrushes.HighlightText;
            }
            else
            {
                e.Graphics.FillRectangle(UserBrushes.Window, e.Bounds);
            }

            var itemValue = this.Items[e.Index].ToString();

            using (var colorBrush = new SolidBrush(itemValue == "Default" ? Color.FromKnownColor(DefaultColor) : Color.FromName(itemValue)))
            {
                if (Enabled)
                {
                    e.Graphics.FillRectangle(colorBrush, colorRect);
                }

                e.Graphics.DrawRectangle(Enabled ? Pens.Black : Pens.Gray, colorRect);
                e.Graphics.DrawString(itemValue, Font, textBrush, new Point(e.Bounds.X + Dpi.ScaleX(18), e.Bounds.Y));
            }
        }
예제 #27
0
파일: ToolWindow.cs 프로젝트: ngoffee/ela
        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.DrawRectangle(Pens.DarkGray, 0, switchBar.Height, ClientRectangle.Width - Dpi.ScaleX(1), ClientRectangle.Height - switchBar.Height - Dpi.ScaleY(1));
        }