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


C# Drawing2D.Matrix类代码示例

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


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

示例1: InitializeMap

        public static SharpMap.Map InitializeMap(float angle)
        {
            using (var ofn = new System.Windows.Forms.OpenFileDialog())
            {
                ofn.Filter = "All files|*.*";
                ofn.FilterIndex = 0;

                if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var m = new SharpMap.Map();
                    var l = new SharpMap.Layers.GdiImageLayer(ofn.FileName);
                    m.Layers.Add(l);

                    m.ZoomToExtents();

                    var mat = new System.Drawing.Drawing2D.Matrix();
                    mat.RotateAt(angle, m.WorldToImage(m.Center));
                    m.MapTransform = mat;
                    m.MaximumExtents = m.GetExtents();
                    m.EnforceMaximumExtents = true;
                    return m;
                }
            }
            return null;

        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:26,代码来源:GdiImageLayerSample.cs

示例2: DrawVerticalScaleGrid

        /// <summary>
        /// Draws grid lines corresponding to a vertical scale</summary>
        /// <param name="g">The Direct2D graphics object</param>
        /// <param name="transform">Graph (world) to window's client (screen) transform</param>
        /// <param name="graphRect">Graph rectangle</param>
        /// <param name="majorSpacing">Scale's major spacing</param>
        /// <param name="lineBrush">Grid line brush</param>
        public static void DrawVerticalScaleGrid(
            this D2dGraphics g,
            Matrix transform,
            RectangleF graphRect,
            int majorSpacing,
            D2dBrush lineBrush)
        {
            double xScale = transform.Elements[0];
            RectangleF clientRect = Transform(transform, graphRect);

            double min = Math.Min(graphRect.Left, graphRect.Right);
            double max = Math.Max(graphRect.Left, graphRect.Right);
            double tickAnchor = CalculateTickAnchor(min, max);
            double step = CalculateStep(min, max, Math.Abs(clientRect.Right - clientRect.Left), majorSpacing, 0.0);
            if (step > 0)
            {
                double offset = tickAnchor - min;
                offset = offset - MathUtil.Remainder(offset, step) + step;
                for (double x = tickAnchor - offset; x <= max; x += step)
                {
                    double cx = (x - graphRect.Left) * xScale + clientRect.Left;
                    g.DrawLine((float)cx, clientRect.Top, (float)cx, clientRect.Bottom, lineBrush);
                }
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:32,代码来源:D2dUtil.cs

示例3: DoPaintRemote

 public void DoPaintRemote(PaintEventArgs e)
 {
     var matrix = new System.Drawing.Drawing2D.Matrix();
     matrix.Translate(this.Left, this.Top);
     e.Graphics.Transform = matrix;
     OnPaint(e);
 }
开发者ID:jackmaynard,项目名称:MissionPlanner,代码行数:7,代码来源:DistanceBar.cs

示例4: ConvertMatrix

 /// <summary>
 /// Converts the matrix.
 /// </summary>
 /// <param name="MediaMatrix">The media matrix.</param>
 /// <returns></returns>
 public static dm ConvertMatrix(mm MediaMatrix)
 {
     var ret = new dm((float) MediaMatrix.M11, (float) MediaMatrix.M12, (float) MediaMatrix.M21,
         (float) MediaMatrix.M22, (float) MediaMatrix.OffsetX,
         (float) MediaMatrix.OffsetY);
     return ret;
 }
开发者ID:andreigec,项目名称:ANDREICSLIB,代码行数:12,代码来源:MathExtras.cs

示例5: Area_Paint

        /// <summary>
        /// Draw all areas of the selected quest and highlight the selected area.
        /// </summary>
        private void Area_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Area.BackColor);

            Matrix transformMatrix = new Matrix();
            transformMatrix.Rotate(90);
            transformMatrix.Multiply(new Matrix(-1, 0, 0, 1, 0, 0)); // Flip x-axis

            WoWQuestStep[] steps = ((QuestDisplayData)bsQuests.Current).Steps;

            float maxX = steps.Max(step => step.AreaPoints.Max(ap => ap.X));
            float maxY = steps.Max(step => step.AreaPoints.Max(ap => ap.Y));

            transformMatrix.Translate(-maxX - 5, -maxY - 5);

            e.Graphics.Transform = transformMatrix;

            // Draw all areas
            foreach (WoWQuestStep step in steps)
            {
                PointF[] drawPoints = ConvertToDrawingPoints(step.AreaPoints);
                if (drawPoints.Length < 3)
                {
                    foreach (PointF point in drawPoints)
                    {
                        // Draw a point 5x5 pixels
                        e.Graphics.FillEllipse(AREA_FILL, point.X - 2, point.Y - 2, 5F, 5F);
                        e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
                    }
                }
                else
                {
                    e.Graphics.FillPolygon(AREA_FILL, drawPoints);
                    e.Graphics.DrawPolygon(AREA_BORDER, drawPoints);
                }
            }

            // Highlight selected area
            if (SelectedAreaPoints != null)
            {
                if (SelectedAreaPoints.Length < 3)
                {
                    foreach (PointF point in SelectedAreaPoints)
                    {
                        e.Graphics.FillEllipse(AREA_HIGHLIGHT, point.X - 2, point.Y - 2, 5F, 5F);
                        e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
                    }
                }
                else
                {
                    e.Graphics.FillPolygon(AREA_HIGHLIGHT, this.SelectedAreaPoints);
                    e.Graphics.DrawPolygon(AREA_BORDER, this.SelectedAreaPoints);
                }
            }
        }
开发者ID:Sanjo,项目名称:Honorbuddy-QuestPOI,代码行数:58,代码来源:FormQuestView.cs

示例6: InitializeMap

        public static SharpMap.Map InitializeMap(int angle, string[] filenames)
        {
            var map = new SharpMap.Map();
            for (int i = 0; i < filenames.Length; i++)
                map.Layers.Add(new SharpMap.Layers.GdalRasterLayer(System.IO.Path.GetFileName(filenames[i]), filenames[i]));

            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;
            map.ZoomToExtents();
            return map;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:12,代码来源:GdalSample.cs

示例7: Map

		/// <summary>
		/// Initializes a new map
		/// </summary>
		/// <param name="size">Size of map in pixels</param>
		public Map(System.Drawing.Size size)
		{
			this.Size = size;
			this.Layers = new List<SharpMap.Layers.ILayer>();
			this.BackColor = System.Drawing.Color.Transparent;
			this._MaximumZoom = double.MaxValue;
			this._MinimumZoom = 0;
			_MapTransform = new System.Drawing.Drawing2D.Matrix();
			MapTransformInverted = new System.Drawing.Drawing2D.Matrix();
			_Center = new SharpMap.Geometries.Point(0, 0);
			_Zoom = 1;
			_PixelAspectRatio = 1.0;
		}		
开发者ID:diegowald,项目名称:intellitrack,代码行数:17,代码来源:Map.cs

示例8: Map

		/// <summary>
		/// Initializes a new map
		/// </summary>
		/// <param name="size">Size of map in pixels</param>
		public Map(System.Drawing.Size size)
		{
			this.Size = size;
            this.Layers = new SharpMap.Layers.LayerCollection();
			this.BackColor = System.Drawing.Color.Transparent;
			this._MaximumZoom = double.MaxValue;
			this._MinimumZoom = 0;
			_MapTransform = new System.Drawing.Drawing2D.Matrix();
			MapTransformInverted = new System.Drawing.Drawing2D.Matrix();
			_Center = SharpMap.Converters.Geometries.GeometryFactory.CreateCoordinate(0, 0);
			_Zoom = 1;
			_PixelAspectRatio = 1.0;
		}		
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:Map.cs

示例9: Save

        internal override void Save(FlowChartModel model)
        {
            float ZoomFactor = 4.0f;

            using (Bitmap bmp = new Bitmap((int)(601*ZoomFactor), (int)(851*ZoomFactor)))
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    System.Drawing.Drawing2D.Matrix mx = new System.Drawing.Drawing2D.Matrix(ZoomFactor, 0, 0, ZoomFactor, 0, 0);                    
                    g.Transform = mx;

                    g.PageUnit = GraphicsUnit.Pixel;
                    g.Clear(Color.White);
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
                    
                    model.Items.ForEach(x =>
                    {
                        x.View.Draw(g);
                    });

                    g.Save();

                    ImageFormat fm = ImageFormat.Bmp;
                    if (Path.GetExtension(fileName).ToLower() == ".png")
                    {
                        fm = System.Drawing.Imaging.ImageFormat.Png;
                    }
                    else if (Path.GetExtension(fileName).ToLower() == ".jpg")
                    {
                        fm = System.Drawing.Imaging.ImageFormat.Jpeg;
                    }
                    else if (Path.GetExtension(fileName).ToLower() == ".jpeg")
                    {
                        fm = System.Drawing.Imaging.ImageFormat.Jpeg;
                    }
                    else if (Path.GetExtension(fileName).ToLower() == ".gif")
                    {
                        fm = System.Drawing.Imaging.ImageFormat.Gif;
                    }
                    else if (Path.GetExtension(fileName).ToLower() == ".tiff")
                    {
                        fm = System.Drawing.Imaging.ImageFormat.Tiff;
                    }
                    bmp.Save(fileName, fm);
                }
            }
        }
开发者ID:JackWangCUMT,项目名称:FlowChart,代码行数:49,代码来源:ImageStorage.cs

示例10: 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

示例11: 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

示例12: 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

示例13: DrawNode

        public bool DrawNode(Node node, object graphics)
        {
            Graphics g = (Graphics)graphics;

            var m = g.Transform;
            var saveM = g.Transform.Clone();
            //      g.SetClip(FillTheGraphicsPath(node.GeometryNode.BoundaryCurve));

            // This is supposed to flip the text around its center

            var c = (float)node.GeometryNode.Center.Y;
            using (var m2 = new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 2 * c))
            {
                m.Multiply(m2);
            }

            m.Translate(
                (float)node.GeometryNode.Center.X,
                (float)node.GeometryNode.Center.Y);

            g.Transform = m;

            var styleStack = GetStyleStack();
            var painter = new TextViewPainter(
                Layout, g,
                SystemColors.WindowText,
                SystemColors.Window,
                SystemFonts.DefaultFont, styleStack);
            var ptr = new TextPointer { Character = 0, Span = 0, Line = TextModel.StartPosition };
            painter.SetSelection(ptr, ptr);
            painter.PaintGdiPlus();
            g.Transform = saveM;
            g.ResetClip();

            saveM.Dispose();
       //     m.Dispose();
            return true;//returning false would enable the default rendering
        }
开发者ID:relaxar,项目名称:reko,代码行数:38,代码来源:CfgBlockNode.cs

示例14: DrawNode

        bool DrawNode(DrawingNode node, object graphics) {
            Graphics g = (Graphics)graphics;
            Image image = ImageOfNode(node);

            //flip the image around its center
            using (System.Drawing.Drawing2D.Matrix m = g.Transform)
            {
                using (System.Drawing.Drawing2D.Matrix saveM = m.Clone())
                {

                    g.SetClip(FillTheGraphicsPath(node.GeometryNode.BoundaryCurve));
                    using (var m2 = new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 2 * (float)node.GeometryNode.Center.Y))
                        m.Multiply(m2);

                    g.Transform = m;
                    g.DrawImage(image, new PointF((float)(node.GeometryNode.Center.X - node.GeometryNode.Width / 2),
                        (float)(node.GeometryNode.Center.Y - node.GeometryNode.Height / 2)));
                    g.Transform = saveM;

                }
            }

            return true;//returning false would enable the default rendering
        }
开发者ID:WenzCao,项目名称:automatic-graph-layout,代码行数:24,代码来源:Form1.cs

示例15: Draw2dTextures

        public void Draw2dTextures(Draw2dData[] todraw, int textureid, float angle)
        {
            GL.PushAttrib(AttribMask.ColorBufferBit);
            GL.BindTexture(TextureTarget.Texture2D, textureid);
            GL.Enable(EnableCap.Texture2D);
            GL.Disable(EnableCap.DepthTest);

            VertexPositionTexture[] vertices;
            ushort[] indices;
            if (todraw.Length >= draw2dtexturesMAX)
            {
                vertices = new VertexPositionTexture[todraw.Length * 4];
                indices = new ushort[todraw.Length * 4];
            }
            else
            {
                if (draw2dtexturesVertices == null)
                {
                    draw2dtexturesVertices = new VertexPositionTexture[draw2dtexturesMAX * 4];
                    draw2dtexturesIndices = new ushort[draw2dtexturesMAX * 4];
                }
                vertices = draw2dtexturesVertices;
                indices = draw2dtexturesIndices;
            }
            ushort i = 0;
            foreach (Draw2dData v in todraw)
            {
                RectangleF rect;
                if (v.inAtlasId == null)
                {
                    rect = new RectangleF(0, 0, 1, 1);
                }
                else
                {
                    rect = TextureAtlas.TextureCoords2d(v.inAtlasId.Value, d_Terrain.texturesPacked);
                }
                float x2 = v.x1 + v.width;
                float y2 = v.y1 + v.height;

                PointF[] pnts = new PointF[4] {
                    new PointF(x2, y2),
                    new PointF(x2,v.y1),
                    new PointF(v.x1,v.y1),
                    new PointF(v.x1,y2)};
                if (angle != 0)
                {
                    System.Drawing.Drawing2D.Matrix mx=new System.Drawing.Drawing2D.Matrix();
                    mx.RotateAt(angle, new PointF(v.x1+v.width/2,v.y1+v.height/2));
                    mx.TransformPoints(pnts);
                }

                vertices[i] = new VertexPositionTexture(pnts[0].X, pnts[0].Y, 0, rect.Right, rect.Bottom, v.color);
                vertices[i + 1] = new VertexPositionTexture(pnts[1].X, pnts[1].Y, 0, rect.Right, rect.Top, v.color);
                vertices[i + 2] = new VertexPositionTexture(pnts[2].X, pnts[2].Y, 0, rect.Left, rect.Top, v.color);
                vertices[i + 3] = new VertexPositionTexture(pnts[3].X, pnts[3].Y, 0, rect.Left, rect.Bottom, v.color);
                indices[i] = i;
                indices[i + 1] = (ushort)(i + 1);
                indices[i + 2] = (ushort)(i + 2);
                indices[i + 3] = (ushort)(i + 3);
                i += 4;
            }
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.ColorArray);
            unsafe
            {
                fixed (VertexPositionTexture* p = vertices)
                {
                    GL.VertexPointer(3, VertexPointerType.Float, StrideOfVertices, (IntPtr)(0 + (byte*)p));
                    GL.TexCoordPointer(2, TexCoordPointerType.Float, StrideOfVertices, (IntPtr)(12 + (byte*)p));
                    GL.ColorPointer(4, ColorPointerType.UnsignedByte, StrideOfVertices, (IntPtr)(20 + (byte*)p));
                    GL.DrawElements(BeginMode.Quads, i, DrawElementsType.UnsignedShort, indices);
                }
            }
            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GL.DisableClientState(ArrayCap.VertexArray);
            GL.DisableClientState(ArrayCap.ColorArray);

            GL.Enable(EnableCap.DepthTest);
            GL.PopAttrib();
        }
开发者ID:henon,项目名称:manic_digger,代码行数:81,代码来源:The3d.cs


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