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


C# Graphics.IntersectClip方法代码示例

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


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

示例1: DrawVerticalComponent

        private void DrawVerticalComponent(int index, Graphics g, LiveSplitState state, float width, float height, Region clipRegion)
        {
            var component = VisibleComponents.ElementAt(index);
            var topPadding = Math.Min(GetPaddingAbove(index), component.PaddingTop) / 2f;
            var bottomPadding = Math.Min(GetPaddingBelow(index), component.PaddingBottom) / 2f;
            g.IntersectClip(new RectangleF(0, topPadding, width, component.VerticalHeight - topPadding - bottomPadding));

            var scale = g.Transform.Elements.First();
            var separatorOffset = component.VerticalHeight * scale < 3 ? 1 : 0;

            if (clipRegion.IsVisible(new RectangleF(
                g.Transform.OffsetX,
                -separatorOffset + g.Transform.OffsetY - topPadding * scale,
                width,
                separatorOffset * 2f + scale * (component.VerticalHeight + bottomPadding))))
                component.DrawVertical(g, state, width, clipRegion);
            g.TranslateTransform(0.0f, component.VerticalHeight - bottomPadding * 2f);
        }
开发者ID:xarrez,项目名称:LiveSplit,代码行数:18,代码来源:ComponentRenderer.cs

示例2: DrawHorizontalComponent

        private void DrawHorizontalComponent(int index, Graphics g, LiveSplitState state, float width, float height, Region clipRegion)
        {
            var component = VisibleComponents.ElementAt(index);
            var leftPadding = Math.Min(GetPaddingToLeft(index), component.PaddingLeft) / 2f;
            var rightPadding = Math.Min(GetPaddingToRight(index), component.PaddingRight) / 2f;
            g.IntersectClip(new RectangleF(leftPadding, 0, component.HorizontalWidth - leftPadding - rightPadding, height));

            var scale = g.Transform.Elements.First();
            var separatorOffset = component.VerticalHeight * scale < 3 ? 1 : 0;

            if (clipRegion.IsVisible(new RectangleF(
                -separatorOffset + g.Transform.OffsetX - leftPadding * scale,
                g.Transform.OffsetY,
                separatorOffset * 2f + scale * (component.HorizontalWidth + rightPadding),
                height)))
                component.DrawHorizontal(g, state, height, clipRegion);
            g.TranslateTransform(component.HorizontalWidth - rightPadding * 2f, 0.0f);
        }
开发者ID:xarrez,项目名称:LiveSplit,代码行数:18,代码来源:ComponentRenderer.cs

示例3: PaintLink


//.........这里部分代码省略.........
                        }
                        // else use linkBrush
                    }
                    else {
                        brushColor = DisabledLinkColor;
                    }

                    if (IsOneLink()) {
                        g.Clip = new Region(finalrect);
                    }
                    else {
                        g.Clip = link.VisualRegion;
                    }
                    
                    if (optimizeBackgroundRendering) {
                        PaintLinkBackground(g);
                    }

                    if( UseCompatibleTextRendering ){
                        SolidBrush useBrush = brushColor == Color.Empty ? linkBrush : new SolidBrush( brushColor );
                        StringFormat stringFormat = CreateStringFormat();
                    
                        g.DrawString(Text, font, useBrush, ClientRectWithPadding, stringFormat);

                        if( useBrush != linkBrush ){
                            useBrush.Dispose();
                        }
                    }
                    else{
                        if(brushColor == Color.Empty ){
                            brushColor = linkBrush.Color;
                        }

                        IntPtr hdc = g.GetHdc();
                        try{
                            using( WindowsGraphics wg = WindowsGraphics.FromHdc( hdc ) ) {
                                brushColor = wg.GetNearestColor(brushColor);
                            }
                        }
                        finally{
                            g.ReleaseHdc();
                        }
                        Rectangle clientRectWithPadding = ClientRectWithPadding;
                        TextRenderer.DrawText(g, Text, font, clientRectWithPadding, brushColor, CreateTextFormatFlags(clientRectWithPadding.Size));
                    }

                    if (Focused && ShowFocusCues && FocusLink == link) {
                        // Get the rectangles making up the visual region, and draw
                        // each one.
                        RectangleF[] rects = link.VisualRegion.GetRegionScans(g.Transform);
                        if( rects != null && rects.Length > 0 ){
                            Rectangle focusRect;

                            if (IsOneLink()) {
                                //draw one merged focus rectangle
                                focusRect = Rectangle.Ceiling(finalrect);
                                Debug.Assert(finalrect != RectangleF.Empty, "finalrect should be initialized");

                                ControlPaint.DrawFocusRectangle(g, focusRect, ForeColor, BackColor);
                            }
                            else {
                                foreach (RectangleF rect in rects) {
                                    ControlPaint.DrawFocusRectangle(g, Rectangle.Ceiling(rect), ForeColor, BackColor);
                                }
                            }
                        }
                    }
                }

                // no else clause... we don't paint anything if we are given a link with no visual region.
                //
            }
            else { // Painting with no link.
                g.IntersectClip(this.textRegion);

                if (optimizeBackgroundRendering) {
                    PaintLinkBackground(g);
                }

                if( UseCompatibleTextRendering ){
                    StringFormat stringFormat = CreateStringFormat();
                    g.DrawString(Text, font, foreBrush, ClientRectWithPadding, stringFormat);
                }
                else{
                    Color color;

                    IntPtr hdc = g.GetHdc();
                    try{
                        using( WindowsGraphics wg = WindowsGraphics.FromHdc( hdc ) ) {
                            color = wg.GetNearestColor(foreBrush.Color);
                        }
                    }
                    finally{
                        g.ReleaseHdc();
                    }
                    Rectangle clientRectWithPadding = ClientRectWithPadding;
                    TextRenderer.DrawText(g, Text, font, clientRectWithPadding, color, CreateTextFormatFlags(clientRectWithPadding.Size));
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:LinkLabel.cs

示例4: Draw

		/// <summary>
		/// Render this object to the specified <see cref="Graphics"/> device
		/// This method is normally only called by the Draw method
		/// of the parent <see cref="GraphObjList"/> collection object.
		/// </summary>
		/// <param name="g">
		/// A graphic device object to be drawn into.  This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="pane">
		/// A reference to the <see cref="PaneBase"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="scaleFactor">
		/// The scaling factor to be used for rendering objects.  This is calculated and
		/// passed down by the parent <see cref="GraphPane"/> object using the
		/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
		/// font sizes, etc. according to the actual size of the graph.
		/// </param>
		override public void Draw( Graphics g, PaneBase pane, float scaleFactor )
		{
			if ( _image != null )
			{
				// Convert the rectangle coordinates from the user coordinate system
				// to the screen coordinate system
				RectangleF tmpRect = _location.TransformRect( pane );

				if ( _isScaled )
					g.DrawImage( _image, tmpRect );
				else
				{
					Region clip = g.Clip.Clone();
					g.IntersectClip( tmpRect );
					g.DrawImageUnscaled( _image, Rectangle.Round( tmpRect ) );
					g.Clip = clip;
					//g.DrawImageUnscaledAndClipped( image, Rectangle.Round( tmpRect ) );
				}
			}

		}
开发者ID:lgatto,项目名称:proteowizard,代码行数:40,代码来源:ImageObj.cs

示例5: DrawInk

        private static void DrawInk(GraphicsPath p, InkPressureFeedbackMode m, Size s, Graphics g)
        {
            RectangleF PathBounds = p.GetBounds();  //get the bounds of the path and compute the square scale transform
            float ds = 0.8f * Math.Min(s.Width / PathBounds.Width, s.Height / PathBounds.Height);

            GraphicsState OriginalGraphicsState = g.Save();

            g.TranslateTransform(s.Width >> 1, s.Height >> 1);
            g.ScaleTransform(ds, -ds);

            switch (m)
            {
                case InkPressureFeedbackMode.Size:
                    g.FillEllipse(Brushes.Black, new Rectangle(-800, -800, 1600, 1600));
                    break;

                case InkPressureFeedbackMode.Width:
                    g.DrawLine(new Pen(Color.Black, 500f), new Point(-500, 0), new Point(500, 0));
                    break;

                case InkPressureFeedbackMode.None:
                case InkPressureFeedbackMode.Color:
                default:
                    GraphicsPath InkRegion = new GraphicsPath();    //upper-left triangular clip region to fake "ink"
                    InkRegion.AddPolygon(new Point[] { Point.Empty, new Point(s.Width, 0), new Point(0, s.Height) });
                    Matrix InverseTransform = g.Transform;
                    InverseTransform.Invert();
                    InkRegion.Transform(InverseTransform);

                    g.IntersectClip(new Region(InkRegion));
                    g.DrawPath(new Pen(Color.Blue, 4 / ds), p);
                    break;
            }

            g.Restore(OriginalGraphicsState);
        }
开发者ID:hadleymj,项目名称:Senior-Design-Fall-2009,代码行数:36,代码来源:TestScriptPreviewControl.cs

示例6: PaintLink

 private void PaintLink(Graphics g, Link link, SolidBrush foreBrush, SolidBrush linkBrush, bool optimizeBackgroundRendering, RectangleF finalrect)
 {
     Font hoverLinkFont = this.Font;
     if (link != null)
     {
         if (link.VisualRegion != null)
         {
             Color empty = Color.Empty;
             LinkState state = link.State;
             if ((state & LinkState.Hover) == LinkState.Hover)
             {
                 hoverLinkFont = this.hoverLinkFont;
             }
             else
             {
                 hoverLinkFont = this.linkFont;
             }
             if (link.Enabled)
             {
                 if ((state & LinkState.Active) == LinkState.Active)
                 {
                     empty = this.ActiveLinkColor;
                 }
                 else if ((state & LinkState.Visited) == LinkState.Visited)
                 {
                     empty = this.VisitedLinkColor;
                 }
             }
             else
             {
                 empty = this.DisabledLinkColor;
             }
             if (this.IsOneLink())
             {
                 g.Clip = new Region(finalrect);
             }
             else
             {
                 g.Clip = link.VisualRegion;
             }
             if (optimizeBackgroundRendering)
             {
                 this.PaintLinkBackground(g);
             }
             if (this.UseCompatibleTextRendering)
             {
                 SolidBrush brush = (empty == Color.Empty) ? linkBrush : new SolidBrush(empty);
                 StringFormat format = this.CreateStringFormat();
                 g.DrawString(this.Text, hoverLinkFont, brush, this.ClientRectWithPadding, format);
                 if (brush != linkBrush)
                 {
                     brush.Dispose();
                 }
             }
             else
             {
                 if (empty == Color.Empty)
                 {
                     empty = linkBrush.Color;
                 }
                 IntPtr hdc = g.GetHdc();
                 try
                 {
                     using (WindowsGraphics graphics = WindowsGraphics.FromHdc(hdc))
                     {
                         empty = graphics.GetNearestColor(empty);
                     }
                 }
                 finally
                 {
                     g.ReleaseHdc();
                 }
                 Rectangle clientRectWithPadding = this.ClientRectWithPadding;
                 TextRenderer.DrawText(g, this.Text, hoverLinkFont, clientRectWithPadding, empty, this.CreateTextFormatFlags(clientRectWithPadding.Size));
             }
             if ((this.Focused && this.ShowFocusCues) && (this.FocusLink == link))
             {
                 RectangleF[] regionScans = link.VisualRegion.GetRegionScans(g.Transform);
                 if ((regionScans != null) && (regionScans.Length > 0))
                 {
                     if (this.IsOneLink())
                     {
                         Rectangle rectangle = Rectangle.Ceiling(finalrect);
                         ControlPaint.DrawFocusRectangle(g, rectangle, this.ForeColor, this.BackColor);
                     }
                     else
                     {
                         foreach (RectangleF ef in regionScans)
                         {
                             ControlPaint.DrawFocusRectangle(g, Rectangle.Ceiling(ef), this.ForeColor, this.BackColor);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         g.IntersectClip(this.textRegion);
         if (optimizeBackgroundRendering)
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:LinkLabel.cs

示例7: RenderControls

 void RenderControls(Graphics g)
 {
     g.IntersectClip(GetDesignRect());
     g.Clear(this.BackColor);
     int x = _model.PageWidth;
     g.DrawLine(Pens.WhiteSmoke,PointToDesignScreen(new Point(x,0)),PointToDesignScreen(new Point(x,this.Height)));
     foreach (Band band in _model.Bands)
     {
         if (band.Row >= _top)
         {
             foreach (BaseWidget widget in band.Items)
             {
                 Point p = PointToDesignScreen(new Point(widget.Col,widget.Row));
                 Brush brush = new SolidBrush(Color.FromKnownColor(KnownColor.WindowText));
                 Font font;
                 FontStyle fontStyle = FontStyle.Regular;
                 //if (widget.IsSelected)
                 //{
                 //    font = _italicFont;
                 //}
                 //else
                 //{
                 //    font = _normalFont;
                 //}
                 if (widget.IsBold)
                     fontStyle |= FontStyle.Bold;
                 if (widget.IsUnderline)
                     fontStyle |= FontStyle.Underline;
                 if (widget.IsItalic)
                     fontStyle |= FontStyle.Italic;
                 font = new Font("Courier New",10, fontStyle);
                 if (widget.IsSelected)
                 {
                     g.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.Highlight)), RectToScreen(widget.GetRectangle()));
                     brush = new SolidBrush(Color.FromKnownColor(KnownColor.HighlightText));
                 }
                 else if (widget is ValueWidget)
                 {
                     g.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.Control)), RectToScreen(widget.GetRectangle()));
                     brush = new SolidBrush(Color.FromKnownColor(KnownColor.ControlText));
                 }
                 DrawString(g, font, brush, widget.ToString(), p.X, p.Y);
                 brush.Dispose();
                 font.Dispose();
             }
         }
     }
 }
开发者ID:saykonot,项目名称:classicreports4net,代码行数:48,代码来源:ReportDesignerPanel.cs

示例8: DrawStringInRectangle

		/// <summary>
		/// Draws string into specified rectangle using given ParagraphFormat.
		/// </summary>
		/// <param name="gr"></param>
		/// <param name="rect"></param>
		/// <param name="pf"></param>
		/// <remarks>
		/// This is the 'main' method of the class. This one is called by StringDrawUtils
		/// to draw formatted string.<br/>
		/// As this class (and consequently this method) isn't to be published, there are some limitations:<br/>
		/// Angle of InitialFormat (specified at construction) has to be zero.<br/>
		/// BackgroundBrush
		/// </remarks>
		public void DrawStringInRectangle(Graphics gr, RectangleF rect, ParagraphFormat pf)
		{
			Debug.Assert(InitialFormat.Angle==0);
			Debug.Assert(pf.BackgroundBrush==null);


			if(pf.VerticalAlignment!=ParagraphVerticalAlignment.Top)
			{
				int lines=Math.Min(GetMaxVisibleLineCount(gr, rect.Height, pf), 
					CountOf(Interval.Full(this), '\n')+1);
				float lineHeight=sdu.GetLineHeight(gr,InitialFormat.Font);
				float totalHeight=(lineHeight*lines)+
					sdu.GetMeasureStringVerticalGap(gr, InitialFormat.Font);

				switch(pf.VerticalAlignment)
				{
					case ParagraphVerticalAlignment.Bottom:
						rect.Offset(0, rect.Height-totalHeight);
						break;
					case ParagraphVerticalAlignment.Center:
						rect.Offset(0, (rect.Height-totalHeight)/2);
						break;
				}
			}

			
			Region oldClip=gr.Clip.Clone();

			gr.IntersectClip(rect);

			DrawStringLineByLine(gr, rect, pf);

			gr.Clip=oldClip;

		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:48,代码来源:SDUFormatedString.cs

示例9: DrawSmoothFilledCurve

		/// <summary>
		/// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
		/// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>).
		/// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>;
		/// the symbols are drawn by the <see cref="Symbol.Draw"/> method.  This method
		/// is normally only called by the Draw method of the
		/// <see cref="CurveItem"/> object.  Note that the <see cref="StepType"/> property
		/// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true).
		/// </summary>
		/// <param name="g">
		/// A graphic device object to be drawn into.  This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="scaleFactor">
		/// The scaling factor to be used for rendering objects.  This is calculated and
		/// passed down by the parent <see cref="GraphPane"/> object using the
		/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
		/// font sizes, etc. according to the actual size of the graph.
		/// </param>
		/// <param name="pane">
		/// A reference to the <see cref="GraphPane"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="curve">A <see cref="LineItem"/> representing this
		/// curve.</param>
		public void DrawSmoothFilledCurve( Graphics g, GraphPane pane,
                                CurveItem curve, float scaleFactor )
		{
			Line source = this;
			if ( curve.IsSelected )
				source = Selection.Line;

			PointF[] arrPoints;
			int count;
			IPointList points = curve.Points;

			if ( this.IsVisible && !this.Color.IsEmpty && points != null &&
				BuildPointsArray( pane, curve, out arrPoints, out count ) &&
				count > 2 )
			{
				float tension = _isSmooth ? _smoothTension : 0f;

				// Fill the curve if needed
				if ( this.Fill.IsVisible )
				{
					Axis yAxis = curve.GetYAxis( pane );

					using ( GraphicsPath path = new GraphicsPath( FillMode.Winding ) )
					{
						path.AddCurve( arrPoints, 0, count - 2, tension );

						double yMin = yAxis._scale._min < 0 ? 0.0 : yAxis._scale._min;
						CloseCurve( pane, curve, arrPoints, count, yMin, path );

						RectangleF rect = path.GetBounds();
						using ( Brush brush = source._fill.MakeBrush( rect ) )
						{
							if ( pane.LineType == LineType.Stack && yAxis.Scale._min < 0 &&
									this.IsFirstLine( pane, curve ) )
							{
								float zeroPix = yAxis.Scale.Transform( 0 );
								RectangleF tRect = pane.Chart._rect;
								tRect.Height = zeroPix - tRect.Top;
								if ( tRect.Height > 0 )
								{
									Region reg = g.Clip.Clone();
									g.IntersectClip( tRect );
									g.FillPath( brush, path );
									g.Clip = reg;
								}
							}
							else
								g.FillPath( brush, path );
							//brush.Dispose();
						}

						// restore the zero line if needed (since the fill tends to cover it up)
						yAxis.FixZeroLine( g, pane, scaleFactor, rect.Left, rect.Right );
					}
				}

				// If it's a smooth curve, go ahead and render the path.  Otherwise, use the
				// standard drawcurve method just in case there are missing values.
				if ( _isSmooth )
				{
					using ( Pen pen = GetPen( pane, scaleFactor ) )
					{
						// Stroke the curve
						g.DrawCurve( pen, arrPoints, 0, count - 2, tension );

						//pen.Dispose();
					}
				}
				else
					DrawCurve( g, pane, curve, scaleFactor );
			}
		}
开发者ID:lgatto,项目名称:proteowizard,代码行数:97,代码来源:Line.cs

示例10: IntersectClipRectangle

        public void IntersectClipRectangle(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(255, 0, 0x33, 0), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0x66, 0xEF, 0x7F));

            // Set clipping region.
            Rectangle clipRect = new Rectangle(0, 0, 200, 200);
            Region clipRegion = new Region(clipRect);
            g.SetClip(clipRegion, CombineMode.Replace);

            // Update clipping region to intersection of

            // existing region with specified rectangle.
            Rectangle intersectRect = new Rectangle(100, 100, 200, 200);
            Region intersectRegion = new Region(intersectRect);
            g.IntersectClip(intersectRegion);

            // Fill rectangle to demonstrate effective clipping region.
            g.FillRectangle(myBrush, 0, 0, 500, 500);

            // Reset clipping region to infinite.
            g.ResetClip();

            // Draw clipRect and intersectRect to screen.
            myPen.Color = Color.FromArgb(196, 0xC3, 0xC9, 0xCF);
            myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);
            g.DrawRectangle(myPen, clipRect);
            g.FillRectangle(myBrush, clipRect);

            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, intersectRect);
            g.FillRectangle(myBrush, intersectRect);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:35,代码来源:DrawingView.cs

示例11: DrawFullAlignedStringInRectangle

		/// <summary>
		/// Draws full aligned string into given rectangle.
		/// </summary>
		/// <param name="gr"><see cref="Graphics"/> object to draw into.</param>
		/// <param name="str"><see cref="string"/> to be drawn.</param>
		/// <param name="rect"><see cref="Rectangle"/> that string is drawn into.</param>
		/// <param name="cf"><see cref="CharacterFormat"/> used to draw the <paramref name="str"/>. </param>
		/// <param name="pf"><see cref="ParagraphFormat"/> used to draw the <paramref name="str"/>. </param>
		/// <remarks>As this method isn't to be exposed as public, there are 
		/// several limitations:<br/>
		/// <see cref="Rectangle.Width"/> has to be non-zero.<br/>
		/// <see cref="CharacterFormat.Angle"/> has to be zero.<br/>
		/// <see cref="ParagraphFormat.MultiLine"/> has to be false.<br/>
		/// <see cref="ParagraphFormat.Alignment"/> has to be <see cref="ParagraphAlignment.Full"/>.<br/>
		/// <see cref="ParagraphFormat.BackgroundBrush"/> has to be null.<br/>
		/// If not satisfied, results might be not as expected.</remarks>
		private void DrawFullAlignedStringInRectangle(Graphics gr, string str, RectangleF rect,
		                                              CharacterFormat cf, ParagraphFormat pf)
		{
			Region oldClip = gr.Clip.Clone();
			gr.IntersectClip(rect);

			float yofs = rect.Y;

			StringFormat sfLeft; //StringFormat for drawing left-aligned lines
			{
				ParagraphFormat pf2 = pf.ShallowCopy();
				pf2.Alignment = ParagraphAlignment.Left;
				pf2.VerticalAlignment = ParagraphVerticalAlignment.Top;
				pf2.MultiLine = false;
				pf2.ShowIncompleteLines = true;
				sfLeft = GetStringFormat(cf, pf2);
			}


			//lineHeight & borders retrieving
			float lineHeight = GetLineHeight(gr, cf.Font);

			int lineCount;

			//lineCount retrieving
			{
				StringFormat sf = GetStringFormat(cf, pf);
				int charfit;
				gr.MeasureString(str, cf.Font, new SizeF(rect.Width, rect.Height), sf,
				                 out charfit, out lineCount);
			}


			//VerticalAlignment business
			switch (pf.VerticalAlignment)
			{
				case ParagraphVerticalAlignment.Bottom:
					yofs += rect.Height - lineHeight*lineCount;
					break;
				case ParagraphVerticalAlignment.Center:
					yofs += (rect.Height - lineHeight*lineCount)/2;
					break;
			}


			int flc = 0; //first line character
			int llc = flc; //last line character (actually the one after last)
			int lineIndex = 0;
			while (lineIndex < lineCount - 1 && flc < str.Length)
			{
				lineIndex++;

				llc = flc;

				//add spaces at the beginneing
				while (llc < str.Length && Char.IsWhiteSpace(str, llc))
					llc++;

				//add words until the line is full
				int pllc = llc; //potential last line character
				while (llc == pllc && llc < str.Length)
				{
					pllc++;
					while (pllc < str.Length && !Char.IsWhiteSpace(str, pllc))
						pllc++;
					if (gr.MeasureString(str.Substring(flc, pllc - flc), cf.Font).Width < rect.Width)
						llc = pllc;
				}

				//If nothing was added before, add single characters (rect.Width is too small)
				if (llc == flc)
					do
					{ //always at least one character per line
						llc++;
					} while (llc < str.Length && gr.MeasureString(str.Substring(flc, llc - flc + 1), cf.Font).Width < rect.Width);

				string line = str.Substring(flc, llc - flc);

				//Newline fotmatting
				int nlindex = line.IndexOf('\n');
				if (nlindex >= 0)
				{
					//Newline may be just "\n" or "\r\n"
					if (nlindex > 1 && line[nlindex - 1] == '\r')
//.........这里部分代码省略.........
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:101,代码来源:StringDrawUtils.cs

示例12: PushClip

	    protected Region PushClip(Graphics g, RectangleF clip)
	    {
	        var previousClip = g.Clip.Clone();
            g.IntersectClip(clip);
	        return previousClip;
	    }
开发者ID:lgatto,项目名称:proteowizard,代码行数:6,代码来源:PaneBase.cs


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