Exemplo n.º 1
0
        private Element LoadElement(XPathNavigator node)
        {
            Element element = null;

            switch (node.Name)
            {
            case DataElement.ElementName:
                _data = new DataElement(this, node);
                if (_data.StartDate != null)
                {
                    _startDate = _data.StartDate.Value;
                }
                element = _data;
                break;

            case HeadElement.ElementName:
                _head   = new HeadElement(this, node);
                element = _head;
                break;

            case BodyElement.ElementName:
                _body   = new BodyElement(this, node);
                element = _body;
                break;

            case CalendarElement.ElementName:
                _calendar = new CalendarElement(this, node);
                element   = _calendar;
                break;

            case DayElement.ElementName:
                element = new DayElement(this, node);
                break;

            case AxisElement.ElementName:
                AxisElement axis = new AxisElement(this, node);
                axis.ViewStartDate = _startDate;
                _axes.Add(axis);
                element = axis;
                break;

            case SpanElement.ElementName:
                element = new SpanElement(this, node);
                break;

            case IntervalElement.ElementName:
                element = new IntervalElement(this, node);
                break;

            case PointElement.ElementName:
                element = new PointElement(this, node);
                break;

            case RelationElement.ElementName:
                RelationElement relation = new RelationElement(this, node);
                relation.Origin = _map[relation.OriginId];
                relation.Target = _map[relation.TargetId];
                element         = relation;
                break;

            default:
                element = new GanttElement(this, node);
                break;
            }

            if (element != null)
            {
                AddElementToMap(element);

                if (node.HasChildren)
                {
                    foreach (XPathNavigator childNode in node.SelectChildren(XPathNodeType.Element))
                    {
                        Element childElement = LoadElement(childNode);
                        if (childElement != null)
                        {
                            element.AddChild(childElement);
                        }
                    }
                }
            }

            return(element);
        }
Exemplo n.º 2
0
        public override void RenderGanttElement(DrawingContext context, RectangleF rectangle, Brush backgroundBrush, Pen borderPen)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // Calculate arrow size
            GanttStyle style = this.Style as GanttStyle;

            _arrowSize = Math.Min(style.Width, style.Height);

            GanttElement originElement = _origin as GanttElement;
            GanttElement targetElement = _target as GanttElement;

            RectangleF origin = originElement.Rectangle;
            RectangleF target = targetElement.Rectangle;

            PointF originEnd   = new PointF(origin.Right, Convert.ToSingle(Math.Ceiling(origin.Top - 1 + origin.Height / 2)));
            PointF targetStart = new PointF(targetElement.StartX, Convert.ToSingle(Math.Ceiling(target.Top - 1 + target.Height / 2)));

            PointF[] linePoints  = null;
            PointF[] arrowPoints = null;

            bool  riseY           = target.Y > origin.Y;
            float doubleArrowSize = _arrowSize * 2;

            if (targetStart.X - originEnd.X > doubleArrowSize)
            {
                PointF pointer = new PointF(targetStart.X, riseY ? target.Top - 1 : target.Bottom);

                // Direct arrow: 3 points
                linePoints = new PointF[3]
                {
                    originEnd,
                    new PointF(pointer.X, originEnd.Y),
                    new PointF(pointer.X, riseY ? pointer.Y - _arrowSize - 1 : pointer.Y + _arrowSize + 1)
                };

                arrowPoints = CreateArrow(pointer, false, riseY);
            }
            else
            {
                PointF pointer = new PointF(target.Left - 1, targetStart.Y);

                // Back arrow: 6 points
                float intermediateY = riseY ? origin.Bottom + 1 : origin.Top - 2;

                linePoints = new PointF[6]
                {
                    originEnd,
                    new PointF(originEnd.X + doubleArrowSize, originEnd.Y),
                    new PointF(originEnd.X + doubleArrowSize, intermediateY),
                    new PointF(pointer.X - doubleArrowSize - 1, intermediateY),
                    new PointF(pointer.X - doubleArrowSize - 1, pointer.Y),
                    new PointF(pointer.X - _arrowSize - 1, pointer.Y)
                };

                arrowPoints = CreateArrow(pointer, true, true);
            }

            if (linePoints != null)
            {
                if (borderPen != null)
                {
                    context.Graphics.DrawLines(borderPen, linePoints);
                }
            }

            if (arrowPoints != null)
            {
                if (backgroundBrush != null)
                {
                    context.Graphics.FillPolygon(backgroundBrush, arrowPoints);
                }
                if (borderPen != null)
                {
                    context.Graphics.DrawPolygon(borderPen, arrowPoints);
                }
            }
        }
Exemplo n.º 3
0
        private Element LoadElement(XPathNavigator node)
        {
            Element element = null;

            switch (node.Name)
            {
                case DataElement.ElementName:
                    _data = new DataElement(this, node);
                    if(_data.StartDate != null)
                        _startDate = _data.StartDate.Value;
                    element = _data;
                    break;
                case HeadElement.ElementName:
                    _head = new HeadElement(this, node);
                    element = _head;
                    break;
                case BodyElement.ElementName:
                    _body = new BodyElement(this, node);
                    element = _body;
                    break;
                case CalendarElement.ElementName:
                    _calendar = new CalendarElement(this, node);
                    element = _calendar;
                    break;
                case DayElement.ElementName:
                    element = new DayElement(this, node);
                    break;
                case AxisElement.ElementName:
                    AxisElement axis = new AxisElement(this, node);
                    axis.ViewStartDate = _startDate;
                    _axes.Add(axis);
                    element = axis;
                    break;
                case SpanElement.ElementName:
                    element = new SpanElement(this, node);
                    break;
                case IntervalElement.ElementName:
                    element = new IntervalElement(this, node);
                    break;
                case PointElement.ElementName:
                    element = new PointElement(this, node);
                    break;
                case RelationElement.ElementName:
                    RelationElement relation = new RelationElement(this, node);
                    relation.Origin = _map[relation.OriginId];
                    relation.Target = _map[relation.TargetId];
                    element = relation;
                    break;
                default:
                    element = new GanttElement(this, node);
                    break;
            }

            if (element != null)
            {
                AddElementToMap(element);

                if (node.HasChildren)
                {
                    foreach (XPathNavigator childNode in node.SelectChildren(XPathNodeType.Element))
                    {
                        Element childElement = LoadElement(childNode);
                        if (childElement != null)
                            element.AddChild(childElement);
                    }
                }
            }

            return element;
        }