private void setPenStyle(PenStyles value) { short Pattern = Convert.ToInt16("FFFF", 16); int Factor = 0; switch (value) { case PenStyles.Dash: Pattern = Convert.ToInt16("EEEE", 16); Factor = 3; break; case PenStyles.Dot: Pattern = Convert.ToInt16("AAAA", 16); Factor = 3; break; case PenStyles.DashDot: Pattern = Convert.ToInt16("E4E4", 16); Factor = 3; break; case PenStyles.DashDotDot: Pattern = Convert.ToInt16("E4E4", 16); Factor = 3; break; case PenStyles.Full: break; } if (Factor > 0) { GL.LineStipple(Factor, Pattern); GL.Enable(EnableCap.LineStipple); } else { GL.Disable(EnableCap.LineStipple); } }
public static void DrawXORRectangle( Graphics grp, int X1, int Y1, int X2, int Y2, PenStyles PenStyle ) { // Extract the Win32 HDC from the Graphics object supplied. IntPtr hdc = grp.GetHdc(); // Create a pen with a dotted style to draw the border of the // rectangle. IntPtr gdiPen = CreatePen( PenStyle, 1, BLACK_PEN ); // Set the ROP cdrawint mode to XOR. SetROP2( hdc, R2_XORPEN ); // Select the pen into the device context. IntPtr oldPen = SelectObject( hdc, gdiPen ); // Create a stock NULL_BRUSH brush and select it into the device // context so that the rectangle isn't filled. IntPtr oldBrush = SelectObject( hdc, GetStockObject( NULL_BRUSH ) ); // Now XOR the hollow rectangle on the Graphics object with // a dotted outline. Rectangle( hdc, X1, Y1, X2, Y2 ); // Put the old stuff back where it was. SelectObject( hdc, oldBrush ); // no need to delete a stock object SelectObject( hdc, oldPen ); DeleteObject( gdiPen ); // but we do need to delete the pen // Return the device context to Windows. grp.ReleaseHdc( hdc ); }
public static void DrawRectangle(Graphics dc, PenStyles penStyle, int penWidth, Color col, int X1, int Y1, int X2, int Y2) { // Extract the Win32 HDC from the Graphics object supplied. IntPtr hdc = dc.GetHdc(); // Create a pen. IntPtr gdiPen = GDI.CreatePen(penStyle, penWidth, GDI.RGB(col.R, col.G, col.B)); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); GDI.SetBkMode(hdc, TRANSPARENT); // Set the ROP cdrawint mode to XOR. GDI.SetROP2(hdc, drawingMode.R2_XORPEN); // Select the pen into the device context. IntPtr oldPen = GDI.SelectObject(hdc, gdiPen); // Create a stock NULL_BRUSH brush and select it into the device // context so that the rectangle isn't filled. IntPtr oldBrush = GDI.SelectObject(hdc, GDI.GetStockObject(NULL_BRUSH)); // Now XOR the hollow rectangle on the Graphics object with // a dotted outline. GDI.Rectangle(hdc, X1, Y1, X2, Y2); // Put the old stuff back where it was. GDI.SelectObject(hdc, oldBrush); // no need to delete a stock object GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(gdiPen); // but we do need to delete the pen // Return the device context to Windows. dc.ReleaseHdc(hdc); }
public static void DrawLine(PenStyles penStyle, int penWidth, Color col, Graphics grp, int X1, int Y1, int X2, int Y2) { // Extract the Win32 HDC from the Graphics object supplied. IntPtr hdc = grp.GetHdc(); // Create a pen. IntPtr gdiPen = GDI.CreatePen(penStyle, penWidth, GDI.RGB(col.R, col.G, col.B)); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); GDI.SetBkMode(hdc, TRANSPARENT); // Set the ROP cdrawint mode to XOR. GDI.SetROP2(hdc, drawingMode.R2_XORPEN); // Select the pen into the device context. IntPtr oldPen = GDI.SelectObject(hdc, gdiPen); // Draw the line. GDI.MoveToEx(hdc, X1, Y1, 0); GDI.LineTo(hdc, X2, Y2); // Put the old stuff back where it was. GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(gdiPen); // Return the device context to Windows. grp.ReleaseHdc(hdc); }
/// <summary> /// Initializes a new instance of the GDIWrap class. /// </summary> public GDIWrap() { // Set up for XOR drawing to begin with this._borderColor = Color.Transparent; this._fillColor = Color.Black; this._lineWidth = 2; this._brushStyle = BrushStyles.BS_NULL; this._penStyle = PenStyles.PS_SOLID; }
private static extern IntPtr CreatePen( PenStyles fnPenStyle, // pen style int nWidth, // pen width int crColor // pen color );
public IntPtr CreatePEN( PenStyles fnPenStyle, // pen style int nWidth, // pen width int crColor // pen color ) { return(CreatePen(fnPenStyle, nWidth, crColor)); }
public IntPtr CreatePEN( PenStyles fnPenStyle, // pen style int nWidth, // pen width int crColor // pen color ) { return CreatePen(fnPenStyle,nWidth,crColor); }
/// <summary> /// internal. /// </summary> internal static void Renew() { if (MeshIndices.Count > 0) { xyzf[] _Colors = null; if ((MeshColors != null) && (MeshColors.Count == MeshVertices.Count)) { _Colors = MeshColors.ToArray(); } xyf[] TextureCoords = null; if (MeshTextureCoords.Count > 0) { TextureCoords = MeshTextureCoords.ToArray(); } CompiledMesh M = new CompiledMesh(MeshIndices.ToArray(), MeshVertices.ToArray(), MeshNormals.ToArray(), TextureCoords, _Colors); // sollte nur im snap modus passieren M.SnapObject = Selector.StoredSnapItems.Count - 1; M.PenWidth = PenWidth; M.Mode = MeshMode; M.Material = Material; M.PenColor = Emission; M.PenStyle = PenStyle; M.Texture = Texture; MeshListCurrent.Progs.Add(M); MeshMode = PolygonMode.Fill; if (Selector.RegisterSnap) { Selector.SnapMesh.Progs.Add(M); } } PenWidth = 1; MeshVertices = new List <xyzf>(); MeshNormals = new List <xyzf>(); MeshTextureCoords = new List <xyf>(); MeshIndices = new List <IndexType>(); HasMaterial = false; _Material = Materials.Chrome; HasTexture = false; _Texture = null; HasPenWidth = false; _PenWidth = 1; HasEmission = false; _Emission = System.Drawing.Color.Black; HasPenStyle = false; _PenStyle = PenStyles.Full; SnapItem = null; MeshMode = PolygonMode.Fill; }
public GDI() { // Get screen's device context hDC = GetDC(ScreenHWND); // Indicates if pen object created and // attached to screen's device context PenCreated = false; CPenWidth = 1; CPenColor = 0; CPenStyle = PenStyles.PS_SOLID; }
public static void DrawRect(Graphics dc, PenStyles penStyle, int penWidth, Color col, int X1, int Y1, int X2, int Y2) { IntPtr hdc = dc.GetHdc(); IntPtr gdiPen = GDI.CreatePen(penStyle, penWidth, RGB(col.R, col.G, col.B)); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); GDI.SetBkMode(hdc, TRANSPARENT); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); IntPtr oldPen = GDI.SelectObject(hdc, gdiPen); IntPtr oldBrush = GDI.SelectObject(hdc, GDI.GetStockObject(NULL_BRUSH)); GDI.Rectangle(hdc, X1, Y1, X2, Y2); GDI.SelectObject(hdc, oldBrush); GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(gdiPen); // no need to delete a stock object but we do need to delete the pen dc.ReleaseHdc(hdc); }
public static void DrawLine(PenStyles penStyles, int penWidth, Color color, Graphics graphics, int x1, int y1, int x2, int y2) { IntPtr hdc = graphics.GetHdc(); IntPtr pen = GDI.CreatePen(penStyles, penWidth, GDI.RGB(color.R, color.G, color.B)); GDI.SetROP2(hdc, DrawingMode.R2_XORPEN); GDI.SetBkMode(hdc, Transparent); GDI.SetROP2(hdc, DrawingMode.R2_XORPEN); IntPtr oldPen = GDI.SelectObject(hdc, pen); GDI.MoveToEx(hdc, x1, y1, 0); GDI.LineTo(hdc, x2, y2); GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(pen); graphics.Dispose(); }
public static void DrawRectangle(Graphics graphics, PenStyles penStyles, int penWidth, Color color, int x1, int y1, int x2, int y2) { IntPtr hdc = graphics.GetHdc(); IntPtr pen = GDI.CreatePen(penStyles, penWidth, GDI.RGB(color.R, color.G, color.B)); GDI.SetROP2(hdc, DrawingMode.R2_XORPEN); GDI.SetBkMode(hdc, Transparent); GDI.SetROP2(hdc, DrawingMode.R2_XORPEN); IntPtr oldPen = GDI.SelectObject(hdc, pen); IntPtr oldBrush = GDI.SelectObject(hdc, GDI.GetStockObject(NullBrush)); GDI.Rectangle(hdc, x1, y1, x2, y2); GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(pen); graphics.ReleaseHdc(); }
public static void DrawLine(Graphics dc, PenStyles penStyle, int penWidth, Color col, int X1, int Y1, int X2, int Y2) { IntPtr hdc = dc.GetHdc(); IntPtr gdiPen = GDI.CreatePen(penStyle, penWidth, RGB(col.R, col.G, col.B)); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); GDI.SetBkMode(hdc, TRANSPARENT); GDI.SetROP2(hdc, drawingMode.R2_XORPEN); IntPtr oldPen = GDI.SelectObject(hdc, gdiPen); GDI.MoveToEx(hdc, X1, Y1, 0); GDI.LineTo(hdc, X2, Y2); GDI.SelectObject(hdc, oldPen); GDI.DeleteObject(gdiPen); dc.ReleaseHdc(hdc); }
// ref: https://www.codeproject.com/Articles/4958/Combining-GDI-and-GDI-to-Draw-Rubber-Band-Rectangl public static void DrawXorRectangle(this Graphics g, PenStyles style, int x1, int y1, int x2, int y2) { IntPtr hdc = g.GetHdc(); IntPtr pen = NativeMethods.CreatePen(style, 1, NativeMethods.BLACK_PEN); NativeMethods.SetROP2(hdc, NativeMethods.R2_XORPEN); IntPtr oldPen = NativeMethods.SelectObject(hdc, pen); IntPtr oldBrush = NativeMethods.SelectObject(hdc, NativeMethods.GetStockObject(NativeMethods.NULL_BRUSH)); NativeMethods.Rectangle(hdc, x1, y1, x2, y2); NativeMethods.SelectObject(hdc, oldBrush); NativeMethods.SelectObject(hdc, oldPen); NativeMethods.DeleteObject(pen); g.ReleaseHdc(hdc); }
public GDI(DrawingModes DM, PenStyles PS, int PW, int PC) { // Get screen's device context hDC = GetDC(ScreenHWND); // Indicates if pen object created and // attached to screen's device context PenCreated = true; // Apply new drawing modes, colors e.t.c. this.CPenWidth = PW; this.CPenColor = PC; this.CPenStyle = PS; this.CDrawMode = DM; // Obtain system resources hPEN = CreatePen(PS, PW, PC); OldROP = SetROP2(hDC, DM); SelectObject(hDC, hPEN); }
public static void DrawRectangle( Graphics g, PenStyles penStyle, Color penColor, int penWidth, LitMath.Vector2 pnt1, LitMath.Vector2 pnt2) { // Extract the Win32 HDC from the Graphics object supplied. IntPtr hdc = g.GetHdc(); // Create a pen with a dotted style to draw the border of the // rectangle. IntPtr gdiPen = CreatePen(penStyle, penWidth, RGB(penColor.R, penColor.G, penColor.B)); // SetBkMode(hdc, TRANSPARENT); // Set the ROP cdrawint mode to XOR. SetROP2(hdc, R2_XORPEN); // Select the pen into the device context. IntPtr oldPen = SelectObject(hdc, gdiPen); // Create a stock NULL_BRUSH brush and select it into the device // context so that the rectangle isn't filled. IntPtr oldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); // Now XOR the hollow rectangle on the Graphics object with // a dotted outline. Rectangle(hdc, (int)pnt1.x, (int)pnt1.y, (int)pnt2.x, (int)pnt2.y); // Put the old stuff back where it was. SelectObject(hdc, oldBrush); // no need to delete a stock object SelectObject(hdc, oldPen); DeleteObject(gdiPen); // but we do need to delete the pen // Return the device context to Windows. g.ReleaseHdc(hdc); }
public static void DrawRectangle(Graphics graphics, PenStyles penStyles, int penWidth, Color color, PointF topLeft, PointF bottomRight) { DrawRectangle(graphics, penStyles, penWidth, color, (int)topLeft.X, (int)topLeft.Y, (int)bottomRight.X, (int)bottomRight.Y); }
private static extern IntPtr CreatePen(PenStyles nPenStyle, int nWidth, int crColor);
// Default contructor - sets member fields public RubberbandRectangle() { penStyle = PenStyles.PS_DOT; }
private static extern IntPtr CreatePen( PenStyles enPenStyle, // Pen style from enum PenStyles int nWidth, // Width of pen int crColor // Color of pen );
public IntPtr CreatePEN(PenStyles penStyles, int width, int color) { return(CreatePen(penStyles, width, color)); }
public IntPtr CreatePEN(PenStyles fnPenStyle, int nWidth, int crColor) { return(CreatePen(fnPenStyle, nWidth, crColor)); }
public static void DrawRectangle(Graphics dc, PenStyles penStyle, int penWidth, Color col, PointF topleft, PointF bottomright) { DrawRectangle(dc, penStyle, penWidth, col, (int)topleft.X, (int)topleft.Y, (int)bottomright.X, (int)bottomright.Y); }
public static void DrawXORRectangle(Graphics grp, int X1, int Y1, int X2, int Y2, PenStyles PenStyle) { // Extract the Win32 HDC from the Graphics object supplied. IntPtr hdc = grp.GetHdc(); // Create a pen with a dotted style to draw the border of the // rectangle. IntPtr gdiPen = CreatePen(PenStyle, 1, BLACK_PEN); // Set the ROP cdrawint mode to XOR. SetROP2(hdc, R2_XORPEN); // Select the pen into the device context. IntPtr oldPen = SelectObject(hdc, gdiPen); // Create a stock NULL_BRUSH brush and select it into the device // context so that the rectangle isn't filled. IntPtr oldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); // Now XOR the hollow rectangle on the Graphics object with // a dotted outline. Rectangle(hdc, X1, Y1, X2, Y2); // Put the old stuff back where it was. SelectObject(hdc, oldBrush); // no need to delete a stock object SelectObject(hdc, oldPen); DeleteObject(gdiPen); // but we do need to delete the pen // Return the device context to Windows. grp.ReleaseHdc(hdc); }
public IntPtr CreatePEN(PenStyles fnPenStyle, int nWidth, int crColor) { return CreatePen(fnPenStyle,nWidth,crColor); }
public static void DrawXorRectangle(this Graphics g, PenStyles style, Point start, Point end) { g.DrawXorRectangle(style, start.X, start.Y, end.X, end.Y); }
public static extern IntPtr CreatePen( PenStyles fnPenStyle, // pen style int nWidth, // pen width int crColor // pen color );
// Default contructor - sets member fields public ROP2() { penStyle = PenStyles.PS_DOT; }
/// <summary> /// overrides the draw method . /// </summary> /// <param name="Device"></param> protected override void OnDraw(OpenGlDevice Device) { int StoredObject = -1; if (Selector.WriteToSnap) { CompiledMesh C = this as CompiledMesh; if (C != null) { StoredObject = C.SnapObject; } Device.Selector.SetObjectNumber(StoredObject); } Entity.CurrentEntity = this; if (Compiling) { MeshCreator.AddProg(this); return; } float PW = Device.PenWidth; PenStyles PS = Device.PenStyle; Material Save = Device.Material; if (Mode == PolygonMode.Line) { Device.PenWidth = PenWidth; Device.PenStyle = PenStyle; Device.Emission = PenColor; } else { Device.Material = Material; } PolygonMode SavePolygonMode = Device.PolygonMode; Device.PolygonMode = Mode; if ((VAO >= 0) && (Device.RenderKind == RenderKind.Render)) { OpenGlDevice.CheckError(); Field C = null; if (Colors != null) { C = Device.Shader.getvar("ColorEnabled"); if (C != null) { C.SetValue(1); } } GL.BindVertexArray(VAO); if (!TesselateOn) { GL.DrawElements(Primitives, VBOIndices.IndexArray.Length, DrawElementsType.UnsignedInt, 0); OpenGlDevice.CheckError(); } else { GLShader SaveShader = Device.Shader; Device.Shader = Device.TesselationtShader; if (FieldResolutionFactor == null) { FieldResolutionFactor = Device.Shader.getvar("ResolutionFactor"); } if (FieldDispFactor == null) { FieldDispFactor = Device.Shader.getvar("gDispFactor"); } if (FieldEyePos == null) { FieldEyePos = Device.Shader.getvar("gEyeWorldPos"); } if (FieldDispFactor != null) { FieldDispFactor.SetValue((float)TessDispFactor); } if (FieldEyePos != null) { FieldEyePos.SetValue(Device.Camera.Position); } Device.texture = TessDisplacementMap; //GL.ActiveTexture(TextureUnit.Texture0 + 1); //GL.BindTexture(TextureTarget.Texture2D, TessDisplacementMap.Handle); if (Texture != null) { Device.texture = Texture; } if (FieldResolutionFactor != null) { FieldResolutionFactor.SetValue((float)TessResolutionFactor); } GL.DrawElements(BeginMode.Patches, VBOIndices.IndexArray.Length, DrawElementsType.UnsignedInt, 0); TessDisplacementMap.Hide(); Device.Shader = SaveShader; Device.texture = null; } GL.BindVertexArray(0); if (Colors != null) { if (C != null) { C.SetValue(0); } } } else { if (Primitives == BeginMode.Quads) { DrawQuads(Device); } else { Texture SaveTexture = Device.texture; Device.texture = Texture; Device.drawMesh(Indices, VBOPosition.xyzPoints, VBONormals.xyzPoints, VBOTexture.xyPoints, VBOColors.xyzPoints); Device.texture = SaveTexture; } } Device.PolygonMode = SavePolygonMode; if (Mode == PolygonMode.Line) { Device.PenWidth = PW; Device.PenStyle = PS; Device.Emission = Color.Black; } Device.Material = Save; }
public static void DrawRectangle(Graphics dc, PenStyles penStyle, int penWidth, Color col, PointF topleft, PointF bottomright) { DrawRectangle(dc, penStyle, penWidth, col, (int)topleft.X, (int)topleft.Y,(int)bottomright.X, (int)bottomright.Y); }
public static extern IntPtr CreatePen(PenStyles enPenStyle, int nWidth, int crColor);
public static extern IntPtr CreatePen(PenStyles fnPenStyle, int nWidth, int crColor);