/// <summary> /// Return a pen based on the type requested /// </summary> /// <param name="_penType">Type of pen from the PenType enumeration</param> /// <returns>Requested pen</returns> public static Pen SetCurrentPen(PenType _penType) { Pen pen = new Pen(Color.AliceBlue); switch (_penType) { case PenType.Generic: pen = null; break; case PenType.RedPen: pen = RedPen(); break; case PenType.BluePen: pen = BluePen(); break; case PenType.GreenPen: pen = GreenPen(); break; case PenType.RedDotDashPen: pen = RedDotDashPen(); break; case PenType.RedDottedPen: pen = RedDottedPen(); break; case PenType.DoubleLinePen: pen = DoubleLinePen(); break; default: pen = null; break; } return pen; }
public GDIPen(PenType aType, PenStyle aStyle, PenJoinStyle aJoinStyle, PenEndCap aEndCap, Colorref colorref, int width, Guid uniqueID) : base(true,uniqueID) { TypeOfPen = aType; Style = aStyle; JoinStyle = aJoinStyle; EndCap = aEndCap; Width = width; Color = colorref; int combinedStyle = (int)aStyle | (int)aType | (int)aJoinStyle | (int)aEndCap; fLogBrush = new LOGBRUSH(); fLogBrush.lbColor = colorref; fLogBrush.lbHatch = IntPtr.Zero; fLogBrush.lbStyle = (int)BrushStyle.Solid; if (PenType.Cosmetic == aType) { // If it's cosmetic, the width must be 1 width = 1; // The color must be in the brush structure // Must mask off the alpha, or we'll get black fLogBrush.lbColor = colorref & 0x00ffffff; // The brush style must be solid fLogBrush.lbStyle = (int)BrushStyle.Solid; } IntPtr penHandle = GDI32.ExtCreatePen((uint)combinedStyle, (uint)width, ref fLogBrush, 0, IntPtr.Zero); SetHandle(penHandle); }
/// <summary> /// Return a pen based on the type requested /// </summary> /// <param name="_penType">Type of pen from the PenType enumeration</param> /// <returns>Requested pen</returns> public static void SetCurrentPen(ref Pen pen, PenType _penType, LineCap endCap) { switch (_penType) { case PenType.Solid: pen.DashStyle = DashStyle.Solid; break; case PenType.Dash: pen.DashStyle = DashStyle.Dash; break; case PenType.Dash_Dot: pen.DashStyle = DashStyle.DashDot; break; case PenType.Dot: pen.DashStyle = DashStyle.Dot; break; case PenType.DoubleLine: pen.CompoundArray = new float[] { 0.0f, 0.1f, 0.2f, 0.3f, 0.7f, 0.8f, 0.9f, 1.0f }; break; default: throw new ArgumentOutOfRangeException("_penType"); } pen.LineJoin = LineJoin.Round; pen.EndCap = endCap; pen.StartCap = LineCap.Round; }
// Trả về kiểu Pen mong muốn public static Pen SetCurrentPen(PenType _penType, Color _lineColor, int _lineWidth) { Pen pen; switch (_penType) { case PenType.Normal: pen = null; break; case PenType.DotDash: pen = DotDashPen(_lineColor, _lineWidth); break; case PenType.Dot: pen = DotPen(_lineColor, _lineWidth); break; case PenType.DoubleLine: pen = DoubleLinePen(_lineColor, _lineWidth); break; case PenType.DashArrow: pen = DashArrowPen(_lineColor, _lineWidth); break; default: pen = null; break; } return(pen); }
public static string GetPenTypeAsString(PenType penType) { switch (penType) { case PenType.Solid: return("___"); break; case PenType.Dash: return("- - -"); break; case PenType.Dash_Dot: return("- . -"); break; case PenType.Dot: return(". . ."); break; case PenType.DoubleLine: return("==="); break; default: throw new ArgumentOutOfRangeException("penType"); } }
public StylusEntry(DrawingAttributes atts, StylusModel stylus, string toolTipText, PenType pt) { if (atts == null) throw new ArgumentNullException("atts"); if (stylus == null) throw new ArgumentNullException("stylus"); this.DrawingAttributes = atts; this.Stylus = stylus; this.ToolTipText = toolTipText; this.PenType = pt; }
/// <summary> /// Функция возвращает символ клетки /// </summary> public char CellToChar(PenType _CellType) { switch (_CellType) { case PenType.BunkerBricks: return('B'); case PenType.BunkerCenter: return('C'); case PenType.BunkerClear: return('-'); case PenType.BunkerDoor: return('='); case PenType.Clear: return('.'); case PenType.Energy: return('+'); case PenType.Fruit: return('f'); case PenType.PacmanSpawn: return('P'); case PenType.Point: return('*'); case PenType.Wall: return('W'); case PenType.BlinkySpawn: return('b'); case PenType.PinkySpawn: return('p'); case PenType.InkySpawn: return('i'); case PenType.ClydeSpawn: return('c'); default: return('.'); } }
public BasePen CreatePen(PenType type) { switch (type) { case PenType.铅笔: return(new QianPen()); case PenType.钢笔: return(new Pen()); default: Console.WriteLine("不存在"); return(null); } }
public StylusEntry(DrawingAttributes atts, StylusModel stylus, string toolTipText, PenType pt) { if (atts == null) { throw new ArgumentNullException("atts"); } if (stylus == null) { throw new ArgumentNullException("stylus"); } this.DrawingAttributes = atts; this.Stylus = stylus; this.ToolTipText = toolTipText; this.PenType = pt; }
public void setPenType(PenType penType) { switch (penType) { case PenType.Dashed: this.Pen.DashStyle = DashStyle.Dash; break; case PenType.Compound: this.Pen.CompoundArray = compoundNumbers; break; default: this.Pen.DashStyle = DashStyle.Solid; break; } }
/// <summary> /// Return a pen based on the type requested /// </summary> /// <param name="_penType">Type of pen from the PenType enumeration</param> /// <returns>Requested pen</returns> public static Pen SetCurrentPen(PenType _penType) { Pen pen; switch (_penType) { case PenType.Generic: pen = null; break; case PenType.RedPen: pen = RedPen(); break; case PenType.BluePen: pen = BluePen(); break; case PenType.GreenPen: pen = GreenPen(); break; case PenType.RedDotDashPen: pen = RedDotDashPen(); break; case PenType.RedDottedPen: pen = RedDottedPen(); break; case PenType.DoubleLinePen: pen = DoubleLinePen(); break; case PenType.DashedArrowPen: pen = DashedArrowLinePen(); break; default: pen = null; break; } return(pen); }
public GPen(PenType aType, PenStyle aStyle, PenJoinStyle aJoinStyle, PenEndCap aEndCap, Colorref colorref, int width, Guid uniqueID) { TypeOfPen = aType; Style = aStyle; JoinStyle = aJoinStyle; EndCap = aEndCap; Width = width; Color = colorref; this.UniqueID = uniqueID; //int combinedStyle = (int)aStyle | (int)aType | (int)aJoinStyle | (int)aEndCap; if (PenType.Cosmetic == aType) { // If it's cosmetic, the width must be 1 width = 1; } }
private void Plot(int x, int y, PenShape penShape, PenType penType, byte penSize) { if (penType == PenType.Splatter) { SetPixel(x, y); return; } if (penShape == PenShape.Circle) { Circle ci = Circle.Circles[penSize]; int width = penSize + 1; int height = penSize * 2 + 1; for (int y2 = 0; y2 < height; y2++) { for (int x2 = 0; x2 < width; x2++) { byte data = ci.Data[(y2 * width) + x2]; if (data == 1) { SetPixel(x + x2 - ci.OffsetX, y + y2 - ci.OffsetY); } } } } if (penShape == PenShape.Square) { Square sq = Square.Squares[penSize]; int width = penSize + 1; int height = penSize * 2 + 1; for (int y2 = 0; y2 < height; y2++) { for (int x2 = 0; x2 < width; x2++) { SetPixel(x + x2 - sq.OffsetX, y + y2 - sq.OffsetY); } } } else { SetPixel(x, y); } }
private void menuItem3_Click(object sender, System.EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); // Create three pens Pen pn1 = new Pen(Color.Red, 3); Pen pn2 = new Pen(Color.Blue); Pen pn3 = new Pen(Color.Red); SolidBrush greenBrush = new SolidBrush(Color.Green); // Setting Pen1 properties pn1.Color = Color.Black; // CAUTION: Setting Brush property of the Pen // object will remove the color set by using Color // property and vice versa. pn1.Brush = greenBrush; pn1.Width = 4; pn1.Alignment = PenAlignment.Left; // Getting PenType value PenType style = pn1.PenType; // Setting Pen2 and Pen3 properties pn2.Width = 3; pn2.Alignment = PenAlignment.Inset; pn3.Width = 3; pn3.Alignment = PenAlignment.Outset; // Drawing Lines g.DrawLine(pn1, new Point(10, 10), new Point(150, 10)); g.DrawLine(pn2, new Point(10, 30), new Point(200, 30)); g.DrawLine(pn3, new Point(10, 50), new Point(250, 50)); // Releasing resorces. If you don't release using Dispose, // GC (Garbase Collector) takes care for you pn1.Dispose(); pn2.Dispose(); pn3.Dispose(); g.Dispose(); }
extern static internal GpStatus GdipGetPenFillType(GpPen pen, out PenType type);
public void OnDisableCollider( ) { Pen = PenType.UNKNOWN; //GetComponent<MeshCollider> ( ).enabled = false; }
GdipGetPenFillType(GpPen pen, out PenType type);
public PenX(Color c, float width, bool bCachedMode) { this.m_PenType = PenType.SolidColor; this.m_Color = c; this.m_Width = width; _SetProp(PenX.Configured.IsNotNull, true); _SetProp(Configured.Color, Color.Black.ToArgb() != c.ToArgb()); _SetProp(Configured.Width, 1 != width); if (bCachedMode) _SetPenVariable(new Pen(c, width)); }
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { _SetPenVariable(null); this.m_ConfiguredProperties = pen.m_ConfiguredProperties; this.m_PenType = pen.PenType; this.m_Alignment = pen.Alignment; if (0 != (this.m_ConfiguredProperties & Configured.Brush)) this.m_Brush = new BrushX(pen.m_Brush); this.m_Color = pen.Color; if (null != pen.m_CompoundArray) this.m_CompoundArray = (float[])pen.CompoundArray.Clone(); else this.m_CompoundArray = null; this.m_DashCap = pen.DashCap; this.m_DashOffset = pen.DashOffset; if (null != pen.m_DashPattern) this.m_DashPattern = (float[])pen.DashPattern.Clone(); else this.m_DashPattern = null; this.m_DashStyle = pen.DashStyle; this.m_EndCap = pen.EndCap; this.m_LineJoin = pen.LineJoin; this.m_MiterLimit = pen.MiterLimit; this.m_StartCap = pen.StartCap; if (null != pen.m_Transform) this.m_Transform = pen.Transform.Clone(); else this.m_Transform = null; this.m_Width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
private void Plot(int x, int y, PenShape penShape, PenType penType, byte penSize) { if (penType == PenType.Splatter) { SetPixel(x, y); return; } if (penShape == PenShape.Circle) { Circle ci = Circle.Circles[penSize]; int width = penSize + 1; int height = penSize * 2 + 1; for (int y2 = 0; y2 < height; y2++) { for (int x2 = 0; x2 < width; x2++) { byte data = ci.Data[(y2 * width) + x2]; if (data == 1) SetPixel(x + x2 - ci.OffsetX, y + y2 - ci.OffsetY); } } } if (penShape == PenShape.Square) { Square sq = Square.Squares[penSize]; int width = penSize + 1; int height = penSize * 2 + 1; for (int y2 = 0; y2 < height; y2++) for (int x2 = 0; x2 < width; x2++) SetPixel(x + x2 - sq.OffsetX, y + y2 - sq.OffsetY); } else SetPixel(x, y); }
public PenX(NamedColor c, double width, bool bCachedMode) { this._penType = PenType.SolidColor; _dashPattern = DashPatternListManager.Instance.BuiltinDefaultSolid; this._color = c; this._width = width; this._startCap = LineCapExtension.Flat; this._endCap = LineCapExtension.Flat; _SetProp(PenX.Configured.IsNotNull, true); _SetProp(Configured.Color, NamedColors.Black != c); _SetProp(Configured.Width, 1 != width); if (bCachedMode) _SetPenVariable(new Pen(ToGdi(c), (float)width)); }
/// <summary> /// Copies the properties of another instance to this instance. /// </summary> /// <param name="pen">the PenHolder object to copy</param> public void CopyFrom(PenX pen) { if (object.ReferenceEquals(this, pen)) return; _SetPenVariable(null); this._configuredProperties = pen._configuredProperties; this._penType = pen.PenType; this._alignment = pen.Alignment; if (0 != (this._configuredProperties & Configured.Brush)) this._brush = new BrushX(pen._brush); this._color = pen.Color; if (null != pen._compoundArray) this._compoundArray = (float[])pen.CompoundArray.Clone(); else this._compoundArray = null; this._dashPattern = pen._dashPattern; // immutable this._dashCap = pen._dashCap; this._cachedDashStyle = pen._cachedDashStyle; if (null != pen._cachedDashPattern) this._cachedDashPattern = (float[])pen._cachedDashPattern.Clone(); else this._cachedDashPattern = null; this._cachedDashOffset = pen._cachedDashOffset; this._endCap = pen.EndCap; this._lineJoin = pen.LineJoin; this._miterLimit = pen.MiterLimit; this._startCap = pen.StartCap; if (null != pen._transformation) this._transformation = pen.Transform.Clone(); else this._transformation = null; this._width = pen.Width; // note: there is an problem with Pen.Clone() : if the Color of the pen // was set to a known color, the color of the cloned pen is the same, but no longer a known color // therefore we avoid the cloning of the pen here // if(m_CachedMode && null!=pen.m_Pen) // _SetPenVariable( (Pen)pen.m_Pen.Clone() ); // else // _SetPenVariable(null); }
public void OnEnableCollider(PenType _pen) { Pen = _pen; //GetComponent<MeshCollider> ( ).enabled = true; }
public static void SetPenType(DependencyObject obj, PenType value) { obj.SetValue(PenTypeProperty, value); }
public virtual GDIPen CreatePen(PenType aType, PenStyle aStyle, PenJoinStyle aJoinStyle, PenEndCap aEndCap, Colorref colorref, int width, Guid uniqueID) { GDIPen aPen = new GDIPen(aType, aStyle, aJoinStyle, aEndCap, colorref, width, uniqueID); return aPen; }
private void parseData() { byte command = 0; int argumentCount = 0; int startX = 0; int startY = 0; int commandCount = 0; XmlElement commandNode = null; XmlElement goaCommandNode = null; XmlElement argNode = null; PenType penType = PenType.Solid; PenShape penShape = PenShape.Square; byte penSize = 0; XmlElement pictureNode = pictureDoc.CreateElement("picture"); pictureDoc.AppendChild(pictureNode); pictureNode.SetAttribute("id", id); XmlElement goaPictureNode = goaDoc.CreateElement("picture"); goaPictureNode.SetAttribute("id", id); layersNode = goaDoc.CreateElement("layers"); XmlElement controlLinesNode = goaDoc.CreateElement("control-lines"); goaDoc.AppendChild(goaPictureNode); goaPictureNode.AppendChild(layersNode); goaPictureNode.AppendChild(controlLinesNode); int stop = 11; for (int i = 0; i < fileData.Length; i++) { byte c = fileData[i]; if (c >= 240 && c <= 250) { commandCount++; argumentCount = 0; command = c; string commandString = commands[c - 240]; commandNode = pictureDoc.CreateElement(commandString); pictureNode.AppendChild(commandNode); //if (commandCount == stop) //break; } if (c == 241) { pictureDrawingEnabled = false; } if (c == 243) { priorityDrawingEnabled = false; } // build up the goa doc if (c >= 244 && c <= 247 && priorityDrawingEnabled && priorityColor <= 4) { goaCommandNode = goaDoc.CreateElement("line"); goaCommandNode.SetAttribute("priority", "" + priorityColor); controlLinesNode.AppendChild(goaCommandNode); } if (c == 248 && priorityDrawingEnabled && priorityColor <= 4) { goaCommandNode = goaDoc.CreateElement("fill"); goaCommandNode.SetAttribute("priority", "" + priorityColor); controlLinesNode.AppendChild(goaCommandNode); } // add command arguments to command nodes if (c < 240) { bool even = argumentCount % 2 == 0; switch (command) { case 240: // enable picture draw and set picture color commandNode.SetAttribute("color", "" + c); pictureDrawingEnabled = true; pictureColor = c; break; case 242: // enable priority draw and set priority color commandNode.SetAttribute("color", "" + c); priorityDrawingEnabled = true; priorityColor = c; break; case 244: // y-corner case 245: // x-corner if (argumentCount == 0) { argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + c); commandNode.AppendChild(argNode); startX = c; } else if (argumentCount == 1) { argNode.SetAttribute("y", "" + c); startY = c; if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } } else { bool shiftX = (command == 245 && even) || (command == 244 && !even); int x = (shiftX)? c : startX; int y = (shiftX)? startY : c; argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + startX); argNode.SetAttribute("y", "" + startY); commandNode.AppendChild(argNode); if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } DrawLine(startX, startY, x, y); startX = x; startY = y; } break; case 246: // absolute line -> converted to line if (even) { argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + c); commandNode.AppendChild(argNode); } else { argNode.SetAttribute("y", "" + c); int x = int.Parse(argNode.GetAttribute("x")); int y = int.Parse(argNode.GetAttribute("y")); SetPixel(x, y); if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } if (((XmlElement)argNode.PreviousSibling) != null) { int x1 = int.Parse(((XmlElement)argNode.PreviousSibling).GetAttribute("x")); int y1 = int.Parse(((XmlElement)argNode.PreviousSibling).GetAttribute("y")); int x2 = int.Parse(argNode.GetAttribute("x")); int y2 = int.Parse(argNode.GetAttribute("y")); DrawLine(x1, y1, x2, y2); } } break; case 247: // relative line -> converted to line if (argumentCount == 0) { argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + c); commandNode.AppendChild(argNode); startX = c; } else if (argumentCount == 1) { argNode.SetAttribute("y", "" + c); startY = c; if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } SetPixel(startX, startY); } else { decimal nibble1 = c / 16; int x = (int)Math.Floor(nibble1); int y = c - (16 * x); if (x >= 8) { x = 8 - x; } if (y >= 8) { y = 8 - y; } startX += x; startY += y; argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + startX); argNode.SetAttribute("y", "" + startY); commandNode.AppendChild(argNode); if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } if (((XmlElement)argNode.PreviousSibling) != null) { int x1 = int.Parse(((XmlElement)argNode.PreviousSibling).GetAttribute("x")); int y1 = int.Parse(((XmlElement)argNode.PreviousSibling).GetAttribute("y")); int x2 = int.Parse(argNode.GetAttribute("x")); int y2 = int.Parse(argNode.GetAttribute("y")); DrawLine(x1, y1, x2, y2); } } break; case 248: // flood fill if (even) { argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + c); commandNode.AppendChild(argNode); } else { argNode.SetAttribute("y", "" + c); int x = int.Parse(argNode.GetAttribute("x")); int y = int.Parse(argNode.GetAttribute("y")); if (priorityDrawingEnabled && priorityColor <= 4) { XmlElement goaArgNode = (XmlElement)goaDoc.ImportNode(argNode.CloneNode(true), true); goaCommandNode.AppendChild(goaArgNode); } Fill(x, y); } break; case 249: // set pen type, shape and size BitArray bits = new BitArray(new Byte[1] { c }); penType = bits[5] ? PenType.Splatter : PenType.Solid; penShape = bits[4] ? PenShape.Square : PenShape.Circle; penSize = 0; if (bits[2]) { penSize += 4; } if (bits[1]) { penSize += 2; } if (bits[0]) { penSize += 1; } break; case 250: // plot int plotX = 0; int plotY = 0; if (penType == PenType.Splatter) { int texture = c; // not used plotX = fileData[++i]; plotY = fileData[++i]; } else { plotX = c; c = fileData[++i]; plotY = c; } argNode = pictureDoc.CreateElement("coord"); argNode.SetAttribute("x", "" + plotX); argNode.SetAttribute("y", "" + plotY); Plot(plotX, plotY, penShape, penType, penSize); break; } argumentCount++; } } }
public virtual void CreatePen(PenType aType, PenStyle aStyle, PenJoinStyle aJoinStyle, PenEndCap aEndCap, uint colorref, int width, Guid uniqueID) { GDIPen aPen = DeviceContext.CreatePen(aType, aStyle, aJoinStyle, aEndCap, colorref, width, uniqueID); fObjectDictionary.Add(uniqueID, aPen); }
internal static extern Status GdipGetPenFillType (IntPtr pen, out PenType type);
// 橡皮 public void change_erase() { this.type = PenType.Erase; setCursor(); }
internal static extern GpStatus GdipGetPenFillType(GpPen pen, out PenType type);
// public方法 // 笔 public void change_pen() { this.type = PenType.Pen; setCursor(); }
static PenType UndoOf(PenType p) { switch (p) { case PenType.Eraser: return PenType.UndoEraser; case PenType.Ink: return PenType.UndoInk; case PenType.UndoEraser: return PenType.Eraser; case PenType.UndoInk: return PenType.Ink; default: return PenType.Ink; } }