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


C# System.Drawing.Drawing2D.Matrix.Clone方法代码示例

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


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

示例1: InitializeTransformMatrix

        protected override bool InitializeTransformMatrix()
        {
            if (this.CurveList == null)
             {
            this.IsInitialized = false;
            InvalidSerieException e = new InvalidSerieException("No data to display...");
            StockLog.Write(e);
            throw e;
             }
             if (this.GraphRectangle.Height > 0)
             {
            EventSeries.Clear();

            // Create fake Event Series;
            for (int i = 0; i < 5; i++)
            {
               EventSeries.Add(new BoolSerie(this.EndIndex, "Test" + i, i%2 == 0));
            }

            minValue = 0.0f;
            maxValue = EventSeries.Count + 1;

            if (graphic == null)
            {
               // Initialise graphics
               this.graphic = this.CreateGraphics();
               RectangleF rect = this.graphic.VisibleClipBounds;
               rect.Inflate(new SizeF(-this.XMargin, -this.YMargin));
               this.GraphRectangle = rect;
            }

            float coefX = (this.GraphRectangle.Width * 0.96f) / (EndIndex - StartIndex);
            float coefY = this.GraphRectangle.Height / (maxValue - minValue);

            matrixValueToScreen = new System.Drawing.Drawing2D.Matrix();
            matrixValueToScreen.Translate(this.GraphRectangle.X - (StartIndex - 0.5f) * coefX, maxValue * coefY + this.GraphRectangle.Y);
            matrixValueToScreen.Scale(coefX, -coefY);

            matrixScreenToValue = (System.Drawing.Drawing2D.Matrix)matrixValueToScreen.Clone();
            matrixScreenToValue.Invert();
             }
             else
             {
            this.Deactivate("App too small...", false);
            return false;
             }
             return true;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:48,代码来源:GraphMutiTimeFrameControl.cs

示例2: InitializeTransformMatrix

        protected override bool InitializeTransformMatrix()
        {
            if (this.CurveList == null)
             {
            this.IsInitialized = false;
            InvalidSerieException e = new InvalidSerieException("No data to display...");
            StockLog.Write(e);
            throw e;
             }
             if (this.GraphRectangle.Height > 0)
             {
            minValue = float.MaxValue;
            maxValue = float.MinValue;
            this.CurveList.GetMinMax(StartIndex, EndIndex, ref minValue, ref maxValue, this.ScaleInvisible);

            if (minValue == maxValue || float.IsNaN(minValue) || float.IsInfinity(minValue) || float.IsNaN(maxValue) || float.IsInfinity(maxValue))
            {
               this.Deactivate("No volume for this stock", false);
               return false;
            }
            if (graphic == null)
            {
               // Initialise graphics
               this.graphic = this.CreateGraphics();
               RectangleF rect = this.graphic.VisibleClipBounds;
               rect.Inflate(new SizeF(-this.XMargin, -this.YMargin));
               this.GraphRectangle = rect;
            }

            float coefX = (this.GraphRectangle.Width * 0.96f) / (EndIndex - StartIndex);
            float coefY = this.GraphRectangle.Height / (maxValue - minValue);

            matrixValueToScreen = new System.Drawing.Drawing2D.Matrix();
            matrixValueToScreen.Translate(this.GraphRectangle.X - (StartIndex - 0.5f) * coefX, maxValue * coefY + this.GraphRectangle.Y);
            matrixValueToScreen.Scale(coefX, -coefY);

            matrixScreenToValue = (System.Drawing.Drawing2D.Matrix)matrixValueToScreen.Clone();
            matrixScreenToValue.Invert();
             }
             else
             {
            this.Deactivate("App too small...", false);
            return false;
             }
             return true;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:46,代码来源:GraphVolumeControl.cs

示例3: InitializeTransformMatrix

        protected override bool InitializeTransformMatrix()
        {
            if (float.IsNaN(this.RangeMin) || float.IsNaN(this.RangeMax))
             {
            return base.InitializeTransformMatrix();
             }

             if (this.CurveList == null)
             {
            this.IsInitialized = false;
            InvalidSerieException e = new InvalidSerieException("No data to display...");
            throw e;
             }
             if (this.CurveList.GetNbVisible() == 0)
             {
            this.Deactivate("No data to display...", false);
            return false;
             }
             if (this.StartIndex == this.EndIndex || this.EndIndex > this.dateSerie.Length - 1)
             {
            this.IsInitialized = false;
            InvalidSerieException e = new InvalidSerieException("Invalid input data range...");
            throw e;
             }
             if (this.GraphRectangle.Height > 0)
             {
            float minValue = this.RangeMin, maxValue = this.RangeMax;
            float coefX = (this.GraphRectangle.Width * 0.96f) / (EndIndex - StartIndex);
            float coefY = this.GraphRectangle.Height / (maxValue - minValue);

            matrixValueToScreen = new System.Drawing.Drawing2D.Matrix();
            matrixValueToScreen.Translate(this.GraphRectangle.X - (StartIndex - 0.5f) * coefX, maxValue * coefY + this.GraphRectangle.Y);
            matrixValueToScreen.Scale(coefX, -coefY);

            matrixScreenToValue = (System.Drawing.Drawing2D.Matrix)matrixValueToScreen.Clone();
            matrixScreenToValue.Invert();
            return true;
             }
             return false;
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:40,代码来源:GraphRangedControl.cs

示例4: TestMatrix2

            public void TestMatrix2()
            {
                System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                mat.Rotate(30);
                mat.Translate(-20, 20);

                var at = new AffineCoordinateTransformation2D(mat);
                var atInv = at.Inverse();

                var p0 = new double[] { 50d, 50d };
                var pt = at.Transform(p0);
                at.Invert();
                var p1 = at.Transform(pt);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p1[0] - p0[0]), 0.01d);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p1[1] - p0[1]), 0.01d);
                var p2 = atInv.Transform(pt);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p2[0] - p0[0]), 0.01d);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p2[1] - p0[1]), 0.01d);

                System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF(50, 50) };

                mat.TransformPoints(pts);
                System.Diagnostics.Debug.WriteLine(string.Format("POINT ({0} {1})", pts[0].X, pts[0].Y));
                System.Drawing.PointF ptt = pts[0];
                System.Drawing.PointF[] ptts = new System.Drawing.PointF[] { new System.Drawing.PointF(ptt.X, ptt.Y) };
                System.Drawing.Drawing2D.Matrix inv = mat.Clone();
                inv.Invert();
                inv.TransformPoints(ptts);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].X - 50f), 0.01);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].Y - 50f), 0.01);
            }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:31,代码来源:ProjectionExamples.cs

示例5: TestMatrix

            public void TestMatrix()
            {
                SharpMap.Geometries.Point p = new Point(10, 10);
                var b = p.AsBinary();

                System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                mat.Rotate(30);
                mat.Translate(-20, 20);
                System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF(50, 50) };

                mat.TransformPoints(pts);
                System.Diagnostics.Debug.WriteLine(string.Format("POINT ({0} {1})", pts[0].X, pts[0].Y));
                System.Drawing.PointF ptt = pts[0];
                System.Drawing.PointF[] ptts = new System.Drawing.PointF[] { new System.Drawing.PointF(ptt.X, ptt.Y) };
                System.Drawing.Drawing2D.Matrix inv = mat.Clone();
                inv.Invert();
                inv.TransformPoints(ptts);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].X - 50f), 0.01);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].Y - 50f), 0.01);
            }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:20,代码来源:ProjectionExamples.cs

示例6: InitializeTransformMatrix

        protected override bool InitializeTransformMatrix()
        {
            using (MethodLogger ml = new MethodLogger(this))
             {
            if (!CheckGraphSanity()) { return false; }
            if (this.GraphRectangle.Height > 0)
            {
               minValue = float.MaxValue;
               maxValue = float.MinValue;
               this.CurveList.GetMinMax(0, dateSerie.Length - 1, ref minValue, ref maxValue, this.ScaleInvisible);

               if (minValue == maxValue || minValue == float.MaxValue || float.IsNaN(minValue) || float.IsInfinity(minValue) || maxValue == float.MinValue || float.IsNaN(maxValue) || float.IsInfinity(maxValue))
               {
                  this.Deactivate("Input data is corrupted and cannot be displayed...", false);
                  return false;
               }

               if (this.IsLogScale && minValue > 0)
               {
                  minValue -= (maxValue - minValue) * 0.025f;
               }
               else
               {
                  minValue -= (maxValue - minValue) * 0.05f;
               }
               maxValue += (maxValue - minValue) * 0.05f;

               float tmpMinValue, tmpMaxValue;
               if (this.IsLogScale)
               {
                  tmpMinValue = minValue < 0 ? (float)-Math.Log10(-minValue + 1) : (float)Math.Log10(minValue + 1);
                  tmpMaxValue = maxValue < 0 ? (float)-Math.Log10(-maxValue + 1) : (float)Math.Log10(maxValue + 1);
               }
               else
               {
                  tmpMinValue = minValue;
                  tmpMaxValue = maxValue;
               }

               float coefX = (this.GraphRectangle.Width * 0.94f) / (dateSerie.Length - 1);
               float coefY = this.GraphRectangle.Height / (tmpMaxValue - tmpMinValue);

               matrixValueToScreen = new System.Drawing.Drawing2D.Matrix();
               matrixValueToScreen.Translate(this.GraphRectangle.X + 20, tmpMaxValue * coefY + this.GraphRectangle.Y);
               matrixValueToScreen.Scale(coefX, -coefY);

               matrixScreenToValue = (System.Drawing.Drawing2D.Matrix)matrixValueToScreen.Clone();
               matrixScreenToValue.Invert();
            }
            else
            {
               this.Deactivate("App too small...", false);
               return false;
            }
            return true;
             }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:57,代码来源:GraphScrollerControl.cs

示例7: LineIntersectsRect

 public bool LineIntersectsRect(Matrix rayMatrix, Rectangle r)
 {
     Matrix m = rayMatrix.Clone();
     m.Translate(200, 0);
     return LineIntersectsRect(
         new System.Drawing.Point((int)rayMatrix.OffsetX, (int)rayMatrix.OffsetY),
         new System.Drawing.Point((int)m.OffsetX, (int)m.OffsetY),
         r);
 }
开发者ID:kfpopeye,项目名称:AddMaterials,代码行数:9,代码来源:FillPatternViewerControlWpf.xaml.cs

示例8: DrawFillPattern


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

                    var pen = new Pen(System.Drawing.Color.Black)
                    {
                        Width = 1f / matrixScale
                    };

                    float dashLength = 1;
                    var segments = fillGrid.GetSegments();

                    if (segments.Count > 0)
                    {
                        pen.DashPattern = segments
                            .Select(Convert.ToSingle)
                            .ToArray();

                        Debug.Print("\tSegments:");
                        foreach (var segment in segments)
                        {
                            Debug.Print("\t\t{0}", segment);
                        }

                        dashLength = pen.DashPattern.Sum();
                    }

                    g.ResetTransform();
                    var rotateMatrix = new Matrix();
                    rotateMatrix.Rotate(degreeAngle);
                    var matrix = new Matrix(1, 0,
                                            0, -1,
                                            centerX, centerY); //-1 reflects about x-axis
                    matrix.Scale(matrixScale, matrixScale);
                    matrix.Translate((float)fillGrid.Origin.U,
                                     (float)fillGrid.Origin.V);
                    var backMatrix = matrix.Clone();
                    backMatrix.Multiply(rotateMatrix);
                    matrix.Multiply(rotateMatrix);

                    var offset = (-10) * dashLength;
                    matrix.Translate(offset, 0);
                    backMatrix.Translate(offset, 0);
                    Debug.Print("Offset: {0}", offset);

                    bool moving_forward = true;
                    bool moving_back = true;
                    int safety = 500;
                    double alternator = 0;
                    while (moving_forward || moving_back)    //draw segments shifting and offsetting each time
                    {
                        Debug.Write("*");
                        var rectF1 = new RectangleF(-2 / matrixScale, -2 / matrixScale, 4 / matrixScale, 4 / matrixScale);

                        if (moving_forward && LineIntersectsRect(matrix, viewRect))
                        {
                            g.Transform = matrix;
                            g.DrawLine(pen, new PointF(0, 0), new PointF(LENGTH, 0));
                        }
                        else
                        {
                            moving_forward = false;
                            Debug.Print("\n----> Matrix does not intersect view");
                        }

                        if (moving_back && LineIntersectsRect(backMatrix, viewRect))
                        {
                            g.Transform = backMatrix;
                            g.DrawLine(pen, new PointF(0, 0), new PointF(LENGTH, 0));
开发者ID:kfpopeye,项目名称:AddMaterials,代码行数:67,代码来源:FillPatternViewerControlWpf.xaml.cs


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