Beispiel #1
0
        public void ComputeTransLastHitGeometry()
        {
            switch (scMgr.GraphicsType)
            {
            case GraphicsType.GDIPLUS:

                if (hitGraphicsPath == null)
                {
                    return;
                }

                transLastHitGraphicsPath = (GraphicsPath)hitGraphicsPath.Clone();
                transLastHitGraphicsPath.Transform(globalMatrix);
                break;

            case GraphicsType.D2D:

                if (hitPathGeometry == null)
                {
                    return;
                }

                SharpDX.Direct2D1.Factory d2dFactory = D2DGraphics.d2dFactory;
                RawMatrix3x2 m32 = GDIDataD2DUtils.TransMatrixToRawMatrix3x2(globalMatrix);
                transLastHitPathGeometry = new TransformedGeometry(d2dFactory, hitPathGeometry, m32);
                break;
            }
        }
Beispiel #2
0
        public override GraphicsPath GetPath()
        {
            GraphicsPath gpLocal = (GraphicsPath)r_model.Clone();

            Matrix mat = new Matrix();

            mat.Translate(base.Pos.X, base.Pos.Y);
            mat.Rotate(_fRot);
            gpLocal.Transform(mat);

            if (Pos.X > (base.clientSize.Width - size))
            {
                GraphicsPath gpWrap = (GraphicsPath)r_model.Clone();
                Matrix       mat2   = new Matrix();
                mat2.Translate((Pos.X - base.clientSize.Width), Pos.Y);
                mat2.Rotate(_fRot, MatrixOrder.Prepend);
                gpWrap.Transform(mat2);
                gpLocal.AddPath(gpWrap, true);
            }

            else if (Pos.X < size)
            {
                GraphicsPath gpWrap = (GraphicsPath)r_model.Clone();
                Matrix       mat2   = new Matrix();
                mat2.Translate(Pos.X + base.clientSize.Width, Pos.Y);
                mat2.Rotate(_fRot, MatrixOrder.Prepend);
                gpWrap.Transform(mat2);
                gpLocal.AddPath(gpWrap, true);
            }

            if (Pos.Y > (base.clientSize.Height - size))
            {
                GraphicsPath gpWrap = (GraphicsPath)r_model.Clone();
                Matrix       mat2   = new Matrix();
                mat2.Translate(Pos.X, Pos.Y - base.clientSize.Height);
                mat2.Rotate(_fRot, MatrixOrder.Prepend);
                gpWrap.Transform(mat2);
                gpLocal.AddPath(gpWrap, true);
            }

            else if (Pos.Y < size)
            {
                GraphicsPath gpWrap = (GraphicsPath)r_model.Clone();
                //Do translation or movement
                Matrix mat2 = new Matrix();
                mat2.Translate(Pos.X, Pos.Y + base.clientSize.Height);
                mat2.Rotate(_fRot, MatrixOrder.Prepend);
                gpWrap.Transform(mat2);
                gpLocal.AddPath(gpWrap, true);
            }

            return(gpLocal);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the path of the laser and translatesd it
        /// </summary>
        /// <returns>Translated graphics path</returns>
        public override GraphicsPath GetPath()
        {
            GraphicsPath laser = (GraphicsPath)_model.Clone();

            Matrix matrice = new Matrix();

            matrice.Translate(_pos.X, _pos.Y);
            //Scale/4 to be the right size compared to ship and rest
            matrice.Scale(_scale / 4, _scale / 4);
            matrice.Rotate(_rot);
            laser.Transform(matrice);
            return(laser);
        }
Beispiel #4
0
        public GraphicsPath GetPath()
        {
            GraphicsPath gpClone = (GraphicsPath)_playerModel.Clone();

            Matrix cloneMatrix = new Matrix();

            cloneMatrix.Translate(_pos.X, _pos.Y);
            cloneMatrix.Rotate(_currentRot);
            cloneMatrix.Scale(20, 20);

            gpClone.Transform(cloneMatrix);

            return(gpClone);
        }
Beispiel #5
0
 private PathGradientBrush GetSpecialCapBrush(GaugeGraphics g, GraphicsPath path, PointF pointOrigin, float angle, Color fillColor, GradientType fillGradientType, Color fillGradientEndColor, GaugeHatchStyle fillHatchStyle)
 {
     using (GraphicsPath graphicsPath = (GraphicsPath)path.Clone())
     {
         graphicsPath.Flatten(null, 0.3f);
         graphicsPath.Reset();
         RectangleF bounds = path.GetBounds();
         bounds.Inflate(-20f, -20f);
         PointF[] points = new PointF[4]
         {
             new PointF(bounds.Left, bounds.Top),
             new PointF(bounds.Right, bounds.Top),
             new PointF(bounds.Right, bounds.Bottom),
             new PointF(bounds.Left, bounds.Bottom)
         };
         graphicsPath.AddLines(points);
         PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);
         pathGradientBrush.SurroundColors = new Color[4]
         {
             Color.Red,
             Color.Green,
             Color.Blue,
             Color.Green
         };
         pathGradientBrush.CenterColor = Color.Transparent;
         pathGradientBrush.CenterPoint = new PointF(bounds.Left, bounds.Top);
         pathGradientBrush.RotateTransform(angle, MatrixOrder.Append);
         pathGradientBrush.TranslateTransform(pointOrigin.X, pointOrigin.Y, MatrixOrder.Append);
         return(pathGradientBrush);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="color"></param>
        /// <param name="size"></param>
        /// <param name="haloColor"></param>
        /// <param name="haloRadius"></param>
        /// <param name="fontName"></param>
        protected override void DrawText(Target2DWrapper <Graphics> target, double x, double y, string text, int color, double size,
                                         int?haloColor, int?haloRadius, string fontName)
        {
            float      sizeInPixels = this.ToPixels(size);
            Color      textColor    = Color.FromArgb(color);
            Font       font         = new Font(FontFamily.GenericSansSerif, sizeInPixels);
            SolidBrush brush        = new SolidBrush(textColor);

            double[]     transformed   = this.Tranform(x, y);
            float        transformedX  = (float)transformed[0];
            float        transformedY  = (float)transformed[1];
            Brush        haloBrush     = null;
            GraphicsPath characterPath = new GraphicsPath();

            characterPath.AddString(text, font.FontFamily, (int)font.Style, font.Size, new PointF(transformedX, transformedY),
                                    StringFormat.GenericTypographic);
            if (haloColor.HasValue && haloRadius.HasValue && haloRadius.Value > 0)
            {
                haloBrush = new SolidBrush(Color.FromArgb(haloColor.Value));

                GraphicsPath haloPath = characterPath.Clone() as GraphicsPath;
                using (haloPath)
                {
                    haloPath.Widen(new Pen(haloBrush, haloRadius.Value * 2));

                    // Draw the character
                    target.Target.FillPath(haloBrush, haloPath);
                }
            }
            // Draw the character
            target.Target.FillPath(brush, characterPath);
        }
        public GraphicsPath TransformPath(GraphicsPath path)
        {
            var p = (GraphicsPath)path.Clone();

            p.Flatten(_Transform, 0.1f);
            return(p);
        }
        // Draw some text along a GraphicsPath.
        private void DrawTextOnPath(Graphics gr, Brush brush, Font font,
                                    string txt, GraphicsPath path, ContentAlignment alignment, GraphicsPath resultPath = null)
        {
            if (resultPath != null)
            {
                resultPath.Reset();
            }

            // Make a copy so we don't mess up the original.
            path = (GraphicsPath)path.Clone();

            // Flatten the path into segments.
            path.Flatten(new Matrix(), 0.005f);

            var points = path.PathPoints;

            gr.Transform.TransformPoints(points);

            // Draw characters.
            int    start_ch    = 0;
            PointF start_point = points[0];

            for (int i = 1; i < points.Length; i++)
            {
                PointF end_point = points[i];
                DrawTextOnSegment(gr, brush, font, txt, ref start_ch, ref start_point, end_point, alignment, resultPath);
                if (start_ch >= txt.Length)
                {
                    break;
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Renders the selection.
        /// </summary>
        /// <param name="selectPath">The selection path.</param>
        /// <param name="deSelect">If set to <c>true</c> clear the selection.</param>
        private void RenderSelection(GraphicsPath selectPath, bool deSelect)
        {
            if (selectPath != null && selectPath.PointCount > 2)
            {
                path            = (GraphicsPath)selectPath.Clone();
                selectionRegion = new Region(selectPath);

                if (normalizedPath != null)
                {
                    normalizedPath.Dispose();
                    normalizedPath = null;
                }
            }
            else if (deSelect)
            {
                if (path != null)
                {
                    path.Dispose();
                    path = null;
                }

                if (normalizedPath != null)
                {
                    normalizedPath.Dispose();
                    normalizedPath = null;
                }

                if (selectionRegion != null)
                {
                    selectionRegion.Dispose();
                    selectionRegion = null;
                }
            }
            Invalidate();
        }
Beispiel #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(BackColor);
            if (_maxPeakPath == null || _resizing)
            {
                base.OnPaint(e);
                return;
            }
            var halfHeight = ClientSize.Height / 2.0f;

            using (var maxPath = (GraphicsPath)_maxPeakPath.Clone())
            {
                using (var matrix = new Matrix())
                {
                    matrix.Translate(0.0f, halfHeight);
                    matrix.Scale(ClientSize.Width, halfHeight);
                    maxPath.Transform(matrix);
                    e.Graphics.FillPath(_outerBrush, maxPath);
                    if (!_innerWaveVisible)
                    {
                        return;
                    }
                    using (var avgPath = (GraphicsPath)_avgPeakPath.Clone())
                    {
                        matrix.Scale(1.0f, 0.5f);
                        avgPath.Transform(matrix);
                        e.Graphics.FillPath(_innerBrush, avgPath);
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Path returns as a queue starting with hull, window, and boost to make sure they draw in the correct dequeue order
        /// </summary>
        /// <returns></returns>
        public override Queue <Tuple <GraphicsPath, Brush> > GetPath()
        {
            //Fade color if faded
            Color hullColor = Fade > 0 && (m_AnimationTimer.ElapsedMilliseconds & 1 << c_FadeFlashBit) > 0 ? Color.FromArgb(c_FadeAlpha, m_Color.R, m_Color.G, m_Color.B) : m_Color;
            Queue <Tuple <GraphicsPath, Brush> > queue = new Queue <Tuple <GraphicsPath, Brush> >();
            //Get clones for all pieces
            GraphicsPath tempHull  = (GraphicsPath)m_Hull.Clone();
            GraphicsPath tempWin   = (GraphicsPath)m_Window.Clone();
            GraphicsPath tempBoost = (GraphicsPath)m_Booster.Clone();

            //Do rest of ship
            Matrix mainMatrix = new Matrix();

            mainMatrix.Scale(c_ShipScale, c_ShipScale);
            mainMatrix.Rotate(m_fRotation, MatrixOrder.Append);
            mainMatrix.Translate(m_pLocation.X, m_pLocation.Y, MatrixOrder.Append);
            tempHull.Transform(mainMatrix);
            tempWin.Transform(mainMatrix);
            queue.Enqueue(new Tuple <GraphicsPath, Brush>(tempHull, new SolidBrush(hullColor)));
            queue.Enqueue(new Tuple <GraphicsPath, Brush>(tempWin, new SolidBrush(Color.LightBlue)));
            //Do booster size scaling
            if (m_LinearSpeed > 0)
            {
                Matrix boosterMatrix = new Matrix();
                boosterMatrix.Scale(1, m_LinearSpeed / c_MaxLinearSpeed);
                tempBoost.Transform(boosterMatrix);
                tempBoost.Transform(mainMatrix);
                queue.Enqueue(new Tuple <GraphicsPath, Brush>(tempBoost, new SolidBrush(Color.Goldenrod)));
            }

            return(queue);
        }
Beispiel #12
0
        protected override void CreateHandles()
        {
            if (Container == null)
            {
                return;
            }
            SetHandles(new Handles());

            //Get the default graphics path and scale it
            IRender      render      = RenderFromContainer();
            GraphicsPath defaultPath = (GraphicsPath)Component.Instance.DefaultHandlePath.Clone();
            Matrix       matrix      = new Matrix();

            matrix.Scale(render.ZoomFactor, render.ZoomFactor);
            defaultPath.Transform(matrix);
            RectangleF pathRectangle = defaultPath.GetBounds();
            RectangleF halfRectangle = new RectangleF(0, 0, pathRectangle.Width / 2, pathRectangle.Height / 2);

            //Loop through each point and add an offset handle
            GraphicsPath path;

            foreach (PointF point in Points)
            {
                path = (GraphicsPath)defaultPath.Clone();
                matrix.Reset();
                matrix.Translate(point.X - Rectangle.X - halfRectangle.Width, point.Y - Rectangle.Y - halfRectangle.Height);
                path.Transform(matrix);
                Handles.Add(new Handle(path, HandleType.Origin));
            }

            Handles[0].CanDock = true;
            Handles[Handles.Count - 1].CanDock = true;
        }
        /// <summary>
        /// Creates a path in form of rounded rectangle. This path is used as shape of the button.
        /// </summary>
        /// <returns>Created path</returns>
        private GraphicsPath CreateBorderPath()
        {
            using (GraphicsPath borderPath = new GraphicsPath())
            {
                const int Radius        = 3;
                const int HorizontalPad = 1;
                const int VerticalPad   = 1;
                int       width         = Width - VerticalPad * 2;
                int       height        = Height - HorizontalPad * 2;
                borderPath.AddLine(HorizontalPad + Radius, VerticalPad, HorizontalPad + width - Radius * 2, VerticalPad);
                borderPath.AddArc(HorizontalPad + width - Radius * 2, VerticalPad, Radius * 2, Radius * 2, 270, 90);
                borderPath.AddLine(HorizontalPad + width, VerticalPad + Radius, HorizontalPad + width,
                                   VerticalPad + height - Radius * 2);
                borderPath.AddArc(HorizontalPad + width - Radius * 2, VerticalPad + height - Radius * 2, Radius * 2,
                                  Radius * 2, 0,
                                  90);
                borderPath.AddLine(HorizontalPad + width - Radius * 2, VerticalPad + height, HorizontalPad + Radius,
                                   VerticalPad + height);
                borderPath.AddArc(HorizontalPad, VerticalPad + height - Radius * 2, Radius * 2, Radius * 2, 90, 90);
                borderPath.AddLine(HorizontalPad, VerticalPad + height - Radius * 2, HorizontalPad, VerticalPad + Radius);
                borderPath.AddArc(HorizontalPad, VerticalPad, Radius * 2, Radius * 2, 180, 90);
                borderPath.CloseFigure();

                return((GraphicsPath)borderPath.Clone());
            }
        }
            /// <summary>Draws the grip in the graphics context.</summary>
            /// <param name="g">Graphics context.</param>
            /// <param name="pageScale">Current zoom factor that can be used to calculate pen width etc. for displaying the handle. Attention: this factor must not be used to transform the path of the handle.</param>
            public void Show(Graphics g, double pageScale)
            {
                var shape = (GraphicsPath)_rotationGripShape.Clone();

                shape.Transform(_spanningHalfYRhombus);
                g.FillPath(Brushes.Blue, shape);
            }
Beispiel #15
0
        public static RectangleF GetBounds(GraphicsPath path, Matrix matrix)
        {
            GraphicsPath path1 = (GraphicsPath)path.Clone();

            path1.Flatten(matrix, 0.5f);
            return(path1.GetBounds());
        }
        public static Image ApplyRegionPathToImage(Image backgroundImage, GraphicsPath regionFillPath, SurfaceOptions options)
        {
            if (backgroundImage != null && regionFillPath != null)
            {
                Image img;

                Rectangle regionArea      = Rectangle.Round(regionFillPath.GetBounds());
                Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
                Rectangle newRegionArea   = Rectangle.Intersect(regionArea, screenRectangle);

                using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
                {
                    using (Matrix matrix = new Matrix())
                    {
                        gp.CloseFigure();
                        matrix.Translate(-Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                        gp.Transform(matrix);
                    }

                    img = ImageHelpers.CropImage(backgroundImage, newRegionArea, gp);
                }

                return(img);
            }

            return(null);
        }
Beispiel #17
0
        public GeometryGraphicsPath Clone()
        {
            GeometryGraphicsPath path = new GeometryGraphicsPath((GraphicsPath)gdiPath.Clone());

            path.tooComplex = this.tooComplex;
            return(path);
        }
Beispiel #18
0
        public override void draw(Graphics g)
        {
            int          x         = getX();
            int          y         = getY();
            int          direction = getDirection();
            Matrix       trans     = new Matrix();
            Matrix       transOrig = new Matrix();
            Matrix       rot       = new Matrix();
            GraphicsPath path      = (GraphicsPath)sPath.Clone();
            Color        c         = Color.Black;
            Pen          p         = new Pen(c);

            path.AddString(health.ToString(), FontFamily.GenericMonospace, 0, 10, new PointF(0, 12), StringFormat.GenericDefault);

            trans.Translate(x, y);
            transOrig.Translate(-5, -5);
            rot.Rotate(direction * 45);

            path.Transform(transOrig);
            path.Transform(rot);
            path.Transform(trans);
            g.DrawPath(p, path);

            this.bounds = path.GetBounds();
        }
        ///// <summary>
        ///// Updates the background drawing
        ///// </summary>
        //protected virtual void UpdateBackground()
        //{
        //    if (Width == 0 || Height == 0)
        //    {
        //        return;
        //    }
        //    m_Background = new Bitmap(Width, Height);
        //    Graphics g = Graphics.FromImage(m_Background);
        //    g.FillRectangle(new SolidBrush(BackColor), 0, 0, Width, Height);
        //    if (GridSize.X > 0 && GridSize.Y > 0)
        //    {
        //        for (int i = m_GridSize.X; i < Width; i += m_GridSize.X)
        //        {
        //            for (int j = m_GridSize.X; j < Height; j += m_GridSize.Y)
        //            {
        //                (m_Background as Bitmap).SetPixel(i, j, m_GridColor);
        //            }
        //        }
        //    }
        //    g.DrawLine(new Pen(m_GridColor), 0, m_Offset.Y, Width, m_Offset.Y);
        //    g.DrawLine(new Pen(m_GridColor), m_Offset.X, 0, m_Offset.X, Height);
        //}

        /// <summary>
        /// Updates the symbol drawing
        /// </summary>
        protected virtual void UpdateDrawing()
        {
            if (Width == 0 || Height == 0)
            {
                return;
            }
            m_Drawing = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(m_Drawing);

            g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Width, Height);
            if (m_Element != null)
            {
                m_Element.Paint(g);
            }
            else
            {
                if (m_Path != null)
                {
                    GraphicsPath path        = (GraphicsPath)m_Path.Clone();
                    Matrix       translation = ComputeTranslationMatrix();
                    path.Transform(translation);
                    g.DrawPath(Pens.Black, path);
                }
            }
        }
Beispiel #20
0
        public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options)
        {
            if (regionFillPath != null)
            {
                Image img;

                Rectangle regionArea      = Rectangle.Round(regionFillPath.GetBounds());
                Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
                Rectangle newRegionArea   = Rectangle.Intersect(regionArea, screenRectangle);

                using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
                {
                    MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                    img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp);

                    if (options.DrawBorder)
                    {
                        GraphicsPath gpOutline = regionDrawPath ?? regionFillPath;

                        using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone())
                        {
                            MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                            img = ImageHelpers.DrawOutline(img, gp2);
                        }
                    }
                }

                return(img);
            }

            return(null);
        }
Beispiel #21
0
        public override GraphicsPath GetPath()
        {
            //Matrix for containing the tranforms
            Matrix MatTrans = new Matrix();

            //translate first
            MatTrans.Translate(location.X, location.Y);
            //then rotate
            MatTrans.Rotate(_fRotation);
            //creating a working path
            GraphicsPath temp = (GraphicsPath)_Model.Clone();

            //adding the string that shows the score
            temp.AddString(_score, FontFamily.GenericSansSerif, (int)FontStyle.Regular, 20, new PointF(0, 0), StringFormat.GenericTypographic);
            //adding a visual life counter for each life the player has
            for (int i = 0; i < _lives; i++)
            {
                int x = (i * 20);

                temp.AddPolygon(new PointF[] { new PointF(10 + x, 25), new PointF(0 + x, 50), new PointF(10 + x, 47), new PointF(20 + x, 50) });
                //_Model.AddPath(temp, false);
            }
            //applying transforms
            temp.Transform(MatTrans);
            //creating a region for distance checking
            Region reg = new Region(temp);

            return(temp);
        }
        public PdnGraphicsPath Clone()
        {
            PdnGraphicsPath path = new PdnGraphicsPath((GraphicsPath)gdiPath.Clone());

            path.tooComplex = this.tooComplex;
            return(path);
        }
Beispiel #23
0
        // </snippet15>

        // Snippet for: M:System.Drawing.Drawing2D.GraphicsPath.Clone
        // <snippet16>
        private void CloneExample(PaintEventArgs e)
        {
            // Set several markers in a path.
            GraphicsPath myPath = new GraphicsPath();

            myPath.AddEllipse(0, 0, 100, 200);
            myPath.AddLine(new Point(100, 100), new Point(200, 100));
            Rectangle rect = new Rectangle(200, 0, 100, 200);

            myPath.AddRectangle(rect);
            myPath.AddLine(new Point(250, 200), new Point(250, 300));

            // Draw the path to the screen.
            Pen myPen = new Pen(Color.Black, 2);

            e.Graphics.DrawPath(myPen, myPath);

            // Clone a copy of myPath.
            GraphicsPath myPath2 = (GraphicsPath)myPath.Clone();

            // Draw the path to the screen.
            Pen myPen2 = new Pen(Color.Red, 4);

            e.Graphics.DrawPath(myPen2, myPath2);
        }
Beispiel #24
0
        void DrawOutlineText(Graphics g, String text, Font font, Rectangle r, Brush b, Color line)
        {
            // set atialiasing
            g.SmoothingMode = SmoothingMode.HighQuality;

            // make thick pen for outlining
            Pen pen = new Pen(line, 3);

            // round line joins of the pen
            pen.LineJoin = LineJoin.Round;

            // create graphics path
            GraphicsPath textPath = new GraphicsPath();

            // convert string to path
            textPath.AddString(text, font.FontFamily, (int)font.Style, font.Size, r, StringFormat.GenericTypographic);

            // clone path to make outlining path
            GraphicsPath outlinePath = (GraphicsPath)textPath.Clone();

            // outline the path
            outlinePath.Widen(pen);
            Brush br = new SolidBrush(line);

            // fill outline path with some color
            g.FillPath(br, outlinePath);
            // fill original text path with some color
            g.FillPath(b, textPath);
        }
Beispiel #25
0
        void DrawElemBound(AutoElem ae, Graphics g, Color ForeColor, string Text)
        {
            if (ae == null || !ae.Available())
            {
                return;
            }

            Rect BudRc = ae.Current.BoundingRectangle;

            if (BudRc == Rect.Empty)
            {
                return;
            }
            var ClientRc = this.RectangleToClient(BudRc.ToRectangle());

            var ForeBrush = new SolidBrush(ForeColor);
            var ForePen   = new Pen(ForeBrush, 3);
            var BackBrush = new SolidBrush(ForeColor.RevColor());
            var BackPen   = new Pen(BackBrush, 5);

            g.DrawRectangle(BackPen, ClientRc);
            g.DrawRectangle(ForePen, ClientRc);

            if (Text != "" && Text != null)
            {
                GraphicsPath gp = new GraphicsPath();
                gp.AddString(Text, this.Font.FontFamily, (int)Font.Style, Font.Size,
                             new Point(ClientRc.Left, ClientRc.Top), StringFormat.GenericDefault);
                var ogp = (GraphicsPath)gp.Clone();
                gp.Widen(BackPen);
                g.FillPath(BackBrush, gp);
                g.FillPath(ForeBrush, ogp);
            }
        }
Beispiel #26
0
    protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
    {
        grfx.ScaleTransform(cx / 300f, cy / 200f);

        for (int i = 0; i < 6; i++)
        {
            GraphicsPath pathClone = (GraphicsPath)path.Clone();
            Matrix       matrix    = new Matrix();
            Pen          penThin   = new Pen(clr, 1);
            Pen          penThick  = new Pen(clr, 5);
            Pen          penWiden  = new Pen(clr, 7.5f);
            Brush        brush     = new SolidBrush(clr);

            matrix.Translate((i % 3) * 100, (i / 3) * 100);

            if (i < 3)
            {
                pathClone.Transform(matrix);
            }
            else
            {
                pathClone.Widen(penWiden, matrix);
            }

            switch (i % 3)
            {
            case 0:  grfx.DrawPath(penThin, pathClone);   break;

            case 1:  grfx.DrawPath(penThick, pathClone);  break;

            case 2:  grfx.FillPath(brush, pathClone);     break;
            }
        }
    }
Beispiel #27
0
        /// <summary>
        /// This is a helper function for the update arrows function it draws the arrow at a correct location
        /// using combination of translation
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        private GraphicsPath GenerateTransforms(int size)
        {
            //creates a ship
            //create a points of array
            PointF[] points = new PointF[4];
            //create a graphics path
            GraphicsPath gp = new GraphicsPath();

            //add points to the array of points
            points[0] = new PointF(0, 0);
            points[1] = new PointF(-10, 20);
            points[2] = new PointF(0, 10);
            points[3] = new PointF(10, 20);
            //create a path
            gp.StartFigure();
            gp.AddLines(points);
            gp.CloseFigure();

            //apply transformation according to the suplied x argument on the same row
            Matrix transforms = new Matrix();

            transforms.Translate(size, 40);
            GraphicsPath obj = (GraphicsPath)gp.Clone();

            obj.Transform(transforms);
            //returns the new path with the ship drawn
            return(obj);
        }
 public override object Clone()
 {
     return(new DrawablePath {
         Path = Path?.Clone() as GraphicsPath,
         Brush = Brush?.Clone() as Brush,
         Pen = Pen?.Clone() as Pen
     });
 }
        public void Rotate(double angle)
        {
            gp = (GraphicsPath)gpBase.Clone();
            Matrix mTransform = new Matrix();

            mTransform.RotateAt((float)angle, new PointF(midX, midY));
            gp.Transform(mTransform);
        }
Beispiel #30
0
 public HatchLoop Clone()
 {
     return
         (new HatchLoop(
              Boundary.Clone() as GraphicsPath,
              LayerName,
              TypeName));
 }