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


C# Region.Intersect方法代码示例

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


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

示例1: CombineAreas

        public Region CombineAreas()
        {
            Region region = new Region();
            region.MakeEmpty();

            foreach (Area area in Areas)
            {
                region.Union(area.Region);
            }

            region.Intersect(new Region(Crop.Bounds));

            return region;
        }
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:14,代码来源:AreaManager.cs

示例2: TrespassArea

        // Returns a percentage of the ErrorArea circle trespassing on the zone.
        // If anyone knows calculus better than me I'd welcome you to clean up this function =)
        public float TrespassArea(Point3D pntLocation, float flErrorRadius) {

            float flReturnPercentage = 0.0F;
            float flErrorArea = (float)(flErrorRadius * flErrorRadius * Math.PI);

            GraphicsPath gpLocationError = new GraphicsPath();
            gpLocationError.AddEllipse(new RectangleF(pntLocation.X - flErrorRadius, pntLocation.Y - flErrorRadius, flErrorRadius * 2, flErrorRadius * 2));
            gpLocationError.CloseAllFigures();

            Region regZone = new Region(this.ZoneGraphicsPath);
            regZone.Intersect(gpLocationError);
            RectangleF[] a_recScans = regZone.GetRegionScans(new Matrix());
            Rectangle recIntersection = new Rectangle(int.MaxValue, int.MaxValue, 0, 0);

            int iPixelCount = 0;

            if (a_recScans.Length > 0) {

                for (int i = 0; i < a_recScans.Length; i++) {
                    recIntersection.X = a_recScans[i].X < recIntersection.X ? (int)a_recScans[i].X : recIntersection.X;
                    recIntersection.Y = a_recScans[i].Y < recIntersection.Y ? (int)a_recScans[i].Y : recIntersection.Y;

                    recIntersection.Width = a_recScans[i].Right > recIntersection.Right ? (int)a_recScans[i].Right - recIntersection.X : recIntersection.Width;
                    recIntersection.Height = a_recScans[i].Bottom > recIntersection.Bottom ? (int)a_recScans[i].Bottom - recIntersection.Y : recIntersection.Height;
                }

                //recIntersection = this.RecFtoRec(regZone.GetBounds(this.CreateGraphics()));
                Point pntVisible = new Point(recIntersection.X, recIntersection.Y);

                for (pntVisible.X = recIntersection.X; pntVisible.X <= recIntersection.Right; pntVisible.X++) {
                    for (pntVisible.Y = recIntersection.Y; pntVisible.Y <= recIntersection.Bottom; pntVisible.Y++) {
                        if (regZone.IsVisible(pntVisible) == true) {
                            iPixelCount++;
                        }
                    }
                }
            }

            flReturnPercentage = (float)iPixelCount / flErrorArea;

            // Accounts for low error when using this method. (98.4% should be 100%)
            // but using regZone.GetRegionScans is slightly lossy.
            if (flReturnPercentage > 0.0F) {
                flReturnPercentage = (float)Math.Min(1.0F, flReturnPercentage + 0.02);
            }

            return flReturnPercentage;
        }
开发者ID:ratdart,项目名称:Procon-1,代码行数:50,代码来源:MapZoneDrawing.cs

示例3: Clipping

        /// <summary>
        /// Initialize a new instance of the Clipping class.
        /// </summary>
        /// <param name="graphics">Graphics context.</param>
        /// <param name="path">Path to clip.</param>
        /// <param name="exclude">Exclude path from clipping.</param>
        public Clipping(Graphics graphics, GraphicsPath path, bool exclude)
        {
            // Cache graphics instance
            _graphics = graphics;

            // Save the existing clipping region
            _previousRegion = _graphics.Clip;

            // Add clipping of path to existing clipping region
            _newRegion = _previousRegion.Clone();

            if (exclude)
                _newRegion.Exclude(path);
            else
                _newRegion.Intersect(path);

            _graphics.Clip = _newRegion;
        }
开发者ID:ComponentFactory,项目名称:Krypton,代码行数:24,代码来源:Clipping.cs

示例4: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            Region regionRing = new Region(outCircle.Path);
            //形成圆环
            regionRing.Xor(innerCircle.Path);
            //截取部分圆环
            regionRing.Intersect(clipRectangle);
            e.Graphics.FillRegion(Brushes.Red, regionRing);
            //画处边框
            using (Pen p = new Pen(Brushes.Black))
            {
                e.Graphics.DrawPath(p, outCircle.Path);
                e.Graphics.DrawPath(p, innerCircle.Path);
            }
        }
开发者ID:qucc,项目名称:RingShapedProgressBar,代码行数:18,代码来源:RingProgressBar.cs

示例5: Form1_Paint

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.Clear(this.BackColor);
            // Создаем два прямоугольника
            Rectangle rect1 = new Rectangle(40, 40, 140, 140);
            Rectangle rect2 = new Rectangle(100, 100, 140, 140);
            // Создаем два региона
            Region rgn1 = new Region(rect1);
            Region rgn2 = new Region(rect2);
            g.DrawRectangle(Pens.Blue, rect1);
            g.DrawRectangle(Pens.Black, rect2);
            // определяем область пересеченияния
            rgn1.Intersect(rgn2);
            // заливаем ее красным цветом
            g.FillRegion(Brushes.Red, rgn1);
            g.Dispose();

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:19,代码来源:Form1.cs

示例6: DrawIcons

 public static Rectangle DrawIcons(Graphics gr, Rectangle aTextRect, CustomAppointment anAppointment, ImageList anAppIcons)
 {
     if ((anAppIcons != null) && (anAppointment.IconIndexes != null))
     {
         int length = anAppointment.IconIndexes.Length;
         int width = anAppIcons.ImageSize.Width;
         int num3 = aTextRect.Width / 3;
         if ((aTextRect.Width / 2) > width)
         {
             int x = (aTextRect.Right - 1) - width;
             int y = aTextRect.Y + 1;
             Region clip = gr.Clip;
             Region region2 = new Region(aTextRect);
             region2.Intersect(clip);
             gr.Clip = region2;
             for (int i = length - 1; i >= 0; i--)
             {
                 using (Image image = anAppIcons.Images[anAppointment.IconIndexes[i]])
                 {
                     Rectangle rect = new Rectangle(x, y, width, width);
                     DrawSingleIcon(gr, rect, image);
                 }
                 x -= width;
                 if (num3 >= (x - aTextRect.X))
                 {
                     aTextRect.Width -= width * (length - i);
                     return aTextRect;
                 }
             }
             gr.ResetClip();
             region2.Dispose();
             region2 = null;
             if (clip != null)
             {
                 gr.Clip = clip;
             }
             aTextRect.Width -= width * length;
         }
     }
     return aTextRect;
 }
开发者ID:north0808,项目名称:haina,代码行数:41,代码来源:Office11Renderer.cs

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

示例8: DrawRegionOperation

        void DrawRegionOperation()
        {
            g = this.CreateGraphics();
            Rectangle rect1 = new Rectangle(100, 100, 120, 120);
            Rectangle rect2 = new Rectangle(70, 70, 120, 120);

            Region rgn1 = new Region(rect1);
            Region rgn2 = new Region(rect2);

            g.DrawRectangle(Pens.Blue, rect1);
            g.DrawRectangle(Pens.Red, rect2);

            switch(rgnOperation)
            {
                case RegionOperation.Union:
                    rgn1.Union(rgn2);
                    break;
                case RegionOperation.Complement:
                    rgn1.Complement(rgn2);
                    break;
                case RegionOperation.Intersect:
                    rgn1.Intersect(rgn2);
                    break;
                case RegionOperation.Exclude:
                    rgn1.Exclude(rgn2);
                    break;
                case RegionOperation.Xor:
                    rgn1.Xor(rgn2);
                    break;
                default:
                    break;

            }

            g.FillRegion(Brushes.Tomato, rgn1);

            g.Dispose();
        }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:38,代码来源:Form1.cs

示例9: DrawRegionOperations

        private void DrawRegionOperations()
        {
            g = this.CreateGraphics();
            // Создаем два прямоугольника
            Rectangle rect1 = new Rectangle(100, 100, 120, 120);
            Rectangle rect2 = new Rectangle(70, 70, 120, 120);
            // Создаем два региона
            Region rgn1 = new Region(rect1);
            Region rgn2 = new Region(rect2);
            // рисуем прямоугольники
            g.DrawRectangle(Pens.Green, rect1);
            g.DrawRectangle(Pens.Black, rect2);

            // обработаем перечисление и вызовем соответствующий метод
            switch (rgnOperation)
            {
                case RegionOperations.Union:
                    rgn1.Union(rgn2);
                    break;
                case RegionOperations.Complement:
                    rgn1.Complement(rgn2);
                    break;
                case RegionOperations.Intersect:
                    rgn1.Intersect(rgn2);
                    break;
                case RegionOperations.Exclude:
                    rgn1.Exclude(rgn2);
                    break;
                case RegionOperations.Xor:
                    rgn1.Xor(rgn2);
                    break;
                default:
                    break;
            }
            // Рисуем регион
            g.FillRegion(Brushes.Blue, rgn1);
            g.Dispose();
        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:38,代码来源:Form1.cs

示例10: DrawImageBackground

        private void DrawImageBackground(PageImage pi, StyleInfo si, Graphics g, RectangleF r)
        {
            Stream strm = null;
            System.Drawing.Image im = null;
            try
            {
                strm = new MemoryStream(pi.ImageData);
                im = System.Drawing.Image.FromStream(strm);

                // http://www.fyireporting.com/forum/viewtopic.php?t=892
                //A.S.> convert pt to px if needed(when printing we need px, when draw preview - pt)

                RectangleF r2;
                if (g.PageUnit == GraphicsUnit.Pixel)
                {
                    r2 = new RectangleF(r.Left + (si.PaddingLeft * g.DpiX) / 72,
                    r.Top + (si.PaddingTop * g.DpiX) / 72,
                    r.Width - ((si.PaddingLeft + si.PaddingRight) * g.DpiX) / 72,
                    r.Height - ((si.PaddingTop + si.PaddingBottom) * g.DpiX) / 72);
                }
                else
                {
                    // adjust drawing rectangle based on padding
                    r2 = new RectangleF(r.Left + si.PaddingLeft,
                    r.Top + si.PaddingTop,
                    r.Width - si.PaddingLeft - si.PaddingRight,
                    r.Height - si.PaddingTop - si.PaddingBottom);
                }

                int repeatX = 0;
                int repeatY = 0;
                switch (pi.Repeat)
                {
                    case ImageRepeat.Repeat:
                        repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
                        repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
                        break;
                    case ImageRepeat.RepeatX:
                        repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
                        repeatY = 1;
                        break;
                    case ImageRepeat.RepeatY:
                        repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
                        repeatX = 1;
                        break;
                    case ImageRepeat.NoRepeat:
                    default:
                        repeatX = repeatY = 1;
                        break;
                }

                //make sure the image is drawn at least 1 times
                repeatX = Math.Max(repeatX, 1);
                repeatY = Math.Max(repeatY, 1);

                float startX = r2.Left;
                float startY = r2.Top;

                Region saveRegion = g.Clip;
                Region clipRegion = new Region(g.Clip.GetRegionData());
                clipRegion.Intersect(r2);
                g.Clip = clipRegion;

                for (int i = 0; i < repeatX; i++)
                {
                    for (int j = 0; j < repeatY; j++)
                    {
                        float currX = startX + i * pi.SamplesW;
                        float currY = startY + j * pi.SamplesH;
                        g.DrawImage(im, new RectangleF(currX, currY, pi.SamplesW, pi.SamplesH));
                    }
                }
                g.Clip = saveRegion;
            }
            finally
            {
                if (strm != null)
                    strm.Close();
                if (im != null)
                    im.Dispose();
            }
        }
开发者ID:huasonli,项目名称:My-FyiReporting,代码行数:82,代码来源:PageDrawing.cs

示例11: SnippingTool_Paint

        private void SnippingTool_Paint(object sender, PaintEventArgs e)
        {
            using (Brush b = new SolidBrush(Color.FromArgb(120, Color.White)))
            using (Pen pen = new Pen(Color.Red, 1))
            using (Region region = new Region(new Rectangle(0, 0, Width, Height)))
            {
                // Create a region
                // Negate it from the current sleection
                region.Exclude(rcSelect);
                region.Intersect(e.ClipRectangle);

                // Draw overlay of non-selected portions
                e.Graphics.FillRegion(b, region);

                // Draw selection
                e.Graphics.DrawRectangle(pen, rcSelect.X, rcSelect.Y, rcSelect.Width - 1, rcSelect.Height - 1);
            }
        }
开发者ID:prashker,项目名称:ClickGrabRepeat,代码行数:18,代码来源:Form2.cs

示例12: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            Region clippingRegion = e.Graphics.Clip;

            TimeSpan time = TimeSpan.FromHours(EpgControl.EpgHoursOffset);
            int left = 0;
            const int step = 15;
            for (int count = 0; count < (24 * 60) / step; count++)
            {
                TimeSpan nextTime = time.Add(TimeSpan.FromMinutes(step));
                int nextLeft = EpgTimeControl.GetTimeCursorPosition(nextTime, 0);
                Rectangle visibleRectangle = new Rectangle(left - 1, 0, nextLeft - left + 1, this.Height);
                visibleRectangle.Intersect(e.ClipRectangle);

                Region cellRegion = new Region(visibleRectangle);
                cellRegion.Intersect(clippingRegion);
                if (!cellRegion.IsEmpty(e.Graphics))
                {
                    int lineLeft = Math.Max(0, left - 1);
                    e.Graphics.DrawLine(_epgBorderPen, lineLeft, 0, lineLeft, this.Height - 1);
                    string timeText = EpgTimeControl.GetTimeString(time);
                    e.Graphics.DrawString(timeText, _timeFont, _timeBrush, lineLeft + 1, 2);
                }

                left = nextLeft;
                time = nextTime;
            }

            if (this.CursorAtTime.HasValue)
            {
                int position = EpgTimeControl.GetTimeCursorPosition(_cursorAtTime.Value, -1);
                e.Graphics.DrawLine(_cursorPen, position, 0, position, this.Height - 1);
                e.Graphics.DrawLine(_cursorShadowPen, position + 1, 0, position + 1, this.Height - 1);

                string timeText = EpgTimeControl.GetTimeString(this.CursorAtTime.Value);
                SizeF size = e.Graphics.MeasureString(timeText, _cursorFont);

                e.Graphics.FillRectangle(_cursorBgBrush, position + 2, 1, size.Width, size.Height);
                e.Graphics.DrawString(timeText, _cursorFont, _cursorBrush, position + 2, 0);
            }

            base.OnPaint(e);
        }
开发者ID:dot-i,项目名称:ARGUS-TV-Clients,代码行数:43,代码来源:EpgTimeGridControl.cs

示例13: DrawItem

        // end DrawGraph
        private bool DrawItem(Graphics wa, Graph.LaneRow row)
        {
            if (row == null || row.NodeLane == -1)
            {
                return false;
            }

            // Clip to the area we're drawing in, but draw 1 pixel past so
            // that the top/bottom of the line segment's anti-aliasing isn't
            // visible in the final rendering.
            int top = wa.RenderingOrigin.Y + _rowHeight / 2;
            var laneRect = new Rectangle(0, top, Width, _rowHeight);
            Region oldClip = wa.Clip;
            var newClip = new Region(laneRect);
            newClip.Intersect(oldClip);
            wa.Clip = newClip;
            wa.Clear(Color.Transparent);

            for (int r = 0; r < 2; r++)
                for (int lane = 0; lane < row.Count; lane++)
                {
                    int mid = wa.RenderingOrigin.X + (int)((lane + 0.5) * LaneWidth);

                    for (int item = 0; item < row.LaneInfoCount(lane); item++)
                    {
                        Graph.LaneInfo laneInfo = row[lane, item];

                        //Draw all non-relative items first, them draw
                        //all relative items on top
                        if (laneInfo.Junctions.FirstOrDefault() != null)
                            if (laneInfo.Junctions.First().IsRelative == (r == 0))
                                continue;

                        List<Color> curColors = GetJunctionColors(laneInfo.Junctions);

                        // Create the brush for drawing the line
                        Brush brushLineColor;
                        bool drawBorder = BranchBorders; //hide border for "non-relatives"
                        if (curColors.Count == 1 || !StripedBranchChange)
                        {
                            if (curColors[0] != _nonRelativeColor)
                            {
                                brushLineColor = new SolidBrush(curColors[0]);
                            }
                            else if (curColors.Count > 1 && curColors[1] != _nonRelativeColor)
                            {
                                brushLineColor = new SolidBrush(curColors[1]);
                            }
                            else
                            {
                                drawBorder = false;
                                brushLineColor = new SolidBrush(_nonRelativeColor);
                            }
                        }
                        else
                        {
                            brushLineColor = new HatchBrush(HatchStyle.DarkDownwardDiagonal, curColors[0], curColors[1]);
                            if (curColors[0] == _nonRelativeColor && curColors[1] == _nonRelativeColor) drawBorder = false;
                        }

                        for (int i = drawBorder ? 0 : 2; i < 3; i++)
                        {
                            Pen penLine;
                            if (i == 0)
                            {
                                penLine = new Pen(new SolidBrush(Color.White), LaneLineWidth + 2);
                            }
                            else if (i == 1)
                            {
                                penLine = new Pen(new SolidBrush(Color.Black), LaneLineWidth + 1);
                            }
                            else
                            {
                                penLine = new Pen(brushLineColor, LaneLineWidth);
                            }

                            if (laneInfo.ConnectLane == lane)
                            {
                                wa.DrawLine
                                    (
                                        penLine,
                                        new Point(mid, top - 1),
                                        new Point(mid, top + _rowHeight + 2)
                                    );
                            }
                            else
                            {
                                wa.DrawBezier
                                    (
                                        penLine,
                                        new Point(mid, top - 1),
                                        new Point(mid, top + _rowHeight + 2),
                                        new Point(mid + (laneInfo.ConnectLane - lane) * LaneWidth, top - 1),
                                        new Point(mid + (laneInfo.ConnectLane - lane) * LaneWidth, top + _rowHeight + 2)
                                    );
                            }
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:pvginkel,项目名称:VisualGit,代码行数:101,代码来源:DvcsGraph.cs

示例14: drawCells

		private void drawCells(Graphics g, System.Drawing.Pen pen,
			System.Drawing.Brush brText, RectangleF rc)
		{
			// DrawBorder3D does not honor clipping, so...
			CellFrameStyle cb = cellBorders;
			if (flowChart.NowPrinting && cb == CellFrameStyle.System3D)
				cb = CellFrameStyle.Simple;

			// draw the cells
			if (cells != null)
			{
				bool[,] coveredCells =
					hasSpanningCells ? getCoveredCells() : null;
				RectangleF cellsRect = RectangleF.FromLTRB(rc.Left,
					rc.Top + captionHeight, rc.Right, rc.Bottom);

				int rowFrom = CurrentRow - maxRowSpan + 1;
				if (rowFrom < 0)
					rowFrom = 0;

				float h = rc.Top + captionHeight;
				for (int r = rowFrom; r < rowsCount; r++)
				{
					RectangleF cellRect = rc;
					cellRect.Y = h;
					if (cellRect.Top >= rc.Bottom) break;

					cellRect.Height = ((Row)rowsList[r]).Height;

					if (cellRect.Bottom >= rc.Bottom) break;

					// If it is a hidden row below a collapsed header row, skip it
					if (isRowCollapsed(r))
						continue;

					if (rowFrom >= currScrollRow)
						h += ((Row)rowsList[r]).Height;

					for (int c = 0; c < columnsCount; ++c)
					{
						RectangleF imgRect = RectangleF.Empty;
						cellRect = getSpannedCellRect(r, c, true, ref imgRect);

						if (cellRect.Height == 0 ||
							cellRect.Width == 0 ||
							cellRect.Bottom <= cellsRect.Top)
							continue;

						Cell cell = (Cell)cells[r * columnsCount + c];

						if (!hasSpanningCells)
						{
							cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);
						}
						else
						{
							// If the cell is covered by a spanned cell
							// and is not a span cell itself, do not draw it
							if (!coveredCells[c,r] ||
								(cell.RowSpan != 1 || cell.ColumnSpan != 1))
							{
								if (cell.RowSpan != 1 || cell.ColumnSpan != 1)
								{
									RectangleF cellVisibleRect =
										RectangleF.Intersect(cellRect, cellsRect);

									// Clip with the visible rect, and draw in the
									// absolute rect
									Region oldClip = g.Clip;
									Region newClip = new Region(cellVisibleRect);
									newClip.Intersect(oldClip);
									g.Clip = newClip;

									cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);

									g.Clip = oldClip;
									newClip.Dispose();
								}
								else
								{
									cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);
								}
							}
						}

						cellRect.X = cellRect.Right;
						if (cellRect.Left >= rc.Right) break;
					}
				}
			}
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:91,代码来源:Table.cs

示例15: DataGridPaintRowContents

		public override void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow,
							       Rectangle clip, DataGrid grid)
		{
			Rectangle rect_cell = new Rectangle ();
			int col_pixel;
			Color backcolor, forecolor;
			Brush backBrush, foreBrush;
			Rectangle not_usedarea = Rectangle.Empty;

			rect_cell.Y = row_rect.Y;
			rect_cell.Height = row_rect.Height;

			if (grid.IsSelected (row)) {
				backcolor =  grid.SelectionBackColor;
				forecolor =  grid.SelectionForeColor;
			} else {
				if (row % 2 == 0) {
					backcolor =  grid.BackColor;
				} else {
					backcolor =  grid.AlternatingBackColor;
				}

				forecolor =  grid.ForeColor;
			}			


			backBrush = ResPool.GetSolidBrush (backcolor);
			foreBrush = ResPool.GetSolidBrush (forecolor);

			// PaintCells at row, column
			int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
			DataGridCell current_cell = grid.CurrentCell;

			if (column_cnt > 0) {
				Region prev_clip = g.Clip;
				Region current_clip;

				for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
					if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
						continue;

					col_pixel = grid.GetColumnStartingPixel (column);

					rect_cell.X = row_rect.X + col_pixel - grid.HorizPixelOffset;
					rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;

					if (clip.IntersectsWith (rect_cell)) {
						current_clip = new Region (rect_cell);
						current_clip.Intersect (row_rect);
						current_clip.Intersect (prev_clip);
						g.Clip = current_clip;

						Brush colBackBrush = backBrush;
						Brush colForeBrush = foreBrush;

						// If we are in the precise cell we are editing, then use the normal colors
						// even if we are selected.
						if (grid.is_editing && column == current_cell.ColumnNumber && row == current_cell.RowNumber) {
							colBackBrush = ResPool.GetSolidBrush (grid.BackColor);
							colForeBrush = ResPool.GetSolidBrush (grid.ForeColor);
						}

						if (is_newrow) {
							grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell, 
														     colBackBrush,
														     colForeBrush);
						} else {
							grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
													       colBackBrush,
													       colForeBrush,
													       grid.RightToLeft == RightToLeft.Yes);
						}

						current_clip.Dispose ();
					}
				}

				g.Clip = prev_clip;
			
				if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
					not_usedarea.X = rect_cell.X + rect_cell.Width;
					not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
					not_usedarea.Y = row_rect.Y;
					not_usedarea.Height = row_rect.Height;
				}
			}
			else {
				not_usedarea = row_rect;
			}

			if (!not_usedarea.IsEmpty && clip.IntersectsWith (not_usedarea))
				g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
						 not_usedarea);
		}
开发者ID:hindlemail,项目名称:mono,代码行数:94,代码来源:ThemeWin32Classic.cs


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