Exemple #1
0
        protected void DoDraw(Graphics g, DockItem item)
        {
            DrawEventArgs e = new DrawEventArgs(g, item);

            OnDraw(e);
        }
Exemple #2
0
 /// <summary>
 /// Use this method to define if the caption of the dock item will be painted
 /// </summary>
 /// <param name="item">The Dock Item.</param>
 /// <returns></returns>
 public virtual bool CaptionVisible(DockItem item)
 {
     return(false);
 }
Exemple #3
0
        private void DoEnterItem(DockItem item)
        {
            DockItemEventArgs e = new DockItemEventArgs(item, MouseButtons.None);

            OnEnterItem(e);
        }
Exemple #4
0
        private void DoSelectItem(DockItem item, MouseButtons button)
        {
            DockItemEventArgs e = new DockItemEventArgs(item, button);

            OnSelectItem(e);
        }
Exemple #5
0
        public virtual void PaintCaption(Graphics canvas, DockItem item, bool scaleCaption)
        {
            if (item == null)
            {
                return;
            }

            if (canvas == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(item.Caption))
            {
                Font cFont         = null;
                int  captionWidth  = 0;
                int  captionHeight = 0;

                try
                {
                    if (scaleCaption)
                    {
                        cFont = new Font(this.Font.Name, this.Font.Size * item.Scale, this.Font.Style, GraphicsUnit.Point);

                        StringFormat format = (StringFormat)StringFormat.GenericTypographic;
                        try
                        {
                            format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
                            SizeF captionSizeF = canvas.MeasureString(item.Caption, cFont, new PointF(0, 0), format);
                            captionHeight = (int)captionSizeF.Height;
                            captionWidth  = (int)captionSizeF.Width;

                            int posX = (int)(item.PaintWidth / 2) + item.X - captionWidth;
                            int posY = (int)(item.Y + (item.Height - item.ReflectionDepth) * item.Scale);
                            TextPainter.DrawString(canvas, item.Caption, cFont, posX, posY, captionWidth * 2, captionHeight * 2, this.ForeColor, true);
                        }
                        finally
                        {
                            format.Dispose();
                            format = null;
                        }
                    }
                    else
                    {
                        StringFormat format = (StringFormat)StringFormat.GenericTypographic;
                        try
                        {
                            format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
                            SizeF captionSizeF = canvas.MeasureString(item.Caption, this.Font, new PointF(0, 0), format);
                            captionHeight = (int)captionSizeF.Height;
                            captionWidth  = (int)captionSizeF.Width;

                            int posX = (int)(item.PaintWidth / 2) + item.X - captionWidth;
                            int posY = (int)(item.Y + (item.Height - item.ReflectionDepth) * item.Scale);
                            TextPainter.DrawString(canvas, item.Caption, this.Font, posX, posY, captionWidth * 2, captionHeight * 2, this.ForeColor, true);
                        }
                        finally
                        {
                            format.Dispose();
                            format = null;
                        }
                    }
                }
                finally
                {
                    if (cFont != null)
                    {
                        cFont.Dispose();
                        cFont = null;
                    }
                }
            }
        }
 public DockItemEventArgs(DockItem item, MouseButtons button)
 {
     this.item   = item;
     this.button = button;
 }