Пример #1
0
        public override void DrawToGraphics(Graphics graphics)
        {
            Brush      pthGrBrush  = Brushes.Black;
            Pen        pen         = Pens.Black;
            RectangleF EllipseFill = new RectangleF(AbsoluteX - 2, AbsoluteY - 2, 24, 24);

            GraphicsPath path = new GraphicsPath();

            path.AddEllipse(EllipseFill);

            Brush TextColor = Brushes.Black;

            switch (this.CurrentState)
            {
            case ItemState.Free:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorToFillState());
                //pen = new Pen(ColorDefinition.GetColorWhenFree());
                break;

            case ItemState.Hover:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenHover());
                //pen = new Pen(ColorDefinition.GetColorWhenFree());
                TextColor = Brushes.White;
                break;

            case ItemState.Selected:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenSelected());
                //pen = new Pen(ColorDefinition.GetColorWhenFree());
                break;
            }

            graphics.FillEllipse(pthGrBrush, EllipseFill);
            graphics.DrawEllipse(pen, EllipseFill);

            if (initialState)
            {
                EllipseFill = new RectangleF(AbsoluteX + 1, AbsoluteY + 1, 18, 18);
                graphics.DrawEllipse(Pens.Black, EllipseFill);
            }

            this.labelItems.labels.Clear();
            this.labelItems.colors.Clear();

            Color color = Color.Black;

            switch (this.CurrentState)
            {
            case ItemState.Hover:
                color = ColorDefinition.GetColorWhenHover();
                break;

            case ItemState.Selected:
                color = ColorDefinition.GetColorWhenSelected();
                break;
            }
            if (this.CurrentState == ItemState.Free)
            {
                color = ColorDefinition.GetColorOfName();
            }
            this.labelItems.labels.Add(Name);
            this.labelItems.colors.Add(color);

            if (!string.IsNullOrEmpty(Name))
            {
                string invariant = GetInvariantPart();
                if (this.CurrentState == ItemState.Free)
                {
                    color = ColorDefinition.GetColorOfInvariant();
                }

                this.labelItems.labels.Add(invariant);
                this.labelItems.colors.Add(color);
            }

            this.labelItems.DrawToGraphics(graphics);


            if (IsUrgent)
            {
                RectangleF rect = new RectangleF(this.AbsoluteX + margin, this.AbsoluteY + margin, 24, 24);
                graphics.DrawString("U", TitleFont, TextColor, rect);
            }
            else if (IsCommitted)
            {
                RectangleF rect = new RectangleF(this.AbsoluteX + margin, this.AbsoluteY + margin, 24, 24);
                graphics.DrawString("C", TitleFont, TextColor, rect);
            }
            else if (IsError)
            {
                RectangleF rect = new RectangleF(this.AbsoluteX + margin, this.AbsoluteY + margin, 24, 24);
                graphics.DrawString("E", TitleFont, TextColor, rect);
            }

            //base.DrawToGraphics(graphics);
            DrawDecorators(graphics);
        }
Пример #2
0
        public override void DrawToGraphics(Graphics graphics)
        {
            Brush      pthGrBrush  = Brushes.Black;
            Pen        pen         = new Pen(Color.Black);
            RectangleF EllipseFill = new RectangleF(AbsoluteX - 2, AbsoluteY - 2, 24, 24);

            GraphicsPath path = new GraphicsPath();

            path.AddRectangle(EllipseFill);

            Brush TextColor = Brushes.Black;

            switch (this.CurrentState)
            {
            case ItemState.Free:
                pthGrBrush = new SolidBrush(Color.Black);
                break;

            case ItemState.Hover:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenHover());
                TextColor  = Brushes.White;
                break;

            case ItemState.Selected:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenSelected());
                break;

            default:
                break;
            } // switch

            graphics.FillRectangle(pthGrBrush, EllipseFill);
            graphics.DrawRectangle(pen, AbsoluteX - 2, AbsoluteY - 2, 24, 24);

            this.labelItems.labels.Clear();
            this.labelItems.colors.Clear();

            Color color = Color.Black;

            switch (this.CurrentState)
            {
            case ItemState.Hover:
                color = ColorDefinition.GetColorWhenHover();
                break;

            case ItemState.Selected:
                color = ColorDefinition.GetColorWhenSelected();
                break;

            default:
                break;
            } // switch

            if (this.CurrentState == ItemState.Free)
            {
                color = ColorDefinition.GetColorOfName();
            }

            this.labelItems.labels.Add(Name);
            this.labelItems.colors.Add(color);

            this.labelItems.DrawToGraphics(graphics);

            DrawDecorators(graphics);
        }
Пример #3
0
        public override void DrawToGraphics(Graphics graphics)
        {
            Pen pen = Pens.Black;

            switch (this.CurrentState)
            {
            case ItemState.Free:
                pen = new Pen(ColorDefinition.GetColorWhenFree());
                break;

            case ItemState.Hover:
                pen = new Pen(ColorDefinition.GetColorWhenHover());
                break;

            case ItemState.Selected:
                pen = new Pen(ColorDefinition.GetColorWhenSelected());
                break;

            default:
                break;
            } // switch

            List <PointF> tempNails = new List <PointF>();

            tempNails.Add(this.GetStartingPoint());
            foreach (NailItem nail in this.Nails)
            {
                tempNails.Add(nail.Center());
            }
            tempNails.Add(this.GetEndPoint());

            float R = NailItem.R;

            if (this.CurrentState == ItemState.Free)
            {
                R = NailItem.R + 5;
            }

            PointF[] points    = new PointF[3];
            PointF   firstNail = PointF.Empty;

            firstNail = tempNails[0];
            for (int i = 0; i < tempNails.Count - 1; i++)
            {
                points[1] = tempNails[i + 1];
                points[0] = GraphUltility.FindPointByDistance(points[1], firstNail, R);
                graphics.DrawLine(pen, firstNail, points[0]);

                if (i + 2 < tempNails.Count)
                {
                    points[2] = GraphUltility.FindPointByDistance(points[1], tempNails[i + 2], R);
                    firstNail = points[2];

                    //Make the intersection curved
                    if (this.CurrentState == ItemState.Free)
                    {
                        graphics.DrawBezier(pen, points[0], points[1], points[1], points[2]);
                    }
                }
            }
            DrawRouteWithBigArrow(graphics, pen, firstNail, tempNails[tempNails.Count - 1]);

            Label.Value        = _weight;
            Label.CurrentState = this.CurrentState;
            Label.DrawToGraphics(graphics);
        }
Пример #4
0
        public override void DrawToGraphics(Graphics graphics)
        {
            Brush      pthGrBrush  = Brushes.Black;
            Pen        pen         = new Pen(Color.Black);
            RectangleF EllipseFill = new RectangleF(AbsoluteX - 2, AbsoluteY - 2, 24, 24);

            GraphicsPath path = new GraphicsPath();

            path.AddEllipse(EllipseFill);

            Brush TextColor = Brushes.Black;

            switch (this.CurrentState)
            {
            case ItemState.Free:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorToFillState());
                break;

            case ItemState.Hover:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenHover());
                TextColor  = Brushes.White;
                break;

            case ItemState.Selected:
                pthGrBrush = new SolidBrush(ColorDefinition.GetColorWhenSelected());
                break;

            default:
                break;
            } // switch

            graphics.FillEllipse(pthGrBrush, EllipseFill);
            graphics.DrawEllipse(pen, EllipseFill);

            //1
            switch (_numberOfTokens)
            {
            case 0:
                break;

            case 1:
                EllipseFill = DrawToken(AbsoluteX + 9, AbsoluteY + 9, 4, 4, graphics);
                break;

            case 2:
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 9, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 9, 4, 4, graphics);
                break;

            case 3:
                EllipseFill = DrawToken(AbsoluteX + 9, AbsoluteY + 4, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 14, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 14, 4, 4, graphics);
                break;

            case 4:
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 4, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 14, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 4, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 14, 4, 4, graphics);
                break;

            case 5:
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 4, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 4, AbsoluteY + 14, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 4, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 14, AbsoluteY + 14, 4, 4, graphics);
                EllipseFill = DrawToken(AbsoluteX + 9, AbsoluteY + 9, 4, 4, graphics);
                break;

            default:
                RectangleF rect      = new RectangleF(AbsoluteX + 5, AbsoluteY + 5, 18, 18);
                Font       titleFont = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular, GraphicsUnit.Pixel);
                graphics.DrawString(_numberOfTokens.ToString(), titleFont, new SolidBrush(Color.Black), rect);
                break;
            } // switch

            this.labelItems.labels.Clear();
            this.labelItems.colors.Clear();

            Color color = Color.Black;

            switch (this.CurrentState)
            {
            case ItemState.Hover:
                color = ColorDefinition.GetColorWhenHover();
                break;

            case ItemState.Selected:
                color = ColorDefinition.GetColorWhenSelected();
                break;

            default:
                break;
            } // switch

            if (this.CurrentState == ItemState.Free)
            {
                color = ColorDefinition.GetColorOfName();
            }

            this.labelItems.labels.Add(Name);
            this.labelItems.colors.Add(color);
            this.labelItems.DrawToGraphics(graphics);

            DrawDecorators(graphics);
        }