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


C# IGraphics.SetClip方法代码示例

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


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

示例1: ClipGraphicsByOverflow

 /// <summary>
 /// Clip the region the graphics will draw on by the overflow style of the containing block.<br/>
 /// Recursively travel up the tree to find containing block that has overflow style set to hidden. if not
 /// block found there will be no clipping and null will be returned.
 /// </summary>
 /// <param name="g">the graphics to clip</param>
 /// <param name="box">the box that is rendered to get containing blocks</param>
 /// <returns>the prev region if clipped, otherwise null</returns>
 public static RectangleF ClipGraphicsByOverflow(IGraphics g, CssBox box)
 {
     var containingBlock = box.ContainingBlock;
     while (true)
     {
         if (containingBlock.Overflow == CssConstants.Hidden)
         {
             var prevClip = g.GetClip();
             var rect = box.ContainingBlock.ClientRectangle;
             rect.X -= 2; // atodo: find better way to fix it
             rect.Width += 2;
             rect.Offset(box.HtmlContainer.ScrollOffset);
             rect.Intersect(prevClip);
             g.SetClip(rect);
             return prevClip;
         }
         else
         {
             var cBlock = containingBlock.ContainingBlock;
             if (cBlock == containingBlock)
                 return RectangleF.Empty;
             containingBlock = cBlock;
         }
     }
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:33,代码来源:RenderUtils.cs

示例2: DrawBackgroundImage

        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(IGraphics g, CssBox box, ImageLoadHandler imageLoadHandler, RectangleF rectangle)
        {
            // image size depends if specific rectangle given in image loader
            var imgSize = new Size(imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
                                   imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPosition, rectangle, imgSize);

            var srcRect = imageLoadHandler.Rectangle == Rectangle.Empty
                              ? new Rectangle(0, 0, imgSize.Width, imgSize.Height)
                              : new Rectangle(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);

            // initial image destination rectangle
            var destRect = new Rectangle(location, imgSize);

            // need to clip so repeated image will be cut on rectangle
            var prevClip = g.GetClip();
            var lRectangle = rectangle;
            lRectangle.Intersect(prevClip);
            g.SetClip(lRectangle);

            switch( box.BackgroundRepeat )
            {
                case "no-repeat":
                    g.DrawImage(imageLoadHandler.Image, destRect, srcRect);
                    break;
                case "repeat-x":
                    DrawRepeatX(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                case "repeat-y":
                    DrawRepeatY(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                default:
                    DrawRepeat(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
            }

            g.SetClip(prevClip);
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:48,代码来源:BackgroundImageDrawHandler.cs

示例3: Render

        private void Render(IGraphics ig)
        {
            string s = cbWhat.Text;

            if (s == "Clipping")
            {
                Pen pn = new Pen(Color.LightGray, 5);
                Pen pn2 = new Pen(Color.Yellow);

                ig.Clear(Color.Black);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.SetClip(new Rectangle(35,35,120,120));

                ig.DrawRectangle(pn, 5,5,45,70);
                ig.DrawRectangle(pn, 15,25,90,120);
                ig.DrawRectangle(pn, 50,30,100,170);
                ig.DrawRectangle(pn, 5,80,180,30);
                ig.DrawRectangle(pn, 75,10,40,160);

                ig.EndContainer(cnt);

                ig.DrawRectangle(pn2, 5,5,45,70);
                ig.DrawRectangle(pn2, 15,25,90,120);
                ig.DrawRectangle(pn2, 50,30,100,170);
                ig.DrawRectangle(pn2, 5,80,180,30);
                ig.DrawRectangle(pn2, 75,10,40,160);
            }
            else if (s == "Transforms")
            {

                ig.Clear(Color.Black);

                ig.RotateTransform(15);
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);

                ig.TranslateTransform(15,-5);

                GraphicsContainer cnt = ig.BeginContainer();

                    ig.SmoothingMode = SmoothingMode.HighQuality;

                    ig.RotateTransform(5);
                    ig.FillEllipse(new SolidBrush(Color.Orange), 100,100,80,40);
                    ig.DrawRectangle(new Pen(Color.Orange,2), 60,80,40,40);

                    GraphicsContainer cnt2  = ig.BeginContainer();

                        ig.SmoothingMode = SmoothingMode.None;

                        ig.RotateTransform(5);
                        ig.ScaleTransform(1.1f, 1.2f);

                        ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130,180,80,40);
                        ig.DrawRectangle(new Pen(Color.YellowGreen,2), 62,80,40,40);

                        GraphicsContainer cnt3  = ig.BeginContainer();

                            ig.SmoothingMode = SmoothingMode.HighQuality;

                            Matrix mm = new Matrix();
                            mm.Shear(0.3f, 0f);
                            ig.Transform = mm;

                            ig.FillEllipse(new SolidBrush(Color.Green), 180,120,80,40);
                            ig.DrawRectangle(new Pen(Color.Green,2), 62,84,40,40);

                        ig.EndContainer(cnt3);

                    ig.EndContainer(cnt2);

                    ig.FillEllipse(new SolidBrush(Color.Blue), 120,150,80,40);
                    ig.DrawRectangle(new Pen(Color.Blue,2), 64,80,40,40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80,210,80,40);
                ig.DrawRectangle(new Pen(Color.Indigo,2), 66,80,40,40);

                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);

            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12);
                ow.EndCap = LineCap.Round;
                ow.StartCap = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;
//.........这里部分代码省略.........
开发者ID:luizcorreia,项目名称:SvgNet,代码行数:101,代码来源:Form1.cs

示例4: OnPaint

 public override void OnPaint(IGraphics g, int width, int height)
 {
     if (widths == null){
         InitSizes(width, height);
     }
     PaintSplitters(g, width, height);
     for (int row = 0; row < RowCount; row++){
         for (int col = 0; col < ColumnCount; col++){
             Tuple<int, int> key = new Tuple<int, int>(row, col);
             if (components.ContainsKey(key)){
                 BasicView v = components[key];
                 g.SetClip(new Rectangle2(xpos[col], ypos[row], widths[col], heights[row]));
                 g.TranslateTransform(xpos[col], ypos[row]);
                 v.OnPaint(g, widths[col], heights[row]);
                 g.ResetTransform();
                 g.ResetClip();
             }
         }
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:20,代码来源:BasicTableLayoutView.cs

示例5: Draw

        /// <summary>
        /// Render all the <see cref="GraphPane"/> objects in the <see cref="PaneList"/> to the
        /// specified graphics device.
        /// </summary>
        /// <remarks>This method should be part of the Paint() update process.  Calling this routine
        /// will redraw all
        /// features of all the <see cref="GraphPane"/> items.  No preparation is required other than
        /// instantiated <see cref="GraphPane"/> objects that have been added to the list with the
        /// <see cref="Add"/> method.
        /// </remarks>
        /// <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>
        public override void Draw(IGraphics g)
        {
            // Save current AntiAlias mode
            SmoothingMode sModeSave = g.SmoothingMode;
            TextRenderingHint sHintSave = g.TextRenderingHint;
            CompositingQuality sCompQual = g.CompositingQuality;
            InterpolationMode sInterpMode = g.InterpolationMode;

            SetAntiAliasMode(g, isAntiAlias);

            // Draw the pane border & background fill, the title, and the GraphObj objects that lie at
            // ZOrder.GBehindAll
            base.Draw(g);

            if (_rect.Width <= 1 || _rect.Height <= 1)
            {
                return;
            }

            float scaleFactor = CalcScaleFactor();

            // Clip everything to the rect
            g.SetClip(_rect);

            // For the MasterPane, All GraphItems go behind the GraphPanes, except those that
            // are explicity declared as ZOrder.AInFront
            _graphObjList.Draw(g, this, scaleFactor, ZOrder.G_BehindChartFill);
            _graphObjList.Draw(g, this, scaleFactor, ZOrder.E_BehindCurves);
            _graphObjList.Draw(g, this, scaleFactor, ZOrder.D_BehindAxis);
            _graphObjList.Draw(g, this, scaleFactor, ZOrder.C_BehindChartBorder);

            // Reset the clipping
            g.ResetClip();

            foreach (GraphPane pane in _paneList)
            {
                pane.Draw(g);
            }

            // Clip everything to the rect
            g.SetClip(_rect);

            _graphObjList.Draw(g, this, scaleFactor, ZOrder.B_BehindLegend);

            // Recalculate the legend rect, just in case it has not yet been done
            // innerRect is the area for the GraphPane's
            RectangleF innerRect = CalcClientRect(g, scaleFactor);
            _legend.CalcRect(g, this, scaleFactor, ref innerRect);
            //this.legend.SetLocation( this,

            _legend.Draw(g, this, scaleFactor);

            _graphObjList.Draw(g, this, scaleFactor, ZOrder.A_InFront);

            // Reset the clipping
            g.ResetClip();

            // Restore original anti-alias mode
            g.SmoothingMode = sModeSave;
            g.TextRenderingHint = sHintSave;
            g.CompositingQuality = sCompQual;
            g.InterpolationMode = sInterpMode;
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:77,代码来源:MasterPane.cs

示例6: Draw

        /// <summary>
        /// Draw all elements in the <see cref="GraphPane"/> to the specified graphics device.
        /// </summary>
        /// <remarks>This method
        /// should be part of the Paint() update process.  Calling this routine will redraw all
        /// features of the graph.  No preparation is required other than an instantiated
        /// <see cref="GraphPane"/> object.
        /// </remarks>
        /// <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>
        public override void Draw( IGraphics g )
        {
            // Calculate the chart rect, deducting the area for the scales, titles, legend, etc.
            //int		hStack;
            //float	legendWidth, legendHeight;

            // Draw the pane border & background fill, the title, and the GraphObj objects that lie at
            // ZOrder.G_BehindAll
            base.Draw( g );

            if ( _rect.Width <= 1 || _rect.Height <= 1 )
                return;

            // Clip everything to the rect
            g.SetClip( _rect );

            // calculate scaleFactor on "normal" pane size (BaseDimension)
            float scaleFactor = CalcScaleFactor();

            // if the size of the ChartRect is determined automatically, then do so
            // otherwise, calculate the legendrect, scalefactor, hstack, and legendwidth parameters
            // but leave the ChartRect alone
            if ( _chart._isRectAuto )
            {
                _chart._rect = CalcChartRect( g, scaleFactor );
                //this.pieRect = PieItem.CalcPieRect( g, this, scaleFactor, this.chartRect );
            }
            else
                CalcChartRect( g, scaleFactor );

            // do a sanity check on the ChartRect
            if ( _chart._rect.Width < 1 || _chart._rect.Height < 1 )
                return;

            // Draw the graph features only if there is at least one curve with data
            // if ( _curveList.HasData() &&
            // Go ahead and draw the graph, even without data.  This makes the control
            // version still look like a graph before it is fully set up
            bool showGraf = AxisRangesValid();

            // Setup the axes for graphing - This setup must be done before
            // the GraphObj's are drawn so that the Transform functions are
            // ready.  Also, this should be done before CalcChartRect so that the
            // Axis.Cross - shift parameter can be calculated.
            _xAxis.Scale.SetupScaleData( this, _xAxis );
            _x2Axis.Scale.SetupScaleData( this, _x2Axis );
            foreach ( Axis axis in _yAxisList )
                axis.Scale.SetupScaleData( this, axis );
            foreach ( Axis axis in _y2AxisList )
                axis.Scale.SetupScaleData( this, axis );

            // Draw the GraphItems that are behind the Axis objects
            if ( showGraf )
                _graphObjList.Draw( g, this, scaleFactor, ZOrder.G_BehindChartFill );

            // Fill the axis background
            _chart.Fill.Draw( g, _chart._rect );

            if ( showGraf )
            {
                // Draw the GraphItems that are behind the CurveItems
                _graphObjList.Draw( g, this, scaleFactor, ZOrder.F_BehindGrid );

                DrawGrid( g, scaleFactor );

                // Draw the GraphItems that are behind the CurveItems
                _graphObjList.Draw( g, this, scaleFactor, ZOrder.E_BehindCurves );

                // Clip the points to the actual plot area
                g.SetClip( _chart._rect );
                _curveList.Draw( g, this, scaleFactor );
                g.SetClip( _rect );

            }

            if ( showGraf )
            {
                // Draw the GraphItems that are behind the Axis objects
                _graphObjList.Draw( g, this, scaleFactor, ZOrder.D_BehindAxis );

                // Draw the Axes
                _xAxis.Draw( g, this, scaleFactor, 0.0f );
                _x2Axis.Draw( g, this, scaleFactor, 0.0f );

                float yPos = 0;
                foreach ( Axis axis in _yAxisList )
                {
                    axis.Draw( g, this, scaleFactor, yPos );
//.........这里部分代码省略.........
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:101,代码来源:GraphPane.cs

示例7: Draw

        /// <summary>
        /// Do all rendering associated with this <see cref="PaneBase"/> to the specified
        /// <see cref="Graphics"/> device.  This abstract method is implemented by the child
        /// classes.
        /// </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>
        public virtual void Draw( IGraphics g  )
        {
            if ( _rect.Width <= 1 || _rect.Height <= 1 )
                return;

            // calculate scaleFactor on "normal" pane size (BaseDimension)
            float scaleFactor = CalcScaleFactor();

            // Fill the pane background and draw a border around it
            DrawPaneFrame( g, scaleFactor );

            // Clip everything to the rect
            g.SetClip( _rect );

            // Draw the GraphItems that are behind everything
            _graphObjList.Draw( g, this, scaleFactor, ZOrder.H_BehindAll );

            // Draw the Pane Title
            DrawTitle( g, scaleFactor );

            // Draw the Legend
            //this.Legend.Draw( g, this, scaleFactor );

            // Reset the clipping
            g.ResetClip();
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:35,代码来源:PaneBase.cs

示例8: ReturnClip

 /// <summary>
 /// Return original clip region to the graphics object.<br/>
 /// Should be used with <see cref="ClipGraphicsByOverflow"/> return value to return clip back to original.
 /// </summary>
 /// <param name="g">the graphics to clip</param>
 /// <param name="prevClip">the region to set on the graphics (null - ignore)</param>
 public static void ReturnClip(IGraphics g, RectangleF prevClip)
 {
     if (prevClip != RectangleF.Empty)
     {
         g.SetClip(prevClip);
     }
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:13,代码来源:RenderUtils.cs

示例9: Draw

        /// <summary>
        /// Do all rendering associated with this <see cref="CurveItem"/> to the specified
        /// <see cref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see cref="CurveList"/>
        /// 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="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="pos">The ordinal position of the current <see cref="Bar"/>
        /// curve.</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>
        public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor)
        {
            RectangleF rect = GetDrawingRect(pane);

            g.FillEllipse(MakeBrush(), rect);
            g.DrawEllipse(MakePen(), rect);

            if(Image != null)
            {
                var left = rect.Left + rect.Width / 2.0 - Image.Width / 2.0;
                var top = rect.Top + rect.Height / 2.0 - Image.Height / 2.0;
                var tmpRect = new RectangleF((float)left, (float)top, Image.Width, Image.Height);
                Region clip = g.Clip;
                g.SetClip(tmpRect);
                g.DrawImageUnscaled(Image, Rectangle.Round(tmpRect));
                g.SetClip(clip, CombineMode.Replace);

            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:41,代码来源:BubbleItem.cs

示例10: 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 virtual void DrawSmoothFilledCurve( IGraphics 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;
                                    g.SetClip( tRect );
                                    g.FillPath( brush, path );
                                    g.SetClip( pane.Chart._rect );
                                }
                            }
                            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, GetPoints(curve, pane));
                }
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:99,代码来源:Line.cs

示例11: DrawRoundedSurface

        private void DrawRoundedSurface(IGraphics g, bool onScreen, Style style)
        {
            int diameter = GetRoundingSize(style) * 2;

            GraphicsPath borderPath = new GraphicsPath();
            borderPath.AddArc(Left, Top, diameter, diameter, 180, 90);
            borderPath.AddArc(Right - diameter, Top, diameter, diameter, 270, 90);
            borderPath.AddArc(Right - diameter, Bottom - diameter, diameter, diameter, 0, 90);
            borderPath.AddArc(Left, Bottom - diameter, diameter, diameter, 90, 90);
            borderPath.CloseFigure();

            // Draw shadow
            if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty)
            {
                shadowBrush.Color = style.ShadowColor;
                g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height);
                g.FillPath(shadowBrush, borderPath);
                g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height);
            }

            // Draw background
            g.FillPath(backgroundBrush, borderPath);

            // Draw header background
            Region oldClip = g.Clip;
            g.SetClip(borderPath, CombineMode.Intersect);
            DrawHeaderBackground(g, style);
            g.Clip.Dispose();
            g.Clip = oldClip;

            // Draw border
            g.DrawPath(borderPen, borderPath);

            borderPath.Dispose();
        }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:35,代码来源:TypeShape.cs

示例12: PaintWords

        /// <summary>
        /// Paint all the words in the box.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="offset">the current scroll offset to offset the words</param>
        private void PaintWords(IGraphics g, PointF offset)
        {
            foreach (var word in Words)
            {
                var wordPoint = new PointF(word.Left + offset.X, word.Top + offset.Y);
                if (word.Selected)
                {
                    // handle paint selected word background and with partial word selection
                    var wordLine = DomUtils.GetCssLineBoxByWord(word);
                    var left = word.SelectedStartOffset > -1 ? word.SelectedStartOffset : (wordLine.Words[0] != word && word.HasSpaceBefore ? -ActualWordSpacing : 0);
                    var padWordRight = word.HasSpaceAfter && !wordLine.IsLastSelectedWord(word);
                    var width = word.SelectedEndOffset > -1 ? word.SelectedEndOffset : word.Width + (padWordRight ? ActualWordSpacing : 0);
                    var rect = new RectangleF(word.Left + offset.X + left, word.Top + offset.Y, width - left, wordLine.LineHeight);

                    g.FillRectangle(GetSelectionBackBrush(false), rect.X, rect.Y, rect.Width, rect.Height);

                    if (HtmlContainer.SelectionForeColor != System.Drawing.Color.Empty && (word.SelectedStartOffset > 0 || word.SelectedEndIndexOffset > -1))
                    {
                        var orgClip = g.GetClip();
                        g.SetClip(rect, CombineMode.Exclude);
                        g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new SizeF(word.Width, word.Height));
                        g.SetClip(rect);
                        g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new SizeF(word.Width, word.Height));
                        g.SetClip(orgClip);
                    }
                    else
                    {
                        g.DrawString(word.Text, ActualFont, GetSelectionForeBrush(), wordPoint, new SizeF(word.Width, word.Height));
                    }
                }
                else
                {
                    //g.DrawRectangle(Pens.Red, wordPoint.X, wordPoint.Y, word.Width - 1, word.Height - 1);
                    g.DrawString(word.Text, ActualFont, ActualColor, wordPoint, new SizeF(word.Width, word.Height));
                }
            }
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:42,代码来源:CssBox.cs

示例13: 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>
        public override void Draw( IGraphics 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;
                    g.SetClip( tmpRect );
                    g.DrawImageUnscaled( _image, Rectangle.Round( tmpRect ) );
                    g.SetClip( clip, CombineMode.Replace );
                    //g.DrawImageUnscaledAndClipped( image, Rectangle.Round( tmpRect ) );
                }
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:39,代码来源:ImageObj.cs


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