FillRectangle() public method

public FillRectangle ( GDIBrush aBrush, Rectangle aRect ) : void
aBrush GDIBrush
aRect System.Drawing.Rectangle
return void
Example #1
0
        public void RunOnce(GDIRenderer aPort)
        {
            int cxClient = fSize.Width;
            int cyClient = fSize.Height;

            aPort.SaveState();

            GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Black, Guid.NewGuid());
            GDISolidBrush rectBrush = new GDISolidBrush(RGBColor.White);

            // Do a rectangle
            Rectangle rect = Rectangle.FromLTRB(cxClient / 8, cyClient / 8,
                (7 * cxClient / 8), (7 * cyClient / 8));
            aPort.FillRectangle(rectBrush, rect.Left, rect.Top, rect.Width, rect.Height);
            aPort.DrawRectangle(rectPen, rect.Left, rect.Top, rect.Width, rect.Height);

            // Now do a couple of lines using a dash/dot/dot pen
            GDIPen aPen = new GDIPen(PenType.Cosmetic, PenStyle.DashDotDot, PenJoinStyle.Round, PenEndCap.Round, RGBColor.Black, 1, Guid.NewGuid());
            aPort.DrawLine(aPen, new Point(0, 0), new Point(cxClient, cyClient));
            aPort.DrawLine(aPen, new Point(0, cyClient), new Point(cxClient, 0));

            // Now an ellipse
            aPort.DrawEllipse(aPen, rect);

            // Last, a rounded rectangle
            Rectangle rRect = Rectangle.FromLTRB(cxClient / 4, cyClient / 4,
                3 * cxClient / 4, 3 * cyClient / 4);
            aPort.DrawRoundRect(aPen, rRect, cxClient / 4, cyClient / 4);

            aPort.ResetState();
  
        }
Example #2
0
        public void RunOnce(GDIRenderer aPort)
        {
            // Do some region stuff
            GDIRegion aRegion = GDIRegion.CreateFromRectangle(10, 10, 50, 250, Guid.NewGuid());
            GDIRegion bRegion = GDIRegion.CreateFromRectangle(10, 10, 50, 250, Guid.NewGuid());
            GDIRegion cRegion = GDIRegion.CreateFromRectangle(0, 0, 0, 0, Guid.NewGuid());
            GDIRegion dRegion = GDIRegion.CreateFromRectangle(30, 40, 200, 100, Guid.NewGuid());

            bool isEqual = aRegion.Equals(bRegion);

            Rectangle[] rects = aRegion.GetRectangles();

            aRegion.Add(dRegion);
            //aRegion.Subtract(dRegion);
            //aRegion.Intersect(dRegion);

            //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.OR);
            //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.XOR);
            //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.Diff);
            //RegionCombineType combType = cRegion.Combine(aRegion, dRegion, RegionCombineStyles.AND);
            //rects = aRegion.GetRectangles();


            Rectangle frame = aRegion.GetFrame();

            uint colorref = RGBColor.RGB(255, 127, 127);
            GDIBrush newBrush = new GDIBrush(BrushStyle.Solid, HatchStyle.DiagCross, colorref, Guid.NewGuid());
            aPort.SetBrush(newBrush);

            //aPort.FillRegion(aRegion, newBrush);
            //aPort.DrawRegion(aRegion);
            //aPort.FrameRegion(aRegion, newBrush, new Size(1, 1));

            //aPort.SetDefaultBrushColor(RGBColor.Yellow);
            //aPort.FillRegion(cRegion, GDISolidBrush.DeviceContextBrush);

            rects = aRegion.GetRectangles();
            //Random rnd = new Random();

            GDIPen regionPen = new CosmeticPen(PenStyle.Solid, RGBColor.Red, Guid.NewGuid());
            GDISolidBrush regionBrush = new GDISolidBrush(RGBColor.Red);

            // I GraphPort does not have FillRegion yet, so we fake it
            foreach (Rectangle r in rects)
            {
                // Create some random color
                //uint randomcolor = RGBColor.RGB((byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255));
                //aPort.DrawRectangle(regionPen, r.Left, r.Top, r.Width, r.Height);
                aPort.FillRectangle(regionBrush, r.Left, r.Top, r.Width, r.Height);
            }
        }
Example #3
0
        public void RunOnce(GDIRenderer aPort)
        {
            aPort.SaveState();

            GDIPen rectPen = new GDICosmeticPen(PenStyle.Solid, RGBColor.Red, Guid.NewGuid());
            GDIBrush rectBrush = new GDISolidBrush(RGBColor.Pink);

            for (int coord = 10; coord < fSize.Height; coord += 50)
            {
                aPort.FillRectangle(rectBrush, coord, coord, 200, 200);
                aPort.DrawRectangle(rectPen, coord, coord, 200, 200);
            }

            aPort.ResetState();
        }