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


C# Region.Translate方法代码示例

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


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

示例1: Graphics

	// Window Constructor. Copies the existing Graphics and creates a new
	// Graphics that has an origin of baseWindow.Location and is always clipped
	// to baseWindow

	internal Graphics(IToolkitGraphics graphics, Rectangle baseWindow)
		: this(graphics)
			{
				this.baseWindow = baseWindow;
				clip = new Region(baseWindow);
				clip.Translate(-baseWindow.X, -baseWindow.Y);
				Clip = clip;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:Graphics.cs

示例2: BlockRegions

        static BlockRegions()
        {
            int n = Constants.PROJ_WIDTH / 4;

            WholeBlock = new Region();
            WholeBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                WholeBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i, i * 4 + 2, Constants.PROJ_HEIGHT - 2 * i));
            }
            WholeBlock.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH, Constants.PROJ_HEIGHT));
            InnerBlock = new Region();
            InnerBlock.MakeEmpty();
            for (int i = 0; i <= n; i++)
            {
                InnerBlock.Union(new Rectangle(n * 2 - 1 - 2 * i, i + 1, i * 4 + 2, Constants.PROJ_HEIGHT - 2 - 2 * i));
            }
            InnerBlock.Intersect(new Rectangle(1, 1, Constants.PROJ_WIDTH - 2, Constants.PROJ_HEIGHT - 2));

            OuterBorder = WholeBlock.Clone();
            OuterBorder.Exclude(InnerBlock);

            Top = InnerBlock.Clone();
            Top.Translate(0, -Constants.BLOCK_HEIGHT);
            Top.Intersect(InnerBlock);

            Left = InnerBlock.Clone();
            Left.Exclude(Top);
            Top.Translate(0, 1);
            Left.Exclude(Top);
            Top.Translate(0, -1);

            Right = Left.Clone();
            Left.Intersect(new Rectangle(0, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));
            Right.Intersect(new Rectangle(Constants.PROJ_WIDTH / 2 + 1, 0, Constants.PROJ_WIDTH / 2, Constants.PROJ_HEIGHT));

            InnerBorder = InnerBlock.Clone();
            InnerBorder.Exclude(Top);
            InnerBorder.Exclude(Left);
            InnerBorder.Exclude(Right);
        }
开发者ID:ZetaTwo,项目名称:Project-Easter-Egg,代码行数:41,代码来源:BlockRegions.cs

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

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

示例5: InfinityTranslate

		public void InfinityTranslate ()
		{
			using (Region r = new Region ()) {
				Assert.IsTrue (r.IsInfinite (graphic), "before");
				r.Translate (10, 10);
				Assert.IsTrue (r.IsInfinite (graphic), "after");
				CheckEmpty ("InfinityTranslate", r);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:TestRegion.cs

示例6: GetTransformCellRect

 private RectangleF GetTransformCellRect(int index)
 {
     RectangleF rect = GetCellRect(index);
     Region region = new Region(rect);
     region.Translate(AutoScrollPosition.X, AutoScrollPosition.Y);
     rect = region.GetBounds(CreateGraphics());
     return rect;
 }
开发者ID:khonsoe,项目名称:keymagic,代码行数:8,代码来源:GlypeTable.cs

示例7: Paint

    public override void Paint(Graphics g) {
      base.Paint(g);

      g.SmoothingMode = SmoothingMode.HighQuality;

      using (Pen pen = new Pen(lineColor, lineWidth)) {

        SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
        titleSize.Height += 10; //add spacing
        SizeF subtitleSize = g.MeasureString(this.Subtitle, ArtPalette.DefaultFont, Rectangle.Width - 45);
        subtitleSize.Height += 5; //add spacing
        if (this.Title == this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) subtitleSize = new SizeF(0, 0);

        if ((int)titleSize.Height + (int)subtitleSize.Height != Rectangle.Height) {
          headerHeight = (int)titleSize.Height + (int)subtitleSize.Height;
          this.UpdateLabels();
        }

        GraphicsPath path = new GraphicsPath();
        path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
        path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
        path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
        path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
        path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
        path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
        path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
        path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
        //shadow
        if (ArtPalette.EnableShadows) {
          Region darkRegion = new Region(path);
          darkRegion.Translate(5, 5);
          g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
        }
        //background
        g.FillPath(Brush, path);

        using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
          Region gradientRegion = new Region(path);
          g.FillRegion(gradientBrush, gradientRegion);
        }

        if (!this.Collapsed) {
          TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
          StringFormat stringFormat = textStyle.StringFormat;
          stringFormat.Trimming = StringTrimming.EllipsisWord;
          stringFormat.FormatFlags = StringFormatFlags.LineLimit;
          Rectangle rect;

          const int verticalHeaderSpacing = 5;
          Point separationLineStart = new Point(Rectangle.X + 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
          Point separationLineEnd = new Point(Rectangle.X + Rectangle.Width - 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
          using (LinearGradientBrush brush = new LinearGradientBrush(separationLineStart, separationLineEnd, Color.Black, Color.White)) {
            using (Pen separationLinePen = new Pen(brush)) {
              g.DrawLine(separationLinePen, separationLineStart, separationLineEnd);
            }
          }


          for (int i = 0; i < this.labels.Count; i++) {
            rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
            g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
          }
        }

        //the border
        g.DrawPath(pen, path);

        //the title
        g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black,
                     new Rectangle(Rectangle.X + 25, Rectangle.Y + 5,
                                   Rectangle.Width - 45, Rectangle.Height - 5 - (int)subtitleSize.Height));

        //the subtitle
        if (this.Title != this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) {
          g.DrawString(this.Subtitle, ArtPalette.DefaultFont, Brushes.Black,
                       new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height -5 ,
                                     Rectangle.Width - 45, Rectangle.Height - 5));
        }


        //the material
        foreach (IShapeMaterial material in Children)
          material.Paint(g);

        //the connectors
        if (this.ShowConnectors) {
          foreach (IConnector t in Connectors)
            t.Paint(g);
        }
      }
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:91,代码来源:OperatorShape.cs

示例8: DrawState

        /// <summary>
        /// Draws the given cell and label onto the specified canvas. No
        /// children or descendants are painted.
        /// </summary>
        public void DrawState(mxICanvas canvas, mxCellState state, String label)
        {
            Object cell = (state != null) ? state.Cell : null;

            if (cell != null && cell != model.Root && (model.IsVertex(cell) || model.IsEdge(cell)))
            {
                Object obj = canvas.DrawCell(state);
                Object lab = null;

                // Holds the current clipping region in case the label will
                // be clipped
                Region clip = null;
                Region newClip = new Region(state.GetRectangle());

                // Indirection for image canvas that contains a graphics canvas
                mxICanvas clippedCanvas = (mxUtils.GetString(state.Style, mxConstants.
                    STYLE_OVERFLOW, "").Equals("hidden")) ? canvas : null;

                if (clippedCanvas is mxImageCanvas)
                {
                    clippedCanvas = ((mxImageCanvas) clippedCanvas).GdiCanvas;
                    Point pt = ((mxImageCanvas) canvas).Translate;
                    newClip.Translate(pt.X, pt.Y);
                }

                if (clippedCanvas is mxGdiCanvas)
                {
                    Graphics g = ((mxGdiCanvas) clippedCanvas).Graphics;
                    clip = g.Clip;
                    g.Clip = newClip;
                }

                if (label != null && state.LabelBounds != null)
                {
                    lab = canvas.DrawLabel(label, state, false);
                }

                // Restores the previous clipping region
                if (clippedCanvas is mxGdiCanvas)
                {
                    ((mxGdiCanvas)clippedCanvas).Graphics.Clip = clip;
                }

                // Invokes the cellDrawn callback with the object which was created
                // by the canvas to represent the cell graphically
                if (obj != null)
                {
                    // LATER: Add inner callback for rendering
                    //CellDrawn(cell, obj, lab);
                }
            }
        }
开发者ID:WallaceGomes,项目名称:mxgraph,代码行数:56,代码来源:mxGraph.cs

示例9: CaretSetPosition

	// Set the caret bounds from a character position
	// Set update region
	internal override void CaretSetPosition( int position)
	{
		// remember Caret position
		caretPosition = position;

		if (!IsHandleCreated)
		{
			return;
		}
		Rectangle newBounds = Rectangle.Empty;
		int height = Font.Height;
		if (Text.Length == 0)
		{
			newBounds = new Rectangle(CaretXFromAlign, 1, 1, height);
		}
		else
		{
			if (position == Text.Length)
			{
				
				// If the last character is a linefeed, position ourselves at the
				// beginning of the following line. Otherwise, position ourselves
				// immediately to the right of the last character.
				LayoutInfo.Item item = layout.Items[position -1];
				newBounds = item.bounds;
				if (item.type == LayoutInfo.Item.CharType.LF)
				{
					newBounds = new Rectangle(CaretXFromAlign, newBounds.Top + height, 1, height);
				}
				else
				{
					newBounds = new Rectangle(newBounds.Right, newBounds.Top, 1, newBounds.Height + 1);
				}
			}
			else
			{
				newBounds = layout.Items[position].bounds;
				newBounds = new Rectangle(newBounds.Left, newBounds.Top, 1, newBounds.Height + 1);
			}
		}

		// This looks better.
		if (newBounds.X == 0)
			newBounds.X = 1;

		// When we change the caret position, find the region to update
		Region region = new Region(newBounds);
		if (!caretHiding)
		{
			region.Xor(caretBounds);
		}
		region.Translate(- XViewOffset, - YViewOffset);
		AddUpdate(region);
		caretBounds = newBounds;
		if (Focused)
		{
			CaretShow();
		}
		
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:62,代码来源:TextBox.cs

示例10: SetTextActual

	// Called to change the text. Sets the update to whats needed to but doesnt change the selection point or caret
	private void SetTextActual( string text)
	{
		if( !IsHandleCreated ) {
			// create handle here to be sure that LayoutInfo will be set correct.
			this.CreateHandle();
		}
		// Layout the new text. Compare with old layout, Creating a region for areas that must be updated.
		bool prevLayout = layout != null;
		LayoutInfo oldLayout = null;
		if (prevLayout)
		{
			oldLayout = (LayoutInfo)layout.Clone();
		}
		string oldText = Text;
		LayoutFromText(text);
		// We must not trigger the onTextChanged event yet else this controls text could be change in the event!
		(this as Control).text = text;
		SetScrollBarPositions();
		if (prevLayout)
		{
			try {
				Region update = new Region(RectangleF.Empty);
				int oldLen = oldText.Length;
				int newLen = text.Length;
				int len    = newLen;
						
				if (oldLen > len)
				{
					len = oldLen;
				}
				for (int i=0;i < len;i++)
				{
					if (i >= oldLen)
					{
						if( i < newLen ) update.Union( layout.Items[i].bounds);
					}
					else if (i >= newLen )
					{
						if( i < oldLen ) update.Union( oldLayout.Items[i].bounds);
					}
					else if ( (i < oldLen && i < newLen) && (Text[i] != oldText[i] || oldLayout.Items[i].bounds != layout.Items[i].bounds ) )
					{
						if( i < newLen ) {
							update.Union( layout.Items[i].bounds);
						}
						if( i < oldLen ) {
							update.Union( oldLayout.Items[i].bounds);
						}
					}
				}
				// Get the offset of the TextDrawArea
				update.Translate( - XViewOffset, - YViewOffset);
				AddUpdate(update);
			}
			catch {	// ignore exceptions here, because in some cases this could happen
			}
		}
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:59,代码来源:TextBox.cs

示例11: SetRoundedRegion

        public static void SetRoundedRegion(Form form, Size overrideSize)
        {
            int width, height;
            if (overrideSize == Size.Empty)
            {
                width = form.ClientSize.Width;
                height = form.ClientSize.Height;
            }
            else
            {
                width = overrideSize.Width;
                height = overrideSize.Height;
            }

            Region r = new Region(new Rectangle(3, 0, width - 6, height));
            r.Union(new Rectangle(2, 1, width - 4, height - 2));
            r.Union(new Rectangle(1, 2, width - 2, height - 4));
            r.Union(new Rectangle(0, 3, width, height - 6));

            RECT rect = new RECT();
            User32.GetWindowRect(form.Handle, ref rect);
            Point windowScreenPos = RectangleHelper.Convert(rect).Location;
            Point clientScreenPos = form.PointToScreen(new Point(0, 0));

            r.Translate(clientScreenPos.X - windowScreenPos.X, clientScreenPos.Y - windowScreenPos.Y);

            form.Region = r;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:28,代码来源:FramelessManager.cs

示例12: InvalidateAdornerWindow

 internal void InvalidateAdornerWindow(Region region)
 {
     if (this.DesignerFrameValid)
     {
         Point autoScrollPosition = ((System.Windows.Forms.Design.DesignerFrame) this.designerFrame).AutoScrollPosition;
         region.Translate(autoScrollPosition.X, autoScrollPosition.Y);
         this.designerFrame.Invalidate(region, true);
         this.designerFrame.Update();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:BehaviorService.cs

示例13: GetClippedRegion

        /// <summary>
        /// Calculates the region of the rectangle that is not overlapped by siblings or children.
        /// </summary>
        /// <param name="rectangle">The rectangle.</param>
        /// <param name="potentialIntersections">An array of potentially intersecting rectangles.</param>
        /// <returns>A region.</returns>
        public static Region GetClippedRegion(Rectangle rectangle, IEnumerable<Rectangle> potentialIntersections)
        {
            var region = new Region(rectangle);

            // Exclude children and intersecting siblings
            RectangleUtil.ChildrenAndIntersectingSiblings(rectangle, potentialIntersections).ForEach(region.Exclude);

            // Set X and Y to 0
            region.Translate(-rectangle.Left, -rectangle.Top);

            return region;
        }
开发者ID:Ancestry,项目名称:quality-bot,代码行数:18,代码来源:ImageUtil.cs

示例14: InvalidateRegion

        public void InvalidateRegion( Region r )
        {
            if( !zoomon ) {
                r.Translate( left_margin - offx, top_margin - offy );
                r.Intersect( DiagramArea );
                Invalidate( r );

            } else {
                Invalidate();

            }
        }
开发者ID:inspirer,项目名称:uml-designer,代码行数:12,代码来源:ViewCtrl.cs

示例15: OnLeave

	// Process when the control loses the focus
	protected override void OnLeave(EventArgs e)
	{
		base.OnLeave (e);
		// Create a region containing the caret and all visible selected text
		Region update = new Region(caretBounds);
		for (int i = 0; i < Text.Length; i++)
		{
			if (layout.Items[i].selected)
			{
				Rectangle b = layout.Items[i].bounds;
				update.Union(new Region(new Rectangle(b.Left,b.Top,b.Width,b.Height + 1)));
			}
		}
		update.Translate(- XViewOffset, - YViewOffset);
		AddUpdate(update);
		caretHiding = true;
		InvalidateDirty();
		mouseDown = false;
		// We dont need to update any selection
		if( null != selectedRegion ) {
			selectedRegion.Dispose();
			selectedRegion = null;
		}
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:25,代码来源:TextBox.cs


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