Exemplo n.º 1
0
        protected void DrawComponent(IGraphicsContext g, int x_left, int y_top, int width, int height, int radius, int thickness, Color color)
        {
            GraphicsPath path = new GraphicsPath();

            path.StartFigure();
            path.AddRectangle(Bounds);
            if (Selected)
            {
                path.AddLine(x_left + 5 + thickness, y_top + height / 2, x_left + 5 + thickness, y_top + radius);
                path.AddLine(x_left + 5 + thickness, y_top + 5 + thickness, x_left + 5 + thickness + width / 2, y_top + 5 + thickness);
                path.AddLine(x_left + 5 + thickness + width / 2, y_top + 5 + thickness, x_left + 5 + thickness, y_top + 5 + thickness);
            }
            path.CloseFigure();

            using (Brush brush = new System.Drawing.SolidBrush(color))
            {
                using (Pen pen = new Pen(brush, thickness))
                {
                    g.DrawPath(pen, path);
                    if (Name != null && Name.Trim() != "")
                    {
                        g.DrawString(Name, brush, radius, new Point(x_left + radius, y_top + 1), false);
                    }
                }
            }
        }
		protected void DrawComponent (IGraphicsContext g, int x_left, int y_top, int width, int height, int radius, int thickness, Color color)
		{
			GraphicsPath path = new GraphicsPath ();
			path.StartFigure ();
			path.AddRectangle (Bounds);
			if (Selected)
			{
				path.AddLine (x_left + 5 + thickness, y_top + height / 2, x_left + 5 + thickness, y_top + radius);
				path.AddLine (x_left + 5 + thickness, y_top + 5 + thickness, x_left + 5 + thickness + width / 2, y_top + 5 + thickness);
				path.AddLine (x_left + 5 + thickness + width / 2, y_top + 5 + thickness, x_left + 5 + thickness, y_top + 5 + thickness);
			}
			path.CloseFigure ();

			using (Brush brush = new System.Drawing.SolidBrush (color))
			{
				using (Pen pen = new Pen (brush, thickness))
				{
					g.DrawPath (pen, path);
					if (Name != null && Name.Trim () != "")
					{
						g.DrawString (Name, brush, radius, new Point (x_left + radius, y_top + 1), false);
					}
				}
			}
		}
Exemplo n.º 3
0
        public void Render(IGraphicsContext context)
        {
            Frame = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
            var rectBackground = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
            context.DrawRectangle(rectBackground, _brushBackground, _penTransparent);

            if (_isIndeterminate)
            {
                var rectForeground = new BasicRectangle(0, 0, context.BoundsWidth, context.BoundsHeight);
                context.DrawRectangle(rectForeground, _brushForeground, _penTransparent);

                const int pixelsPerIteration = 1;
                float inclination = 15 * context.Density;
                float barSize = 20 * context.Density;
                float widthBetweenBars = 0;//2 * context.Density;
                float totalBarWidth = barSize + inclination + widthBetweenBars;
                int barCount = (int)Math.Ceiling(context.BoundsWidth / totalBarWidth);
                for (int a = -1; a < barCount + 1; a++) // bleed paths out of bounds partially visible
                {
                    float offset = (_animationCounter % totalBarWidth) * pixelsPerIteration;
                    float x = (a * totalBarWidth) + offset;
                    var path = new BasicPath();
                    path.AddLine(new BasicPathLine(new BasicPoint(x, context.BoundsHeight), new BasicPoint(x + barSize, context.BoundsHeight)));
                    path.AddLine(new BasicPathLine(new BasicPoint(x + barSize, context.BoundsHeight), new BasicPoint(x + barSize + inclination, 0)));
                    path.AddLine(new BasicPathLine(new BasicPoint(x + barSize + inclination, 0), new BasicPoint(x + inclination, 0)));
                    path.AddLine(new BasicPathLine(new BasicPoint(x + inclination, 0), new BasicPoint(x, context.BoundsHeight)));
                    context.DrawPath(path, _brushIndeterminateForeground, _penTransparent);
                }
            } 
            else
            {
                var rectForeground = new BasicRectangle(0, 0, _value * context.BoundsWidth, context.BoundsHeight);
                context.DrawRectangle(rectForeground, _brushForeground, _penTransparent);
            }
        }
Exemplo n.º 4
0
        protected void DrawState(IGraphicsContext g, int x_left, int y_top, int width, int height, int radius, int thickness, Color color, bool drawTestRect)
        {
            if (drawTestRect)
            {
                GraphicsPath path = new GraphicsPath();
                Rectangle    rect = new Rectangle(x_left, y_top, width, height);
                path.AddRectangle(rect);
                path.CloseFigure();

                using (Brush brush = new System.Drawing.SolidBrush(Color.Yellow))
                {
                    using (Pen pen = new Pen(brush, thickness))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }

            if (true)
            {
                GraphicsPath path = new GraphicsPath();
                path.StartFigure();
                path.AddArc(x_left, y_top, radius, radius, 180, 90);
                if (IsStartState)
                {
                    path.AddLine(x_left + radius, y_top, x_left, y_top + radius);
                }
                path.AddLine(x_left + radius, y_top, x_left + width - radius - radius, y_top);
                path.AddArc(x_left + width - radius, y_top, radius, radius, 270, 90);
                path.AddLine(x_left + width, y_top + radius, x_left + width, y_top + height - radius - radius);
                path.AddArc(x_left + width - radius, y_top + height - radius, radius, radius, 0, 90);
                path.AddLine(x_left + width - radius, y_top + height, x_left + radius, y_top + height);
                path.AddArc(x_left, y_top + height - radius, radius, radius, 90, 90);
                path.AddLine(x_left, y_top + height - radius, x_left, y_top + radius);
                if (Selected)
                {
                    path.AddLine(x_left + 5 + thickness, y_top + radius, x_left + 5 + thickness, y_top + height / 2);
                    path.AddLine(x_left + 5 + thickness, y_top + height / 2, x_left + 5 + thickness, y_top + radius);
                }
                path.CloseFigure();
                if (IsFinalState)
                {
                    path.StartFigure();
                    path.AddLine(x_left + width - radius, y_top + height, x_left + width, y_top + height - radius);
                    path.CloseFigure();
                }

                using (Brush brush = new System.Drawing.SolidBrush(color))
                {
                    using (Pen pen = new Pen(brush, thickness))
                    {
                        g.DrawPath(pen, path);

                        if (IsNotEmptyString(Name))
                        {
                            DrawString(g, Name, brush, (int)((radius * 2.0) / 3.0), new Point(x_left + radius, y_top + 1), FontStyle.Bold);
                        }
                        int ypos = y_top + 1 + radius + radius / 2;
                        if (IsNotEmptyString(EntryAction))
                        {
                            DrawString(g, "e:" + EntryAction, brush, radius / 2, new Point(x_left + radius, ypos), FontStyle.Regular);
                            ypos += (radius + radius) / 3;
                        }
                        if (IsNotEmptyString(ExitAction))
                        {
                            DrawString(g, "x:" + ExitAction, brush, radius / 2, new Point(x_left + radius, ypos), FontStyle.Regular);
                            ypos += (radius + radius) / 3;
                        }
                        if (IsNotEmptyString(DoAction))
                        {
                            DrawString(g, "a:" + DoAction, brush, radius / 2, new Point(x_left + radius, ypos), FontStyle.Regular);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void DrawState(IGraphicsContext g, int x_left, int y_top, int width, int height, int radius, int thickness, Color color, bool drawTestRect)
        {
            if (drawTestRect)
            {
                GraphicsPath path = new GraphicsPath ();
                Rectangle rect = new Rectangle (x_left, y_top, width, height);
                path.AddRectangle (rect);
                path.CloseFigure ();

                using (Brush brush = new System.Drawing.SolidBrush (Color.Yellow))
                {
                    using (Pen pen = new Pen (brush, thickness))
                    {
                        g.DrawPath (pen, path);
                    }
                }
            }

            if (true)
            {
                GraphicsPath path = new GraphicsPath ();
                path.StartFigure ();
                path.AddArc (x_left, y_top, radius, radius, 180, 90);
                if (IsStartState)
                {
                    path.AddLine (x_left + radius, y_top, x_left, y_top + radius);
                }
                path.AddLine (x_left + radius, y_top, x_left + width - radius - radius, y_top);
                path.AddArc (x_left + width - radius, y_top, radius, radius, 270, 90);
                path.AddLine (x_left + width, y_top + radius, x_left + width, y_top + height - radius - radius);
                path.AddArc (x_left + width - radius, y_top + height - radius, radius, radius, 0, 90);
                path.AddLine (x_left + width - radius, y_top + height, x_left + radius, y_top + height);
                path.AddArc (x_left, y_top + height - radius, radius, radius, 90, 90);
                path.AddLine (x_left, y_top + height - radius, x_left, y_top + radius);
                if (Selected)
                {
                    path.AddLine (x_left + 5 + thickness, y_top + radius, x_left + 5 + thickness, y_top + height / 2);
                    path.AddLine (x_left + 5 + thickness, y_top + height / 2, x_left + 5 + thickness, y_top + radius);
                }
                path.CloseFigure ();
                if (IsFinalState)
                {
                    path.StartFigure ();
                    path.AddLine (x_left +width - radius, y_top + height, x_left + width, y_top + height - radius);
                    path.CloseFigure ();
                }

                using (Brush brush = new System.Drawing.SolidBrush (color))
                {
                    using (Pen pen = new Pen (brush, thickness))
                    {
                        g.DrawPath (pen, path);

                        if (IsNotEmptyString (Name))
                        {
                            DrawString (g, Name, brush, (int) ((radius * 2.0) / 3.0), new Point (x_left + radius, y_top + 1), FontStyle.Bold);
                        }
                        int ypos = y_top + 1 + radius + radius / 2;
                        if (IsNotEmptyString (EntryAction))
                        {
                            DrawString (g, "e:" + EntryAction, brush, radius / 2, new Point (x_left + radius, ypos), FontStyle.Regular);
                            ypos += (radius + radius) / 3;
                        }
                        if (IsNotEmptyString (ExitAction))
                        {
                            DrawString (g, "x:" + ExitAction, brush, radius / 2, new Point (x_left + radius, ypos), FontStyle.Regular);
                            ypos += (radius + radius) / 3;
                        }
                        if (IsNotEmptyString (DoAction))
                        {
                            DrawString (g, "a:" + DoAction, brush, radius / 2, new Point (x_left + radius, ypos), FontStyle.Regular);
                        }
                    }
                }

            }
        }