예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetroTaskPointCollectionEventArgs"/> class.
 /// </summary>
 /// <param name="item">The item.</param>
 public MetroTaskPointCollectionEventArgs(ZeroitMetroTaskPoint item)
 {
     this._item = item;
 }
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            IEnumerator <ZeroitMetroTaskPoint> enumerator = this._PointCollection.GetEnumerator();
            Rectangle rectangle;
            Rectangle rectangle1 = new Rectangle();
            Graphics  graphics   = e.Graphics;

            if (AllowTransparency)
            {
                MakeTransparent(this, graphics);
            }

            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            int   circleWidth = this._StartPointWidth;
            Point point       = new Point(checked (circleWidth + 6), checked (circleWidth + 6));
            Point point1      = new Point(checked (circleWidth + 6), checked (this.Height - (checked (circleWidth + 6))));

            this._PointPosition.Clear();
            this._TextRectangles.Clear();

            if (this._PointCollection.Count > 0)
            {
                while (enumerator.MoveNext())
                {
                    ZeroitMetroTaskPoint current = enumerator.Current;
                    if (current.CircleWidth > circleWidth)
                    {
                        circleWidth = current.CircleWidth;
                    }
                }

                point         = new Point(checked (circleWidth + 6), checked (circleWidth + 6));
                point1        = new Point(checked (circleWidth + 6), checked (this.Height - (checked (circleWidth + 6))));
                this.distance = checked ((int)Math.Round(Design.Drawing.MeasurePointDistance(point, point1)));
                this.distance = checked ((int)Math.Round((double)this.distance / (double)this._PointCollection.Count));
                int count = checked (this._PointCollection.Count - 1);
                for (int i = 0; i <= count; i = checked (i + 1))
                {
                    List <Rectangle> rectangles = this._PointPosition;
                    rectangle = new Rectangle(checked (checked (circleWidth + 6) - checked ((int)Math.Round((double)this._PointCollection[i].CircleWidth / 2))), checked (checked (checked (this.Height - (checked (circleWidth + 6))) - checked ((int)Math.Round((double)this._PointCollection[i].CircleWidth / 2))) - checked (this.distance * (checked (i + 1)))), this._PointCollection[i].CircleWidth, this._PointCollection[i].CircleWidth);
                    rectangles.Add(rectangle);
                }
            }
            Pen        pen        = new Pen(this._LineColor);
            SolidBrush solidBrush = new SolidBrush(this._LineColor);
            Pen        pen1       = new Pen(this._HoverColor);


            graphics.DrawLine(pen, point, point1);


            Point point2 = new Point(checked (checked (circleWidth + 6) - checked ((int)Math.Round((double)this._StartPointWidth / 2))), checked (checked (this.Height - (checked (circleWidth + 6))) - checked ((int)Math.Round((double)this._StartPointWidth / 2))));

            System.Drawing.Size size = new System.Drawing.Size(this._StartPointWidth, this._StartPointWidth);
            rectangle = new Rectangle(point2, size);

            switch (taskShape)
            {
            case TaskShape.Circle:
                graphics.FillEllipse(solidBrush, rectangle);
                break;

            case TaskShape.Rectangle:
                graphics.FillRectangle(solidBrush, rectangle);
                break;

            case TaskShape.Pie:
                graphics.FillPie(solidBrush, rectangle, PieAngle.StartAngle, PieAngle.SweepAngle);
                break;
            }


            if (this._PointPosition.Count > 0)
            {
                int num = checked (this._PointCollection.Count - 1);
                for (int j = 0; j <= num; j = checked (j + 1))
                {
                    SolidBrush solidBrush1 = new SolidBrush((this._PointCollection[j].Finished
                                        ? this._FinishedColor
                                        : this._PointCollection[j].CirceColor));


                    switch (taskShape)
                    {
                    case TaskShape.Circle:
                        graphics.FillEllipse(solidBrush1, this._PointPosition[j]);

                        break;

                    case TaskShape.Rectangle:
                        graphics.FillRectangle(solidBrush1, this._PointPosition[j]);

                        break;

                    case TaskShape.Pie:
                        graphics.FillPie(solidBrush1, this._PointPosition[j], PieAngle.StartAngle, PieAngle.SweepAngle);

                        break;
                    }

                    if (this._HotPoint != rectangle1 && j == this._HotIndex && this._PointCollection[this._HotIndex].Enabled)
                    {
                        solidBrush1.Color = this._HoverColor;
                    }
                    SizeF sizeF = graphics.MeasureString(this._PointCollection[j].Text, this.Font);
                    int   num1  = checked (checked (circleWidth * 2) + 6);
                    rectangle = this._PointPosition[j];
                    Rectangle rectangle2 = new Rectangle(num1, checked (checked (rectangle.Y + checked ((int)Math.Round((double)this._PointCollection[j].CircleWidth / 2))) - checked ((int)Math.Round((double)((float)(sizeF.Height / 2f))))), checked ((int)Math.Round((double)((float)(sizeF.Width + 2f)))), checked (this.distance - checked ((int)Math.Round((double)((float)(sizeF.Height + 2f))))));
                    this._TextRectangles.Add(rectangle2);
                    graphics.DrawString(this._PointCollection[j].Text, this.Font, solidBrush1, rectangle2);
                    int num2 = checked ((int)Math.Round((double)this._PointCollection[j].CircleWidth / 4));
                    if (this._PointCollection[j].Icon != null)
                    {
                        Image icon = this._PointCollection[j].Icon;
                        rectangle = this._PointPosition[j];
                        int       x          = checked (rectangle.X + num2);
                        Rectangle item       = this._PointPosition[j];
                        Rectangle rectangle3 = new Rectangle(x, checked (item.Y + num2), checked (num2 * 2), checked (num2 * 2));
                        graphics.DrawImage(icon, rectangle3);
                    }
                }
                if (this._HotPoint != rectangle1)
                {
                    if (this._PointCollection[this._HotIndex].Enabled)
                    {
                        switch (taskShape)
                        {
                        case TaskShape.Circle:
                            graphics.DrawEllipse(pen1, this._HotPoint);
                            break;

                        case TaskShape.Rectangle:
                            graphics.DrawRectangle(pen1, this._HotPoint);
                            break;

                        case TaskShape.Pie:
                            graphics.DrawPie(pen1, this._HotPoint, PieAngle.StartAngle, PieAngle.SweepAngle);
                            break;
                        }
                    }
                }
            }
            base.OnPaint(e);
        }