当前位置: 首页>>代码示例>>C#>>正文


C# System.Drawing.Drawing2D.GraphicsPath.Reset方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath.Reset方法的具体用法?C# System.Drawing.Drawing2D.GraphicsPath.Reset怎么用?C# System.Drawing.Drawing2D.GraphicsPath.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.GraphicsPath的用法示例。


在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.Reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPath

            private System.Drawing.Drawing2D.GraphicsPath GetPath(int index)
            {
                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
                path.Reset();

                Rectangle rect = this.GetTabRect(index);

                if (index == 0)
                {
                    path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
                    path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
                    path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                }
                else
                {
                    if (index == this.SelectedIndex)
                    {
                        path.AddLine(rect.Left + 5 - rect.Height, rect.Bottom + 1, rect.Left + 4, rect.Top + 2);
                        path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left + 5 - rect.Height, rect.Bottom + 1);
                    }
                    else
                    {
                        path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
                        path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
                        path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
                        path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
                    }
                }
                return path;
            }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:32,代码来源:SPTabControl.cs

示例2: PaintXErrorBars

    protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
    {

      // Plot error bars for the independent variable (x)
      PlotRangeList rangeList = pdata.RangeList;
      PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
      INumericColumn posErrCol = _positiveErrorColumn.Document;
      INumericColumn negErrCol = _negativeErrorColumn.Document;

      if (posErrCol == null && negErrCol == null)
        return; // nothing to do if both error columns are null

      System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

      Region oldClippingRegion = g.Clip;
      Region newClip = (Region)oldClippingRegion.Clone();

      foreach (PlotRange r in rangeList)
      {
        int lower = r.LowerBound;
        int upper = r.UpperBound;
        int offset = r.OffsetToOriginal;
        for (int j = lower; j < upper; j++)
        {
          AltaxoVariant x = pdata.GetXPhysical(j + offset);
          Logical3D lm = layer.GetLogical3D(pdata, j + offset);
          lm.RX += _cachedLogicalShiftOfIndependent;
          if (lm.IsNaN)
            continue;

          Logical3D lh = lm;
          Logical3D ll = lm;
          bool lhvalid = false;
          bool llvalid = false;
          if (posErrCol != null)
          {
            lh.RX = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
            lhvalid = !lh.IsNaN;
          }
          if (negErrCol != null)
          {
            ll.RX = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
            llvalid = !ll.IsNaN;
          }
          if (!(lhvalid || llvalid))
            continue; // nothing to do for this point if both pos and neg logical point are invalid.

          // now paint the error bar
          if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
          {
            double xlm, ylm;
            layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
            newClip.Union(oldClippingRegion);
            newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
            g.Clip = newClip;
          }

          if (lhvalid && llvalid)
          {
            errorBarPath.Reset();
            layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
            layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
            g.DrawPath(_strokePen, errorBarPath);
          }
          else if (llvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
          }
          else if (lhvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
          }


          // now the end bars
          if (_showEndBars)
          {
            if (lhvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

            if (llvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }
//.........这里部分代码省略.........
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:ErrorBarPlotStyle.cs

示例3: intersectPolygon

        //private static bool rectIntersectWithPolygon(RectangleF rect, Path path)
        //{
        //    System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
        //    temp.Reset();
        //    List<PointF> points = default(List<PointF>);
        //    foreach(object i in path.content)
        //    {
        //        if(i is Node)
        //        {
        //            Node node = (Node)i;
        //            if(rect.Contains((float)node.lon, (float)node.lat))
        //                return true;
        //            points.Add(new PointF((float)node.lon, (float)node.lat));
        //        }
        //    }
        //    temp.AddPolygon(points.ToArray());
        //    Region myRegion = new Region();
        //    myRegion.MakeEmpty();
        //    myRegion.Union(temp);
        //    PointF tempPt = new PointF();
        //    tempPt.X = rect.X;
        //    tempPt.Y = rect.Y;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X + rect.Width;
        //    tempPt.Y = rect.Y;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X;
        //    tempPt.Y = rect.Y + rect.Height;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    tempPt.X = rect.X + rect.Width;
        //    tempPt.Y = rect.Y + rect.Height;
        //    if(pointInPolygon(tempPt, myRegion))
        //        return true;
        //    return false;
        //}
        private static bool intersectPolygon(RectangleF rect, Path path)
        {
            System.Drawing.Drawing2D.GraphicsPath temp = new System.Drawing.Drawing2D.GraphicsPath();
            temp.Reset();

            //            List<PointF> points = default(List<PointF>);
            List<PointF> points = new List<PointF>();
            foreach (object i in path.content)
            {
                if (i is Node)
                {
                    Node node = (Node)i;

                    if (rect.Contains((float)node.lon, (float)node.lat))
                        return true;

                    points.Add(new PointF((float)node.lon, (float)node.lat));

                }
            }

            if (points.Count >= 3)
            {
                temp.AddPolygon(points.ToArray());
            }
            else if (points.Count == 2)
            {
                temp.AddLine(points[0], points[1]);
            }

            Region myRegion = new Region();
            myRegion.MakeEmpty();
            myRegion.Union(temp);

            PointF tempPt = new PointF();
            tempPt.X = rect.X;
            tempPt.Y = rect.Y;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X + rect.Width;
            tempPt.Y = rect.Y;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X;
            tempPt.Y = rect.Y + rect.Height;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            tempPt.X = rect.X + rect.Width;
            tempPt.Y = rect.Y + rect.Height;
            if (pointInPolygon(tempPt, myRegion))
                return true;

            return false;
        }
开发者ID:ackratos,项目名称:USTCMap,代码行数:95,代码来源:Index.cs

示例4: Carte_Paint

        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int i;
            double w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
            this.ForeColor = Color.Black;
            Brush brosse =new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            double deltax,deltay,voldeltax,voldeltay;
            double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1=new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();

            PointF[] points = new PointF[4] ;
               double angle=0,norme=0;
            double sinx = 0, cosx = 1;
            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {

                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));

                    p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
                    p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
                    p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
                    p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
                    p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
                    p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
                    p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
                    p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);

                    System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;

                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
//.........这里部分代码省略.........
开发者ID:crocovert,项目名称:musliw,代码行数:101,代码来源:Carte.cs

示例5: PaintOneRange


//.........这里部分代码省略.........
						break;

					case ValueInterpretation.AbsoluteValue:
						{
							if (posErrCol != null)
							{
								var vPosLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(posErrCol[originalRowIndex]);
								vPosLogical = Calc.RMath.ClampToInterval(vPosLogical, logicalClampMinimum, logicalClampMaximum);
								logicalPos.SetR(axisNumber, vPosLogical);
								logicalPosValid = !logicalPos.IsNaN && vPosLogical != vMeanLogical;
							}

							if (negErrCol != null)
							{
								var vNegLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(negErrCol[originalRowIndex]);
								vNegLogical = Calc.RMath.ClampToInterval(vNegLogical, logicalClampMinimum, logicalClampMaximum);
								logicalNeg.SetR(axisNumber, vNegLogical);
								logicalNegValid = !logicalNeg.IsNaN && vNegLogical != vMeanLogical;
							}

							if (object.ReferenceEquals(negErrCol, posErrCol))
							{
								logicalNegValid = false; // then we need only to plot the positive column, since both colums are identical
							}
						}
						break;
				} // end switch

				if (!(logicalPosValid || logicalNegValid))
					continue; // nothing to do for this point if both pos and neg logical point are invalid.

				if (logicalNegValid)
				{
					errorBarPath.Reset();
					layer.CoordinateSystem.GetIsoline(errorBarPath, logicalMean, logicalNeg);
					PointF[] shortenedPathPoints = null;
					bool shortenedPathPointsCalculated = false;
					if (_useSymbolGap)
					{
						double gap = _symbolGapOffset + _symbolGapFactor * symbolSize;
						if (gap > 0)
						{
							errorBarPath.Flatten();
							var pathPoints = errorBarPath.PathPoints;
							shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gap / 2), RADouble.NewAbs(0));
							shortenedPathPointsCalculated = true;
							if (null == shortenedPathPoints && _forceVisibilityOfEndCap && !(strokePen.EndCap is Altaxo.Graph.Gdi.LineCaps.FlatCap))
							{
								var totalLineLength = GdiExtensionMethods.TotalLineLength(pathPoints);
								var shortTheLineBy = Math.Max(0, totalLineLength - 0.125 * strokePen.Width);
								shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(shortTheLineBy), RADouble.NewAbs(0));
							}
						}
					}

					if (shortenedPathPointsCalculated)
					{
						if (null != shortenedPathPoints)
						{
							g.DrawLines(strokePen, shortenedPathPoints);
						}
					}
					else
					{
						g.DrawPath(strokePen, errorBarPath);
					}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:67,代码来源:ErrorBarPlotStyle.cs

示例6: drawQuadTex

 void drawQuadTex(Graphics g, Bitmap tex, PointF[] quad) {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddPolygon(new PointF[] { quad[0], quad[1], quad[3] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     g.DrawImage(tex, new PointF[] { quad[0], quad[1], quad[3] });
     gp.Reset();
     gp.AddPolygon(new PointF[] { quad[2], quad[3], quad[1] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     g.DrawImage(tex, new PointF[] { quad[2], quad[3], quad[1] });
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     gp.Dispose();
     g.ResetClip();
 }
开发者ID:nastys,项目名称:Uwizard,代码行数:14,代码来源:Form1.cs


注:本文中的System.Drawing.Drawing2D.GraphicsPath.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。