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


C# Graphics.IsVisible方法代码示例

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


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

示例1: PaintColumnHeaders

        private void PaintColumnHeaders(Graphics g, Rectangle clipBounds, bool singleBorderAdded)
        {
            if (g.IsVisible(this.layout.ColumnHeaders))
            {
                Rectangle bandBounds, cellBounds;
                bandBounds = cellBounds = this.layout.ColumnHeaders;
                bandBounds.Height = cellBounds.Height = this.columnHeadersHeight;
                int cx = 0;
                bool isFirstDisplayedColumn = true, isLastVisibleColumn = false;
                DataGridViewCell cell;
                DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle();
                DataGridViewAdvancedBorderStyle dataGridViewAdvancedBorderStylePlaceholder = new DataGridViewAdvancedBorderStyle(), dgvabsEffective;
                DataGridViewColumn dataGridViewColumnNext = null;

                // first paint the visible frozen columns
                DataGridViewColumn dataGridViewColumn = this.Columns.GetFirstColumn(DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen);
                while (dataGridViewColumn != null)
                {
                    cell = dataGridViewColumn.HeaderCell;
                    cellBounds.Width = dataGridViewColumn.Thickness;
                    if (singleBorderAdded && isFirstDisplayedColumn)
                    {
                        cellBounds.Width++;
                    }
                    Debug.Assert(cellBounds.Width > 0);
                    if (this.RightToLeftInternal)
                    {
                        cellBounds.X = bandBounds.Right - cx - cellBounds.Width;
                    }
                    else
                    {
                        cellBounds.X = bandBounds.X + cx;
                    }

                    BuildInheritedColumnHeaderCellStyle(inheritedCellStyle, cell);

                    dataGridViewColumnNext = this.Columns.GetNextColumn(dataGridViewColumn,
                        DataGridViewElementStates.Visible | DataGridViewElementStates.Frozen,
                        DataGridViewElementStates.None);
                    if (dataGridViewColumnNext == null)
                    {
                        isLastVisibleColumn = (this.displayedBandsInfo.FirstDisplayedScrollingCol < 0);
                    }

                    dgvabsEffective = AdjustColumnHeaderBorderStyle(this.AdvancedColumnHeadersBorderStyle, dataGridViewAdvancedBorderStylePlaceholder,
                                                                    isFirstDisplayedColumn, isLastVisibleColumn);

                    // [....]: should paintSelectionBackground be dev-settable?
                    cell.PaintWork(g, 
                                   clipBounds, 
                                   cellBounds, 
                                   -1, 
                                   dataGridViewColumn.State, 
                                   inheritedCellStyle, 
                                   dgvabsEffective,
                                   DataGridViewPaintParts.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon | DataGridViewPaintParts.SelectionBackground);

                    cx += cellBounds.Width;
                    if (cx >= bandBounds.Width)
                    {
                        break;
                    }

                    dataGridViewColumn = dataGridViewColumnNext;
                    isFirstDisplayedColumn = false;
                }

                // then paint the visible scrolling ones
                Rectangle scrollingBounds = bandBounds;
                if (!this.RightToLeftInternal)
                {
                    scrollingBounds.X -= this.negOffset;
                }
                scrollingBounds.Width += this.negOffset;

                if (this.displayedBandsInfo.FirstDisplayedScrollingCol >= 0 && cx < scrollingBounds.Width)
                {
                    Region clipRegion = null;
                    if (this.negOffset > 0)
                    {
                        clipRegion = g.Clip;
                        Rectangle rowRect = bandBounds;
                        if (!this.RightToLeftInternal)
                        {
                            rowRect.X += cx;
                        }
                        rowRect.Width -= cx;
                        g.SetClip(rowRect);
                    }

                    dataGridViewColumn = this.Columns[this.displayedBandsInfo.FirstDisplayedScrollingCol];
                    while (dataGridViewColumn != null)
                    {
                        Debug.Assert(dataGridViewColumn.Visible && !dataGridViewColumn.Frozen);

                        cell = dataGridViewColumn.HeaderCell;
                        cellBounds.Width = dataGridViewColumn.Thickness;
                        if (singleBorderAdded && isFirstDisplayedColumn)
                        {
                            cellBounds.Width++;
//.........这里部分代码省略.........
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:DataGridViewMethods.cs

示例2: PaintTopLeftHeaderCell

 private void PaintTopLeftHeaderCell(Graphics g)
 {
     if (g.IsVisible(this.layout.TopLeftHeader))
     {
         DataGridViewCell cell = this.TopLeftHeaderCell;
         DataGridViewCellStyle inheritedCellStyle = new DataGridViewCellStyle();
         BuildInheritedColumnHeaderCellStyle(inheritedCellStyle, cell);
         Rectangle cellBounds = this.layout.TopLeftHeader;
         cellBounds.Width = this.rowHeadersWidth;
         cellBounds.Height = this.columnHeadersHeight;
         // [....]: Should paintSelectionBackground be dev-settable?
         cell.PaintWork(g, 
                        this.layout.TopLeftHeader, 
                        cellBounds, 
                        -1, 
                        cell.State, 
                        inheritedCellStyle, 
                        this.AdjustedTopLeftHeaderBorderStyle,
                        DataGridViewPaintParts.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon | DataGridViewPaintParts.SelectionBackground);
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:DataGridViewMethods.cs

示例3: DrawCharacter

        /// <summary>
        /// Draw single character
        /// Called by onPaint
        /// </summary>
        /// <param name="cx">Horizontal character position</param>
        /// <param name="cy">Vertical character position</param>
        /// <param name="g">Active graphics object</param>
		private void DrawCharacter(int cx, int cy, Graphics g) 
		{
			try 
			{
				int code = CharacterCode[cy,cx];
				if (CharacterBitmap[code] == null)	
				{
					CharacterBitmap[code] = this.MakeCharacterBitmap(code, g);
				}

				if (g.IsVisible(GetCharacterRectangle(cy,cx)))
				{
					// GDI+ Method is definitely TOO SLOW!!!!
					// g.DrawImageUnscaled(CharacterBitmap[code], cx * CharacterWidth + iFrameEffective, cy * CharacterHeight + iFrameEffective);

					// Use old and unmanaged BitBlt instead...
					Win32.TurboBitmapCopy(g,CharacterBitmap[code],cx * CharacterWidth + iFrameEffective,cy * CharacterHeight + iFrameEffective);
				}
			}
			catch 
			{
				System.Diagnostics.Debug.WriteLine("Error in " + Name + " DrawCharacter routine");
			}
		}
开发者ID:nocoolnicksleft,项目名称:TurboControl,代码行数:31,代码来源:MatrixDisplay.cs

示例4: DrawBorder

        public void DrawBorder(Graphics g, Rectangle rect)
        {
            Rectangle rectTopCenter = Rectangle.Empty;
            bool showTopCenter = false;
            if (!IsEmpty(TOPCENTER))
            {
                rectTopCenter = new Rectangle(
                    rect.Left + GetWidth(TOPLEFT),
                    rect.Top,
                    rect.Width - GetWidth(TOPLEFT) - GetWidth(TOPRIGHT),
                    _slices[TOPCENTER].Height);
                showTopCenter = g.IsVisible(rectTopCenter);
            }

            Rectangle rectBottomCenter = Rectangle.Empty;
            bool showBottomCenter = false;
            if (!IsEmpty(BOTTOMCENTER))
            {
                rectBottomCenter = new Rectangle(
                    rect.Left + GetWidth(BOTTOMLEFT),
                    rect.Bottom - _slices[BOTTOMCENTER].Height,
                    rect.Width - GetWidth(BOTTOMLEFT) - GetWidth(BOTTOMRIGHT),
                    _slices[BOTTOMCENTER].Height);
                showBottomCenter = g.IsVisible(rectBottomCenter);
            }

            Rectangle rectMiddleLeft = Rectangle.Empty;
            bool showMiddleLeft = false;
            if (!IsEmpty(MIDDLELEFT))
            {
                rectMiddleLeft = new Rectangle(
                    rect.Left,
                    rect.Top + GetHeight(TOPLEFT),
                    _slices[MIDDLELEFT].Width,
                    rect.Height - GetHeight(TOPLEFT) - GetHeight(BOTTOMLEFT));
                showMiddleLeft = g.IsVisible(rectMiddleLeft);
            }

            Rectangle rectMiddleCenter = Rectangle.Empty;
            bool showMiddleCenter = false;
            if (!IsEmpty(MIDDLECENTER) && IsFlagSet(_flags, BorderPaintMode.PaintMiddleCenter))
            {
                rectMiddleCenter = new Rectangle(
                    rect.Left + GetWidth(MIDDLELEFT),
                    rect.Top + GetHeight(TOPCENTER),
                    rect.Width - GetWidth(MIDDLELEFT) - GetWidth(MIDDLERIGHT),
                    rect.Height - GetHeight(TOPCENTER) - GetHeight(BOTTOMCENTER));
                showMiddleCenter = g.IsVisible(rectMiddleCenter);
            }

            Rectangle rectMiddleRight = Rectangle.Empty;
            bool showMiddleRight = false;
            if (!IsEmpty(MIDDLERIGHT))
            {
                rectMiddleRight = new Rectangle(
                    rect.Right - _slices[MIDDLERIGHT].Width,
                    rect.Top + GetHeight(TOPRIGHT),
                    _slices[MIDDLERIGHT].Width,
                    rect.Height - GetHeight(TOPRIGHT) - GetHeight(BOTTOMRIGHT));
                showMiddleRight = g.IsVisible(rectMiddleRight);
            }

            bool useGdi = IsFlagSet(_flags, BorderPaintMode.GDI);
            IntPtr pTarget = !useGdi ? IntPtr.Zero : g.GetHdc();
            try
            {
                IntPtr pSource = !useGdi ? IntPtr.Zero : Gdi32.CreateCompatibleDC(pTarget);
                try
                {
                    IntPtr pOrig = !useGdi ? IntPtr.Zero : Gdi32.SelectObject(pSource, _hBitmap);
                    try
                    {

                        if (!IsEmpty(TOPLEFT))
                            DrawSlice(g, TOPLEFT, rect.Location, pSource, pTarget);
                        if (!IsEmpty(TOPRIGHT))
                            DrawSlice(g, TOPRIGHT, new Point(rect.Right - _slices[TOPRIGHT].Width, rect.Top), pSource, pTarget);
                        if (!IsEmpty(BOTTOMLEFT))
                            DrawSlice(g, BOTTOMLEFT, new Point(rect.Left, rect.Bottom - _slices[BOTTOMLEFT].Height), pSource, pTarget);
                        if (!IsEmpty(BOTTOMRIGHT))
                            DrawSlice(g, BOTTOMRIGHT, new Point(rect.Right - _slices[BOTTOMRIGHT].Width, rect.Bottom - _slices[BOTTOMRIGHT].Height), pSource, pTarget);

                        if (showTopCenter)
                            HorizontalFill(g, TOPCENTER, rectTopCenter, pSource, pTarget);
                        if (showBottomCenter)
                            HorizontalFill(g, BOTTOMCENTER, rectBottomCenter, pSource, pTarget);
                        if (showMiddleLeft)
                            VerticalFill(g, MIDDLELEFT, rectMiddleLeft, pSource, pTarget);
                        if (showMiddleRight)
                            VerticalFill(g, MIDDLERIGHT, rectMiddleRight, pSource, pTarget);
                        if (showMiddleCenter)
                            StretchFill(g, MIDDLECENTER, rectMiddleCenter, pSource, pTarget);

                    }
                    finally
                    {
                        if (pSource != IntPtr.Zero)
                            Gdi32.SelectObject(pSource, pOrig);
                    }
                }
//.........这里部分代码省略.........
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:101,代码来源:BorderPaint.cs

示例5: DrawText

            public void DrawText(
                Graphics graphics,
                Bitmap backing,
                Point position,
                Color foreColor,
                Color backColor)
            {
                COLORREF foreColorRef = new COLORREF(foreColor);

                int width = backing.Width;
                int height = backing.Height;
                Rectangle bounds = new Rectangle(0, 0, width, height);
                Rectangle margin = new Rectangle(-height, 0, width + 2 * height, height);
                Debug.Assert(service.offscreenStrip != null);
                Debug.Assert(service.offscreenStrip.Width == width);
                Debug.Assert(service.offscreenStrip.Height == height);

                using (GDIBrush backBrush = new GDIBrush(backColor))
                {
                    GDI.FillRect(service.hdcOffscreenStrip, ref bounds, backBrush);
                }

                ProcessText(
                    position,
                    delegate (
                        int iItem,
                        Point where,
                        int endX,
                        ref SCRIPT_ITEM item,
                        ref ItemInfo itemExtra,
                        Font font)
                    {
                        if (!graphics.IsVisible(new Rectangle(where.X - height, 0, endX - where.X + 2 * height, height)))
                        {
                            return true;
                        }

                        int fontCacheIndex = service.FontCacheIndex(font);

                        GDI.SetTextColor(service.hdcOffscreenStrip, foreColorRef);
                        GDI.SetBkMode(service.hdcOffscreenStrip, GDI.TRANSPARENT);
                        GDI.SelectObject(service.hdcOffscreenStrip, service.fontToHFont[font]);

                        int hr = ScriptTextOut(
                            service.hdcOffscreenStrip,
                            ref service.caches[fontCacheIndex].cache,
                            where.X,
                            where.Y,
                            (ScriptTextOutOptions)0,
                            IntPtr.Zero/*cliprect*/,
                            ref item.a,
                            IntPtr.Zero/*reserved*/,
                            0/*reserved*/,
                            itemExtra.glyphs,
                            itemExtra.cGlyphs,
                            itemExtra.iAdvances,
                            null/*piJustify*/,
                            itemExtra.goffsets);
                        if (hr < 0)
                        {
                            Marshal.ThrowExceptionForHR(hr);
                        }

                        return true;
                    });

                using (GDIRegion gdiRgnClip = new GDIRegion(graphics.Clip.GetHrgn(graphics)))
                {
                    using (GraphicsHDC gdiHdcOffscreen = new GraphicsHDC(graphics))
                    {
                        // Graphics/GDI+ doesn't pass clip region through so we have to reset it explicitly
                        GDI.SelectClipRgn(gdiHdcOffscreen, gdiRgnClip);

                        GDI.BitBlt(
                            gdiHdcOffscreen,
                            0,
                            0,
                            width,
                            height,
                            service.hdcOffscreenStrip,
                            0,
                            0,
                            GDI.SRCCOPY);
                    }
                }
            }
开发者ID:programmatom,项目名称:TextEditor,代码行数:86,代码来源:TextServiceUniscribe.cs

示例6: Render

        public override void Render(Graphics graphics, SizeF minimumSize, PointF location)
        {
            if (Node.Tag is ShaderFragmentNodeTag)
            {
                SizeF size = Measure(graphics);
                if (!graphics.IsVisible(new Rectangle() {X = (int)location.X, Y = (int)location.Y, Width = (int)size.Width, Height = (int)size.Height }))
                    return;

                if (_builder == null)
                {
                    var nodeGraph = ModelConversion.ToShaderPatcherLayer(_graphControl);
                    var shader = ShaderPatcherLayer.NodeGraph.GeneratePreviewShader(nodeGraph, ((ShaderFragmentNodeTag)Node.Tag).Id);

                    _builder  = PreviewRender.Manager.Instance.CreatePreview(shader);
                }

                    // (assuming no rotation on this transformation -- scale is easy to find)
                Size idealSize = new Size((int)(graphics.Transform.Elements[0] * size.Width), (int)(graphics.Transform.Elements[3] * size.Height));
                if (_builder != null && _builder.Bitmap != null) {
                        // compare the current bitmap size to the size we'd like
                    Size bitmapSize = _builder.Bitmap.Size;
                    float difference = System.Math.Max(System.Math.Abs(1.0f - bitmapSize.Width / (float)(idealSize.Width)), System.Math.Abs(1.0f - bitmapSize.Height / (float)(idealSize.Height)));
                    if (difference > 0.1f) {
                        _builder.Invalidate();
                    }
                }

                if (_builder.Bitmap==null) {
                    _builder.Update(_document, idealSize);
                }

                if (_builder.Bitmap!=null) {
                    graphics.DrawImage(_builder.Bitmap, new RectangleF() { X = location.X, Y = location.Y, Width = size.Width, Height = size.Height });
                }
            }
        }
开发者ID:ldh9451,项目名称:XLE,代码行数:36,代码来源:ShaderFragmentNodes.cs

示例7: PaintRows

 private void PaintRows(Graphics g, ref Rectangle boundingRect)
 {
     int num = 0;
     bool alignToRight = this.isRightToLeft();
     Rectangle rect = boundingRect;
     Rectangle empty = Rectangle.Empty;
     bool rowHeadersVisible = this.layout.RowHeadersVisible;
     Rectangle rectangle3 = Rectangle.Empty;
     int dataGridRowsLength = this.DataGridRowsLength;
     DataGridRow[] dataGridRows = this.DataGridRows;
     int numVisibleColumns = this.myGridTable.GridColumnStyles.Count - this.firstVisibleCol;
     for (int i = this.firstVisibleRow; i < dataGridRowsLength; i++)
     {
         if (num > boundingRect.Height)
         {
             break;
         }
         rect = boundingRect;
         rect.Height = dataGridRows[i].Height;
         rect.Y = boundingRect.Y + num;
         if (rowHeadersVisible)
         {
             rectangle3 = rect;
             rectangle3.Width = this.layout.RowHeaders.Width;
             if (alignToRight)
             {
                 rectangle3.X = rect.Right - rectangle3.Width;
             }
             if (g.IsVisible(rectangle3))
             {
                 dataGridRows[i].PaintHeader(g, rectangle3, alignToRight, this.gridState[0x8000]);
                 g.ExcludeClip(rectangle3);
             }
             if (!alignToRight)
             {
                 rect.X += rectangle3.Width;
             }
             rect.Width -= rectangle3.Width;
         }
         if (g.IsVisible(rect))
         {
             empty = rect;
             if (!alignToRight)
             {
                 empty.X -= this.negOffset;
             }
             empty.Width += this.negOffset;
             dataGridRows[i].Paint(g, empty, rect, this.firstVisibleCol, numVisibleColumns, alignToRight);
         }
         num += rect.Height;
     }
     boundingRect.Y += num;
     boundingRect.Height -= num;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:54,代码来源:DataGrid.cs


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