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


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

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


在下文中一共展示了System.Drawing.Drawing2D.Matrix.Scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Render

        public bool Render(DisplayInformation dpInfo, LayoutManager lm, bool isDesktopMode)
        {
            if( m_outputPath == string.Empty)
                return false;

            Rectangle wallRect;

            if (isDesktopMode)
            {
                wallRect = dpInfo.DesktopBounds;
            }
            else
            {
                wallRect = dpInfo.Primary.Bounds;
                wallRect.X = 0;
                wallRect.Y = 0;
            }

            //  Create the bitmap representing the wallpaper
            Bitmap bmp = new Bitmap(wallRect.Width, wallRect.Height);

            Graphics e = Graphics.FromImage(bmp);

            e.FillRectangle(Brushes.Black, 0, 0, wallRect.Width, wallRect.Height);

            foreach(KeyValuePair<int, LayoutCanvas> kvp in lm)
            {
                LayoutCanvas canvas = kvp.Value;
                Screen screen = dpInfo.Screens[kvp.Key];

                //  Get X and Y coordinates of screen in IMAGE coordinates (taking into account
                //  the shifts required to display the image properly)
                int x = (screen.X < 0) ? wallRect.Width + screen.X : screen.X;
                int y = (screen.Y < 0) ? -screen.Y : screen.Y;

                Rectangle scrBounds = new Rectangle(x, y, screen.Width, screen.Height);

                //  Fill screen background
                if (screen.Y >= 0)
                {
                    e.FillRectangle(new SolidBrush(canvas.BackgroundColour), scrBounds);
                }
                else
                {
                    Rectangle scrTop = new Rectangle(x, wallRect.Height - y, scrBounds.Width, -wallRect.Y);
                    Rectangle scrBtm = new Rectangle(x, -wallRect.Y - y, scrBounds.Width, scrBounds.Height + wallRect.Y);

                    Brush brush = new SolidBrush(canvas.BackgroundColour);

                    e.FillRectangle(brush, scrTop);
                    e.FillRectangle(brush, scrBtm);
                }

                //  Sort based on ZIndex
                LayoutObject[] clone = new LayoutObject[canvas.Count];
                canvas.CopyTo(clone);
                BubbleSort(clone);

                for( int i = 0; i < clone.Length; i++)
                {
                    LayoutObject lo = clone[i];

                    string trueSource = string.Empty;

                    if (canvas.IsShuffleEnabled)
                    {
                        trueSource = FileRandomizer.GetRandomFile(
                            Path.GetDirectoryName(lo.Source));
                    }
                    else
                    {
                        trueSource = lo.Source;
                    }

                    Rectangle loBounds = new Rectangle(lo.X + x, lo.Y + y, lo.ActualWidth, lo.ActualHeight);

                    if (scrBounds.IntersectsWith(loBounds))
                    {
                        //  Get intersecting region
                        Rectangle intRect = Rectangle.Intersect(scrBounds, loBounds);

                        //  Resized image
                        Bitmap bmpImage;

                        if (lo.IsFlippedX || lo.IsFlippedY)
                        {
                            bmpImage = new Bitmap(loBounds.Width, loBounds.Height);
                            Graphics gb = Graphics.FromImage(bmpImage);

                            System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();

                            m.Scale((lo.IsFlippedX) ? -1 : 1, (lo.IsFlippedY) ? -1 : 1);

                            if(lo.IsFlippedX)
                                m.Translate((float)-loBounds.Width + 1, 0);

                            if (lo.IsFlippedY)
                                m.Translate(0, (float)-loBounds.Height + 1);

                            gb.Transform = m;
//.........这里部分代码省略.........
开发者ID:philip-d,项目名称:PaperStitcher,代码行数:101,代码来源:Renderer.cs

示例5: TestScale

        public void TestScale(float tx, float ty, float sx, float sy)
        {
            dsxy = sx;
            matrixd = new System.Drawing.Drawing2D.Matrix();//System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 0);

            matrixd.Scale(sx, sy, System.Drawing.Drawing2D.MatrixOrder.Append);
            matrixd.Translate(tx, ty, System.Drawing.Drawing2D.MatrixOrder.Append);
        }
开发者ID:skipme,项目名称:ComGraMet,代码行数:8,代码来源:CGMImageStructure.cs

示例6: SetBoundingRect

 public override void SetBoundingRect(System.Drawing.RectangleF bounds)
 {
     // this method hasn't been used yet
     switch (this.Shape)
     {
         case PathShape.Curve:
             throw new NotImplementedException();
         case PathShape.Ellipse:
             //m_path = new VectorPath();
             //m_path.AddEllipse(bounds);
             //break;
         case PathShape.Rectangle:
             //m_path = new VectorPath();
             //m_path.AddRectangle(bounds);
             //break;
         case PathShape.Freeform:
             RectangleF oldBounds = GetBoundingRect();
             SizeF oldSize = oldBounds.Size;
             SizeF newSize = bounds.Size;
             PointF oldCorner = oldBounds.Location;
             PointF newCorner = bounds.Location;
             System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
             m.Translate(-oldCorner.X, -oldCorner.Y);
             m.Scale(newSize.Width / oldSize.Width, newSize.Height / oldSize.Height);
             m.Translate(newCorner.X, newCorner.Y);
             m_path.Transform(m);
             break;
     }
 }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:29,代码来源:RegionToolParameter.cs

示例7: GetCurrentPosteriorVector

		private static Vector3D GetCurrentPosteriorVector(Vector3D imagePosterior, int sourceWidth, float adjustedSourceHeight, int rotation, float scaleX, float scaleY, bool flipX, bool flipY)
		{
			// figure out where the posterior direction went
			using (var transform = new Matrix())
			{
				var points = new[] {new PointF(sourceWidth*imagePosterior.X, adjustedSourceHeight*imagePosterior.Y)};
				transform.Rotate(rotation);
				transform.Scale(scaleX*(flipY ? -1 : 1), scaleY*(flipX ? -1 : 1));
				transform.TransformPoints(points);
				return new Vector3D(points[0].X, points[0].Y, 0);
			}
		}
开发者ID:jasper-yeh,项目名称:ClearCanvas,代码行数:12,代码来源:MammographyImageSpatialTransform.cs

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

示例9: DrawFillPattern

        private void DrawFillPattern(Graphics g)
        {
            Stopwatch sw = Stopwatch.StartNew();
            float matrixScale;
            var fillPattern = FillPattern;
            if (fillPattern == null)
                return;

            if (fillPattern.Target == FillPatternTarget.Model)
                matrixScale = Scale;
            else
                matrixScale = Scale * 10;

            try
            {
                var width =
                    (ActualWidth == 0 ? Width : ActualWidth) == 0
                    ? 100
                    : (ActualWidth == 0 ? Width : ActualWidth);

                if (double.IsNaN(width))
                    width = 100;

                var height =
                    (ActualHeight == 0 ? Height : ActualHeight) == 0
                    ? 30
                    : (ActualHeight == 0 ? Height : ActualHeight);

                if (double.IsNaN(height))
                    height = 30;

                var viewRect = new Rectangle(0, 0,
                                             (int)width, (int)height);

                var centerX = (viewRect.Left + viewRect.Left
                               + viewRect.Width) / 2;

                var centerY = (viewRect.Top + viewRect.Top
                               + viewRect.Height) / 2;

                g.TranslateTransform(centerX, centerY);

                var rectF = new Rectangle(-1, -1, 2, 2);
                g.FillRectangle(Brushes.Blue, rectF); //draw a small rectangle in the center of the image

                g.ResetTransform();

                var fillGrids = fillPattern.GetFillGrids();

                Debug.Print(new string('-', 100));
                Debug.Print("FilPattern name: {0}", fillPattern.Name);
                if (fillPattern.Target == FillPatternTarget.Model)
                    Debug.Print("FillPattern type: Model");
                else
                    Debug.Print("FillPattern type: Drafting");
                Debug.Print("Matrix scale: {0}", matrixScale);
                Debug.Print("Grids count: {0}", fillGrids.Count);
                Debug.Print("Len\\Area: {0}", fillPattern.LengthPerArea);
                Debug.Print("Lines\\Len: {0}", fillPattern.LinesPerLength);
                Debug.Print("Strokes\\Area: {0}", fillPattern.StrokesPerArea);

                foreach (var fillGrid in fillGrids)
                {
                    var degreeAngle = (float)RadianToGradus(fillGrid.Angle);
                    Debug.Print(new string('-', 50));
                    Debug.Print("Origin: U:{0} V:{1}",
                                fillGrid.Origin.U, fillGrid.Origin.V);
                    Debug.Print("Offset: {0}", fillGrid.Offset);
                    Debug.Print("Angle: {0}", degreeAngle);
                    Debug.Print("Shift: {0}", fillGrid.Shift);

                    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
//.........这里部分代码省略.........
开发者ID:kfpopeye,项目名称:AddMaterials,代码行数:101,代码来源:FillPatternViewerControlWpf.xaml.cs

示例10: OnPaint

        /// <summary>
        /// When the element is called on to be painted this method is called
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
                base.OnPaint(e);
                Bitmap tempBuffer = new Bitmap(Width, Height);
                Graphics tempGraph = Graphics.FromImage(tempBuffer);
                tempGraph.SmoothingMode = _drawingQuality;
                Rectangle inflatedInvalidationRect = Rectangle.Inflate(e.ClipRectangle,5,5);

                if (IsInitialized)
                {
                    tempGraph.DrawImage(_backBuffer, inflatedInvalidationRect, inflatedInvalidationRect, GraphicsUnit.Pixel);
                }
                else
                {
                    UpdateBackBuffer();
                    tempGraph.DrawImage(_backBuffer, new Point(0, 0));
                }

                //Draws selected shapes last 
                if (_modelElementsSelected.Count > 0)
                {
                    for (int i = _modelElementsSelected.Count - 1; i >= 0; i--)
                    {
                        ModelElement me = _modelElementsSelected[i];
                        System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
                        Point translator = VirtualToPixel(me.Location.X,me.Location.Y);
                        m.Translate(translator.X, translator.Y);
                        m.Scale(_virtualZoom, _virtualZoom);
                        tempGraph.Transform = m;
                        me.Paint(tempGraph);
                        tempGraph.Transform = new System.Drawing.Drawing2D.Matrix();
                    }
                }

                //If the users is dragging a select box we draw it here
                if (_selectBoxDraw)
                {
                    SolidBrush highlightBrush = new SolidBrush(Color.FromArgb(30,SystemColors.Highlight));
                    tempGraph.FillRectangle(highlightBrush, Rectangle.Inflate(_selectBox,-1,-1));
                    Rectangle outlineRect = new Rectangle(_selectBox.X, _selectBox.Y, _selectBox.Width - 1, _selectBox.Height - 1);
                    tempGraph.DrawRectangle(SystemPens.Highlight, outlineRect);

                    //garbage collection
                    highlightBrush.Dispose();
                }

                //Draws the temporary bitmap to the screen
                e.Graphics.SmoothingMode = _drawingQuality;
                e.Graphics.DrawImage(tempBuffer, inflatedInvalidationRect, inflatedInvalidationRect, GraphicsUnit.Pixel);

                //Garbage collection
                tempBuffer.Dispose();    
                tempGraph.Dispose();
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:58,代码来源:Modeler.cs

示例11: UpdateBackBuffer

        /// <summary>
        /// Paints the elements to the backbuffer
        /// </summary>
        private void UpdateBackBuffer()
        {
            _backBuffer = new Bitmap(Width, Height);
            Graphics graph = Graphics.FromImage(_backBuffer);
            graph.SmoothingMode = _drawingQuality;
            graph.FillRectangle(Brushes.White, 0, 0, _backBuffer.Width, _backBuffer.Height);

            //When the backbuffer is updated this code draws the watermark
            if (_showWaterMark)
            {
                Bitmap watermark = Images.MapWindowLogoPale;
                if ((_backBuffer.Width > watermark.Width) && (_backBuffer.Height > watermark.Height))
                {
                    graph.DrawImage(watermark, _backBuffer.Width - watermark.Width - 18, _backBuffer.Height - watermark.Height -18 ,watermark.Width , watermark.Height);
                }
            }

            //Check if there are any model elements to draw
            foreach (ModelElement me in _modelElements)
            {
                if (_modelElementsSelected.Contains(me) == false)
                {
                    System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
                    Point translator = VirtualToPixel(new Point(me.Location.X, me.Location.Y));
                    m.Translate(translator.X,translator.Y);
                    m.Scale(_virtualZoom, _virtualZoom);
                    graph.Transform = m;
                    me.Paint(graph);
                    graph.Transform = new System.Drawing.Drawing2D.Matrix();
                }
            }

            //Updates is initialized
            IsInitialized = true;
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:38,代码来源:Modeler.cs

示例12: GetDytqMap

        /// <summary>
        ///获取低压台区网络图
        /// </summary>
        /// <param name="tqcode"></param>
        /// <returns></returns>
        public static Bitmap GetDytqMap(string tqcode ,int width,int height) {
            int w = width;
            int h = height;
            Bitmap bp = new Bitmap(w, h);
            Graphics g = Graphics.FromImage(bp);
            IList<PS_xl> list = Ebada.Client.ClientHelper.PlatformSqlMap.GetList<PS_xl>("where linecode like '" + tqcode + "%' and linevol='0.4'");
            RectangleF rf = RectangleF.Empty;
            int bl = 10000;
            Dictionary<PS_xl, IList<PS_gt>> gts = new Dictionary<PS_xl, IList<PS_gt>>();
            List<PS_gtsb> gtsbs = new List<PS_gtsb>();

            foreach (PS_xl xl in list) {
                IList<PS_gt> gtlist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gt>("where linecode ='" + xl.LineCode + "' order by gtcode");
                if (gtlist.Count == 0) continue;
                IList<PS_gtsb> gtsblist = Client.ClientHelper.PlatformSqlMap.GetList<PS_gtsb>(" where sbtype like '17%' and  gtid in (select gtid from ps_gt where linecode ='" + xl.LineCode + "')");
                gtsbs.AddRange(gtsblist);
                IList<PS_gt> gtlist2 = new List<PS_gt>();
                foreach (PS_gt gt in gtlist) {
                    if (gt.gtLat == 0 || gt.gtLon == 0) continue;
                    gtlist2.Add(gt);
                    if (rf.IsEmpty)
                        rf = new RectangleF((float)gt.gtLon*bl, (float)gt.gtLat*bl, 1f, 1f);
                    else
                        rf=RectangleF.Union(rf,new RectangleF((float)gt.gtLon*bl, (float)gt.gtLat*bl,1f,1f));
                    //rf..Inflate((float)gt.gtLon, (float)gt.gtLat);
                }
                gts.Add(xl, gtlist2);
            }
            DataTable gtbhtable = Ebada.Core.ConvertHelper.ToDataTable(gtsbs,typeof(PS_gtsb));
            //g.TranslateTransform(-rf.X, -rf.Y);
            rf.Inflate(3, 3);
            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(-rf.X, -rf.Y);
            float f1=w / rf.Width;
            float f2=h/rf.Height;
            float scale = Math.Min(f1,f2);


            matrix.Scale(scale, scale, System.Drawing.Drawing2D.MatrixOrder.Append);
            if (f1 < f2)
                matrix.Translate(0, (h - f1 * rf.Height) / 2, System.Drawing.Drawing2D.MatrixOrder.Append);
            else
                matrix.Translate((w - f2 * rf.Width) / 2, 0, System.Drawing.Drawing2D.MatrixOrder.Append);
            
            List<PointF> plist = new List<PointF>();
            g.Clear(Color.White);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Font f = new Font("宋体", 9);
            PointF p0 = Point.Empty;
            Pen pen0 = new Pen(Color.Blue);
            pen0.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            List<string> gt0list = new List<string>();//记录重叠杆塔
            List<RectangleF> gtboxlist = new List<RectangleF>();
            foreach (PS_xl xl in gts.Keys) {
                plist.Clear();
                foreach (PS_gt gt in gts[xl]) {
                    plist.Add(new PointF((float)gt.gtLon*bl, (float)gt.gtLat*bl));
                }
                if (plist.Count <2) continue;
                PointF[] pts=plist.ToArray();

                matrix.TransformPoints(pts);
                for(int i=0;i<pts.Length;i++){
                    pts[i].Y = h - pts[i].Y;
                }
                g.DrawLines(Pens.Blue,pts );
                bool b1 = Math.Abs(pts[0].X - pts[1].X) > Math.Abs(pts[0].Y - pts[1].Y);
                Point offset = new Point(b1 ? 0 : 20, b1 ? 20 : 0);
                int gtnum = 0;
                for(int i=0;i<pts.Length;i++) {
                    PS_gt gt =gts[xl][i];
                    if (gt.gtLat==0.0m||gt.gtLon==0.0m) continue;
                    if (gt.gtJg == "是" && i==0) {
                        if (xl.ParentID.Length > 10) continue;//台区下干线除外
                        PointF pf0 = pts[i];
                        bool ret = false;
                        if (gt0list.Contains(xl.ParentID)) {
                            
                            foreach (RectangleF rtf in gtboxlist) {
                                if (rtf.Contains(pf0)) { ret = true; break; }
                            }
                        } else {
                            gt0list.Add(xl.ParentID);
                        }
                        if (ret) continue;
                        RectangleF rtf0 = RectangleF.Empty;
                        rtf0.Location = pf0;
                        rtf0.Inflate(10, 10);
                        gtboxlist.Add(rtf0);

                    }
                    
                    DataRow[] rows= gtbhtable.Select("gtid='" + gt.gtID + "'");
                    int n = 1;
                    foreach (DataRow row in rows) {
//.........这里部分代码省略.........
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:101,代码来源:GMapHelper.cs

示例13: GraphicsView_MouseMove

        private void GraphicsView_MouseMove(object sender, MouseEventArgs e)
        {
            if (movestart == null) return;
            if (!TranslateFocus)
                return;
            System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
            //m.Translate(Translate.X, Translate.Y, System.Drawing.Drawing2D.MatrixOrder.Append);
            m.Scale(ZoomScale, ZoomScale, System.Drawing.Drawing2D.MatrixOrder.Append);
            m.Invert();

            Point movement = new Point(movestart.X - e.X, movestart.Y - e.Y);
            movement.X = -movement.X;
            movement.Y = -movement.Y;
            Point[] t = new Point[] { movement };
            m.TransformPoints(t);
            movement = t[0];

            Translate.X -= movestart.X - e.X;
            Translate.Y -= movestart.Y - e.Y;

            movestart = e.Location;

            HighPrecisionDraw = false;
            this.Refresh();
        }
开发者ID:skipme,项目名称:ComGraMet,代码行数:25,代码来源:GraphicsView.cs

示例14: GraphicsView_Paint

        private void GraphicsView_Paint(object sender, PaintEventArgs e)
        {
            #if DEBUG
            if (this.DesignMode)
                return;
            #endif
            Graphics gr = e.Graphics;
            gr.Clear(Color.White);
            //
            if (HighPrecisionDraw)
            {
                gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            }
            //
            gr.DrawString(string.Format("ZoomScale: {0}", Scale), Font, Brushes.Black, 0, 0);

            System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix();
            m.Scale(ZoomScale, ZoomScale, System.Drawing.Drawing2D.MatrixOrder.Append);
            m.Translate(Translate.X, Translate.Y, System.Drawing.Drawing2D.MatrixOrder.Append);

            gr.Transform = m;

            cgmimage.Draw(gr);
        }
开发者ID:skipme,项目名称:ComGraMet,代码行数:25,代码来源:GraphicsView.cs

示例15: MapRenderer_Paint

 private void MapRenderer_Paint(object sender, PaintEventArgs e)
 {
     if (Map == null || backBuffer == null)
         return;
     RenderToBackBuffer();
     e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
     matrix.Scale(scale, scale);
     e.Graphics.Transform = matrix;
     e.Graphics.DrawImage(backBuffer, new PointF(-offsetX % Chunk.CHUNKSIZE_X, -offsetY % Chunk.CHUNKSIZE_Y));
     // e.Graphics.DrawImage(backBuffer, new Point());
     e.Graphics.Transform = new System.Drawing.Drawing2D.Matrix();
     e.Graphics.DrawLine(Pens.Red, new Point(-(int)(offsetX * scale), 0), new Point(-(int)(offsetX * scale), ClientSize.Height));
     e.Graphics.DrawLine(Pens.Red, new Point(0, -(int)(offsetY * scale)), new Point(ClientSize.Width, -(int)(offsetY * scale)));
 }
开发者ID:jvbsl,项目名称:OctoAwesome-MapViewer,代码行数:15,代码来源:MapRenderer.cs


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