Пример #1
0
        public override void OnPaint(ItemPaintArgs itemPaintArgs)
        {
            Image im = image == null?imageDelegate() : image;

            if (im == null)
            {
                return;
            }

            Point loc = itemPaintArgs.Rectangle.Location;

            if (hAlign == HorizontalAlignment.Center)
            {
                loc.X += ((itemPaintArgs.Rectangle.Width / 2) - (im.Width / 2));
            }
            else if (hAlign == HorizontalAlignment.Right)
            {
                loc.X += (itemPaintArgs.Rectangle.Width - im.Width);
            }

            if (vAlign == VerticalAlignment.Middle)
            {
                loc.Y += ((itemPaintArgs.Rectangle.Height / 2) - (im.Height / 2));
            }

            if (im.Width <= itemPaintArgs.Rectangle.Width)
            {
                itemPaintArgs.Graphics.DrawImage(im, loc.X, loc.Y, im.Width, im.Height);
            }
            else
            {
                itemPaintArgs.Graphics.DrawImage(im, new Rectangle(itemPaintArgs.Rectangle.Left, loc.Y, itemPaintArgs.Rectangle.Width, im.Height), new Rectangle(0, 0, itemPaintArgs.Rectangle.Width, im.Height), GraphicsUnit.Pixel);
            }
        }
Пример #2
0
        protected virtual void OnPaintInternal(ItemPaintArgs itemPaintArgs, Font localFont, Brush localForeBrush)
        {
            if (data == null)
            {
                return;
            }

            string output = (data is DateTime ? HelpersGUI.DateTimeToString((DateTime)data, Messages.DATEFORMAT_DMY_HM, true) : data.ToString());  // exception for DateTime: CA-46983

            // Replace either form of line ending with a space
            output = output.Replace("\n", " ").Replace("\r", "");
            Point  loc  = new Point();
            string text = Ellipsise(itemPaintArgs.Graphics, output, itemPaintArgs.Rectangle, localFont, out loc);

            if (!string.IsNullOrEmpty(text))
            {
                // Change text and background colour for selected rows
                bool selected = (respondToSelect && (itemPaintArgs.State & ItemState.Selected) > 0);
                if (selected)
                {
                    Size      textSize = Drawing.MeasureText(text, localFont);
                    Rectangle textRect;
                    textRect = new Rectangle(loc, textSize);
                    itemPaintArgs.Graphics.FillRectangle(new SolidBrush(SystemColors.Highlight), textRect);
                    localForeBrush = new SolidBrush(SystemColors.HighlightText);
                }

                itemPaintArgs.Graphics.DrawString(text, localFont, localForeBrush, loc);
            }
        }
        private void PaintManyInternal(ItemPaintArgs itemPaintArgs)
        {
            CurrentRectangle = new Rectangle();
            for (int i = 0; i < items.Length; i++)
            {
                GridStringItem item   = items[i];
                Point          locStr = itemPaintArgs.Rectangle.Location;
                locStr.Y += (itemPaintArgs.Rectangle.Height * i) / items.Length;
                item.OnPaint(
                    new ItemPaintArgs(itemPaintArgs.Graphics,
                                      new Rectangle(locStr, new Size(itemPaintArgs.Rectangle.Width,
                                                                     itemPaintArgs.Rectangle.Height / items.Length)), itemPaintArgs.State));

                if (item.DataSize.Width > DataSize.Width)
                {
                    DataSize.Width = item.DataSize.Width;
                }
                DataSize.Height += item.DataSize.Height;

                if (item.CurrentRectangle.Width > CurrentRectangle.Width)
                {
                    CurrentRectangle.Width = item.CurrentRectangle.Width;
                }

                CurrentRectangle.Height += item.CurrentRectangle.Height;
            }
        }
Пример #4
0
        public override void OnPaint(ItemPaintArgs itemPaintArgs)
        {
            if (items.Length == 0)
            {
                return;
            }
            Rectangle rect = itemPaintArgs.Rectangle;

            // Padding at top, bottom and between each item.
            // If this changes, CurrentItem() needs to change.
            rect.Y += Padding;

            if (RegularSpacing)
            {
                rect.Height = ItemHeight;
            }
            else
            {
                rect.Height -= Padding * items.Length;
                rect.Height /= items.Length;
            }

            foreach (GridItemBase item in items)
            {
                item.OnPaint(new ItemPaintArgs(itemPaintArgs.Graphics, rect, itemPaintArgs.State));
                rect.Y += rect.Height + Padding;
            }
        }
Пример #5
0
        public override void OnPaint(ItemPaintArgs itemPaintArgs)
        {
            lastPaintRectangle = itemPaintArgs.Rectangle;

            if (items.Length == 0)
            {
                return;
            }
            Rectangle rect = itemPaintArgs.Rectangle;

            int ind = indent * IndentDistance;

            if (rect.Width - ind < MinimumWidth)  // not enough room to indent fully: do as much as we can
            {
                ind = Math.Max(rect.Width - MinimumWidth, 0);
            }
            rect.X     += ind;
            rect.Width -= ind;

            for (int i = 0; i < items.Length; ++i)
            {
                items[i].OnPaint(new ItemPaintArgs(itemPaintArgs.Graphics, rect, itemPaintArgs.State));

                if (i < items.Length - 1)
                {
                    ind         = widths[i] + Padding;
                    rect.X     += ind;
                    rect.Width -= ind;
                }
            }
        }
 public override void OnPaint(ItemPaintArgs itemPaintArgs)
 {
     if (!string.IsNullOrEmpty(sortdata.ToString()))
     {
         PaintManyInternal(itemPaintArgs);
         base.DrawGlyphs(itemPaintArgs);
     }
 }
Пример #7
0
 public override void OnPaint(ItemPaintArgs itemPaintArgs)
 {
     if (!string.IsNullOrEmpty(sortdata.ToString()))
     {
         base.OnPaint(itemPaintArgs);
         DrawGlyphs(itemPaintArgs);
     }
 }
Пример #8
0
        public void DrawGlyphs(ItemPaintArgs itemPaintArgs)
        {
            Graphics g = itemPaintArgs.Graphics;

            if (SortPriority > -1 && itemPaintArgs.Rectangle.Width - (AscendingTriangle.Width + 16) > 0)
            {
                // Draw the number showing the precedence of sorting in this column versus sorting in other columns
                g.DrawString((SortPriority + 1).ToString(), SortFont, foreBrush, itemPaintArgs.Rectangle.Right - (AscendingTriangle.Width + 15), itemPaintArgs.Rectangle.Top + ((itemPaintArgs.Rectangle.Height / 2) - 7));
            }
            if (Sort != SortOrder.None && itemPaintArgs.Rectangle.Width - (AscendingTriangle.Width + 5) > 0)
            {
                // Draw the triangle showing ascending/descending sort order
                DrawTriangle(g, Sort == SortOrder.Ascending ? AscendingTriangle : DescendingTriangle, itemPaintArgs);
            }

            DrawSideLine(g, itemPaintArgs, itemPaintArgs.Rectangle.Left - 1);
            DrawSideLine(g, itemPaintArgs, itemPaintArgs.Rectangle.Right - 1);
        }
Пример #9
0
        public override void OnPaint(ItemPaintArgs itemPaintArgs)
        {
            if (!Row.HasChildren)
            {
                return;  // nothing to draw
            }
            Point     loc  = itemPaintArgs.Rectangle.Location;
            Rectangle rect = new Rectangle(loc.X, loc.Y + TopMargin, IconWidth, IconHeight);

            if (Application.RenderWithVisualStyles)
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(
                    Row.Expanded ?
                    VisualStyleElement.TreeView.Glyph.Opened :
                    VisualStyleElement.TreeView.Glyph.Closed);
                renderer.DrawBackground(itemPaintArgs.Graphics, rect);
            }

            else
            {
                itemPaintArgs.Graphics.DrawImage(Row.Expanded ? Images.StaticImages.tree_minus : Images.StaticImages.tree_plus, rect);
            }
        }
Пример #10
0
 public abstract void OnPaint(ItemPaintArgs itemPaintArgs);
Пример #11
0
 public override void OnPaint(ItemPaintArgs itemPaintArgs)
 {
     OnPaintInternal(itemPaintArgs,
                     Hot ? hotFont : font,
                     Hot ? hotBrush : foreBrush);
 }
Пример #12
0
 public override void OnPaint(ItemPaintArgs itemPaintArgs)
 {
 }
Пример #13
0
 private void DrawTriangle(Graphics g, Image triangle, ItemPaintArgs itemPaintArgs)
 {
     g.DrawImageUnscaled(triangle, itemPaintArgs.Rectangle.Right - triangle.Width - 5, itemPaintArgs.Rectangle.Top + ((itemPaintArgs.Rectangle.Height - triangle.Height) / 2), triangle.Width, triangle.Height);
 }
Пример #14
0
 private void DrawSideLine(Graphics g, ItemPaintArgs itemPaintArgs, int x)
 {
     g.DrawLine(LinePen, x, itemPaintArgs.Rectangle.Top, x, itemPaintArgs.Rectangle.Bottom - 1);
 }