Inheritance: IBracket
Beispiel #1
0
        public void RunOnce(GDIRenderer aPort)
        {
            // Do some path stuff
            GPath aPath = new GPath();
            
            aPath.Begin();
            aPath.MoveTo(10, 10, false);
            aPath.LineTo(10, 100, false);
            aPath.LineTo(100, 100, true);
            aPath.End();

            GDIBrush pathBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.BDiagonal, RGBColor.Cyan, Guid.NewGuid());
            aPort.FillPath(pathBrush, aPath);

            GDIPen pathPen = new GDIPen(PenType.Geometric, 
                PenStyle.Solid, 
                PenJoinStyle.Round, 
                PenEndCap.Round, 
                RGBColor.Black, 
                10, 
                Guid.NewGuid());
            //aPort.DrawPath(pathPen, aPath);

            // Now use a GDIPath
            aPort.SetBkMode((int)BackgroundMixMode.Transparent);
            aPort.SetTextColor(RGBColor.Black);

            GDIFont aFont = new GDIFont("Impact", 96, Guid.NewGuid());

            GDIContext dc = aPort.DeviceContext;
            GDIPath gdipath = new GDIPath(dc, Guid.NewGuid());
            gdipath.Begin();
            aPort.SetFont(aFont);
            aPort.DrawString(200, 200, "The Scaled Text");
            gdipath.End();
            aPort.Flush();

            // First fill the text
            aPort.FillPath(pathBrush, gdipath);

            // Then stroke the path around it
            GDIPen textPen = new GDIPen(PenType.Geometric,
                PenStyle.Solid,
                PenJoinStyle.Round,
                PenEndCap.Round,
                RGBColor.Black,
                2,
                Guid.NewGuid());
            aPort.DrawPath(textPen, gdipath);
            aPort.Flush();

        }
        public virtual void ReplayPath(GPath aPath)
        {
            BeginPath();

            bool closeFigure = false;

            for (int i = 0; i < aPath.Commands.Length; i++)
            {
                byte command = aPath.Commands[i];
                closeFigure = (command & GDI32.PT_CLOSEFIGURE) != 0;
                if (closeFigure)
                    command -= GDI32.PT_CLOSEFIGURE;

                switch (command)
                {
                    case GDI32.PT_MOVETO:
                        GDI32.MoveToEx(this, aPath.Vertices[i].X, aPath.Vertices[i].Y, IntPtr.Zero);
                        break;

                    case GDI32.PT_LINETO:
                        GDI32.LineTo(this, aPath.Vertices[i].X, aPath.Vertices[i].Y);
                        break;

                    case GDI32.PT_BEZIERTO:
                        // Consume 2 more points to call BezierTo
                        POINT[] pts = new POINT[3];
                        pts[0] = new POINT(aPath.Vertices[i].X, aPath.Vertices[i].Y);
                        pts[1] = new POINT(aPath.Vertices[i + 1].X,aPath.Vertices[i + 1].Y);
                        pts[2] = new POINT(aPath.Vertices[i + 2].X,aPath.Vertices[i + 1].Y);
                        PolyBezierTo(pts);
                        i += 2;
                        break;
                }
            }

            if (closeFigure)
                EndPath();
        }
Beispiel #3
0
        public virtual void SetPathAsClipRegion(GPath aPath)
        {
            // 1. Replay the path on the device context
            DeviceContext.ReplayPath(aPath);

            // 2. Call the right routine
            GDI32.SelectClipPath(DeviceContext, GDI32.RGN_COPY);
        }
        public override void DrawPath(IPen aPen, GPath aPath)
        {
            BufferChunk chunk = new BufferChunk(aPath.Vertices.Length * 8 + 128);
            chunk += GDI32.EMR_POLYDRAW;

            ChunkUtils.Pack(chunk, aPath.Vertices);


            for (int i = 0; i < aPath.Vertices.Length; i++)
                chunk += aPath.Commands[i];

            // Pack the pen
            ChunkUtils.Pack(chunk, aPen);

            SendCommand(chunk);
        }
Beispiel #5
0
        public virtual void FramePath(GDIPen aPen, GPath aPath)
        {
            // 1. Set the path on the context
            DeviceContext.ReplayPath(aPath);

            // 2. Set the pen
            SetPen(aPen);

            // 2. Stroke the path using the specified pen
            DeviceContext.StrokePath();
        }
Beispiel #6
0
        public virtual void FillPath(GDIBrush aBrush, GPath aPath)
        {
            // 1. Set the path on the context
            DeviceContext.ReplayPath(aPath);

            // 2. Set the brush as the active brush
            SetBrush(aBrush);

            // 3. call FillPath()
            DeviceContext.FillPath();
        }
Beispiel #7
0
 public virtual void FillPath(GDIBrush aBrush, GPath aPath)
 {
 }
Beispiel #8
0
 public virtual void DrawPath(GDIPen aPen, GPath aPath)
 {
 }
 public virtual void FillPath(IBrush aBrush, GPath aPath)
 {
     if (null != FillPathHandler)
         FillPathHandler(aBrush, aPath);
 }
Beispiel #10
0
 public virtual void DrawPath(IPen aPen, GPath aPath)
 {
     if (null != DrawPathHandler)
         DrawPathHandler(aPen, aPath);
 }
Beispiel #11
0
        public static GDIRegion CreateFromPath(GPath aPath, Guid uniqueID)
        {
            // 1. Create a simple device context
            GDIContext deviceContext = GDIContext.CreateForDefaultDisplay();

            // 2. Replay the path into the context
            deviceContext.ReplayPath(aPath);

            // 3. Create a region from the replayed path
            IntPtr regionHandle = GDI32.PathToRegion(deviceContext);

            GDIRegion newRegion = new GDIRegion(regionHandle, true, uniqueID);

            return newRegion;
        }