public IGProcessItem AddItem( string text, int width, Font textFont, Color textColor, StringAlignment textAlignment, Color backColorFrom, Color backColorTo, LinearGradientMode backColorGradientMode, Color lineColor, float lineWidth, Image icon) { IGProcessItem item = new IGProcessItem ( text, width, textFont, textColor, textAlignment, backColorFrom, backColorTo, backColorGradientMode, lineColor, lineWidth, icon ); _items.Add(item); return(item); }
public void PrepareItems() { if (_items.Count == 0) { return; } int itemsTotalWidht = _items.Sum(ob => ob.Width); itemsTotalWidht += ((_items.Count - 1) * _itemSeperatorWidth); int itemStartX = 0; switch (_itemAlignment) { case StringAlignment.Center: itemStartX = (Width - itemsTotalWidht) / 2; break; case StringAlignment.Far: itemStartX = Width - itemsTotalWidht - 5; break; case StringAlignment.Near: itemStartX = 5; break; } PointF location = new PointF(itemStartX, (Height - _itemHeight) / 2); for (int i = 0; i < _items.Count; ++i) { IGProcessItem pItem = _items[i]; pItem.BoundRect = new RectangleF(location, new Size(pItem.Width, ItemHeight)); pItem.Origin = new PointF(pItem.BoundRect.X + pItem.BoundRect.Width / 2, pItem.BoundRect.Y + pItem.BoundRect.Height / 2); location.X = location.X + pItem.Width + ItemSeperatorWidth; } PrepareGraphicsPath(); }
private void PrepareGraphicsPath() { for (int i = 0; i < _items.Count; ++i) { IGProcessItem pItem = _items[i]; RectangleF rect = pItem.BoundRect; GraphicsPath grPath = new GraphicsPath(); bool isFirst = (i == 0); bool isLast = (i == _items.Count - 1); int itemRoundWidth = (_itemRoundingShape == ItemRoundingShapeType.Circular ? _itemRoundWidth : 0); PointF[] points = new PointF[isFirst || isLast ? 5 : 6]; if (isLast) { points[0] = new PointF(rect.X + rect.Width - itemRoundWidth, rect.Y); points[1] = new PointF(rect.X, rect.Y); points[2] = new PointF(rect.X + _itemTriangleWidth, rect.Y + rect.Height / 2); points[3] = new PointF(rect.X, rect.Y + rect.Height); points[4] = new PointF(rect.X + rect.Width - itemRoundWidth, rect.Y + rect.Height); } else { points[0] = new PointF(rect.X + (isFirst ? itemRoundWidth : 0), rect.Y); points[1] = new PointF(rect.X + rect.Width - _itemTriangleWidth, rect.Y); points[2] = new PointF(rect.X + rect.Width, rect.Y + rect.Height / 2); points[3] = new PointF(rect.X + rect.Width - _itemTriangleWidth, rect.Y + rect.Height); points[4] = new PointF(rect.X + (isFirst ? itemRoundWidth : 0), rect.Y + rect.Height); } if (isFirst == false && isLast == false) { points[5] = new PointF(rect.X + _itemTriangleWidth, rect.Y + rect.Height / 2); } grPath.AddLines(points); if ((isFirst || isLast) && _itemRoundingShape == ItemRoundingShapeType.Circular) { int roundRectWidth = 2 * _itemRoundWidth; RectangleF r = new RectangleF(rect.X + (isLast ? rect.Width - roundRectWidth : 0), rect.Y, roundRectWidth, rect.Height); grPath.AddArc(r, 90, (isLast ? -1 : 1) * 180); } grPath.CloseFigure(); if (pItem.GrPath != null) { pItem.GrPath.Dispose(); } pItem.GrPath = grPath; } }
public void DrawProcessItem(Graphics gr, IGProcessItem item) { Brush brush; if (item.BackColorTo == Color.Empty) { brush = new SolidBrush(item.BackColorFrom); } else { brush = new LinearGradientBrush(item.BoundRect, item.BackColorFrom, item.BackColorTo, item.BackColorGradientMode); } gr.FillPath(brush, item.GrPath); if (item.LineColor != Color.Empty) { gr.DrawPath(new Pen(item.LineColor, item.LineWidth), item.GrPath); } if (item.Icon != null) { gr.DrawImage(item.Icon, new PointF(item.BoundRect.X + _itemTriangleWidth, item.BoundRect.Y + (item.BoundRect.Height - item.Icon.Height) / 2)); } StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = item.TextAlignment;; RectangleF textRect = item.BoundRect; textRect.X += (_itemTriangleWidth + 3) + (item.Icon != null ? item.Icon.Width : 0); textRect.Width -= (2 * _itemTriangleWidth + 3); textRect.Y += 1; gr.DrawString(item.Text, item.TextFont, new SolidBrush(item.TextColor), textRect, sf); }
public void AddItem(IGProcessItem item) { _items.Add((IGProcessItemInner)item); }