public GradientRectangle(int x, int y, int width, int height, uint colorBegin, uint colorEnd, uint colorBorder, float angle) :base("GradientRectangle",x,y,width,height) { fColorBegin = colorBegin; fColorEnd = colorEnd; fColorBorder = colorBorder; fAngle = angle; fBorderPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, colorBorder, 1, Guid.NewGuid()); fGradient = new GradientRect(0, 0, width, height, colorBegin, colorEnd, GradientRectDirection.Vertical); fBorder = new System.Drawing.Rectangle(0, 0, width, height); }
public virtual void ReceiveData(BufferChunk aRecord) { // First read out the record type int recordType = aRecord.NextInt32(); // Then deserialize the rest from there switch (recordType) { case GDI32.EMR_HEADER: break; // Transform related case GDI32.EMR_SCALEVIEWPORTEXTEX: case GDI32.EMR_SCALEWINDOWEXTEX: break; case GDI32.EMR_SETWINDOWEXTEX: { int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); //SetWindowExtent(width, height); } break; case GDI32.EMR_SETWINDOWORGEX: { int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); //SetWindowOrigin(x, y); } break; case GDI32.EMR_SETVIEWPORTEXTEX: { int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); //SetViewportExtent(width, height); } break; case GDI32.EMR_SETVIEWPORTORGEX: { int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); //SetViewportOrigin(x, y); } break; case GDI32.EMR_SETWORLDTRANSFORM: case GDI32.EMR_MODIFYWORLDTRANSFORM: break; case GDI32.EMR_SETBRUSHORGEX: break; case GDI32.EMR_EOF: Flush(); break; case GDI32.EMR_SETPIXELV: { int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); Int32 colorref = aRecord.NextInt32(); SetPixel(x, y, System.Drawing.Color.FromArgb(colorref)); } break; case GDI32.EMR_SETMAPPERFLAGS: break; case GDI32.EMR_SETPOLYFILLMODE: SetPolyFillMode((PolygonFillMode)aRecord.NextInt32()); break; case GDI32.EMR_SETSTRETCHBLTMODE: break; case GDI32.EMR_SETMAPMODE: MappingModes aMode = (MappingModes)aRecord.NextInt32(); SetMappingMode(aMode); break; case GDI32.EMR_SETTEXTCOLOR: SetTextColor(aRecord.NextUInt32()); break; case GDI32.EMR_SETBKCOLOR: SetBkColor(aRecord.NextUInt32()); break; case GDI32.EMR_SETDCBRUSHCOLOR: //SetDefaultBrushColor(aRecord.NextUInt32()); break; case GDI32.EMR_SETDCPENCOLOR: //SetDefaultPenColor(aRecord.NextUInt32()); break; case GDI32.EMR_SETBKMODE: SetBkMode(aRecord.NextInt32()); break; case GDI32.EMR_SETROP2: SetROP2((BinaryRasterOps)aRecord.NextInt32()); break; case GDI32.EMR_SETTEXTALIGN: case GDI32.EMR_SETCOLORADJUSTMENT: break; case GDI32.EMR_MOVETOEX: //MoveTo(aRecord.NextInt32(), aRecord.NextInt32()); break; case GDI32.EMR_OFFSETCLIPRGN: case GDI32.EMR_SETMETARGN: case GDI32.EMR_EXCLUDECLIPRECT: case GDI32.EMR_INTERSECTCLIPRECT: break; case GDI32.EMR_SAVEDC: SaveState(); break; case GDI32.EMR_RESTOREDC: RestoreState(aRecord.NextInt32()); break; case GDI32.EMR_CREATEPEN: { int aStyle = aRecord.NextInt32(); int width = aRecord.NextInt32(); uint colorref = aRecord.NextUInt32(); Guid uniqueID = this.UnpackGuid(aRecord); //CreateCosmeticPen((PenStyle)aStyle, colorref, uniqueID); } break; case GDI32.EMR_CREATEBRUSHINDIRECT: { BrushStyle aStyle = (BrushStyle)aRecord.NextInt32(); // chunk += aStyle; HatchStyle hatch = (HatchStyle)aRecord.NextInt32(); // chunk += hatch; uint color = aRecord.NextUInt32(); // chunk += color; Guid uniqueID = this.UnpackGuid(aRecord); //CreateBrush(aStyle, hatch, color, uniqueID); } break; case GDI32.EMR_SELECTOBJECT: break; case GDI32.EMR_DELETEOBJECT: break; case GDI32.EMR_SELECTSTOCKOBJECT: //SelectStockObject(aRecord.NextInt32()); break; case GDI32.EMR_SELECTUNIQUEOBJECT: { Guid uniqueID = this.UnpackGuid(aRecord); SelectUniqueObject(uniqueID); } break; case GDI32.EMR_ELLIPSE: { int left = aRecord.NextInt32(); int top = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); GDIPen aPen = ChunkUtils.UnpackGDIPen(aRecord); DrawEllipse(aPen, new Rectangle(left, top, width, height)); } break; case GDI32.EMR_ROUNDRECT: { int left = aRecord.NextInt32(); int top = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); int xRadius = aRecord.NextInt32(); int yRadius = aRecord.NextInt32(); Rectangle rect = new Rectangle(left, top, width, height); GDIPen aPen = ChunkUtils.UnpackGDIPen(aRecord); DrawRoundRect(aPen, rect, xRadius, yRadius); } break; case GDI32.EMR_RECTANGLE: { int left = aRecord.NextInt32(); int top = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); //DrawRectangle(left, top, right, bottom); } break; case GDI32.EMR_GRADIENTFILL: // Only rectangles at the moment { // Unpack the vertices TRIVERTEX[] pVertex = this.UnpackTRIVERTEX(aRecord); // unpack the gradient mesh GRADIENT_RECT[] pMesh = UnpackGRADIENT_RECT(aRecord); // unpack the mode GradientRectDirection dwMode = (GradientRectDirection)aRecord.NextUInt32(); GradientRect gRect = new GradientRect(pVertex, pMesh, dwMode); //this.DrawGradientRectangle(gRect); } break; case GDI32.EMR_ARC: case GDI32.EMR_ARCTO: case GDI32.EMR_ANGLEARC: case GDI32.EMR_CHORD: case GDI32.EMR_PIE: break; case GDI32.EMR_SELECTPALETTE: case GDI32.EMR_CREATEPALETTE: case GDI32.EMR_SETPALETTEENTRIES: case GDI32.EMR_RESIZEPALETTE: case GDI32.EMR_REALIZEPALETTE: break; case GDI32.EMR_LINETO: { // Get the start Point int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); Point startPoint = new Point(x, y); // Get the end point x = aRecord.NextInt32(); y = aRecord.NextInt32(); Point endPoint = new Point(x, y); // Get the pen GDIPen aPen = ChunkUtils.UnpackGDIPen(aRecord); // Draw the line DrawLine(aPen, startPoint, endPoint); } break; case GDI32.EMR_EXTFLOODFILL: break; case GDI32.EMR_POLYDRAW: //EMRPOLYDRAW polydraw = (EMRPOLYDRAW)aRecord; //fRenderer.PolyDraw(polydraw.aptl, polydraw.abTypes); break; case GDI32.EMR_SETARCDIRECTION: case GDI32.EMR_SETMITERLIMIT: break; //case GDI32.EMR_BEGINPATH: // BeginPath(); // break; //case GDI32.EMR_ENDPATH: // EndPath(); // break; //case GDI32.EMR_FILLPATH: // FillPath(); // break; //case GDI32.EMR_STROKEANDFILLPATH: // DrawPath(); // break; //case GDI32.EMR_STROKEPATH: // FramePath(); // break; case GDI32.EMR_ABORTPATH: case GDI32.EMR_FLATTENPATH: case GDI32.EMR_WIDENPATH: break; case GDI32.EMR_CLOSEFIGURE: case GDI32.EMR_SELECTCLIPPATH: break; case GDI32.EMR_BITBLT: { // Get the X, Y int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); // Now create a pixbuff on the specified size int dataSize = aRecord.NextInt32(); GDIDIBSection pixBuff = GDIDIBSection.Create(width, height); // Copy the received data into it right pixel data pointer aRecord.CopyTo(pixBuff.Pixels, dataSize); // And finally, call the PixBlt function PixBlt(pixBuff.ToPixelArray(), x, y); } break; case GDI32.EMR_POLYBEZIERTO: break; case GDI32.EMR_POLYBEZIER: { Point[] points = UnpackPoints(aRecord); // Now we have everything, so call the call GDIPen aPen = ChunkUtils.UnpackGDIPen(aRecord); this.DrawBeziers(aPen, points); } break; case GDI32.EMR_POLYGON: { Point[] points = UnpackPoints(aRecord); // Now we have everything, so call the call Polygon(points); } break; case GDI32.EMR_POLYPOLYGON: break; case GDI32.EMR_POLYLINE: { GDIPen aPen = ChunkUtils.UnpackGDIPen(aRecord); Point[] points = UnpackPoints(aRecord); // Now we have everything, so call the call DrawLines(aPen, points); } break; case GDI32.EMR_POLYLINETO: { Point[] points = UnpackPoints(aRecord); //PolyLineTo(points); } break; case GDI32.EMR_POLYPOLYLINE: break; case GDI32.EMR_POLYTEXTOUTA: case GDI32.EMR_POLYTEXTOUTW: break; case GDI32.EMR_EXTTEXTOUTA: case GDI32.EMR_EXTTEXTOUTW: { int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); int strLength = aRecord.NextInt32(); string text = (string)aRecord; DrawString(x, y, text); } break; case GDI32.EMR_EXTCREATEFONTINDIRECTW: { LOGFONT newFont = new LOGFONT(); int faceNameLength = aRecord.NextInt32(); newFont.lfFaceName = aRecord.NextUtf8String(faceNameLength); newFont.lfHeight = aRecord.NextInt32(); newFont.lfCharSet = aRecord.NextByte(); newFont.lfClipPrecision = aRecord.NextByte(); newFont.lfEscapement = aRecord.NextInt32(); newFont.lfItalic = aRecord.NextByte(); newFont.lfOrientation = aRecord.NextInt32(); newFont.lfOutPrecision = aRecord.NextByte(); newFont.lfPitchAndFamily = aRecord.NextByte(); newFont.lfQuality = aRecord.NextByte(); newFont.lfStrikeOut = aRecord.NextByte(); newFont.lfUnderline = aRecord.NextByte(); newFont.lfWeight = aRecord.NextInt32(); newFont.lfWidth = aRecord.NextInt32(); Guid uniqueID = this.UnpackGuid(aRecord); //CreateFont(newFont.lfFaceName, newFont.lfHeight, uniqueID); } break; case GDI32.EMR_CREATEMONOBRUSH: case GDI32.EMR_EXTCREATEPEN: case GDI32.EMR_CREATEDIBPATTERNBRUSHPT: break; case GDI32.EMR_FILLRGN: case GDI32.EMR_FRAMERGN: case GDI32.EMR_INVERTRGN: case GDI32.EMR_PAINTRGN: case GDI32.EMR_EXTSELECTCLIPRGN: break; case GDI32.EMR_ALPHABLEND: { // Get the X, Y int x = aRecord.NextInt32(); int y = aRecord.NextInt32(); int width = aRecord.NextInt32(); int height = aRecord.NextInt32(); int srcX = aRecord.NextInt32(); int srcY = aRecord.NextInt32(); int srcWidth = aRecord.NextInt32(); int srcHeight = aRecord.NextInt32(); byte alpha = aRecord.NextByte(); // Now create a pixbuff on the specified size int buffWidth = aRecord.NextInt32(); int buffHeight = aRecord.NextInt32(); GDIDIBSection pixBuff = GDIDIBSection.Create(buffWidth, buffHeight); int dataSize = aRecord.NextInt32(); // Copy the received data into it right pixel data pointer aRecord.CopyTo(pixBuff.Pixels, dataSize); // And finally, call the BitBlt function //AlphaBlend(x, y, width, height, pixBuff, srcX, srcY, srcWidth, srcHeight, alpha); } break; case GDI32.EMR_STRETCHBLT: case GDI32.EMR_MASKBLT: case GDI32.EMR_PLGBLT: case GDI32.EMR_SETDIBITSTODEVICE: case GDI32.EMR_STRETCHDIBITS: case GDI32.EMR_TRANSPARENTBLT: break; case GDI32.EMR_GDICOMMENT: case GDI32.EMR_GLSRECORD: case GDI32.EMR_GLSBOUNDEDRECORD: break; case GDI32.EMR_SETLAYOUT: break; case GDI32.EMR_PIXELFORMAT: break; case GDI32.EMR_CREATECOLORSPACE: case GDI32.EMR_SETCOLORSPACE: case GDI32.EMR_DELETECOLORSPACE: case GDI32.EMR_COLORCORRECTPALETTE: case GDI32.EMR_SETICMMODE: case GDI32.EMR_SETICMPROFILEA: case GDI32.EMR_SETICMPROFILEW: case GDI32.EMR_COLORMATCHTOTARGETW: case GDI32.EMR_CREATECOLORSPACEW: break; case GDI32.EMR_RESERVED_105: // These will likely never show up case GDI32.EMR_RESERVED_106: case GDI32.EMR_RESERVED_107: case GDI32.EMR_RESERVED_108: case GDI32.EMR_RESERVED_109: case GDI32.EMR_RESERVED_110: case GDI32.EMR_RESERVED_117: case GDI32.EMR_RESERVED_119: case GDI32.EMR_RESERVED_120: case GDI32.EMR_POLYBEZIER16: // Probably no real need to implement these case GDI32.EMR_POLYBEZIERTO16: case GDI32.EMR_POLYGON16: case GDI32.EMR_POLYPOLYGON16: case GDI32.EMR_POLYLINE16: case GDI32.EMR_POLYLINETO16: case GDI32.EMR_POLYPOLYLINE16: case GDI32.EMR_POLYDRAW16: default: //if (CommandReceived != null) // CommandReceived(aRecord); break; } }
public virtual void DrawGradientRectangle(GradientRect aGradient) { GDI32.GradientRectangle(DeviceContext, aGradient.Vertices, aGradient.Vertices.Length, aGradient.Boundary, aGradient.Boundary.Length, (int)aGradient.Direction); }
public virtual void DrawGradientRectangle(GradientRect aGradient) { }