상속: IBracket
예제 #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();
        }
예제 #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);
        }
예제 #4
0
        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);
        }
예제 #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();
        }
예제 #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();
        }
예제 #7
0
 public virtual void FillPath(GDIBrush aBrush, GPath aPath)
 {
 }
예제 #8
0
 public virtual void DrawPath(GDIPen aPen, GPath aPath)
 {
 }
예제 #9
0
 public virtual void FillPath(IBrush aBrush, GPath aPath)
 {
     if (null != FillPathHandler)
         FillPathHandler(aBrush, aPath);
 }
예제 #10
0
 public virtual void DrawPath(IPen aPen, GPath aPath)
 {
     if (null != DrawPathHandler)
         DrawPathHandler(aPen, aPath);
 }
예제 #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;
        }