public void RunOnce(GDIRenderer aPort) { int cxClient = fSize.Width; int cyClient = fSize.Height; aPort.SaveState(); GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Black, Guid.NewGuid()); GDISolidBrush rectBrush = new GDISolidBrush(RGBColor.White); // Do a rectangle Rectangle rect = Rectangle.FromLTRB(cxClient / 8, cyClient / 8, (7 * cxClient / 8), (7 * cyClient / 8)); aPort.FillRectangle(rectBrush, rect.Left, rect.Top, rect.Width, rect.Height); aPort.DrawRectangle(rectPen, rect.Left, rect.Top, rect.Width, rect.Height); // Now do a couple of lines using a dash/dot/dot pen GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.DashDotDot, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Black, 1, Guid.NewGuid()); aPort.DrawLine(aPen, new Point(0, 0), new Point(cxClient, cyClient)); aPort.DrawLine(aPen, new Point(0, cyClient), new Point(cxClient, 0)); // Now an ellipse aPort.DrawEllipse(aPen, rect); // Last, a rounded rectangle Rectangle rRect = Rectangle.FromLTRB(cxClient / 4, cyClient / 4, 3 * cxClient / 4, 3 * cyClient / 4); aPort.DrawRoundRect(aPen, rRect, cxClient / 4, cyClient / 4); aPort.ResetState(); }
public void RunOnce(GDIRenderer aPort) { System.Drawing.Point[] points = new Point[10]; for (int i = 0; i < 10; i++) { points[i].X = fSize.Width * fFigure[i].X / 200; points[i].Y = fSize.Height * fFigure[i].Y / 100; } // Select a gray brush to draw with //aPort.SelectStockObject(GDI32.GRAY_BRUSH); GDIBrush aBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.Vertical, RGBColor.Blue, Guid.NewGuid()); aPort.SetBrush(aBrush); // First draw with ALTERNATE method aPort.SetPolyFillMode(PolygonFillMode.Alternate); aPort.Polygon(points); // Translate the x coordinates by half the screen for (int i = 0; i < 10; i++) { points[i].X += fSize.Width / 2; } // Now draw with WINDING method aPort.SetPolyFillMode(PolygonFillMode.Winding); aPort.Polygon(points); }
public void RunOnce(GDIRenderer aPort) { aPort.SaveState(); // Select a gray brush to draw with aPort.UseDefaultBrush(); aPort.UseDefaultPen(); aPort.SetDefaultBrushColor(RGBColor.DarkGreen); aPort.SetDefaultPenColor(RGBColor.Black); // Flip the coordinate system so 0,0 is in the lower left aPort.SetMappingMode(MappingModes.LoEnglish); //aPort.SetViewportOrigin(0, fSize.Width); aPort.ScaleTransform(1, -1); aPort.Flush(); GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Red, Guid.NewGuid()); GDIBrush rectBrush = new GDISolidBrush(RGBColor.DarkCyan); for (int i = 0; i < 4; i++) { //aPort.DrawRectangle(rectPen, rects[i].Left, rects[i].Top, rects[i].Width, rects[i].Height); aPort.StrokeAndFillRectangle(rectPen, rectBrush, rects[i]); } aPort.Flush(); aPort.ResetState(); }
public SketchWindow(int width, int height) :base() { InitializeComponent(); fBlackPen = new GDIPen(RGBColor.Black); this.Size = new System.Drawing.Size(width, height); this.Text = "Sketcher"; this.AllowDrop = true; fPointList = new List<Point>(); // Create the backing buffer to retain the image // Make it bigger than any likely displays backingBuffer = GDIDIBSection.Create(1600, 1200); GDIContext bufferContext = GDIContext.CreateForBitmap(backingBuffer); bufferContext.ClearToWhite(); fBackingGraphPort = new GDIRenderer(bufferContext); fRetainedGraphPort = new GraphPortDelegate(); fRetainedGraphPort.AddGraphPort(fBackingGraphPort); fRetainedGraphPort.AddGraphPort(GraphPort); CreateSession(); }
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 void RunOnce(GDIRenderer aPort) { // Do some region stuff GDIRegion aRegion = GDIRegion.CreateFromRectangle(10, 10, 50, 250, Guid.NewGuid()); GDIRegion bRegion = GDIRegion.CreateFromRectangle(10, 10, 50, 250, Guid.NewGuid()); GDIRegion cRegion = GDIRegion.CreateFromRectangle(0, 0, 0, 0, Guid.NewGuid()); GDIRegion dRegion = GDIRegion.CreateFromRectangle(30, 40, 200, 100, Guid.NewGuid()); bool isEqual = aRegion.Equals(bRegion); Rectangle[] rects = aRegion.GetRectangles(); aRegion.Add(dRegion); //aRegion.Subtract(dRegion); //aRegion.Intersect(dRegion); //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.OR); //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.XOR); //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.Diff); //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.AND); //rects = aRegion.GetRectangles(); Rectangle frame = aRegion.GetFrame(); uint colorref = RGBColor.RGB(255, 127, 127); GDIBrush newBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.DiagCross, colorref, Guid.NewGuid()); aPort.SetBrush(newBrush); //aPort.FillRegion(aRegion, newBrush); //aPort.DrawRegion(aRegion); //aPort.FrameRegion(aRegion, newBrush, new Size(1, 1)); //aPort.SetDefaultBrushColor(RGBColor.Yellow); //aPort.FillRegion(cRegion, GDISolidBrush.DeviceContextBrush); rects = aRegion.GetRectangles(); //Random rnd = new Random(); GDIPen regionPen = new CosmeticPen(PenStyle.Solid, RGBColor.Red, Guid.NewGuid()); GDISolidBrush regionBrush = new GDISolidBrush(RGBColor.Red); // I GraphPort does not have FillRegion yet, so we fake it foreach (Rectangle r in rects) { // Create some random color //uint randomcolor = RGBColor.RGB((byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255)); //aPort.DrawRectangle(regionPen, r.Left, r.Top, r.Width, r.Height); aPort.FillRectangle(regionBrush, r.Left, r.Top, r.Width, r.Height); } }
public void RunOnce(GDIRenderer aPort) { aPort.SetBkMode((int)BackgroundMixMode.Transparent); aPort.SetTextColor(fTextColor); //Guid fontID = Guid.NewGuid(); //aPort.CreateFont("Times New Roman", 96, fontID); //aPort.SelectUniqueObject(fontID); aPort.SetFont(fFont); aPort.DrawString(fOrigin.X, fOrigin.Y, fStringMessage); aPort.Flush(); }
public void RunOnce(GDIRenderer aPort) { aPort.SaveState(); GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Red, Guid.NewGuid()); GDIBrush rectBrush = new GDISolidBrush(RGBColor.Pink); for (int coord = 10; coord < fSize.Height; coord += 50) { aPort.FillRectangle(rectBrush, coord, coord, 200, 200); aPort.DrawRectangle(rectPen, coord, coord, 200, 200); } aPort.ResetState(); }
public Form1() { InitializeComponent(); // Get the right device context fDeviceContext = GDIContext.CreateForWindowClientArea(this.Handle); // This is fairly fast for the window //fDeviceContext = GDIContext.CreateForDesktopBackground(); // This one is the desktop background and is fast //fDeviceContext = GDIContext.CreateForDefaultDisplay(); // This one is way slow on Vista fChannel = new GDIRenderer(fDeviceContext); fDemoCounter = 0; //this.Text = "PixTour"; bezierer = new BezierTest(ClientRectangle.Size); aTextTest = new TextTest(ClientRectangle.Size); PrintDeviceContext(fDeviceContext); }
public SketchView(MultiSession session, int width, int height) { fSession = session; // Create the backing buffer to retain the image backingBuffer = GDIDIBSection.Create(width, height); GDIContext bufferContext = GDIContext.CreateForBitmap(backingBuffer); bufferContext.ClearToWhite(); fBackingGraphPort = new GDIRenderer(bufferContext); //fBackingGraphPort.ClearToWhite(); // Add the channel for graphics commands fSketchChannel = fSession.CreateChannel(PayloadType.Whiteboard); fChunkDecoder = new GraphPortChunkDecoder(); fChunkDecoder.AddGraphPort(fBackingGraphPort); fSketchChannel.FrameReceivedEvent += new RtpStream.FrameReceivedEventHandler(GDICommandReceived); }
public void RunOnce(GDIRenderer aPort) { aPort.SaveState(); // Orient the axis with origin at upper // left hand corner, y-axis positive going down the screen aPort.SetMappingMode(MappingModes.Text); // Draw the curve aPort.DrawBeziers(fBlackPen, fFigure); // Draw the control lines // Control line 1 aPort.DrawLine(fRedPen, new Point(fFigure[0].X, fFigure[0].Y), new Point(fFigure[1].X, fFigure[1].Y)); // Control line 2 aPort.DrawLine(fRedPen, new Point(fFigure[2].X, fFigure[2].Y), new Point(fFigure[3].X, fFigure[3].Y)); aPort.Flush(); aPort.ResetState(); }
public void RunOnce(GDIRenderer aPort) { int i; int cxClient = fSize.Width; int cyClient = fSize.Height; Point[] points = new Point[fNumSegments]; aPort.SaveState(); GDIPen redPen = new GDIPen(RGBColor.Red); aPort.DrawLine(redPen, new Point(0, cyClient/2), new Point(cxClient, cyClient / 2)); GDIPen blackPen = new GDIPen(RGBColor.Black); for (i = 0; i < fNumSegments; i++) { points[i].X = i * cxClient / fNumSegments; points[i].Y = (int)(((double)cyClient/2.0f)*(1.0f-Math.Sin(Math.PI*2.0f*(double)i/(double)fNumSegments))); } aPort.DrawLines(blackPen, points); aPort.ResetState(); }
public Command_Render(GDIRenderer graphPort) { fGraphPort = graphPort; }