public void Round(System.Drawing.Region region) { GraphicsPath gPath = new GraphicsPath(); int x = 2, y = 2; int thisWidth = this.Width; int thisHeight = this.Height; if (radius) { //var g=CreateGraphics(); //var pen = new System.Drawing.Pen(System.Drawing.Color.Black,10); //g.SmoothingMode = SmoothingMode.AntiAlias; //g.DrawEllipse(pen,x,y,this.Width,this.Height); //g.PixelOffsetMode = PixelOffsetMode.HighQuality; gPath.AddEllipse(x, y, this.Width - 3f, this.Height - 3f); gPath.Flatten(); gPath.ClearMarkers(); gPath.CloseAllFigures(); Region = new System.Drawing.Region(gPath); } else { gPath.AddLine(x, y, thisWidth, y); gPath.AddLine(thisWidth, y, thisWidth, thisHeight); gPath.AddLine(thisWidth, thisHeight, x, thisHeight); gPath.AddLine(x, y, x, thisHeight); Region = new System.Drawing.Region(gPath); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; _gp.ClearMarkers(); int numFilled = 0; for (int i = 0; i < 5; i++) { FillState fs = Rated ? _savedStars[i] : _stars[i]; DrawStar(e.Graphics, fs, i); if (fs != FillState.None) { numFilled++; } } e.Graphics.SetClip(new RectangleF(0, 0, (numFilled * 20) + 1, Height), CombineMode.Replace); using (LinearGradientBrush lgb = new LinearGradientBrush(DisplayRectangle, _starFillColor, _starFillColor, 90f)) { e.Graphics.FillPath(lgb, _gp); } e.Graphics.ResetClip(); }
public void Draw(Graphics g, LaneBook laneBook, Point originLocation) { if (StartPosition == null || EndPosition == null) { return; } ScoreLane futureLane = laneBook.Find( x => x.StartTick <= TopLeftPosition.Tick && TopLeftPosition.Tick <= x.EndTick); ScoreLane pastLane = laneBook.Find( x => x.StartTick <= BottomRightPosition.Tick && BottomRightPosition.Tick <= x.EndTick); int passingLanes = futureLane != null ? futureLane.Index - pastLane.Index : laneBook.Count - pastLane.Index - 1; PointF topLeft = new PointF( pastLane.LaneRect.Left + TopLeftPosition.Lane * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (TopLeftPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y - minHeight / 2); PointF topRight = new PointF( pastLane.LaneRect.Left + (BottomRightPosition.Lane + 1) * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (TopLeftPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y - minHeight / 2); PointF bottomLeft = new PointF( pastLane.LaneRect.Left + TopLeftPosition.Lane * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (BottomRightPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y + minHeight / 2); PointF bottomRight = new PointF( pastLane.LaneRect.Left + (BottomRightPosition.Lane + 1) * ScoreInfo.UnitLaneWidth - originLocation.X, pastLane.LaneRect.Bottom - (BottomRightPosition.Tick - pastLane.StartTick) * ScoreInfo.UnitBeatHeight - originLocation.Y + minHeight / 2); using (GraphicsPath graphicsPath = new GraphicsPath()) { var smoothingMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.Default; var itrLane = pastLane; for (int i = 0; i <= passingLanes; ++i, itrLane = laneBook.Next(itrLane)) { graphicsPath.AddLines(new PointF[] { topLeft, bottomLeft, bottomRight, topRight }); graphicsPath.CloseFigure(); if (itrLane.StartTick <= Status.DrawTickLast && itrLane.EndTick >= Status.DrawTickFirst) { using (Pen pen = new Pen(Color.White, 1)) { pen.DashPattern = new float[] { 4f, 4f }; RectangleF clipRect = new RectangleF( itrLane.LaneRect.X - originLocation.X, itrLane.LaneRect.Y - originLocation.Y, //HACK: 選択領域矩形が少し大きいので見切れないようにする itrLane.LaneRect.Width + 1, itrLane.LaneRect.Height + 5); g.Clip = new Region(clipRect); g.DrawPath(pen, graphicsPath); } } topLeft = topLeft.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); topRight = topRight.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); bottomLeft = bottomLeft.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); bottomRight = bottomRight.Add(ScoreLane.Width + ScorePanel.Margin.Left + ScorePanel.Margin.Right, itrLane.LaneRect.Height); graphicsPath.ClearMarkers(); } g.SmoothingMode = smoothingMode; } g.ResetClip(); }
public void ClearPath() { if (Helpers.Debug) { fnId = $"{classId}.ClearPath()"; } currentPath.ClearMarkers(); pathList.Clear(); Helpers.PrintDebug(fnId, $"pathList.Count: {pathList.Count}"); }
protected override void refreshPath() { path = new GraphicsPath(); Rectangle rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height); path.ClearMarkers(); path.AddEllipse(rect); this.Region = new Region(path); }
protected override void refreshPath() { path = new GraphicsPath(); Rectangle rect = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height); Point p1 = new Point(rect.Width / 2, 0); Point p2 = new Point(rect.Width, rect.Height / 2); Point p3 = new Point(rect.Width / 2, rect.Height); Point p4 = new Point(0, rect.Height / 2); if (type == RelationshipType.AssociativeEntity) { path.ClearMarkers(); path.AddRectangle(rect); } else { path.ClearMarkers(); path.AddPolygon(new Point[] { p1, p2, p3, p4 }); } this.Region = new Region(path); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); points.Clear(); switch (CurrentStatus) { case DrawStatus.ToolDraw: CurrentStatus = DrawStatus.Idle; Redo.Push(new Bitmap(Image)); RedoLocation.Push(Location); Cursor = Cursors.Default; if (path != null) { path.ClearMarkers(); } if (Test.CurrentBrush == BrushType.Picker) { Test.CurrentBrush = tempBrush; } //grp.DrawPath(pen, path); break; case DrawStatus.ShapeDraw: grp = CreateGraphics(); Undo.Push(new Bitmap(Image)); Redo.Clear(); Bitmap temp = (Bitmap)Image; Image = new Bitmap(Width, Height); grp = Graphics.FromImage(Image); grp.DrawImage(temp, 0, 0); DrawShape.Draw(grp, pen, AreaRect, Test.CurrentShape); CurrentStatus = DrawStatus.Idle; Cursor = Cursors.Default; break; //ongoing } }
public GraphicsPath GetPath() { m_path.ClearMarkers(); if (m_points.Count < 3) { throw new System.Exception("Polygon should have at least 3 points!"); } PointF pt1 = new PointF(); PointF pt2 = new PointF(); PointF lastpoint = new PointF(); for (int i = 0; i < m_points.Count; i++) { pt1 = GetLineStart(i); pt2 = GetLineEnd(i); if (i == 0) { m_path.AddLine(pt1, pt2); lastpoint = pt2; continue; } else { AddCubicBezierFromQuadricBezier(lastpoint, m_points[i], pt1); } m_path.AddLine(pt1, pt2); lastpoint = pt2; } pt1 = GetLineStart(0); AddCubicBezierFromQuadricBezier(lastpoint, m_points[0], pt1); return(m_path); }
// </snippet14> // Snippet for: M:System.Drawing.Drawing2D.GraphicsPath.ClearMarkers // <snippet15> private void ClearMarkersExample(PaintEventArgs e) { // Set several markers in a path. GraphicsPath myPath = new GraphicsPath(); myPath.AddEllipse(0, 0, 100, 200); myPath.SetMarkers(); myPath.AddLine(new Point(100, 100), new Point(200, 100)); Rectangle rect = new Rectangle(200, 0, 100, 200); myPath.AddRectangle(rect); myPath.SetMarkers(); myPath.AddLine(new Point(250, 200), new Point(250, 300)); myPath.SetMarkers(); // Clear the markers. myPath.ClearMarkers(); // Draw the path to the screen. Pen myPen = new Pen(Color.Black, 2); e.Graphics.DrawPath(myPen, myPath); }
/// <summary> /// 画表盘,改变此函数,可实际多表盘的风格 /// </summary> private void DrawPlate() { if (tmpBackImage == null) { tmpBackImage = new Bitmap(this.Width, this.Height); } using (Graphics g = Graphics.FromImage(tmpBackImage)) { g.SmoothingMode = SmoothingMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; g.Clear(BackColor); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; //sf.LineAlignment = StringAlignment.Center; //外层彩圏 GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(0, 0, Width - 1, Height - 1); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.White; pgb.SurroundColors = new Color[] { plateColor }; pgb.CenterPoint = new PointF(30, 30); g.FillEllipse(pgb, 0, 0, Width - 1, Height - 1); //白框 gp.ClearMarkers(); gp.AddEllipse(10, 10, Width - 1 - 20, Height - 1 - 20); pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.Black; pgb.SurroundColors = new Color[] { Color.White }; g.FillEllipse(pgb, 10, 10, Width - 1 - 20, Height - 1 - 20); //黑圈 g.FillEllipse(new SolidBrush(Color.Black), 20, 20, Width - 1 - 40, Height - 1 - 40); //灰背景 gp.ClearMarkers(); gp.AddEllipse(10, 10, Width - 1 - 20, Height - 1 - 20); pgb = new PathGradientBrush(gp); pgb.CenterColor = System.Windows.Forms.ControlPaint.LightLight(plateColor); pgb.SurroundColors = new Color[] { Color.White }; pgb.CenterPoint = new PointF(30, 30); g.FillEllipse(pgb, 22, 22, Width - 1 - 44, Height - 1 - 44); float tmpJiaoDu = 360.00f / 12; float tmpR = Width / 2.00f - 30; //报警颜色段 //g.FillPie(new SolidBrush(colorPart1), 30, 30, Width - 1 - 60, Height - 1 - 60, 135, tmpJiaoDu * 12); //刻度 for (int i = 0; i < 60; i++) { g.DrawLine(new Pen(Color.Black, 1), new PointF(Width / 2.0f, Height / 2.0f), new PointF((float)(Width / 2.0 - Math.Sin(Math.PI * (i * 6) / 180) * tmpR), (float)(Height / 2.0 + Math.Cos(Math.PI * (i * 6) / 180) * tmpR))); } //灰背景,把多余的报警颜色段覆盖 g.FillEllipse(pgb, 35, 35, Width - 1 - 70, Height - 1 - 70); //刻度 for (int i = 0; i < 12; i++) { g.DrawLine(new Pen(Color.Black, 1), new PointF(Width / 2.0f, Height / 2.0f), new PointF((float)(Width / 2.0 - Math.Sin(Math.PI * (i * 30) / 180) * tmpR), (float)(Height / 2.0 + Math.Cos(Math.PI * (i * 30) / 180) * tmpR))); } ////灰背景,把多余的报警颜色段覆盖 //g.FillEllipse(pgb, 40, 40, Width - 1 - 80, Height - 1 - 80); //刻度 for (int i = 0; i < 4; i++) { g.DrawLine(new Pen(Color.Black, 2), new PointF(Width / 2.0f, Height / 2.0f), new PointF((float)(Width / 2.0 - Math.Sin(Math.PI * (i * 90) / 180) * tmpR), (float)(Height / 2.0 + Math.Cos(Math.PI * (i * 90) / 180) * tmpR))); } //灰背景,把多余的报警颜色段覆盖 g.FillEllipse(pgb, 40, 40, Width - 1 - 80, Height - 1 - 80); //画刻度上的文字 string tmpStr = ""; Font tmpFont = new Font("黑体", 10, FontStyle.Bold); // sf.LineAlignment = StringAlignment.Center; for (int i = 0; i < 12; i++) { g.TranslateTransform(Width / 2.0f, Height / 2.0f); //把g的中心移动到图像中间 g.RotateTransform(i * tmpJiaoDu + 30); //把g旋转一定角度 tmpStr = string.Format("{0}", i + 1); g.DrawString(tmpStr, tmpFont, new SolidBrush(Color.Black), new Rectangle(-Width / 2, 45 - Height / 2, Width, All.Class.Num.GetFontHeight(tmpFont)), sf); g.RotateTransform(360 - i * tmpJiaoDu - 30); g.TranslateTransform(-Width / 2.0f, -Height / 2.0f); } //画下方数据区 //gp = new GraphicsPath(); //tmpR = Width / 2.00f - 21; //gp.AddArc(21, 21, Width - 1 - 42, Height - 1 - 42, 45, 90); //gp.AddLine((float)(Width / 2.0f - Math.Sin(45 * Math.PI / 180) * tmpR), (float)(Height / 2.0f + Math.Cos(45 * Math.PI / 180) * tmpR), // (float)(Width / 2.0f + Math.Sin(45 * Math.PI / 180) * tmpR), (float)(Height / 2.0f + Math.Cos(45 * Math.PI / 180) * tmpR)); //gp.CloseFigure(); //pgb = new PathGradientBrush(gp); //pgb.CenterColor = Color.White; //pgb.SurroundColors = new Color[] { System.Windows.Forms.ControlPaint.Light(plateColor) }; //g.FillPath(pgb, gp); //画标题 tmpStr = title; //tmpFont = new Font("宋体", 12, FontStyle.Bold); g.DrawString(tmpStr, Font, new SolidBrush(ForeColor), new RectangleF(0, Height * 0.65f, Width, tmpFont.GetHeight()), sf); gp = new GraphicsPath(); sf.Dispose(); pgb.Dispose(); gp.Dispose(); } }
public void ClearMarkers() { Changed(); gdiPath.ClearMarkers(); }
public Size Draw(Graphics g, Point location, int width) { Point pos = location; Point startPos = pos; int propertyOffset = 24; int textHeight = Convert.ToInt32(g.MeasureString("AAA", Font).Height); int propertyTextHeight = Convert.ToInt32(g.MeasureString("AAA", FontProperty).Height); int maxPropertyTextWidth = propertyOffset + GetMaxPropertyTextWidth(g, Properties.Select(p => p.Text).ToList(), FontProperty); maxPropertyTextWidth = Math.Max(maxPropertyTextWidth, Convert.ToInt32(g.MeasureString(this.Text, Font).Width)); if (maxPropertyTextWidth > width) { width = maxPropertyTextWidth + 1; } Rectangle rectProperties = new Rectangle(); if (IsExpanded) { int rectHeight = textHeight + 10; foreach (var prop in Properties) { rectHeight += (propertyTextHeight + 2) * (1 + prop.NumberOfSubProperties); } rectProperties = new Rectangle(pos, new Size(width, rectHeight)); g.FillRectangle(BackgroundBrush, rectProperties); //g.DrawRectangle(BorderPen, rectProperties); } CategoryRectangle = new Rectangle(pos, new Size(width, textHeight + 2)); GPathHeader.ClearMarkers(); GPathHeader.AddRectangle(CategoryRectangle); g.FillRectangle(HeaderBackgroundBrush, CategoryRectangle); //g.DrawRectangle(BorderPen, rect); pos.Offset(2, 0); Point trianglePoint = new Point(pos.X, pos.Y + 6); DrawTriangle(g, trianglePoint, IsExpanded, TextBrush); pos.Offset(9, 0); g.DrawString(Text, Font, TextBrush, pos); if (IsExpanded) { pos.Offset(0, textHeight); pos.Offset(13, 2); foreach (RawProperty prop in Properties) { prop.Bounds = new Rectangle(startPos.X, pos.Y, CategoryRectangle.Width, textHeight * (1 + prop.NumberOfVisibleSubProperties)); prop.Draw(g, pos, FontProperty, TextBrush, textHeight); pos.Offset(0, prop.Bounds.Height); } } Bounds = IsExpanded ? rectProperties : CategoryRectangle; Size size = new Size(width, IsExpanded ? rectProperties.Height : CategoryRectangle.Height); return(size); }
/// <summary> /// 画表盘,改变此函数,可实际多表盘的风格 /// </summary> private void DrawPlate() { if (tmpBackImage == null) { tmpBackImage = new Bitmap(this.Width, this.Height); } using (Graphics g = Graphics.FromImage(tmpBackImage)) { g.PixelOffsetMode = PixelOffsetMode.Half; g.SmoothingMode = SmoothingMode.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; g.Clear(BackColor); //外层彩圏 GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(0, 0, Width - 1, Height - 1); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.White; pgb.SurroundColors = new Color[] { plateColor }; pgb.CenterPoint = new PointF(30, 30); g.FillEllipse(pgb, 0, 0, Width - 1, Height - 1); //白框 gp.ClearMarkers(); gp.AddEllipse(10, 10, Width - 1 - 20, Height - 1 - 20); pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.Black; pgb.SurroundColors = new Color[] { Color.White }; g.FillEllipse(pgb, 10, 10, Width - 1 - 20, Height - 1 - 20); //黑圈 g.FillEllipse(new SolidBrush(Color.Black), 20, 20, Width - 1 - 40, Height - 1 - 40); //灰背景 gp.ClearMarkers(); gp.AddEllipse(10, 10, Width - 1 - 20, Height - 1 - 20); pgb = new PathGradientBrush(gp); pgb.CenterColor = System.Windows.Forms.ControlPaint.LightLight(plateColor); pgb.SurroundColors = new Color[] { Color.White }; pgb.CenterPoint = new PointF(30, 30); g.FillEllipse(pgb, 22, 22, Width - 1 - 44, Height - 1 - 44); //刻度 float tmpJiaoDu = 270.00f / part; float tmpR = Width / 2.00f - 30; for (int i = 0; i <= part; i++) { g.DrawLine(new Pen(Color.Black, 1), new PointF(Width / 2.0f, Height / 2.0f), new PointF((float)(Width / 2.0 - Math.Sin(Math.PI * (45 + i * tmpJiaoDu) / 180) * tmpR), (float)(Height / 2.0 + Math.Cos(Math.PI * (45 + i * tmpJiaoDu) / 180) * tmpR))); } //刻度上的弧 g.DrawArc(new Pen(Color.Black, 2), 37, 37, Width - 1 - 74, Height - 1 - 74, 135, 225); g.DrawArc(new Pen(Color.Black, 2), 37, 37, Width - 1 - 74, Height - 1 - 74, 0, 45); //报警颜色段 g.FillPie(new SolidBrush(colorPart1), 38, 38, Width - 1 - 76, Height - 1 - 76, 135, tmpJiaoDu * partValue1); g.FillPie(new SolidBrush(colorPart2), 38, 38, Width - 1 - 76, Height - 1 - 76, (135 + (int)(tmpJiaoDu * partValue1)) % 360, tmpJiaoDu * (partValue2 - partValue1)); g.FillPie(new SolidBrush(colorPart3), 38, 38, Width - 1 - 76, Height - 1 - 76, (135 + (int)(tmpJiaoDu * partValue2)) % 360, tmpJiaoDu * (part - partValue2)); //灰背景,把多余的报警颜色段覆盖 g.FillEllipse(pgb, 53, 53, Width - 1 - 106, Height - 1 - 106); //画刻度上的文字 string tmpStr = ""; Font tmpFont = new Font("黑体", 10, FontStyle.Bold); for (int i = 0; i <= part; i++) { g.TranslateTransform(Width / 2.0f, Height / 2.0f); //把g的中心移动到图像中间 g.RotateTransform(i * tmpJiaoDu + 225); //把g旋转一定角度 tmpStr = string.Format("{0}", (max - min) * i / part + min); g.DrawString(tmpStr, tmpFont, new SolidBrush(Color.Black), -tmpStr.Length * tmpFont.GetHeight() / 4.0f, 39 - Height / 2.0f); g.RotateTransform(360 - i * tmpJiaoDu - 225); g.TranslateTransform(-Width / 2.0f, -Height / 2.0f); } //画下方数据区 gp = new GraphicsPath(); tmpR = Width / 2.00f - 21; gp.AddArc(21, 21, Width - 1 - 42, Height - 1 - 42, 45, 90); gp.AddLine((float)(Width / 2.0f - Math.Sin(45 * Math.PI / 180) * tmpR), (float)(Height / 2.0f + Math.Cos(45 * Math.PI / 180) * tmpR), (float)(Width / 2.0f + Math.Sin(45 * Math.PI / 180) * tmpR), (float)(Height / 2.0f + Math.Cos(45 * Math.PI / 180) * tmpR)); gp.CloseFigure(); pgb = new PathGradientBrush(gp); pgb.CenterColor = Color.White; pgb.SurroundColors = new Color[] { System.Windows.Forms.ControlPaint.Light(plateColor) }; g.FillPath(pgb, gp); //画标题 tmpStr = title; //tmpFont = new Font("宋体", 12, FontStyle.Bold); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; //sf.LineAlignment = StringAlignment.Center; g.DrawString(tmpStr, Font, new SolidBrush(ForeColor), new RectangleF(0, Height * 0.65f, Width, tmpFont.GetHeight()), sf); gp = new GraphicsPath(); sf.Dispose(); pgb.Dispose(); gp.Dispose(); } }