public void StartDrawing(Graphics dc, int drawBuffer) { mDc = dc; DrawBufferFlag = drawBuffer; IsStartDrawing = true; if (DrawBufferFlag == 0) { Control mapCtrl = Control.FromHandle(Handle); if (mStaticImage == null) { mClipRectangle = mapCtrl.ClientRectangle; mStaticImage = new Bitmap(mClipRectangle.Width, mClipRectangle.Height); m_staticDirty = true; } System.Drawing.Drawing2D.SmoothingMode m_smoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; //绘制在背景图片上 mBitMapGc = Graphics.FromImage(mStaticImage); mBitMapGc.SmoothingMode = m_smoothingMode; mBitMapGc.Clear(Color.White); //m_model.BackgroundLayer.Draw(dcStatic, r); //if (m_model.GridLayer.Enabled) // m_model.GridLayer.Draw(dcStatic, r); //绘制十字丝 RgPoint rCenterPoint = new RgPoint(0, 0); PointF nullPoint = DisplayTransformation.ToScreen(rCenterPoint); mBitMapGc.DrawLine(Pens.Blue, nullPoint.X - 10, nullPoint.Y, nullPoint.X + 10, nullPoint.Y); mBitMapGc.DrawLine(Pens.Blue, nullPoint.X, nullPoint.Y - 10, nullPoint.X, nullPoint.Y + 10); } }
public override void render(Graphics g, Transform t) { if (!Visible) { return; } if (originalText == "") { return; } var s = t.transform(new PointF((float)x, (float)y)); System.Drawing.Drawing2D.SmoothingMode oldMode = g.SmoothingMode; //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; if (!horizontal) { g.TranslateTransform(s.X, s.Y); g.RotateTransform(-90); g.FillRectangle(Fill, bounds(t)); drawBlocks(g, offsetY(size), offsetX(size)); g.ResetTransform(); } else { g.FillRectangle(Fill, bounds(t)); s.X += offsetX(size); s.Y += offsetY(size); drawBlocks(g, s.X, s.Y); } g.SmoothingMode = oldMode; }
public override void AfficheGDI( Graphics g, Temps maintenant, Rectangle tailleEcran, Color couleur ) { #if DEBUG RenderStart(CHRONO_TYPE.RENDER); #endif System.Drawing.Drawing2D.SmoothingMode s = g.SmoothingMode ; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; g.Clear(Color.Black); CompositingQuality q = g.CompositingQuality ; g.CompositingQuality = CompositingQuality.HighSpeed; for ( int i = (NB_ANNEAUX-2); i >= 0; i--) { if ( _anneaux[i,0].z > _zCamera) { int iPlusUn = i + 1 ; for (int j = 0; j < TAILLE_ANNEAU; j++) { int jPlusUn = j < (TAILLE_ANNEAU-1) ? j+1 : 0 ; Triangle( g, couleur, _anneaux[i,j], _anneaux[i,jPlusUn], _anneaux[iPlusUn,jPlusUn] ) ; Triangle( g, couleur, _anneaux[i,j], _anneaux[iPlusUn,jPlusUn], _anneaux[iPlusUn,j] ); } } } g.SmoothingMode = s ; g.CompositingQuality = q ; //dessine(g); #if DEBUG RenderStop(CHRONO_TYPE.RENDER); #endif }
public override void render(Graphics g, Transform t) { if (!Visible) { return; } if (x.Count() < 2) { return; } var points = x.Zip(y, (px, py) => t.transform(new PointF((float)px, (float)py))).ToArray(); System.Drawing.Drawing2D.SmoothingMode oldMode = g.SmoothingMode; if (points.Count() == 2 && (points[0].X == points[1].X || points[0].Y == points[1].Y)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; } g.DrawLines(Stroke, points); g.SmoothingMode = oldMode; }
public static void DrawCircle(Graphics g, float xPos, float yPos, float radius, Color color) { System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (Brush brush = new SolidBrush(color)) { g.FillEllipse(brush, xPos - radius, yPos - radius, radius * 2, radius * 2); } g.SmoothingMode = oldSmoothingMode; }
public override void render(Graphics g, Transform t) { PointF zero = t.transform(new PointF((float)x0(), (float)y0())); PointF one = t.transform(new PointF((float)x1(), (float)y1())); RectangleF rect = RendererUtilities.MakeRectangleF(zero.X, zero.Y, one.X, one.Y); System.Drawing.Drawing2D.SmoothingMode oldMode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; g.FillRectangle(Fill, rect); g.DrawRectangle(Stroke, rect.X, rect.Y, rect.Width, rect.Height); g.SmoothingMode = oldMode; }
public static void DrawShadow(Graphics g, string text, Font font, Color color, float xPos, float yPos) { System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (Brush brush = new SolidBrush(color)) { using (Pen pen = new Pen(Color.Black, 3)) { using (System.Drawing.Drawing2D.GraphicsPath path = GetStringPath(text, g.DpiY, font, new PointF(xPos, yPos))) { g.DrawPath(pen, path); g.FillPath(brush, path); } } } g.SmoothingMode = oldSmoothingMode; }
public static void FillRectangleRounded(this Graphics g, Brush b, int d, Rectangle r) { System.Drawing.Drawing2D.SmoothingMode mode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; g.FillPie(b, r.X, r.Y, d, d, 180, 90); g.FillPie(b, r.X + r.Width - d, r.Y, d, d, 270, 90); g.FillPie(b, r.X, r.Y + r.Height - d, d, d, 90, 90); g.FillPie(b, r.X + r.Width - d, r.Y + r.Height - d, d, d, 0, 90); g.FillRectangle(b, r.X + d / 2, r.Y, r.Width - d, d / 2); g.FillRectangle(b, r.X, r.Y + d / 2, r.Width, r.Height - d); g.FillRectangle(b, r.X + d / 2, r.Y + r.Height - d / 2, r.Width - d, d / 2); g.SmoothingMode = mode; }
public void StartDrawing(UcMapControl mapCtrl) { if (m_staticImage == null) { cliprectangle = mapCtrl.ClientRectangle; m_staticImage = new Bitmap(cliprectangle.Width, cliprectangle.Height); // m_staticImage.Save("D:\\a.png", ImageFormat.Png); m_staticDirty = true; } System.Drawing.Drawing2D.SmoothingMode m_smoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; //绘制在背景图片上 BitMapGc = Graphics.FromImage(m_staticImage); BitMapGc.SmoothingMode = m_smoothingMode; BitMapGc.Clear(Color.White); //m_model.BackgroundLayer.Draw(dcStatic, r); //if (m_model.GridLayer.Enabled) // m_model.GridLayer.Draw(dcStatic, r); //绘制十字丝 RPoint rCenterPoint = new RPoint(0, 0, 0); PointF nullPoint = Transform.ToScreen(rCenterPoint, mapCtrl); BitMapGc.DrawLine(Pens.Blue, nullPoint.X - 10, nullPoint.Y, nullPoint.X + 10, nullPoint.Y); BitMapGc.DrawLine(Pens.Blue, nullPoint.X, nullPoint.Y - 10, nullPoint.X, nullPoint.Y + 10); if (m_staticDirty) { m_staticDirty = false; List <ILayer> layers = mapCtrl.mMap.Layers; for (int layerindex = layers.Count - 1; layerindex >= 0; layerindex--) { if (layers[layerindex].Visible) { layers[layerindex].Draw(this); } } } if (NewObject != null) { if (NewObject is Polygon) { SolidBrush brush = new SolidBrush(Color.Blue); SolidBrush brush2 = new SolidBrush(Color.Pink); Pen pen = new Pen(brush2); DrawPolygon2(BitMapGc, NewObject as Polygon, brush, pen, false); } } BitMapGc.Dispose(); }
public static void DrawShadow(Graphics g, RectangleF rect, Color color) { System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; using (Brush brush = new SolidBrush(color)) { using (Pen pen = new Pen(Color.Black, 3)) { using (System.Drawing.Drawing2D.GraphicsPath path = new GraphicsPath()) { path.AddRectangle(rect); g.DrawPath(pen, path); g.FillPath(brush, path); } } } g.SmoothingMode = oldSmoothingMode; }
public static void DrawTextShadow(Graphics g, string text, PointF point, Font font, Color color) { point = new PointF(point.X, point.Y - 0.5f); GraphicsPath path = new GraphicsPath(); path.AddString(text, font.FontFamily, (int)font.Style, g.DpiY * font.SizeInPoints / 72, point, StringFormat.GenericDefault); System.Drawing.Drawing2D.SmoothingMode oldSmoothingMode = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; System.Drawing.Drawing2D.InterpolationMode oldInterpolationMode = g.InterpolationMode; g.InterpolationMode = InterpolationMode.Bilinear; using (Pen pen = new Pen(color, 5)) { g.DrawPath(pen, path); } g.SmoothingMode = oldSmoothingMode; g.InterpolationMode = oldInterpolationMode; }
private void OnDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); Rectangle rect = e.Bounds; rect.X += 1; rect.Y += 1; rect.Height -= 2; rect.Width = rect.Height; System.Drawing.Brush brush = new System.Drawing.SolidBrush(Color.White); System.Drawing.Brush fill = new System.Drawing.SolidBrush(Color.LightSteelBlue); System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black, 0); e.Graphics.FillRectangle(brush, rect); e.Graphics.DrawRectangle(pen, rect); System.Drawing.Drawing2D.SmoothingMode mode = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; rect.Inflate(-2, -2); string shapeId = _list.Items[e.Index].ToString(); ShapeTemplate shape = ShapeTemplate.FromId(shapeId); RectangleF rectf = new RectangleF( (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); MindFusion.FlowChartX.ShapeTemplate.PathData data = shape.initData(rectf, 0); System.Drawing.Drawing2D.GraphicsPath path = shape.getPath(data, 0); e.Graphics.FillPath(fill, path); e.Graphics.DrawPath(pen, path); path.Dispose(); path = shape.getDecorationPath(data, 0); if (path != null) { e.Graphics.DrawPath(pen, path); path.Dispose(); } e.Graphics.SmoothingMode = mode; pen.Dispose(); fill.Dispose(); brush.Dispose(); // Draw the text; rectf.X = rectf.Right + 6; rectf.Width = (float)e.Bounds.Width - rectf.X; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; System.Drawing.Brush textBrush = new System.Drawing.SolidBrush(Color.Black); e.Graphics.DrawString(shapeId, Font, textBrush, rectf, format); textBrush.Dispose(); format.Dispose(); }
public SvgDocument() { this.styleElements = new ArrayList(); this.recordanim = true; this.playAnim = false; this.controltime = 0; this.filename = "���"; this.update = true; this.undoStack = new UndoStack(); this.xmlreader = null; this.preelement = null; this.elements = new ArrayList(0x10); this.infos = new Hashtable(0x10); this.groups = new ArrayList(0x10); this.undoGroup = new ArrayList(0x10); this.errorinfos = new ArrayList(0x10); this.selectCollection = new SvgElementCollection(); this.oldSelect = new SvgElementCollection(); this.root = null; this.serialize = null; this.editRoots = new SvgElementCollection(); //this.styleSheetList = null; this.ChangeElements = new SvgElementCollection(); this.NumberOfUndoOperations = 1; this.ValidPath = new GraphicsPath(); this.firstload = false; this.FilePath = string.Empty; this.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; this.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; this.Changed = false; this.SelectChanged = false; this.OnlyShowCurrent = false; this.DefsChanged = true; this.OldControlTime = 0; this.PlayAnimChanged = false; this.AutoShowAnim = false; this.XmlParserContext = null; XmlNamespaceManager manager1 = new XmlNamespaceManager(base.NameTable); manager1.PushScope(); manager1.AddNamespace("svg", SvgDocument.SvgNamespace); manager1.AddNamespace("xlink", SvgDocument.XLinkNamespace); manager1.AddNamespace("a", SvgDocument.AudioNamespace); manager1.AddNamespace("tonli", SvgDocument.TonliNamespace); base.NodeChanged += new XmlNodeChangedEventHandler(this.ChangeNode); base.NodeInserted += new XmlNodeChangedEventHandler(this.ChangeNode); base.NodeRemoved += new XmlNodeChangedEventHandler(this.ChangeNode); this.XmlParserContext = new System.Xml.XmlParserContext(base.NameTable, manager1, "", "svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", this.BaseURI, "zh", XmlSpace.None, Encoding.UTF8); this.selectCollection.NotifyEvent = true; this.selectCollection.OnCollectionChangedEvent += new OnCollectionChangedEventHandler(this.ChangeSelect); this.serialize = new SerializeDocument(this); this.AddStyleElement(SvgDocument.SvgNamespace, "style"); this.SvgdataUid=string.Empty; layers =new SvgElementCollection(); }
public override void AfficheGDI(Graphics g, Temps maintenant, Rectangle tailleEcran, Color couleur) { #if DEBUG RenderStart(CHRONO_TYPE.RENDER); #endif System.Drawing.Drawing2D.SmoothingMode s = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; CompositingQuality q = g.CompositingQuality; g.CompositingQuality = CompositingQuality.HighSpeed; InterpolationMode In = g.InterpolationMode; g.InterpolationMode = InterpolationMode.NearestNeighbor; using (LinearGradientBrush linGrBrush = new LinearGradientBrush(tailleEcran, Color.Black, // Opaque red getCouleurOpaqueAvecAlpha(couleur, 255), LinearGradientMode.Vertical)) g.FillRectangle(linGrBrush, tailleEcran); float X, Y, X2, Y2; bool nuageAffiche; using (Bitmap bmp1 = BitmapNuance(g, _nuage1, getCouleurAvecAlpha(couleur, ALPHA)), bmp2 = BitmapNuance(g, _nuage2, getCouleurAvecAlpha(couleur, ALPHA)), bmp3 = BitmapNuance(g, _nuage3, getCouleurAvecAlpha(couleur, ALPHA)) ) for (int i = 0; i < NB_NUAGES; i++) { nuageAffiche = false; for (int j = 0; j < _nuages[i]._nbParticules; j++) { if (_nuages[i]._points[j].z > _zCamera) { Coord2DFrom3D(_nuages[i]._points[j].x - _nuages[i]._tailles[j], _nuages[i]._points[j].y - _nuages[i]._tailles[j], _nuages[i]._points[j].z, out X, out Y); Coord2DFrom3D(_nuages[i]._points[j].x + _nuages[i]._tailles[j], _nuages[i]._points[j].y + _nuages[i]._tailles[j], _nuages[i]._points[j].z, out X2, out Y2); try { NormalizeCoord(ref X, ref X2, ref Y, ref Y2); if ((X < _largeur) && (X2 > 0) && (Y < _hauteur) && (Y2 > 0)) { switch (_nuages[i]._type[j]) { case 0: g.DrawImage(bmp1, X, Y, X2 - X, Y2 - Y); break; case 1: g.DrawImage(bmp2, X, Y, X2 - X, Y2 - Y); break; case 2: g.DrawImage(bmp3, X, Y, X2 - X, Y2 - Y); break; } nuageAffiche = true; } } catch { nuageAffiche = false; } } } if (!nuageAffiche) { CreateNuage(ref _nuages[i], false); } } g.SmoothingMode = s; g.CompositingQuality = q; g.InterpolationMode = In; #if DEBUG RenderStop(CHRONO_TYPE.RENDER); #endif }