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


C# Region.Transform方法代码示例

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


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

示例1: UpdateScaledRegion

 private void UpdateScaledRegion()
 {
     myScaledRegion = mySelectedRegion.Clone();
     myScaledRegion.Transform( new System.Drawing.Drawing2D.Matrix( Image.ZoomScale, 0.0f, 0.0f, Image.ZoomScale, 0.0f, 0.0f ) );
 }
开发者ID:Metapyziks,项目名称:SprytEditor,代码行数:5,代码来源:Canvas.cs

示例2: RotateRegion

        private void RotateRegion(Region g, float angle)
        {
            //technically mirror, not rotate
            using (Matrix m = new Matrix())
            {

                rc = this.ClientRectangle;
                m.Translate((float)rc.Width, 0);//(angle, new PointF(rc.Left + (rc.Width / 2),
                                          //rc.Top + (rc.Height / 2)));
                m.Scale(-1, 1);
                g.Transform(m);
            }
        }
开发者ID:Nibiru-1337,项目名称:Slideshow,代码行数:13,代码来源:myButton.cs

示例3: InvalidateTransform

 private void InvalidateTransform(Region region)
 {
     Matrix mx = new Matrix();
     mx.Scale(scaleFactor, scaleFactor);
     mx.Translate(-hScrollBar.Value, -vScrollBar.Value);
     region.Transform(mx);
     Invalidate(region);
 }
开发者ID:lvoinescu,项目名称:samDiagrams,代码行数:8,代码来源:DiagramContainer.cs

示例4: DrawDotDensity

        private void DrawDotDensity(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt)
        {
            int DotCount;
            int DotSize = (int)_Theme.DotSize;
            double DotValue = _Theme.DotValue;

            Brush BrDot = new SolidBrush(_Theme.DotColor);
            Pen PnDot = new Pen(_Theme.DotColor);
            PointF[] Pt = new PointF[1];

            int j;
            int TrialCount;

            Shape _Shape;
            GraphicsPath gpShp = new GraphicsPath();
            RectangleF RectRnd = new RectangleF();
            Matrix _Matrix = new Matrix();
            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            Theme _ATheme = m_Themes.GetActiveTheme();
            bool bLayerVisibility;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            //*** Traverse Layers collection
            foreach (Layer _Layer in Layers)
            {
                if (DotValue == 0)
                    break;

                if ((_ATheme == null))
                {
                    bLayerVisibility = _Layer.Visible;
                }
                else
                {
                    bLayerVisibility = (bool)(_ATheme.LayerVisibility[_Layer.ID]);
                }
                //*** Consider polygon layers lying within current map extent and visibility is on
                if (_Layer.LayerType == ShapeType.Polygon & _Layer.Extent.IntersectsWith(CurExt) & bLayerVisibility)
                {
                    //Render layer only if it lies within current map extent
                    Hashtable ht = _Layer.GetRecords(_Layer.LayerPath + "\\" + _Layer.ID);
                    IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                    //*** Traverse each Shape of the layer
                    while (dicEnumerator.MoveNext())
                    {
                        _Shape = (Shape)dicEnumerator.Value;
                        //*** Consider shape only if it lies within current map extent
                        if (_Shape.Extent.IntersectsWith(CurExt))
                        {
                            if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                            {
                                DotCount = (int)((double)((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DataValue / DotValue);
                                Region Rgn = new Region();
                                RectangleF[] Rect;
                                PointF[] Vertex = new PointF[3];
                                //*** for triangle
                                object MarkerSize = Math.Sqrt(3) / 4 * DotSize;
                                //*** for triangle

                                if (DotCount > 0)
                                {
                                    gpShp.Reset();
                                    for (j = 0; j <= _Shape.Parts.Count - 1; j++)
                                    {
                                        gpShp.AddPolygon((PointF[])_Shape.Parts[j]);
                                    }
                                    Rgn = new Region(gpShp);
                                    //Rgn.Intersect(CurExt)
                                    Rgn.Transform(mTransMatrix);
                                    Rect = Rgn.GetRegionScans(_Matrix);
                                    //http://www.dotnet247.com/247reference/a.aspx?u=http://www.bobpowell.net/gdiplus_faq.htm
                                    //Rect.Sort(Rect)
                                }
                                else
                                {
                                    Rect = new RectangleF[0];   // Rect[] length is set to 0 because Rect.length was required in If condition below.
                                }

                                //*** Draw random dots inside region
                                j = 1;
                                TrialCount = 1;

                                //*** Bugfix / Enhancement 19 Jun 2006 Distribution of Dots
                                while (j <= DotCount)
                                {
                                    if (DotCount == 0)
                                        break;

                                    if (Rect.Length == 0)
                                        break;

                                    VBMath.Randomize();

                                    try
                                    {
                                        if (Rect.Length / 2 > j + 1)
//.........这里部分代码省略.........
开发者ID:SDRC-India,项目名称:sdrcdevinfo,代码行数:101,代码来源:Map.cs

示例5: TransformRegion

        public void TransformRegion(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            Rectangle regionRect = new Rectangle(100, 50, 100, 100);
            g.DrawRectangle(myPen, regionRect);
            g.FillRectangle (myBrush, regionRect);

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect);

            // Create a transform matrix and set it to have a 45 degree

            // rotation.
            Matrix transformMatrix = new Matrix();
            transformMatrix.RotateAt(45, new Point(100, 50));

            // Apply the transform to the region.
            myRegion.Transform(transformMatrix);

            // Fill the transformed region with red and draw it to the screen
            // in color.
            myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F);
            myPen.Color = Color.FromArgb(255, 0, 0x33, 0);
            g.FillRegion(myBrush, myRegion);

            title = "TransformRegion";
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:30,代码来源:DrawingView.cs

示例6: RenderShadow

		//Implement a base rendering of an element
		protected internal override void RenderShadow(Graphics graphics,IRender render)
		{
			if (mPoints == null) return;
			if (mPoints.Count < 2) return;

			PointF startLocation = (PointF) mPoints[0];
			PointF startReference = (PointF) mPoints[1];
			PointF endLocation = (PointF) mPoints[mPoints.Count-1];
			PointF endReference = (PointF) mPoints[mPoints.Count-2];

			Layer layer = this.Layer;
			Pen shadowPen = new Pen(layer.ShadowColor);
			GraphicsPath shadowPath = GetPathInternal();
			shadowPen.Color = render.AdjustColor(layer.ShadowColor,0,this.Opacity);

			//Save the current region
			Region current = graphics.Clip;

			//Mask out the start marker
			if (Start.Marker != null)
			{
				Region region = new Region(Start.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(Start.Marker,startLocation,startReference,new Matrix()));
				region.Translate(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Mask out the end marker
			if (End.Marker != null)
			{
				Region region = new Region(End.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(End.Marker,endLocation,endReference,new Matrix()));
				region.Translate(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
				graphics.SetClip(region,CombineMode.Exclude);
			}

			graphics.TranslateTransform(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
			
			//Draw line
			if (Layer.SoftShadows)
			{
				shadowPen.Color = Color.FromArgb(20,shadowPen.Color);
				graphics.CompositingQuality = CompositingQuality.HighQuality;
				graphics.SmoothingMode = SmoothingMode.HighQuality;
			}

			graphics.DrawPath(shadowPen, shadowPath);

			if (layer.SoftShadows)
			{
				graphics.CompositingQuality = render.CompositingQuality;
				graphics.SmoothingMode = SmoothingMode;
			}

			//Restore graphics
			if (Start.Marker != null || End.Marker != null)
			{
				graphics.Clip = current;
				if (Start.Marker != null) RenderMarkerShadow(Start.Marker,startLocation,startReference,graphics,render);
				if (End.Marker != null) RenderMarkerShadow(End.Marker,endLocation,endReference,graphics,render);
			}

			graphics.TranslateTransform(-layer.ShadowOffset.X ,-layer.ShadowOffset.Y);
		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:65,代码来源:Line.cs

示例7: RenderAction

		protected internal override void RenderAction(Graphics graphics, IRender render,IRenderDesign renderDesign)
		{
			if (mPoints == null || mPoints.Count < 2) return;

			PointF startLocation = (PointF) mPoints[0];
			PointF startReference = (PointF) mPoints[1];
			PointF endLocation = (PointF) mPoints[mPoints.Count-1];
			PointF endReference = (PointF) mPoints[mPoints.Count-2];

			//Save the current region
			Region current = graphics.Clip;

			//Mask out the start marker
			if (Start.Marker != null)
			{
				Region region = new Region(Start.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(Start.Marker,startLocation,startReference,new Matrix()));
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Mask out the end marker
			if (End.Marker != null)
			{
				Region region = new Region(End.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(End.Marker,endLocation,endReference,new Matrix()));
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Render element action
			base.RenderAction (graphics,render,renderDesign);

			//Render markers
			if (Start.Marker != null || End.Marker != null)
			{
				graphics.Clip = current;

				if (Start.Marker != null) RenderMarkerAction(Start.Marker,startLocation,startReference,graphics,render,renderDesign);
				if (End.Marker != null) RenderMarkerAction(End.Marker,endLocation,endReference,graphics,render,renderDesign);
			}

			//Render any ports
			if (Ports != null)
			{
				foreach (Port port in Ports.Values)
				{
					if (port.Visible)
					{
						graphics.TranslateTransform(-Rectangle.X + port.Rectangle.X,-Rectangle.Y + port.Rectangle.Y);
						port.SuspendValidation();
						port.Render(graphics, render);
						port.ResumeValidation();
						graphics.TranslateTransform(Rectangle.X - port.Rectangle.X,Rectangle.Y - port.Rectangle.Y);						
					}
				}
			}
		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:56,代码来源:Line.cs

示例8: RenderAction

		protected internal override void RenderAction(Graphics graphics,IRender render,IRenderDesign renderDesign)
		{
			if (Points == null) return;

			PointF location;
			PointF reference;
			Segment segment = null;

			//Save the current region
			Region current = graphics.Clip;

			//Mask out each marker
			for (int i=0; i<Points.Count-1; i++)
			{
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				segment = Segments[i];
				
				//Mask out the start marker
				if (segment.Start.Marker != null)
				{
					Region region = new Region(segment.Start.Marker.GetPathInternal());
					region.Transform(GetMarkerTransform(segment.Start.Marker,location,reference,new Matrix()));
					graphics.SetClip(region,CombineMode.Exclude);
				}
			}

			//Mask out final marker
			if (segment.End.Marker != null)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];

				Region region = new Region(segment.End.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(segment.End.Marker,location,reference,new Matrix()));
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Draw the path
			GraphicsPath path = GetPathInternal();
			if (path == null) return;

			if (renderDesign.ActionStyle == ActionStyle.Default)
			{
				Pen pen = new Pen(render.AdjustColor(BorderColor,BorderWidth,Opacity));
				pen.Width = BorderWidth;
				graphics.DrawPath(pen,path);
			}
			else
			{
				graphics.DrawPath(Component.Instance.ActionPen,path);
			}

			//Reset the clip
			graphics.Clip = current;

			//Render the markers
			for (int i=0;i<Points.Count-1;i++)
			{
				segment = Segments[i];
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				if (segment.Start.Marker != null) RenderMarkerAction(segment.Start.Marker,location,reference,graphics,render,renderDesign);
			}

			//Render final marker
			if (segment.End.Marker != null)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];
				RenderMarkerAction(segment.End.Marker,location,reference,graphics,render,renderDesign);				
			}
		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:75,代码来源:ComplexLine.cs

示例9: RenderShadow

		protected internal override void RenderShadow(Graphics graphics, IRender render)
		{
			if (Points == null) return;

			PointF location;
			PointF reference;
			Segment segment = null;

			Layer layer = this.Layer;
			Pen shadowPen = new Pen(layer.ShadowColor);
			GraphicsPath shadowPath = GetPathInternal();
			shadowPen.Color = render.AdjustColor(layer.ShadowColor,0,this.Opacity);

			//Save the current region
			Region current = graphics.Clip;

			//Mask out each marker
			for (int i=0;i<Points.Count-1;i++)
			{
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				segment = Segments[i];
				
				//Mask out the start marker
				if (segment.Start.Marker != null)
				{
					Region region = new Region(segment.Start.Marker.GetPathInternal());
					region.Transform(GetMarkerTransform(segment.Start.Marker,location,reference,new Matrix()));
					region.Translate(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
					graphics.SetClip(region,CombineMode.Exclude);
				}
			}

			//Mask out final marker
			if (segment.End.Marker != null)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];

				Region region = new Region(segment.End.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(segment.End.Marker,location,reference,new Matrix()));
				region.Translate(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Draw the path
			graphics.TranslateTransform(layer.ShadowOffset.X ,layer.ShadowOffset.Y);
			graphics.DrawPath(shadowPen,shadowPath);

			//Reset the clip
			graphics.Clip = current;

			//Render the markers
			for (int i=0;i<Points.Count-1;i++)
			{
				segment = Segments[i];
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				if (segment.Start.Marker != null) RenderMarkerShadow(segment.Start.Marker,location,reference,graphics,render);
			}

			//Render final marker
			if (segment.End.Marker != null)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];
				RenderMarkerShadow(segment.End.Marker,location,reference,graphics,render);				
			}

			graphics.TranslateTransform(-layer.ShadowOffset.X ,-layer.ShadowOffset.Y);
		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:73,代码来源:ComplexLine.cs

示例10: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            ProgressBarPath MyPath = new ProgressBarPath();
            MyPath = GetPath(this.DisplayRectangle, true);

            if ((this.BackgroundImage != null)) {
                e.Graphics.DrawImage(this.BackgroundImage, this.DisplayRectangle);
            }

            //Call the appropriate Paint Method to draw the bar
            switch (BarType) {

                case eBarType.Bar:
                    if (Value > 0) {
                        PaintBar(e);
                    }

                    break;
                case eBarType.CylonBar:
                    PaintCylonBar(e);

                    break;
                case eBarType.CylonGlider:
                    PaintCylonGlider(e);

                    break;
            }

            //Create the Border Graphicspath and Draw it
            if (Border) {
                Pen MyPen = new Pen(BorderColor, BorderWidth);
                MyPen.Alignment = PenAlignment.Inset;
                var _with1 = MyPath;

                if (Shape == eShape.Text) {
                    if (ShapeTextRotate != eRotateText.None) {
                        Matrix mtrx = new Matrix();
                        mtrx.Rotate(GetRotateAngle(ShapeTextRotate));
                        _with1.Path.Transform(mtrx);
                    }

                    e.Graphics.Transform = TextMatrix(MyPath);
                }
                e.Graphics.DrawPath(MyPen, _with1.Path);
                e.Graphics.ResetTransform();
                MyPen.Dispose();
            }

            //Make a Region from the Graphicspath to clip the shape
            this.Region = null;
            if (Border)
                if (BorderWidth == 1)
                    MyPath = GetPath(this.DisplayRectangle, false);
            Region mRegion = null;

            if (Shape == eShape.Text) {
                if (ShapeTextRotate != eRotateText.None) {
                    Matrix mtrx = new Matrix();
                    mtrx.Rotate(GetRotateAngle(ShapeTextRotate));
                    MyPath.Path.Transform(mtrx);
                }

                mRegion = new Region(MyPath.Path);
                mRegion.Transform(TextMatrix(MyPath));
            } else {
                mRegion = new Region(MyPath.Path);
            }
            this.Region = mRegion;
            mRegion.Dispose();

            //Add the Text
            if (this.TextShow != eTextShow.None & this.TextPlacement == eTextPlacement.OverBar)
                PutText(e, this.DisplayRectangle);

        }
开发者ID:mlnlover11,项目名称:IExtendFramework,代码行数:77,代码来源:ProgressBar.cs

示例11: Render

		protected internal override void Render(Graphics graphics, IRender render)
		{
			if (Points == null) return;

			PointF location;
			PointF reference;
			Segment segment = null;

			//Save the current region
			Region current = graphics.Clip;

			//Mask out each marker
			for (int i=0;i<Points.Count-1;i++)
			{
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				segment = Segments[i];
				
				//Mask out the start marker
				if (segment.Start.Marker != null && !segment.Start.Marker.DrawBackground)
				{
					Region region = new Region(segment.Start.Marker.GetPathInternal());
					region.Transform(GetMarkerTransform(segment.Start.Marker,location,reference,new Matrix()));
					graphics.SetClip(region,CombineMode.Exclude);
				}
			}

			//Mask out final marker
			if (segment.End.Marker != null && !segment.End.Marker.DrawBackground)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];

				Region region = new Region(segment.End.Marker.GetPathInternal());
				region.Transform(GetMarkerTransform(segment.End.Marker,location,reference,new Matrix()));
				graphics.SetClip(region,CombineMode.Exclude);
			}
			
			//Draw the path
			Pen pen = null;

			if (CustomPen == null)
			{
				pen = new Pen(BorderColor,BorderWidth);
				pen.DashStyle = BorderStyle;
	
				//Check if winforms renderer and ajdust color as required
				pen.Color = render.AdjustColor(BorderColor,BorderWidth,Opacity);
			}
			else	
			{
				pen = CustomPen;
			}
			graphics.DrawPath(pen,GetPathInternal());
			
			//Reset the clip
			graphics.Clip = current;

			//Render the segment items
			for (int i=0;i<Points.Count-1;i++)
			{
				segment = Segments[i];
				location = (PointF) Points[i];
				reference = (PointF) Points[i+1];

				if (segment.Start.Marker != null) RenderMarker(segment.Start.Marker,location,reference,graphics,render);

				//Render the segment image and annotation
				RenderSegment(segment,location,reference,graphics,render);
			}

			//Render final marker
			if (segment.End.Marker != null)
			{
				location = (PointF) Points[Points.Count-1];
				reference = (PointF) Points[Points.Count-2];
				RenderMarker(segment.End.Marker,location,reference,graphics,render);				
			}

		}
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:81,代码来源:ComplexLine.cs

示例12: InfinityRotate

		public void InfinityRotate ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				using (Matrix m = new Matrix ()) {
					m.Rotate (45);
					r.Transform (m);
				}
				Assert.IsTrue (r.IsInfinite (graphic), "after");
				CheckEmpty ("InfinityRotate", r);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:12,代码来源:TestRegion.cs

示例13: InfinityScaleDown

		public void InfinityScaleDown ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				using (Matrix m = new Matrix ()) {
					m.Scale (0.5f, 0.5f);
					r.Transform (m);
				}
				Assert.IsTrue (r.IsInfinite (graphic), "after");
				CheckEmpty ("InfinityScaleDown", r);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:12,代码来源:TestRegion.cs

示例14: InfinityIntersectTransform

		public void InfinityIntersectTransform ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				r.Intersect (new Rectangle (-10, -10, 20, 20));
				using (Matrix m = new Matrix (2, 0, 0, 0.5f, 10, 10)) {
					r.Transform (m);
				}
				RectangleF bounds = r.GetBounds (graphic);
				Assert.AreEqual (-10, bounds.X, "X");
				Assert.AreEqual (5, bounds.Y, "Y");
				Assert.AreEqual (40, bounds.Width, "Width");
				Assert.AreEqual (10, bounds.Height, "Height");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:15,代码来源:TestRegion.cs

示例15: DrawToBitmap

 void DrawToBitmap(MapDisplay mapdisplay, RectangleF clip)
 {
     Matrix inverse = transform.Clone();
     inverse.Invert();
     using (Region clipRegion = new Region(clip)) {
         clipRegion.Transform(inverse);
         mapdisplay.Draw(bitmap, transform, clipRegion);
     }
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:9,代码来源:MapDisplayTests.cs


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