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


C# Graphics.TranslateTransform方法代码示例

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


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

示例1: Draw

    public void Draw(Graphics graphics, Size buffersize)
    {
        //store transform, (like opengl's glPushMatrix())
        Matrix mat1 = graphics.Transform;

        //transform into position
        graphics.TranslateTransform(m_position.X, m_position.Y);
        graphics.RotateTransform(m_angle/(float)Math.PI * 180.0f);

        try
        {
            //draw body
            graphics.DrawRectangle(new Pen(m_color), rect);

            //draw line in the "forward direction"
            graphics.DrawLine(new Pen(Color.Yellow), 1, 0, 1, 5);
        }
        catch(OverflowException exc)
        {
            //physics overflow :(
        }

        //restore transform
        graphics.Transform = mat1;
    }
开发者ID:zenmumbler,项目名称:GranZero,代码行数:25,代码来源:RigidBody.cs

示例2: paint

    public void paint(Graphics g)
    {
        int Xpos = (int)(xpos*TuioDemo.width);
            int Ypos = (int)(ypos*TuioDemo.height);
            int size = TuioDemo.height/10;

            g.TranslateTransform(Xpos,Ypos);
            g.RotateTransform((float)(angle/Math.PI*180.0f));
            g.TranslateTransform(-1*Xpos,-1*Ypos);

            g.FillRectangle(black, new Rectangle(Xpos-size/2,Ypos-size/2,size,size));

            g.TranslateTransform(Xpos,Ypos);
            g.RotateTransform(-1*(float)(angle/Math.PI*180.0f));
            g.TranslateTransform(-1*Xpos,-1*Ypos);

            Font font = new Font("Arial", 10.0f);
            g.DrawString(symbol_id+"",font, white, new PointF(Xpos-10,Ypos-10));
    }
开发者ID:tasku12,项目名称:TUIO,代码行数:19,代码来源:TuioDemoObject.cs

示例3: SetScale

    private void SetScale(Graphics g)
    {
        g.TranslateTransform(Width / 2, Height / 2);

        float inches = Math.Min(Width / g.DpiX, Height / g.DpiX);

        g.ScaleTransform(inches * g.DpiX / 2000, inches * g.DpiY / 2000);
    }
开发者ID:rajalekshminovasoft,项目名称:CJ,代码行数:8,代码来源:ReportCITATQ.ascx.cs

示例4: PaintTransparentBackground

            protected void PaintTransparentBackground(Graphics g, Rectangle clipRect)
            {
                if (this.Parent != null)
                {
                    clipRect.Offset(this.Location);
                    PaintEventArgs e = new PaintEventArgs(g, clipRect);
                    GraphicsState state = g.Save();
                    g.SmoothingMode = SmoothingMode.HighSpeed;
                    try
                    {
                        g.TranslateTransform(System.Convert.ToSingle(- this.Location.X), System.Convert.ToSingle(- this.Location.Y));
                        this.InvokePaintBackground(this.Parent, e);
                        this.InvokePaint(this.Parent, e);

                    }
                    finally
                    {
                        g.Restore(state);
                        clipRect.Offset(- this.Location.X, - this.Location.Y);
                    }
                }
                else
                {
                    System.Drawing.Drawing2D.LinearGradientBrush backBrush = new System.Drawing.Drawing2D.LinearGradientBrush(this.Bounds, SystemColors.ControlLightLight, SystemColors.ControlLight, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                    g.FillRectangle(backBrush, this.Bounds);
                    backBrush.Dispose();
                }
            }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:28,代码来源:SPTabControl.cs

示例5: DrawMeasure

  private void DrawMeasure(Graphics graphics, IGeometry geometry)
  {
    string measureUnits = AppSettings.MeasureUnits;
    bool inFeet = measureUnits == "feet" || measureUnits == "both";
    bool inMeters = measureUnits == "meters" || measureUnits == "both";

    System.Drawing.Font font = AppSettings.MeasureFont;
    font = new System.Drawing.Font(font.FontFamily, Convert.ToSingle(font.Size * _resolution), font.Style, font.Unit);
    SolidBrush brush = new SolidBrush(Color.FromArgb(64, 64, 64));
    SolidBrush glowBrush = new SolidBrush(Color.White);

    StringFormat format = new StringFormat();
    format.Alignment = StringAlignment.Center;
    format.LineAlignment = StringAlignment.Center;

    double convert = 1 / (AppSettings.MapUnits == "feet" ? 1 : Constants.MetersPerFoot);
    StringCollection text = new StringCollection();

    switch (geometry.OgcGeometryType)
    {
      case OgcGeometryType.LineString:
        ILineString lineString = (ILineString)geometry;

        double d = lineString.Length * convert;

        if (inFeet)
        {
          text.Add(d < 5280 ? d.ToString("0") + " ft" : (d / 5280).ToString("0.0") + " mi");
        }

        if (inMeters)
        {
          d *= Constants.MetersPerFoot;
          text.Add(d < 1000 ? d.ToString("0") + " m" : (d / 1000).ToString("0.0") + " km");
        }

        IPoint p;
        double angle;

        GetMidpoint(lineString, out p, out angle);

        angle = -(angle * 180 / Math.PI);
        angle = angle < -90 || 90 < angle ? angle + 180 : angle < 0 ? angle + 360 : angle;

        p = _transform.ReverseTransform(p);

        float x = Convert.ToSingle(p.Coordinate.X * _resolution);
        float y = Convert.ToSingle(p.Coordinate.Y * _resolution);

        format.LineAlignment = StringAlignment.Far;

        int[] pos = new int[] { 0, 1, 2, 3, 5, 6, 7, 8, 4 };

        for (int i = 0; i < 9; ++i)
        {
          float offsetX = (pos[i] % 3) - 1;
          float offsetY = Convert.ToSingle(Math.Floor(pos[i] / 3.0)) - 1;

          System.Drawing.Drawing2D.GraphicsState state = graphics.Save();
          graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
          graphics.TranslateTransform(x, y);
          graphics.RotateTransform(Convert.ToSingle(angle));
          graphics.DrawString(text.Join("\n"), font, i < 8 ? glowBrush : brush, Convert.ToSingle(offsetX * _resolution), Convert.ToSingle(offsetY - 3 * _resolution), format);
          graphics.Restore(state);
        }
        break;

      case OgcGeometryType.Polygon:
        IPolygon polygon = (IPolygon)geometry;
        IPoint c = polygon.Centroid;

        if (c != null)
        {
          double a = polygon.Area * convert * convert;
          double acres = a / Constants.SquareFeetPerAcre;

          if (inFeet)
          {
            double squareMile = Constants.FeetPerMile * Constants.FeetPerMile;
            text.Add(a <= squareMile ? a.ToString("0") + " sq ft" : (a / squareMile).ToString("0.00") + " sq mi");
          }

          if (inMeters)
          {
            a *= Constants.MetersPerFoot * Constants.MetersPerFoot;
            text.Add(a <= 100000 ? a.ToString("0") + " sq m" : (a / 1000000).ToString("0.00") + " sq km");
          }

          if (inFeet)
          {
            text.Add(acres.ToString("0.00") + " acres");
          }

          DrawText(graphics, c, text.Join("\n"), font, brush, glowBrush, 0, 0, format);
        }
        break;
    }
  }
开发者ID:ClaireBrill,项目名称:GPV,代码行数:98,代码来源:MapMaker.cs

示例6: DrawBar

 private void DrawBar(Graphics objGraphics, 
         int Value, int BarNumber, string Label)
 {
     int intLeft   = (BarNumber*75)+60;
         int intBottom   = 275;
         int intHeight   = (25*Value);
          //绘制柱面
         objGraphics.FillRectangle(Brushes.Red,intLeft,
            intBottom-intHeight,35,intHeight);
         //使用GraphicsPath方法绘制柱面顶层
         GraphicsPath pthTop = new GraphicsPath();
         pthTop.AddLine(intLeft-1, intBottom-intHeight,
            intLeft+20, intBottom-intHeight-10);
         pthTop.AddLine(intLeft+55,intBottom-
            intHeight-10,intLeft+35,
            intBottom-intHeight);
         objGraphics.FillPath(Brushes.LightSalmon,
            pthTop);
         // 绘制柱面左侧
         GraphicsPath pthRight = new GraphicsPath();
         pthRight.AddLine(intLeft+35,intBottom-
            intHeight,intLeft+55,intBottom-
            intHeight-10);
         pthRight.AddLine(intLeft+55,
            intBottom-15,intLeft+35,intBottom);
         objGraphics.FillPath(Brushes.Firebrick,
            pthRight);
         //绘制标签
         objGraphics.TranslateTransform(intLeft+15,
            intBottom-intHeight - 30);
         objGraphics.RotateTransform(300);
         objGraphics.DrawString(Label,new
            Font("Arial",10,FontStyle.Bold),
            Brushes.Black,0,0);
         objGraphics.ResetTransform();
 }
开发者ID:AJLoveChina,项目名称:workAtQmm,代码行数:36,代码来源:WebDemo.aspx.cs


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