Beispiel #1
0
 public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
 {
     System.Drawing.Point[] points = new System.Drawing.Point[nPoints];
     for (int i = 0; i < nPoints; i++)
     {
         points[i] = new System.Drawing.Point(xPoints[i], yPoints[i]);
     }
     nativeGraphics.FillPolygon(brush, points);
 }
Beispiel #2
0
 public void DrawPolygon(System.Drawing.Point[] points, bool fill = false)
 {
     System.Drawing.Graphics g            = this;
     System.Drawing.Point[]  screenPoints = viewportToScreen(points);
     g.DrawPolygon(CurrentPen as System.Drawing.Pen, screenPoints);
     if (fill)
     {
         g.FillPolygon(CurrentBrush as System.Drawing.Brush, screenPoints);
     }
 }
        // Draws a triangle, for the non-noisy edge map drawing
        private void DrawTriangle(System.Drawing.Graphics g, Corner c1, Corner c2, Center cn, System.Drawing.Color color)
        {
            int[] x = new int[3];
            int[] y = new int[3];
            System.Drawing.Point[] points = new System.Drawing.Point[3];
            points[0] = new System.Drawing.Point((int)cn.loc.x, (int)cn.loc.y);
            points[1] = new System.Drawing.Point((int)c1.loc.x, (int)c1.loc.y);
            points[2] = new System.Drawing.Point((int)c2.loc.x, (int)c2.loc.y);

            g.FillPolygon(new System.Drawing.SolidBrush(color), points);
        }
        /// <summary>
        /// Fills the specified data series points.
        /// </summary>
        /// <param name="dataSeries">The data series.</param>
        /// <param name="points">The points.</param>
        public void FillSeries(WpfGraphDataSeries dataSeries, IEnumerable <System.Drawing.PointF> points)
        {
            var brush = dataSeries.GdiFill;

            if (dataSeries.GdiFill is System.Drawing.Drawing2D.LinearGradientBrush)
            {
                var gradient = dataSeries.GdiFill as System.Drawing.Drawing2D.LinearGradientBrush;
                gradient.ResetTransform();
                gradient.ScaleTransform((_size.Width / gradient.Rectangle.Width), (_size.Height / gradient.Rectangle.Height));
            }

            _g.FillPolygon(dataSeries.GdiFill, points.ToArray());
        }
Beispiel #5
0
        private static void DrawArea(System.Drawing.Graphics graphics, System.Drawing.Brush brush, System.Drawing.Pen pen, float x_min, float x_max, float left, float width, float y_min, float y_max, float top, float height, float[,] values)
        {
            int length = values.GetLength(0);

            System.Drawing.PointF[] points = new System.Drawing.PointF[length];
            for (int i = 0; i < length; i++)
            {
                points[i] = Coordinate(values[i, 0], x_min, x_max, left, width, values[i, 1], y_min, y_max, top, height);
            }

            System.Drawing.PointF[] areaPoints = new System.Drawing.PointF[points.Length + 2];
            System.Array.Copy(points, 0, areaPoints, 0, points.Length);
            areaPoints[points.Length]     = Coordinate(x_max, x_min, x_max, left, width, y_min, y_min, y_max, top, height);
            areaPoints[points.Length + 1] = Coordinate(x_min, x_min, x_max, left, width, y_min, y_min, y_max, top, height);
            graphics.FillPolygon(brush, areaPoints);
        }
Beispiel #6
0
 public void DrawPolygon(Point[] points, UInt32?edgeColor = null, UInt32?fillColor = null)
 {
     System.Drawing.Graphics g            = this;
     System.Drawing.Point[]  screenPoints = viewportToScreen(points);
     System.Drawing.Pen      p            = CurrentPen as System.Drawing.Pen;
     if (edgeColor != null)
     {
         p = new System.Drawing.Pen(ToSysColor(edgeColor));
     }
     g.DrawPolygon(p, screenPoints);
     if (fillColor != null)
     {
         System.Drawing.Brush b = new System.Drawing.SolidBrush(ToSysColor(fillColor));
         g.FillPolygon(b, screenPoints);
     }
 }
Beispiel #7
0
        private static void RenderShape(GH_Canvas canvas, System.Drawing.Graphics graphics, System.Drawing.PointF[] points, System.Drawing.Color color)
        {
            int   alpha    = GH_Canvas.ZoomFadeMedium;
            float x0       = points[0].X;
            float x        = x0;
            float y0       = points[0].Y;
            float y        = y0;
            int   arg_32_0 = 1;
            int   num      = points.Length - 1;

            for (int i = arg_32_0; i <= num; i++)
            {
                x0 = System.Math.Min(x0, points[i].X);
                x  = System.Math.Max(x, points[i].X);
                y0 = System.Math.Min(y0, points[i].Y);
                y  = System.Math.Max(y, points[i].Y);
            }
            System.Drawing.RectangleF bounds = System.Drawing.RectangleF.FromLTRB(x0, y0, x, y);
            bounds.Inflate(1f, 1f);
            System.Drawing.Drawing2D.LinearGradientBrush fill = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, color, GH_GraphicsUtil.OffsetColour(color, 50), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
            fill.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
            graphics.FillPolygon(fill, points);
            fill.Dispose();
            if (alpha > 0)
            {
                System.Drawing.Color col0 = System.Drawing.Color.FromArgb(System.Convert.ToInt32(0.5 * (double)alpha), System.Drawing.Color.White);
                System.Drawing.Color col  = System.Drawing.Color.FromArgb(0, System.Drawing.Color.White);
                System.Drawing.Drawing2D.LinearGradientBrush highlightFill = new System.Drawing.Drawing2D.LinearGradientBrush(bounds, col0, col, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                highlightFill.WrapMode = System.Drawing.Drawing2D.WrapMode.TileFlipXY;
                System.Drawing.Pen highlightEdge = new System.Drawing.Pen(highlightFill, 3f);
                highlightEdge.LineJoin      = System.Drawing.Drawing2D.LineJoin.Round;
                highlightEdge.CompoundArray = new float[]
                {
                    0f,
                    0.5f
                };
                graphics.DrawPolygon(highlightEdge, points);
                highlightFill.Dispose();
                highlightEdge.Dispose();
            }
            graphics.DrawPolygon(new System.Drawing.Pen(color, 1f)
            {
                LineJoin = System.Drawing.Drawing2D.LineJoin.Round
            }, points);
        }
        public System.Drawing.Bitmap DrawAspectMap(int scale)
        {
            if (this.triangulation.triangles.Count < 1)
            {
                throw new NotImplementedException();
            }

            double minX = this.LowerLeft.X; double minY = this.LowerLeft.Y;

            int width = (int)(this.UpperRight.X - minX);

            int height = (int)(this.UpperRight.Y - minY);

            System.Drawing.Bitmap result = new System.Drawing.Bitmap(width / scale, height / scale);

            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(result);

            foreach (QuasiTriangle item in this.triangulation.triangles)
            {
                Point first = collection.GetPoint(item.First);

                Point second = collection.GetPoint(item.Second);

                Point third = collection.GetPoint(item.Third);

                Triangle temp = new Triangle(first, second, third);

                double tempSlope = CalculateAspect(temp);

                //int color = (int)((tempSlope + Math.PI / 2) * 255 / (Math.PI));

                int color = (int)(tempSlope * 255 / (2 * Math.PI));

                System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(color, color, color));

                g.FillPolygon(brush,
                              new System.Drawing.PointF[] {
                    new System.Drawing.PointF((float)(first.X - minX), (float)(result.Height - (first.Y - minY))),
                    new System.Drawing.PointF((float)(second.X - minX), (float)(result.Height - (second.Y - minY))),
                    new System.Drawing.PointF((float)(third.X - minX), (float)(result.Height - (third.Y - minY)))
                });
            }

            return(result);
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }

            if (_points.Count > 0)
            {
                System.Drawing.Point[] points = GetViewportPoints(_points.Count + 1);
                points[points.Length - 1] = _viewportMousePosition;

                if (_closePath)
                {
                    if (base.Brush != null)
                    {
                        System.Drawing.Drawing2D.Matrix prevBrushMatrix = PathVObjectCreateDesigner.AdaptBrushToViewport(base.Brush, this.VObjectHost.HostViewer);
                        try
                        {
                            g.FillPolygon(base.Brush, points, _fillMode);
                        }
                        finally
                        {
                            if (prevBrushMatrix != null)
                            {
                                VObjectsUtils.SetBrushMatrix(base.Brush, prevBrushMatrix);
                            }
                        }
                    }
                    if (base.Pen != null)
                    {
                        g.DrawPolygon(base.CreateViewportPen(), points);
                    }
                }
                else
                {
                    if (base.Pen != null)
                    {
                        g.DrawLines(base.CreateViewportPen(), points);
                    }
                }
            }
        }
Beispiel #10
0
        // implement Draw() (step 5)
        public void Draw(System.Drawing.Graphics image)
        {
            System.Drawing.Brush brush = new System.Drawing.SolidBrush(color);
            System.Drawing.Pen   pen   = new System.Drawing.Pen(color);

            // Determine if circle, since use [upperLeft, width, height, !vertices] only
            if (name.Equals("Circle"))
            {
                image.DrawEllipse(pen, UpperLeft.X, UpperLeft.Y, Height, Width);
                image.FillEllipse(brush, new System.Drawing.Rectangle(UpperLeft.X, UpperLeft.Y, Width, Height));
            }
            else
            {
                image.DrawPolygon(pen, Vertices);
                image.FillPolygon(brush, Vertices);
            }

            brush.Dispose();
            pen.Dispose();
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }

            if (_points.Count > 1)
            {
                using (System.Drawing.Pen pen = CreateViewportPen())
                {
                    System.Drawing.Point[] points = (System.Drawing.Point[])_points.ToArray(typeof(System.Drawing.Point));

                    if (_closePath)
                    {
                        if (base.Brush != null)
                        {
                            System.Drawing.Drawing2D.Matrix prevBrushMatrix = PathVObjectCreateDesigner.AdaptBrushToViewport(base.Brush, base.VObjectHost.HostViewer);
                            try
                            {
                                g.FillPolygon(base.Brush, points, _fillMode);
                            }
                            finally
                            {
                                if (prevBrushMatrix != null)
                                {
                                    VObjectsUtils.SetBrushMatrix(base.Brush, prevBrushMatrix);
                                }
                            }
                        }
                        g.DrawPolygon(pen, points);
                    }
                    else
                    {
                        g.DrawLines(pen, points);
                    }
                }
            }
        }
        public void FillPolygon(Polygon poly)
        {
            var minX   = float.MaxValue;
            var minY   = float.MaxValue;
            var maxX   = float.MinValue;
            var maxY   = float.MinValue;
            var points = new System.Drawing.PointF[poly.Points.Count];

            for (var i = 0; i < points.Length; i++)
            {
                float x = poly.Points[i].X;
                float y = poly.Points[i].Y;
                minX      = Math.Min(minX, x);
                minY      = Math.Min(minY, y);
                maxX      = Math.Max(maxX, x);
                maxY      = Math.Max(maxY, y);
                points[i] = new System.Drawing.PointF(x, y);
            }
            var bounds = new System.Drawing.RectangleF(minX, minY, maxX - minX, maxY - minY);

            g.FillPolygon(GetBrush(bounds), points);
        }
Beispiel #13
0
        public override void Draw(System.Drawing.Rectangle renderingRect, System.Drawing.Graphics g, ICoordinateMapper coordinateMapper)
        {
            if (g == null)
            {
                throw new System.ArgumentNullException("g");
            }
            if (coordinateMapper == null)
            {
                throw new System.ArgumentNullException("coordinateMapper");
            }

            // FillPath doesn't support specifying FillMode, it always uses FillMode.Alternate,
            // so we have to use Graphics.FillPolygon method in other cases.
            if (!_closePath || base.Brush == null || _fillMode == System.Drawing.Drawing2D.FillMode.Alternate)
            {
                base.Draw(renderingRect, g, coordinateMapper);
            }
            else
            {
                System.Drawing.PointF[] transformedPoints = VObjectsUtils.TransformPoints(base.Transform, _points);
                for (int i = 0; i < transformedPoints.Length; i++)
                {
                    transformedPoints[i] = coordinateMapper.WorkspaceToControl(transformedPoints[i], Aurigma.GraphicsMill.Unit.Point);
                }

                System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode;
                System.Drawing.Pen pen = base.CreateViewportPen(coordinateMapper);
                try
                {
                    switch (base.DrawMode)
                    {
                    case VObjectDrawMode.Draft:
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                        break;

                    case VObjectDrawMode.Normal:
                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        break;

                    default:
                        throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUnexpectedDrawMode"));
                    }

                    if (base.Brush != null)
                    {
                        AdaptBrushToViewport(coordinateMapper);
                        try
                        {
                            g.FillPolygon(base.Brush, transformedPoints, _fillMode);
                        }
                        finally
                        {
                            RestoreBrush();
                        }
                    }
                    if (pen != null)
                    {
                        g.DrawPolygon(pen, transformedPoints);
                    }
                }
                finally
                {
                    pen.Dispose();
                    g.SmoothingMode = oldSmoothingMode;
                }
            }
        }
        // Draws a voronoi polygon
        private void DrawPolygon(System.Drawing.Graphics g, Center c, System.Drawing.Color color, bool noisyEdges, bool smoothBlending, bool lighting, bool drawBiomes)
        {
            Corner eC1 = null;
            Corner eC2 = null;

            c.area = 0;

            foreach (Center n in c.neighbors)
            {
                DEdge e = EdgeWithCenters(c, n);

                //Experimental Color (Biome Blending)
                if (smoothBlending && drawBiomes)
                {
                    color = BlendBiome(color, c, n);
                }

                //Experimental Lighting (Light Vectors)
                if (lighting && drawBiomes)
                {
                    color = ColorWithSlope(color, c, n, e);
                }


                // If noisy edges is off, draw triangles to create voronoi polygons (center to vertices of each edge)
                if (!noisyEdges)
                {
                    if (e.v0 == null)
                    {
                        continue;
                    }

                    Corner corner1A = e.v0.border ? e.v0 : e.v1;
                    if (corner1A.border)
                    {
                        if (eC1 == null)
                        {
                            eC1 = corner1A;
                        }
                        else
                        {
                            eC2 = corner1A;
                        }
                    }

                    DrawTriangle(g, e.v0, e.v1, c, color);

                    c.area = Math.Abs(c.loc.x * (e.v0.loc.y - e.v1.loc.y)
                                      + e.v0.loc.x * (e.v1.loc.y - c.loc.y)
                                      + e.v1.loc.x * (c.loc.y - e.v0.loc.y)) / 2;
                }

                //Experimental Polygon Drawing using noisy (natural) edges
                if (noisyEdges)
                {
                    // For each of the noisy edge paths fill the polygon created betweeen them and the center
                    if (path0[e.index] != null)
                    {
                        List <Point> tPath = path0[e.index];

                        System.Drawing.Point[] tA = new System.Drawing.Point[tPath.Count + 2];
                        tA[0] = new System.Drawing.Point((int)c.loc.x, (int)c.loc.y);
                        for (int i = 0; i < tPath.Count; i++)
                        {
                            tA[i + 1] = new System.Drawing.Point((int)tPath[i].x, (int)tPath[i].y);
                        }
                        tA[tA.Count() - 1] = new System.Drawing.Point((int)c.loc.x, (int)c.loc.y);

                        g.FillPolygon(new System.Drawing.SolidBrush(color), tA);
                    }

                    if (path1[e.index] != null)
                    {
                        List <Point> tPath = path1[e.index];

                        System.Drawing.Point[] tA = new System.Drawing.Point[tPath.Count + 2];
                        tA[0] = new System.Drawing.Point((int)c.loc.x, (int)c.loc.y);
                        for (int i = 0; i < tPath.Count; i++)
                        {
                            tA[i + 1] = new System.Drawing.Point((int)tPath[i].x, (int)tPath[i].y);
                        }
                        tA[tA.Count() - 1] = new System.Drawing.Point((int)c.loc.x, (int)c.loc.y);

                        g.FillPolygon(new System.Drawing.SolidBrush(color), tA);
                    }
                }
            }

            if (eC2 != null)
            {
                if (CloseEnough(eC1.loc.x, eC2.loc.x, 1))
                {
                    DrawTriangle(g, eC1, eC2, c, color);
                }
                else
                {
                    System.Drawing.Point[] points = new System.Drawing.Point[4];
                    points[0] = new System.Drawing.Point((int)c.loc.x, (int)c.loc.y);
                    points[1] = new System.Drawing.Point((int)eC1.loc.x, (int)eC1.loc.y);
                    int tX = (int)((CloseEnough(eC1.loc.x, bounds.x, 1) || CloseEnough(eC2.loc.x, bounds.x, 0.5)) ? bounds.x : bounds.right);
                    int tY = (int)((CloseEnough(eC1.loc.y, bounds.y, 1) || CloseEnough(eC2.loc.y, bounds.y, 0.5)) ? bounds.y : bounds.bottom);
                    points[2] = new System.Drawing.Point(tX, tY);
                    points[3] = new System.Drawing.Point((int)eC2.loc.x, (int)eC2.loc.y);
                    g.FillPolygon(new System.Drawing.SolidBrush(color), points);
                    c.area += 0;
                }
            }
        }
Beispiel #15
0
        // OnPaint is now an override rather than an event in version 1.1
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            // create a Graphics object
            System.Drawing.Graphics g = e.Graphics;

            // find the rectangle for the splitter and paint it
            System.Drawing.Rectangle r = this.ClientRectangle;             // fixed in version 1.1
            g.FillRectangle(new System.Drawing.SolidBrush(this.BackColor), r);

            #region Vertical Splitter

            // Check the docking style and create the control rectangle accordingly
            if (this.Dock == System.Windows.Forms.DockStyle.Left || this.Dock == System.Windows.Forms.DockStyle.Right)
            {
                // create a new rectangle in the vertical center of the splitter for our collapse control button
                rr = new System.Drawing.Rectangle(r.X, (int)r.Y + ((r.Height - 115) / 2), 8, 115);
                // force the width to 8px so that everything always draws correctly
                this.Width = 8;

                // draw the background color for our control image
                if (hot)
                {
                    g.FillRectangle(new System.Drawing.SolidBrush(hotColor), new System.Drawing.Rectangle(rr.X + 1, rr.Y, 6, 115));
                }
                else
                {
                    g.FillRectangle(new System.Drawing.SolidBrush(this.BackColor), new System.Drawing.Rectangle(rr.X + 1, rr.Y, 6, 115));
                }

                // draw the top & bottom lines for our control image
                g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark, 1), rr.X + 1, rr.Y, rr.X + rr.Width - 2, rr.Y);
                g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark, 1), rr.X + 1, rr.Y + rr.Height, rr.X + rr.Width - 2, rr.Y + rr.Height);

                if (this.Enabled)
                {
                    // draw the arrows for our control image
                    // the ArrowPointArray is a point array that defines an arrow shaped polygon
                    g.FillPolygon(new System.Drawing.SolidBrush(System.Drawing.SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 2, rr.Y + 3));
                    g.FillPolygon(new System.Drawing.SolidBrush(System.Drawing.SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 2, rr.Y + rr.Height - 9));
                }

                // draw the dots for our control image using a loop
                int x = rr.X + 3;
                int y = rr.Y + 14;

                // Visual Styles added in version 1.1
                switch (visualStyle)
                {
                case VisualStyles.Mozilla:

                    for (int i = 0; i < 30; i++)
                    {
                        // light dot
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y + (i * 3), x + 1, y + 1 + (i * 3));
                        // dark dot
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDarkDark), x + 1, y + 1 + (i * 3), x + 2, y + 2 + (i * 3));
                        // overdraw the background color as we actually drew 2px diagonal lines, not just dots
                        if (hot)
                        {
                            g.DrawLine(new System.Drawing.Pen(hotColor), x + 2, y + 1 + (i * 3), x + 2, y + 2 + (i * 3));
                        }
                        else
                        {
                            g.DrawLine(new System.Drawing.Pen(this.BackColor), x + 2, y + 1 + (i * 3), x + 2, y + 2 + (i * 3));
                        }
                    }
                    break;

                case VisualStyles.DoubleDots:
                    for (int i = 0; i < 30; i++)
                    {
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y + 1 + (i * 3), 1, 1);
                        // dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x - 1, y + (i * 3), 1, 1);
                        i++;
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + 2, y + 1 + (i * 3), 1, 1);
                        // dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + 1, y + (i * 3), 1, 1);
                    }
                    break;

                case VisualStyles.Win9x:

                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y, x + 2, y);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y, x, y + 90);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + 2, y, x + 2, y + 90);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x, y + 90, x + 2, y + 90);
                    break;

                case VisualStyles.XP:

                    for (int i = 0; i < 18; i++)
                    {
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLight), x, y + (i * 5), 2, 2);
                        // light light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + 1, y + 1 + (i * 5), 1, 1);
                        // dark dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDarkDark), x, y + (i * 5), 1, 1);
                        // dark fill
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x, y + (i * 5), x, y + (i * 5) + 1);
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x, y + (i * 5), x + 1, y + (i * 5));
                    }
                    break;

                case VisualStyles.Lines:

                    for (int i = 0; i < 44; i++)
                    {
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x, y + (i * 2), x + 2, y + (i * 2));
                    }

                    break;
                }

                // Added in version 1.3
                if (this.borderStyle != System.Windows.Forms.Border3DStyle.Flat)
                {
                    // Paint the control border
                    System.Windows.Forms.ControlPaint.DrawBorder3D(e.Graphics, this.ClientRectangle, this.borderStyle, System.Windows.Forms.Border3DSide.Left);
                    System.Windows.Forms.ControlPaint.DrawBorder3D(e.Graphics, this.ClientRectangle, this.borderStyle, System.Windows.Forms.Border3DSide.Right);
                }
            }

            #endregion

            // Horizontal Splitter support added in v1.2

            #region Horizontal Splitter

            else if (this.Dock == System.Windows.Forms.DockStyle.Top || this.Dock == System.Windows.Forms.DockStyle.Bottom)
            {
                // create a new rectangle in the horizontal center of the splitter for our collapse control button
                rr = new System.Drawing.Rectangle((int)r.X + ((r.Width - 115) / 2), r.Y, 115, 8);
                // force the height to 8px
                this.Height = 8;

                // draw the background color for our control image
                if (hot)
                {
                    g.FillRectangle(new System.Drawing.SolidBrush(hotColor), new System.Drawing.Rectangle(rr.X, rr.Y + 1, 115, 6));
                }
                else
                {
                    g.FillRectangle(new System.Drawing.SolidBrush(this.BackColor), new System.Drawing.Rectangle(rr.X, rr.Y + 1, 115, 6));
                }

                // draw the left & right lines for our control image
                g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark, 1), rr.X, rr.Y + 1, rr.X, rr.Y + rr.Height - 2);
                g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark, 1), rr.X + rr.Width, rr.Y + 1, rr.X + rr.Width, rr.Y + rr.Height - 2);

                if (this.Enabled)
                {
                    // draw the arrows for our control image
                    // the ArrowPointArray is a point array that defines an arrow shaped polygon
                    g.FillPolygon(new System.Drawing.SolidBrush(System.Drawing.SystemColors.ControlDarkDark), ArrowPointArray(rr.X + 3, rr.Y + 2));
                    g.FillPolygon(new System.Drawing.SolidBrush(System.Drawing.SystemColors.ControlDarkDark), ArrowPointArray(rr.X + rr.Width - 9, rr.Y + 2));
                }

                // draw the dots for our control image using a loop
                int x = rr.X + 14;
                int y = rr.Y + 3;

                // Visual Styles added in version 1.1
                switch (visualStyle)
                {
                case VisualStyles.Mozilla:

                    for (int i = 0; i < 30; i++)
                    {
                        // light dot
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + (i * 3), y, x + 1 + (i * 3), y + 1);
                        // dark dot
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDarkDark), x + 1 + (i * 3), y + 1, x + 2 + (i * 3), y + 2);
                        // overdraw the background color as we actually drew 2px diagonal lines, not just dots
                        if (hot)
                        {
                            g.DrawLine(new System.Drawing.Pen(hotColor), x + 1 + (i * 3), y + 2, x + 2 + (i * 3), y + 2);
                        }
                        else
                        {
                            g.DrawLine(new System.Drawing.Pen(this.BackColor), x + 1 + (i * 3), y + 2, x + 2 + (i * 3), y + 2);
                        }
                    }
                    break;

                case VisualStyles.DoubleDots:

                    for (int i = 0; i < 30; i++)
                    {
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + 1 + (i * 3), y, 1, 1);
                        // dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + (i * 3), y - 1, 1, 1);
                        i++;
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + 1 + (i * 3), y + 2, 1, 1);
                        // dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + (i * 3), y + 1, 1, 1);
                    }
                    break;

                case VisualStyles.Win9x:

                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y, x, y + 2);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x, y, x + 88, y);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x, y + 2, x + 88, y + 2);
                    g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + 88, y, x + 88, y + 2);
                    break;

                case VisualStyles.XP:

                    for (int i = 0; i < 18; i++)
                    {
                        // light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLight), x + (i * 5), y, 2, 2);
                        // light light dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlLightLight), x + 1 + (i * 5), y + 1, 1, 1);
                        // dark dark dot
                        g.DrawRectangle(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDarkDark), x + (i * 5), y, 1, 1);
                        // dark fill
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + (i * 5), y, x + (i * 5) + 1, y);
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + (i * 5), y, x + (i * 5), y + 1);
                    }
                    break;

                case VisualStyles.Lines:

                    for (int i = 0; i < 44; i++)
                    {
                        g.DrawLine(new System.Drawing.Pen(System.Drawing.SystemColors.ControlDark), x + (i * 2), y, x + (i * 2), y + 2);
                    }

                    break;
                }

                // Added in version 1.3
                if (this.borderStyle != System.Windows.Forms.Border3DStyle.Flat)
                {
                    // Paint the control border
                    System.Windows.Forms.ControlPaint.DrawBorder3D(e.Graphics, this.ClientRectangle, this.borderStyle, System.Windows.Forms.Border3DSide.Top);
                    System.Windows.Forms.ControlPaint.DrawBorder3D(e.Graphics, this.ClientRectangle, this.borderStyle, System.Windows.Forms.Border3DSide.Bottom);
                }
            }

            #endregion

            else
            {
                throw new System.Exception("The Collapsible Splitter control cannot have the Filled or None Dockstyle property");
            }


            // dispose the Graphics object
            g.Dispose();
        }
Beispiel #16
0
        public static string getExpertImage()
        {
            if (SessionClass.Flow.Count > 0)
            {
                System.Drawing.Bitmap   bm = new System.Drawing.Bitmap(400, SessionClass.Flow.Count * 90);
                System.Drawing.Graphics g  = System.Drawing.Graphics.FromImage(bm);
                g.Clear(System.Drawing.Color.White);
                int x = 100;
                int y = 10;
                System.Drawing.StringFormat f = new System.Drawing.StringFormat();
                f.Alignment     = System.Drawing.StringAlignment.Center;
                f.LineAlignment = System.Drawing.StringAlignment.Center;
                System.Drawing.Font font;
                System.Drawing.Drawing2D.LinearGradientBrush b = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Point(0, 40), new System.Drawing.Point(30, 130), System.Drawing.Color.GreenYellow, System.Drawing.Color.LemonChiffon);
                for (int i = 0; i < SessionClass.Flow.Count; i++)
                {
                    if (((Node)SessionClass.Flow[i]).type == 1)
                    {
                        font = new System.Drawing.Font("Arial Unicode MS", 9, System.Drawing.FontStyle.Regular);
                        g.DrawImageUnscaled(System.Drawing.Image.FromFile(HttpContext.Current.Request.MapPath("tskRect.png")), x - 3, y);
                        g.DrawString(((Node)SessionClass.Flow[i]).fromTitle.Substring(0, ((Node)SessionClass.Flow[i]).fromTitle.Length > 56 ? 56 : ((Node)SessionClass.Flow[i]).fromTitle.Length), font, System.Drawing.Brushes.Black, new System.Drawing.Rectangle(x + 35, y + 8, 170, 40), f);
                        y += 85;
                    }
                    else
                    {
                        font = new System.Drawing.Font("Arial Unicode MS", 10, System.Drawing.FontStyle.Regular);
                        g.DrawImageUnscaled(System.Drawing.Image.FromFile(HttpContext.Current.Request.MapPath("tskOval.png")), x, y);
                        g.DrawString(((Node)SessionClass.Flow[i]).fromTitle.Substring(0, ((Node)SessionClass.Flow[i]).fromTitle.Length > 52 ? 52 : ((Node)SessionClass.Flow[i]).fromTitle.Length), font, System.Drawing.Brushes.Black, new System.Drawing.Rectangle(x + 30, y + 6, 172, 40), f);
                        y += 85;
                    }
                    if (((Node)SessionClass.Flow[i]).from == -1)
                    {
                        break;
                    }
                }

                if (SessionClass.Flow.Count > 0)
                {
                    x = 100;
                    y = 10;
                    int y1, y2;
                    for (int i = 1; i < SessionClass.Flow.Count; i++)
                    {
                        System.Drawing.Pen p = new System.Drawing.Pen(System.Drawing.Color.Black);
                        p.Width = 1.5F;
                        y1      = (((i) * 50) + y + ((i - 1) * 35));
                        y2      = (((i) * 50) + y + ((i) * 35));
                        g.DrawLine(p, 200, y1 + 2, 200, y2);
                        System.Drawing.Point[] pns = new System.Drawing.Point[4];
                        pns[0] = new System.Drawing.Point(195, y2 - 5);
                        pns[1] = new System.Drawing.Point(200, y2);
                        pns[2] = new System.Drawing.Point(205, y2 - 5);
                        pns[3] = new System.Drawing.Point(195, y2 - 5);
                        g.FillPolygon(System.Drawing.Brushes.Black, pns);

                        g.DrawString(((Node)SessionClass.Flow[i - 1]).decision.Equals("True")?"Yes":"No", new System.Drawing.Font("Arial Unicode MS", 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, new System.Drawing.Point(205, y1 + 6));
                        if (((Node)SessionClass.Flow[i]).from == -1)
                        {
                            break;
                        }
                    }
                }
                string res = HttpContext.Current.Server.MapPath("Results") + "\\User" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".png";
                bm.Save(res, System.Drawing.Imaging.ImageFormat.Png);
                return("Results/" + res.Replace(HttpContext.Current.Server.MapPath("Results") + "\\", ""));
            }
            return("");
        }
Beispiel #17
0
        public void ShowSpecialChar(
            System.Drawing.Graphics CurGraphics,
            System.Char CurChar,
            System.Int32 Y,
            System.Int32 X,
            System.Drawing.Color CurFGColor,
            System.Drawing.Color CurBGColor)
        {
            //prntSome.printSome("ShowSpecialChar");
            if (CurChar == '\0')
            {
                return;
            }
            switch (CurChar)
            {
            case '`':     // diamond

                System.Drawing.Point[] CurPoints = new System.Drawing.Point[4];

                CurPoints[0] = new System.Drawing.Point(X + this.CharSize.Width / 2, Y + this.CharSize.Height / 6);
                CurPoints[1] = new System.Drawing.Point(X + 5 * this.CharSize.Width / 6, Y + this.CharSize.Height / 2);
                CurPoints[2] = new System.Drawing.Point(X + this.CharSize.Width / 2, Y + 5 * this.CharSize.Height / 6);
                CurPoints[3] = new System.Drawing.Point(X + this.CharSize.Width / 6, Y + this.CharSize.Height / 2);

                CurGraphics.FillPolygon(
                    new System.Drawing.SolidBrush(CurFGColor),
                    CurPoints);
                break;

            case 'l':
            case 'Z':     // top left bracket
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2 - 1, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                break;

            case 'q':
            case 'D':     // horizontal line
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                break;

            case 'B':     // top tee-piece
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                break;

            case '?':     // top right bracket
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                break;

            case '3':     // vertical line
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                break;

            case 'C':     // left hand tee-piece
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                break;

            case 'E':     // cross piece
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                break;

            case '4':     // right hand tee-piece
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height);
                break;

            case '@':     // bottom left bracket
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                break;

            case 'A':     // bottom tee-piece
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                break;

            case 'Y':     // bottom right bracket
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X, Y + this.CharSize.Height / 2,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                CurGraphics.DrawLine(new System.Drawing.Pen(CurFGColor, 1),
                                     X + this.CharSize.Width / 2, Y,
                                     X + this.CharSize.Width / 2, Y + this.CharSize.Height / 2);
                break;

            default:
                break;
            }
        }