Пример #1
0
        public override void DrawToGraphics(Graphics graphics)
        {
            string label = Value.ToString();

            if (!string.IsNullOrEmpty(label))
            {
                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();
                }

                //Shorten label
                int allowedLength = 50;
                if (label.Length > allowedLength)
                {
                    label = label.Substring(0, allowedLength) + "...";
                }

                float width  = graphics.MeasureString(label, this.TitleFont).Width;
                float height = this.TitleFont.Size + 5;

                RectangleF rect = new RectangleF(X, Y, width, height);
                graphics.DrawString(label, this.TitleFont, new SolidBrush(color), rect);
                if (Math.Abs(this.Width - width) > 15)
                {
                    this.Width = width;
                }
            }
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #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);
        }