Esempio n. 1
0
        private void CreateObjects()
        {
            brSolid = new SolidBrushPlus(Color.CornflowerBlue);
            penSolid = new PenPlus(Color.Red, 10);
            penSolid.SetEndCap(LineCap.LineCapRound);
            penSolid.SetStartCap(LineCap.LineCapArrowAnchor);

            brHatch = new HatchBrush(HatchStyle.HatchStyle25Percent,
                Color.Black, Color.White);
            penHatch = new PenPlus(brHatch, 10);

            penSolidTrans = new PenPlus(Color.FromArgb(-0x5f7f7f7f), 10);

            penSolidCustomCap = new PenPlus(Color.Black, 20);
            GraphicsPath path = new GraphicsPath(FillMode.FillModeAlternate);
            path.AddEllipse(-0.5f, -1.5f, 1, 3);
            CustomLineCap cap = new CustomLineCap(null, path, LineCap.LineCapFlat, 0);
            penSolidCustomCap.SetCustomEndCap(cap);

            penDash = new PenPlus(Color.Black, 5);
            penDash.SetDashStyle(DashStyle.DashStyleDot);

            brGrad = new LinearGradientBrush(
                new GpPointF(0, 0), new GpPointF(100, 100),
                Color.Black, Color.White);
            penGradient = new PenPlus(brGrad, 30);
        }
Esempio n. 2
0
        public bool IsOutlineVisible(float x,
                                     float y,
                                     PenPlus pen,
                                     GraphicsPlus g)
        {
            bool ret;

            SetStatus(NativeMethods.GdipIsOutlineVisiblePathPoint(nativePath, x, y, pen.nativePen, g.nativeGraphics, out ret));
            return(ret);
        }
Esempio n. 3
0
        public GpStatus Widen(
            PenPlus pen,
            Matrix matrix,
            float flatness
            )
        {
            GpMatrix nativeMatrix = new GpMatrix();

            if (matrix != null)
            {
                nativeMatrix = matrix.nativeMatrix;
            }

            return(SetStatus(NativeMethods.GdipWidenPath(
                                 nativePath,
                                 pen.nativePen,
                                 nativeMatrix,
                                 flatness
                                 )));
        }
Esempio n. 4
0
        private void drawRotatedArrow(GraphicsPlus graphics)
        {
            Debug.WriteLine("drawRotatedArrow: " + this.rotationAngle, this.ToString());

            Point center = new Point(this.Width / 2, this.Height / 2);

            int arWidthHalf = ARROW_WIDTH / 2;
            //int arHeightHalf = ARROW_HEIGHT / 2;

            Point[] arrowPoints = {
                new Point(center.X, center.Y - arWidthHalf),
                new Point(center.X - 2*arWidthHalf/3, center.Y + arWidthHalf),
                new Point(center.X + 2*arWidthHalf/3, center.Y + arWidthHalf),
                new Point(center.X, center.Y + arWidthHalf/2)
            };
            Debug.WriteLine("drawRotatedArrow: points "
                + PointUtil.pointsStr(arrowPoints), this.ToString());

            PointMath.RotatePoints(arrowPoints, center, this.rotationAngle);
            Debug.WriteLine("drawRotatedArrow: points "
                + PointUtil.pointsStr(arrowPoints), this.ToString());

            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            PenPlus pen = new PenPlus(ARROW_COLOR, 3);
            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);

            graphics.DrawLine(pen, new GpPoint(arrowPoints[0].X, arrowPoints[0].Y),
                                   new GpPoint(arrowPoints[1].X, arrowPoints[1].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[1].X, arrowPoints[1].Y),
                                   new GpPoint(arrowPoints[3].X, arrowPoints[3].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[3].X, arrowPoints[3].Y),
                                   new GpPoint(arrowPoints[2].X, arrowPoints[2].Y));
            graphics.DrawLine(pen, new GpPoint(arrowPoints[2].X, arrowPoints[2].Y),
                                   new GpPoint(arrowPoints[0].X, arrowPoints[0].Y));
            pen.Dispose();
        }
Esempio n. 5
0
 public GpStatus DrawEllipse(PenPlus pen,
                    int x,
                    int y,
                    int width,
                    int height)
 {
     return SetStatus(NativeMethods.GdipDrawEllipseI(nativeGraphics,
                                                   pen.nativePen,
                                                   x,
                                                   y,
                                                   width,
                                                   height));
 }
Esempio n. 6
0
 public GpStatus DrawCurve(PenPlus pen,
                   GpPoint[] points,
                  int offset,
                  int numberOfSegments,
                  float tension)
 {
     return SetStatus(NativeMethods.GdipDrawCurve3I(nativeGraphics,
                                                  pen.nativePen,
                                                  points,
                                                  points.Length,
                                                  offset,
                                                  numberOfSegments,
                                                  tension));
 }
Esempio n. 7
0
 public GpStatus DrawCurve(PenPlus pen,
                   GpPointF[] points)
 {
     return SetStatus(NativeMethods.GdipDrawCurve(nativeGraphics,
                                                pen.nativePen, points,
                                                points.Length));
 }
Esempio n. 8
0
 public GpStatus DrawBezier(PenPlus pen,
                   int x1,
                   int y1,
                   int x2,
                   int y2,
                   int x3,
                   int y3,
                   int x4,
                   int y4)
 {
     return SetStatus(NativeMethods.GdipDrawBezierI(nativeGraphics,
                                                  pen.nativePen,
                                                  x1,
                                                  y1,
                                                  x2,
                                                  y2,
                                                  x3,
                                                  y3,
                                                  x4,
                                                  y4));
 }
Esempio n. 9
0
 public bool IsOutlineVisible(GpPoint point,
                   PenPlus pen,
                   GraphicsPlus g)
 {
     return IsOutlineVisible(point.X, point.Y, pen, g);
 }
Esempio n. 10
0
 public bool IsOutlineVisible(float x,
                   float y,
                   PenPlus pen,
                   GraphicsPlus g)
 {
     bool ret;
     SetStatus(NativeMethods.GdipIsOutlineVisiblePathPoint(nativePath, x, y, pen.nativePen, g.nativeGraphics, out ret));
     return ret;
 }
Esempio n. 11
0
        public GpStatus Widen(
        PenPlus pen,
        Matrix matrix,
        float flatness
    )
        {
            GpMatrix nativeMatrix = new GpMatrix();
            if (matrix != null)
                nativeMatrix = matrix.nativeMatrix;

            return SetStatus(NativeMethods.GdipWidenPath(
                nativePath,
                pen.nativePen,
                nativeMatrix,
                flatness
            ));
        }
Esempio n. 12
0
 /// <summary>
 ///   Initializes a new instance of <c>PieSlice</c> class with given 
 ///   bounds and visual style.
 /// </summary>
 /// <param name="xBoundingRect">
 ///   x-coordinate of the upper-left corner of the rectangle that is 
 ///   used to draw the top surface of the pie slice.
 /// </param>
 /// <param name="yBoundingRect">
 ///   y-coordinate of the upper-left corner of the rectangle that is 
 ///   used to draw the top surface of the pie slice.
 /// </param>
 /// <param name="widthBoundingRect">
 ///   Width of the rectangle that is used to draw the top surface of 
 ///   the pie slice.
 /// </param>
 /// <param name="heightBoundingRect">
 ///   Height of the rectangle that is used to draw the top surface of 
 ///   the pie slice.
 /// </param>
 /// <param name="sliceHeight">
 ///   Height of the pie slice.
 /// </param>
 /// <param name="startAngle">
 ///   Starting angle (in degrees) of the pie slice.
 /// </param>
 /// <param name="sweepAngle">
 ///   Sweep angle (in degrees) of the pie slice.
 /// </param>
 /// <param name="surfaceColor">
 ///   Color used to paint the pie slice.
 /// </param>
 /// <param name="shadowStyle">
 ///   Shadow style used for slice rendering.
 /// </param>
 /// <param name="edgeColorType">
 ///   Edge color style used for slice rendering.
 /// </param>
 public PieSlice(float xBoundingRect, float yBoundingRect, float widthBoundingRect, float heightBoundingRect, float sliceHeight, float startAngle, float sweepAngle, Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType)
     : this()
 {
     // set some persistent values
     m_actualStartAngle = startAngle;
     m_actualSweepAngle = sweepAngle;
     m_surfaceColor = surfaceColor;
     m_shadowStyle = shadowStyle;
     m_edgeColorType = edgeColorType;
     // create pens for rendering
     Color edgeLineColor = EdgeColor.GetRenderingColor(edgeColorType, surfaceColor);
     m_pen = new PenPlus(edgeLineColor,3);
     //m_pen.SetLineJoin(LineJoin.LineJoinRound);
     //LineJoin = LineJoin.Round;
     InitializePieSlice(xBoundingRect, yBoundingRect, widthBoundingRect, heightBoundingRect, sliceHeight);
 }
Esempio n. 13
0
 /// <summary>
 ///   Draws the outer periphery of the pie slice.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> object used to draw the surface.
 /// </param>
 /// <param name="pen">
 ///   <c>Pen</c> used to draw outline.
 /// </param>
 /// <param name="brush">
 ///   <c>Brush</c> used to fill the quadrilateral.
 /// </param>
 /// <param name="boundingRect">
 ///   Bounding rectangle that is used to draw the top surface of the 
 ///   pie slice.
 /// </param>
 /// <param name="startAngle">
 ///   Start angle (in degrees) of the periphery section.
 /// </param>
 /// <param name="endAngle">
 ///   End angle (in degrees) of the periphery section.
 /// </param>
 /// <param name="pointStart">
 ///   Point representing the start of the periphery.
 /// </param>
 /// <param name="pointEnd">
 ///   Point representing the end of the periphery.
 /// </param>
 protected void DrawCylinderSurfaceSection(GraphicsPlus graphics, PenPlus pen, BrushPlus brush, float startAngle, float endAngle, GpPointF pointStart, GpPointF pointEnd)
 {
     GraphicsPath path = CreatePathForCylinderSurfaceSection(startAngle, endAngle, pointStart, pointEnd);
     graphics.FillPath(brush, path);
     graphics.DrawPath(pen, path);
 }
Esempio n. 14
0
        private void TestGdiPlus(GraphicsPlus graphics)
        {
            graphics.DrawImage(bmp, 0, 0, ClientRectangle.Width, ClientRectangle.Height);

            PenPlus pen;

            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            pen= new PenPlus(Color.Black, 15);
            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);

            pen.SetWidth(3);

            pen.SetColor(Color.FromArgb(0x7f7f7f7f));
            pen.SetWidth(40);
            graphics.DrawLine(pen, 20, 20, ClientRectangle.Right - 20, ClientRectangle.Bottom - 20);
            graphics.DrawLine(pen, ClientRectangle.Right - 20, 20, 20, ClientRectangle.Bottom - 20);

            SmoothingMode mode = graphics.GetSmoothingMode();
            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);
            foreach(GraphicsPath p in allPaths)
                graphics.DrawPath(penWrite, p);
            graphics.SetSmoothingMode(mode);
            pen.Dispose();
        }
Esempio n. 15
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            GpStatusPlus stat = NativeMethods.GdiplusStartup(out token, input, out output);
            string bitmapPath = System.IO.Path.GetDirectoryName(GetType().Assembly.GetModules()[0].FullyQualifiedName);
            bitmapPath = System.IO.Path.Combine(bitmapPath, "test.jpg");
            StreamOnFile sf = new StreamOnFile(bitmapPath);
            bmp = new BitmapPlus(sf);
            penWrite = new PenPlus(Color.Blue, 3);

            path = new GraphicsPath(FillMode.FillModeAlternate);
        }
Esempio n. 16
0
 public GpStatus DrawArc(PenPlus pen,
                int x,
                int y,
                int width,
                int height,
                float startAngle,
                float sweepAngle)
 {
     return SetStatus(NativeMethods.GdipDrawArcI(nativeGraphics,
                                               pen.nativePen,
                                               x,
                                               y,
                                               width,
                                               height,
                                               startAngle,
                                               sweepAngle));
 }
Esempio n. 17
0
 public GpStatus DrawArc(PenPlus pen,
                 GpRect rect,
                float startAngle,
                float sweepAngle)
 {
     return DrawArc(pen,
                    rect.X,
                    rect.Y,
                    rect.Width,
                    rect.Height,
                    startAngle,
                    sweepAngle);
 }
Esempio n. 18
0
 /// <summary>
 ///   Draws the <c>Quadrilateral</c> with <c>Graphics</c> provided.
 /// </summary>
 /// <param name="graphics">
 ///   <c>Graphics</c> used to draw.
 /// </param>
 /// <param name="pen">
 ///   <c>Pen</c> used to draw outline.
 /// </param>
 /// <param name="brush">
 ///   <c>Brush</c> used to fill the inside. 
 /// </param>
 public void Draw(GraphicsPlus graphics, PenPlus pen, BrushPlus brush)
 {
     graphics.FillPath(brush, m_path);
     graphics.DrawPath(pen, m_path);
 }
Esempio n. 19
0
 public GpStatus DrawBezier(PenPlus pen,
                    GpPoint pt1,
                    GpPoint pt2,
                    GpPoint pt3,
                    GpPoint pt4)
 {
     return DrawBezier(pen,
                       pt1.X,
                       pt1.Y,
                       pt2.X,
                       pt2.Y,
                       pt3.X,
                       pt3.Y,
                       pt4.X,
                       pt4.Y);
 }
Esempio n. 20
0
 public GpStatus DrawLine(PenPlus pen,
                 GpPoint pt1,
                 GpPoint pt2)
 {
     return DrawLine(pen,
                     pt1.X,
                     pt1.Y,
                     pt2.X,
                     pt2.Y);
 }
Esempio n. 21
0
 public GpStatus DrawCurve(PenPlus pen,
                   GpPoint[] points,
                  float tension)
 {
     return SetStatus(NativeMethods.GdipDrawCurve2I(nativeGraphics,
                                                  pen.nativePen,
                                                  points,
                                                  points.Length,
                                                  tension));
 }
Esempio n. 22
0
 public GpStatus DrawPath(PenPlus pen,
                  GraphicsPath path)
 {
     return SetStatus(NativeMethods.GdipDrawPath(nativeGraphics,
                                               pen != null ? pen.nativePen : null,
                                               path != null ? path.nativePath : null));
 }
Esempio n. 23
0
 public GpStatus DrawEllipse(PenPlus pen,
                     GpRect rect)
 {
     return DrawEllipse(pen,
                        rect.X,
                        rect.Y,
                        rect.Width,
                        rect.Height);
 }
Esempio n. 24
0
 public GpStatus DrawRectangle(PenPlus pen,
                       GpRectF rect)
 {
     return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
 }
Esempio n. 25
0
 //public PixelOffsetMode GetPixelOffsetMode()
 //{
 //    PixelOffsetMode pixelOffsetMode = PixelOffsetMode.PixelOffsetModeInvalid;
 //    SetStatus(NativeMethods.GdipGetPixelOffsetMode(nativeGraphics,
 //                                                 out pixelOffsetMode));
 //    return pixelOffsetMode;
 //}
 //public GpStatus SetPixelOffsetMode(PixelOffsetMode pixelOffsetMode)
 //{
 //    return SetStatus(NativeMethods.GdipSetPixelOffsetMode(nativeGraphics,
 //                                                        pixelOffsetMode));
 //}
 //public GpStatus SetPageUnit(Unit unit)
 //{
 //    return SetStatus(NativeMethods.GdipSetPageUnit(nativeGraphics,
 //                                                 unit));
 //}
 //public Unit GetPageUnit()
 //{
 //    Unit unit;
 //    SetStatus(NativeMethods.GdipGetPageUnit(nativeGraphics, out unit));
 //    return unit;
 //}
 //public float GetPageScale()
 //{
 //    float scale;
 //    SetStatus(NativeMethods.GdipGetPageScale(nativeGraphics, out scale));
 //    return scale;
 //}
 //public float GetDpiX()
 //{
 //    float dpi;
 //    SetStatus(NativeMethods.GdipGetDpiX(nativeGraphics, out dpi));
 //    return dpi;
 //}
 //public float GetDpiY()
 //{
 //    float dpi;
 //    SetStatus(NativeMethods.GdipGetDpiY(nativeGraphics, out dpi));
 //    return dpi;
 //}
 public GpStatus DrawLine(PenPlus pen,
                 float x1,
                 float y1,
                 float x2,
                 float y2)
 {
     return SetStatus(NativeMethods.GdipDrawLine(nativeGraphics,
                                               pen.nativePen, x1, y1, x2,
                                               y2));
 }
Esempio n. 26
0
 public GpStatus DrawRectangle(PenPlus pen,
                      float x,
                      float y,
                      float width,
                      float height)
 {
     return SetStatus(NativeMethods.GdipDrawRectangle(nativeGraphics,
                                                    pen.nativePen, x, y,
                                                    width, height));
 }
Esempio n. 27
0
 public GpStatus DrawRectangles(PenPlus pen,
                        GpRect[] rects)
 {
     return SetStatus(NativeMethods.GdipDrawRectanglesI(nativeGraphics,
                                                      pen.nativePen,
                                                      rects,
                                                      rects.Length));
 }
Esempio n. 28
0
 internal GpPen GetNativePen(PenPlus pen)
 {
     return pen.nativePen;
 }
Esempio n. 29
0
 public bool IsOutlineVisible(GpPoint point,
                              PenPlus pen,
                              GraphicsPlus g)
 {
     return(IsOutlineVisible(point.X, point.Y, pen, g));
 }
Esempio n. 30
0
        private void drawDirectionLinePlus(GraphicsPlus graphics)
        {
            graphics.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias);

            PenPlus pen = new PenPlus(TARGET_LINE_COLOR, 3);
            pen.SetEndCap(LineCap.LineCapRound);
            pen.SetStartCap(LineCap.LineCapRound);

            graphics.DrawLine(pen, this.Width / 2, this.Height / 2, targetPoint.X, targetPoint.Y);
            pen.Dispose();
        }