public void DrawAt(IGraphPort graphPort, int x, int y, Rectangle updateRect) { int centerX = updateRect.Width/2; int centerY = updateRect.Height/2; int Radius = (updateRect.Height / 2) - 5; int N = 36; double theta = 3.14159 * 2 / N; GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Red, 1, Guid.NewGuid()); for (int p = 0; p < N; p++) { byte num = (byte)(((double)p / (double)N) * 254.0); byte r = (byte)rnd.Next(0, num); byte g = (byte)rnd.Next(0, num); byte b = (byte)rnd.Next(0, num); uint color = RGBColor.RGB(r, g, b); //graphPort.PenColor = color; for (int q = 0; q < p; q++) { graphPort.DrawLine(aPen, new Point((int)(centerX + Radius * Math.Sin(p * theta)), (int)(centerY + Radius * Math.Cos(p * theta))), new Point((int)(centerX + Radius * Math.Sin(q * theta)), (int)(centerY + Radius * Math.Cos(q * theta)))); } } }
static GDICosmeticPen() { Black = new GDICosmeticPen(RGBColor.Black); Red = new GDICosmeticPen(RGBColor.Red); Green = new GDICosmeticPen(RGBColor.Green); Blue = new GDICosmeticPen(RGBColor.Blue); }
//public virtual void Line(int x1, int y1, int x2, int y2) //{ // Point[] points = new Point[]{new Point(x1,y1), new Point(x2,y2)}; // DrawLines(points); //} //public virtual void LineTo(int x, int y) //{ // GDI32.LineTo(HDC, x, y); //} //public virtual void LineTo(Point toPoint) //{ // LineTo(toPoint.X, toPoint.Y); //} public virtual void DrawLine(GDIPen aPen, Point startPOINT, Point endPoint) { Point[] points = new Point[2]; points[0] = startPOINT; points[1] = endPoint; DrawLines(aPen, points); }
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 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 MouseTestWindow() : base("MouseTestWindow", 20, 20, 320, 600) { // Use a layout handler so all our graphics line up vertically //this.LayoutHandler = new LinearLayout(this, 4, 4, Orientation.Vertical); blackPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Black, 1, Guid.NewGuid()); Rectangle bounds = ClientRectangle; fLastDown = new Point(); fArea = new ActiveArea("area", 50,50, 200, 200); AddGraphic(fArea); fArea.Debug = true; fArea.MouseMoveEvent += new MouseEventHandler(this.MouseMovedActivity); fArea.MouseDownEvent += new MouseEventHandler(this.MouseDownActivity); fArea.MouseUpEvent += new MouseEventHandler(this.MouseUpActivity); BackgroundColor = RGBColor.LtGray; }
public virtual void DrawPolygon(System.Drawing.Point[] points, GDIPen aPen, GDIBrush aBrush) { SaveState(); // Set the brush // Set the pen // Select the current pen and brush TOAPI.Types.POINT[] pts = new POINT[points.Length]; for (int i = 0; i < pts.Length; i++) { pts[i].X = points[i].X; pts[i].Y = points[i].Y; } GDI32.Polygon(DeviceContext, pts, pts.Length); ResetState(); }
public virtual void DrawRectangles(GDIPen aPen, Rectangle[] rects) { // fDeviceContext.DrawRectangle(aPen, x, y, width, height); }
public virtual void DrawBeziers(GDIPen aPen, Point[] points) { SetPen(aPen); TOAPI.Types.POINT[] pts = new POINT[points.Length]; for (int i = 0; i < pts.Length; i++) { pts[i].X = points[i].X; pts[i].Y = points[i].Y; } GDI32.PolyBezier(DeviceContext, pts, (uint)pts.Length); }
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(); }
public virtual void DrawLines(GDIPen aPen, Point[] points) { fDeviceContext.DrawLines(fCurrentPen, points); }
public virtual void DrawPath(GDIPen aPen, GPath aPath) { }
public virtual void DrawLine(GDIPen aPen, Point startPoint, Point endPoint) { }
public static GDIPen UnpackGPen(BufferChunk chunk) { uint penColor; PenStyle penStyle; Guid uniqueID; int penSize; penStyle = (PenStyle)chunk.NextInt32(); penSize = chunk.NextInt32(); penColor = chunk.NextUInt32(); uniqueID = UnpackGuid(chunk); GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.Solid, PenJoinStyle.Round, PenEndCap.Round, penColor, penSize, uniqueID); return aPen; }
public virtual void DrawRectangles(GDIPen aPen, Rectangle[] rects) { // 1. Select a hollow brush so the inside does // not get filled. SelectStockObject(GDI32.HOLLOW_BRUSH); // 2. Set the pen SetPen(aPen); // 3. And draw the rectangles foreach (Rectangle r in rects) { DeviceContext.Rectangle(r.Left, r.Top, r.Right, r.Bottom); } }
/// <summary> /// Draw the frame of a rectangle using the specified pen. /// </summary> /// <param name="aPen"></param> /// <param name="x">left</param> /// <param name="y">top</param> /// <param name="width">Width of rectangle.</param> /// <param name="height">Height of rectangle.</param> public virtual void DrawRectangle(GDIPen aPen, int x, int y, int width, int height) { // 1. Select a hollow brush so the inside does // not get filled. SelectStockObject(GDI32.HOLLOW_BRUSH); // 2. Set the pen SetPen(aPen); // 3. And draw the rectangle DeviceContext.Rectangle(x, y, x + width - 1, y + height - 1); }
//public virtual void DrawLine(Point startPOINT, Point endPoint) //{ // MoveTo(startPOINT.X, startPOINT.Y); // LineTo(endPoint); //} /// DrawLine // Assume we want to draw a line using the currently selected // GDIPen, whichever that may be, and the currently selected color //public virtual void DrawLine(GDIPen aPen, int x1, int y1, int x2, int y2) //{ // SetPen(aPen); // MoveTo(x1, y1); // LineTo(x2, y2); //} /// DrawLine // Assume we want to draw a line using the currently selected // GDIPen, whichever that may be, and the currently selected color //public virtual void DrawLine(int x1, int y1, int x2, int y2) //{ // MoveTo(x1, y1); // LineTo(new System.Drawing.Point(x2, y2)); //} public virtual void DrawLines(GDIPen aPen, System.Drawing.Point[] points) { SetPen(aPen); TOAPI.Types.POINT[] pts = new POINT[points.Length]; for (int i = 0; i < pts.Length; i++) { pts[i].X = points[i].X; pts[i].Y = points[i].Y; } DeviceContext.PolyLine(pts); }
/// DrawEllipse /// public virtual void DrawEllipse(GDIPen aPen, Rectangle rect) { }
public virtual void SelectObject(GDIPen aPen) { }
public virtual void SetPen(GDIPen aPen) { // 1. Check to see if the pen object already exists in our // list of objects bool containsObject = fObjectDictionary.ContainsKey(aPen.UniqueID); // 2. If the object is already in the dictionary, then select // it as the current brush and return. if (containsObject) // and the object is a brush { // Get a hold of the actual object in the dictionary GDIObject aUniqueObject = fObjectDictionary[aPen.UniqueID]; // Select it based on it's handle if (aUniqueObject != null) DeviceContext.SelectObject(aUniqueObject); return; } // 3. If the brush is not found, then create a new brush, // and put it into the table. CreatePen(aPen.TypeOfPen, aPen.Style, aPen.JoinStyle, aPen.EndCap, aPen.Color, aPen.Width, aPen.UniqueID); // 4. Select the new brush SelectUniqueObject(aPen.UniqueID); }
public virtual void FrameRectangle(GDIPen pen, Rectangle aRect) { SaveState(); SetPen(pen); DrawRectangle(aRect); ResetState(); }
public static void Pack(BufferChunk chunk, GDIPen aPen) { chunk += GDI32.EMR_CREATEPEN; chunk += (int)aPen.Style; chunk += 1; chunk += aPen.Color; Pack(chunk, aPen.UniqueID); }
public virtual void DrawRoundRect(GDIPen aPen, Rectangle rect, int xRadius, int yRadius) { SetPen(aPen); DeviceContext.RoundRect(rect.Left, rect.Top, rect.Right, rect.Bottom, xRadius, yRadius); }
public virtual void DrawRoundRect(GDIPen aPen, Rectangle rect, int xRadius, int yRadius) { }
public virtual void DrawEllipse(GDIPen aPen, Rectangle rect) { // 1. Select a hollow brush so the inside does // not get filled. SelectStockObject(GDI32.HOLLOW_BRUSH); // 2. Set the pen SetPen(aPen); // 3. Draw the ellipse GDI32.Ellipse(DeviceContext, rect.Left, rect.Top, rect.Right, rect.Bottom); }
public virtual void StrokeAndFillRectangle(GDIPen aPen, GDIBrush aBrush, Rectangle aRect) { SaveState(); // Select the pen and brush into the context SetPen(aPen); SetBrush(aBrush); // Draw the rectangle DeviceContext.Rectangle(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom); ResetState(); }
public virtual void DrawBeziers(GDIPen aPen, Point[] points) { fDeviceContext.DrawBezier(fCurrentPen, points[0], points[1], points[2], points[3]); }