FillRectangle() public method

public FillRectangle ( Brush brush, Rectangle rect ) : void
brush Brush
rect Rectangle
return void
Ejemplo n.º 1
1
        public override void Draw(Graphics g, Pen p)
        {
            base.Draw(g, p);

            var r = this.RectangleF;

            var sText = g.MeasureString(this.ColouredPlace.ColorSetName, new Font("Arial", 8));
            g.FillRectangle(Brushes.Gray, r.Right, r.Top - sText.Height, sText.Width, sText.Height);

            g.DrawString(
                this.ColouredPlace.ColorSetName,
                new Font("Arial", 8),
                Brushes.Blue,
                r.Right,
                r.Top - sText.Height
            );

            var tokensString = this.ColouredPlace.Tokens.ToString();
            var f = new Font("", 7);
            sText = g.MeasureString(tokensString, f);

            g.FillRectangle(Brushes.Green, r.Right, r.Bottom, sText.Width, sText.Height);
            g.DrawString(
                tokensString,
                new Font("", 7),
                Brushes.Black,
                r.Right,
                r.Bottom
            );
        }
Ejemplo n.º 2
1
                 protected internal override void Paint(Graphics gr)
                 {           
                   var hf = CandleView.BAR_WIDTH / 2;

                   if (m_View.Kind== ViewKind.SideBySide)
                   {
                       var hh = Host.Height / Host.Zoom;

                       gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, hf, m_Lay_BuyHeight);
                       gr.FillRectangle(Brushes.Red, this.Left+hf, hh - m_Lay_SellHeight, hf, m_Lay_SellHeight);
                   }
                   else if (m_View.Kind== ViewKind.Stacked)
                   {
                      var hh = Host.Height / Host.Zoom;

                      gr.FillRectangle(Brushes.Green, this.Left, hh - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
                      gr.FillRectangle(Brushes.Red, this.Left, hh - m_Lay_BuyHeight-m_Lay_SellHeight, CandleView.BAR_WIDTH, m_Lay_SellHeight);
                   }
                   else//centered
                   {
                      var mid = (Host.Height / 2) / Host.Zoom;

                      gr.FillRectangle(Brushes.Green, this.Left, mid - m_Lay_BuyHeight, CandleView.BAR_WIDTH, m_Lay_BuyHeight);
                      gr.FillRectangle(Brushes.Red, this.Left, mid, CandleView.BAR_WIDTH, m_Lay_SellHeight);
                   }
                 }
Ejemplo n.º 3
1
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
        public static void FillPill(Brush b, RectangleF rect, Graphics g)
        {
            if (rect.Width > rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Height, rect.Height));
                g.FillEllipse(b, new RectangleF(rect.Left + rect.Width - rect.Height, rect.Top, rect.Height, rect.Height));

                var w = rect.Width - rect.Height;
                var l = rect.Left + ((rect.Height) / 2);
                g.FillRectangle(b, new RectangleF(l, rect.Top, w, rect.Height));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width < rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Width));
                g.FillEllipse(b, new RectangleF(rect.Left, rect.Top + rect.Height - rect.Width, rect.Width, rect.Width));

                var t = rect.Top + (rect.Width / 2);
                var h = rect.Height - rect.Width;
                g.FillRectangle(b, new RectangleF(rect.Left, t, rect.Width, h));
                g.SmoothingMode = SmoothingMode.Default;
            }
            else if (rect.Width == rect.Height)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.FillEllipse(b, rect);
                g.SmoothingMode = SmoothingMode.Default;
            }
        }
Ejemplo n.º 5
0
 private void T_Tick(object sender, EventArgs e)
 {
     this.SuspendLayout();
     state = obj.GetState;
     int istate = 1;
     try {  istate = Convert.ToInt32(state);
         state += "%";
     }
     catch (Exception ex) {}
     rect.Size = new Size(this.Width - 1, this.Height - 1);
     bmp = new Bitmap(this.Width, this.Height);
     g = Graphics.FromImage(bmp);
     g.DrawRectangle(new Pen(Color.Black), rect);
     g.FillRectangle(Brushes.Blue, new Rectangle(1, 1, rect.Width - 1, rect.Height - 1));
     g.FillRectangle(Brushes.White, new Rectangle(1, 1, rect.Width - 1, (int)(rect.Height-rect.Height*0.01* istate)));
     using (Font _normalFont = new Font("Century Gothic", 48, FontStyle.Regular, GraphicsUnit.Point))
     {
         StringFormat stringFormat = new StringFormat();
         stringFormat.Alignment = StringAlignment.Center;
         stringFormat.LineAlignment = StringAlignment.Center;
         g.DrawString(state, _normalFont, Brushes.Black,rect,stringFormat);
     }
     g.Dispose();
     this.BackgroundImage = bmp;
     this.ResumeLayout();
 }
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (Image != null)
            {
                base.Paint(graphics, clipBounds,
                           new Rectangle(cellBounds.X + Image.Width, cellBounds.Y, cellBounds.Width - Image.Height,cellBounds.Height),
                           rowIndex, cellState, value, formattedValue,errorText, cellStyle, advancedBorderStyle, paintParts);

                if ((cellState & DataGridViewElementStates.Selected) != 0)
                {
                    graphics.FillRectangle(
                        new SolidBrush(this.DataGridView.DefaultCellStyle.SelectionBackColor)
                        , cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                else
                {
                    graphics.FillRectangle(new SolidBrush(this.DataGridView.DefaultCellStyle.BackColor),
                                           cellBounds.X, cellBounds.Y, Image.Width, cellBounds.Height);
                }
                graphics.DrawImage(Image, cellBounds.X, cellBounds.Y+2, Image.Width,
                                         Math.Min(Image.Height,cellBounds.Height));

            }
            else
            {
                base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            }
        }
Ejemplo n.º 7
0
 protected void DrawBackground(Graphics g, DrawState state)
 {
     Rectangle rc = ClientRectangle;
     // Draw background
     if (state == DrawState.Normal || state == DrawState.Disable)
     {
         g.FillRectangle(new SolidBrush(SystemColors.Control), rc);
         using (SolidBrush rcBrush = state == DrawState.Disable ?
             new SolidBrush(SystemColors.ControlDark) :
             new SolidBrush(SystemColors.ControlDarkDark))
         {
             // Draw border rectangle
             g.DrawRectangle(new Pen(rcBrush), rc.Left, rc.Top, rc.Width - 1, rc.Height - 1);
         }
     }
     else if ( state == DrawState.Hot || state == DrawState.Pressed  )
     {
         // Erase whaterver that was there before
         if ( state == DrawState.Hot )
             g.FillRectangle(new SolidBrush(ColorUtil.VSNetSelectionColor), rc);
         else
             g.FillRectangle(new SolidBrush(ColorUtil.VSNetPressedColor), rc);
         // Draw border rectangle
         g.DrawRectangle(SystemPens.Highlight, rc.Left, rc.Top, rc.Width-1, rc.Height-1);
     }
 }
Ejemplo n.º 8
0
        protected override void PaintSquare(Graphics graphics, Rectangle clipRectangle, int pipeWidth, bool isHighlighted, bool isFrozen, bool isFlooded)
        {
            /* pipe brush - if flooded, it's red, otherwise silver */
            Brush pipeBrush = isFlooded ? Brushes.Red : Brushes.Silver;

            int x = (clipRectangle.Width - pipeWidth) / 2;
            int y = clipRectangle.Y;
            int w = pipeWidth;
            int h = clipRectangle.Height - x;

            /* pipe rectangle, first upside */
            Rectangle pipeRectangle = new Rectangle(x, y, w, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x, y + h - pipeWidth));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x + w, y), new Point(x + w, y + h));

            x = clipRectangle.X;
            y = (clipRectangle.Height - pipeWidth) / 2;
            w = clipRectangle.Width - y;
            h = pipeWidth;

            /* pipe rectangle, second leftside */
            pipeRectangle = new Rectangle(x, y, w - BORDER_WIDTH, h);
            graphics.FillRectangle(pipeBrush, pipeRectangle);

            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y), new Point(x + w - pipeWidth, y));
            graphics.DrawLine(new Pen(Color.Gray, BORDER_WIDTH), new Point(x, y + h), new Point(x + w, y + h));
        }
Ejemplo n.º 9
0
        public void DrawFormBackgroud(Graphics g, Rectangle r)
        {
            drawing = new Bitmap(this.Width, this.Height, g);
            gg = Graphics.FromImage(drawing);

            Rectangle shadowRect = new Rectangle(r.X, r.Y, r.Width, 10);
            Rectangle gradRect = new Rectangle(r.X, r.Y + 9, r.Width, 42);
            //LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 41, 61), Color.FromArgb(47, 64, 94), LinearGradientMode.Vertical);
            LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 41), Color.FromArgb(47, colorR, 64), LinearGradientMode.Vertical);
            //LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.FromArgb(47, 64, 94), Color.FromArgb(49, 66, 95), LinearGradientMode.Vertical);
            LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.Green, Color.DarkGreen, LinearGradientMode.Vertical);
            ColorBlend blend = new ColorBlend();

            // Set multi-color gradient
            blend.Positions = new[] { 0.0f, 0.35f, 0.5f, 0.65f, 1.0f };
            //blend.Colors = new[] { Color.FromArgb(47, 64, 94), Color.FromArgb(64, 88, 126), Color.FromArgb(66, 90, 129), Color.FromArgb(64, 88, 126), Color.FromArgb(49, 66, 95) };
            blend.Colors = new[] { Color.FromArgb(47,colorR, 64), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(66, colorR+35, 90), Color.FromArgb(64, colorR+32, 88), Color.FromArgb(49, colorR+1, 66) };
            grad.InterpolationColors = blend;
            Font myf=new System.Drawing.Font(this.Font.FontFamily,16);
            // Draw basic gradient and shadow
            //gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            gg.FillRectangle(grad, gradRect);
            gg.FillRectangle(shadow, shadowRect);
            gg.DrawString("Добавить один ПК", myf, Brushes.GhostWhite, new PointF(55, 15));
            gg.DrawImage(Properties.Resources.singleAdd1.ToBitmap(), 10, 10,32,32);

            g.DrawImageUnscaled(drawing, 0, 0);
            gg.Dispose();

            // Draw checkers
            //g.FillRectangle(checkers, r);
        }
        protected override void PaintSquare(Graphics graphics, Rectangle clipRectangle, int pipeWidth, bool isHighlighted, bool isFrozen, bool isFlooded, FloodProgress floodProgress)
        {
            /* paint square as usual */
            this.PaintSquare(graphics, clipRectangle, pipeWidth, isHighlighted, isFrozen, isFlooded);

            int x = (clipRectangle.Width - pipeWidth) / 2;
            int y = clipRectangle.Y;
            int w = pipeWidth;
            int h = clipRectangle.Height;

            /* flooding ? */
            if (!isFlooded)
            {
                /* calculate height to fill */
                int fill = floodProgress.GetRatio(clipRectangle.Height);

                /* check direction */
                if (floodProgress.Direction == Direction.Down)
                {
                    /* flood rectangle */
                    Rectangle floodRectangle = new Rectangle(x, y, w, fill);

                    /* fill rectangle */
                    graphics.FillRectangle(Brushes.Red, floodRectangle);
                }
                else if (floodProgress.Direction == Direction.Up)
                {
                    /* flood rectangle */
                    Rectangle floodRectangle = new Rectangle(x, h - fill, w, fill);

                    /* fill rectangle */
                    graphics.FillRectangle(Brushes.Red, floodRectangle);
                }
            }
        }
Ejemplo n.º 11
0
 public static void drawUnit(Graphics g, int gridWidth, int gridHeight, Unit unit, Brush color)
 {
     int unitX = 5 + (unit.x * gridWidth) + (int)(gridWidth * 0.5);
     int unitY = 5 + (unit.y * gridHeight) + (int)(gridHeight * 0.5);
     Rectangle unitBaseRect = new Rectangle(unitX - (int)(gridWidth * 2.4), unitY - (int)(gridHeight * 2.4), (int)(gridWidth * 4.8), (int)(gridHeight * 4.8));
     Rectangle unitGunRect = new Rectangle(unitX - (int)(gridWidth * 0.2), unitY - (int)(gridHeight * 0.2), (int)(gridWidth * 0.4), (int)(gridHeight * 0.4));
     Rectangle unitHatchRect = new Rectangle(unitX - (int)(gridWidth * 0.4), unitY - (int)(gridHeight * 0.4), (int)(gridWidth * 0.8), (int)(gridHeight * 0.8));
     switch (unit.direction)
     {
         case Direction.UP:
             unitGunRect.Y -= (int)(gridHeight * 1.8);
             unitGunRect.Height = (int)(gridHeight * 2);
             break;
         case Direction.DOWN:
             unitGunRect.Height = (int)(gridHeight * 2);
             break;
         case Direction.LEFT:
             unitGunRect.X -= (int)(gridWidth * 1.8);
             unitGunRect.Width = (int)(gridWidth * 2);
             break;
         case Direction.RIGHT:
             unitGunRect.Width = (int)(gridWidth * 2);
             break;
     }
     g.FillRectangle(color, unitBaseRect);
     g.FillRectangle(Brushes.Black, unitGunRect);
     g.FillEllipse(color, unitHatchRect);
     g.DrawEllipse(Pens.Black, unitHatchRect);
 }
        protected override void Draw(Graphics g)
        {
            regionFillPath = new GraphicsPath();

            for (int i = 0; i < nodes.Count - 1; i++)
            {
                regionFillPath.AddLine(nodes[i].Position, nodes[i + 1].Position);
            }

            if (nodes.Count > 2)
            {
                regionFillPath.CloseFigure();

                using (Region region = new Region(regionFillPath))
                {
                    g.ExcludeClip(region);
                    g.FillRectangle(shadowBrush, 0, 0, Width, Height);
                    g.ResetClip();
                }

                g.DrawRectangleProper(borderPen, currentArea);
            }
            else
            {
                g.FillRectangle(shadowBrush, 0, 0, Width, Height);
            }

            if (nodes.Count > 1)
            {
                g.DrawPath(borderPen, regionFillPath);
            }

            base.Draw(g);
        }
Ejemplo n.º 13
0
 public static void DrawValueLine(Graphics g, int value, int x, int y, int width, int height)
 {
     Color colorStart;
     Color colorEnd;
     int value100 = value/100;
     int value1 = value%100;
     if (value100 >= 1)
     {
         colorStart = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1-0.1, 0.4, 0.5);
         colorEnd = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1-0.1, 1, 0.5);
         using (Brush b1 = new LinearGradientBrush(new Rectangle(x, y, width, 10), colorStart, colorEnd, LinearGradientMode.Horizontal))
         {
             g.FillRectangle(b1, x, y, width, 10);
         }
     }
     if (value1 >= 1)
     {
         colorStart = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1, 0.4, 0.5);
         colorEnd = NarlonLib.Drawing.DrawTool.HSL2RGB(value100 * 0.1, 1, 0.5);
         using (Brush b1 = new LinearGradientBrush(new Rectangle(x, y, value1 *width/100, 10), colorStart, colorEnd, LinearGradientMode.Horizontal))
         {
             g.FillRectangle(b1, x, y, value1 * width/ 100, 10);
         }
     }
 }
Ejemplo n.º 14
0
        private static void RaisedInnerBorder(Graphics g, Brush dark, Rectangle r, Brush light) {
            g.FillRectangle(light, r.Left, r.Top, r.Width - 1, 1);
            g.FillRectangle(light, r.Left, r.Top, 1, r.Height - 1);

            g.FillRectangle(dark, r.Right - 1, r.Top, 1, r.Height);
            g.FillRectangle(dark, r.Left, r.Bottom - 1, r.Width, 1);
        }
Ejemplo n.º 15
0
        private void DrawSpectrum(Graphics g)
        {
            const int offset = 20;

            _data.SpectrumData = _data.SpectrumData
                .Select(f => 1 - Math.Pow(1 - f, 3))
                .Select(f => (float)f)
                //.Where(f=>f > 0.1)
                .ToList();

            if (!_data.SpectrumData.Any())
                return;

            float barWidth = Math.Max((Width / _data.SpectrumData.Count), 2);
            for (int i = 0; i < _data.SpectrumData.Count; i++) {
                var value = Math.Abs(_data.SpectrumData[i]); // value should always be between 0 : 1.0

                float x = i * barWidth;
                float y = (value * Height * 0.5f);
                float G = (127 + (value * 128));
                float B = (int)(255 / Width * x);
                float R = (int)(DateTime.Now.Millisecond * 0.15);

                var brush = new SolidBrush(Color.FromArgb((int)R, (int)G, (int)B));
                g.FillRectangle(brush, x, Height / 2 + offset, barWidth, y);
                g.FillRectangle(brush, x, Height / 2 - offset - y, barWidth, y);
            }
        }
Ejemplo n.º 16
0
        protected void DrawListBoxItem(Graphics g, Rectangle bounds, int Index, bool selected, bool editSel)
        {
            // Draw List box item
              if ( Index != -1)
              {
            if ( selected )
            {
              // Draw highlight rectangle
              Brush b = ColorUtil.VSNetSelectionBrush;
              g.FillRectangle(b, bounds.Left, bounds.Top, bounds.Width, bounds.Height);

              Pen p = ColorUtil.VSNetBorderPen;
              g.DrawRectangle(p, bounds.Left, bounds.Top, bounds.Width-1, bounds.Height-1);
            }
            else
            {
              // Erase highlight rectangle
              g.FillRectangle(SystemBrushes.Window, bounds.Left, bounds.Top, bounds.Width, bounds.Height);
            }

            string item = (string)Items[Index];
            Color currentColor = Color.FromName(item);

            using ( Brush b = new SolidBrush(currentColor) )
            {
              g.FillRectangle(new SolidBrush(currentColor), bounds.Left+2, bounds.Top+2, 20, bounds.Height-4);
            }
            g.DrawRectangle(Pens.Black, new Rectangle(bounds.Left+1, bounds.Top+1, 21, bounds.Height-3));
            g.DrawString(item, SystemInformation.MenuFont, SystemBrushes.ControlText, new Point(bounds.Left + 28, bounds.Top));

              }
        }
Ejemplo n.º 17
0
 public override void DrawBackground(Graphics graphics, Rectangle bounds)
 {
     var rect = Rectangle.Inflate(bounds, 0, 0);
     switch (_state)
     {
         //case 2: //hot
         //    //TODO
         //    break;
         case 3: //pressed
             rect.Inflate(-2, -2);
             graphics.FillRectangle(SystemBrushes.ControlLight, rect);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.SunkenOuter, Border3DSide.Bottom | Border3DSide.Right);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.Sunken, Border3DSide.Top | Border3DSide.Left);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.SunkenInner, Border3DSide.Top | Border3DSide.Left);
             break;
         //case 6: //hot+pressed
         //    //TODO
         //    break;
         default: //normal, also fallback
             rect.Inflate(-2, -2);
             graphics.FillRectangle(SystemBrushes.ControlLight, rect);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.Raised, Border3DSide.Bottom | Border3DSide.Right);
             rect.Inflate(-1, -1);
             ControlPaint.DrawBorder3D(graphics, rect, Border3DStyle.RaisedInner, Border3DSide.Top | Border3DSide.Left);
             break;
     }
 }
Ejemplo n.º 18
0
        protected void DrawListBoxItem(Graphics g, Rectangle bounds, int index, bool selected, bool editSel)
        {
            // Draw List box item
            if ( index != -1)
            {
                if ( selected && !editSel)
                    // Draw highlight rectangle
                    g.FillRectangle(new SolidBrush(SystemColors.Highlight), bounds.Left, bounds.Top, bounds.Width, bounds.Height);
                else
                    // Erase highlight rectangle
                    g.FillRectangle(new SolidBrush(SystemColors.Window), bounds.Left, bounds.Top, bounds.Width, bounds.Height);

                string colorName = (string)this.Items[index];
                Color currentColor = Color.FromName(colorName);

                Brush brush;
                if ( selected )
                    brush =  new SolidBrush(SystemColors.HighlightText);
                else
                    brush = new SolidBrush(SystemColors.MenuText);

                g.FillRectangle(new SolidBrush(currentColor), bounds.Left+2, bounds.Top+2, 20, bounds.Height-4);
                Pen blackPen = new Pen(new SolidBrush(Color.Black), 1);
                g.DrawRectangle(blackPen, new Rectangle(bounds.Left+1, bounds.Top+1, 21, bounds.Height-3));
                g.DrawString(colorName, SystemInformation.MenuFont, brush, new Point(bounds.Left + 28, bounds.Top));
            }
        }
Ejemplo n.º 19
0
 private void DrawHouse(Graphics g, int mouseX, int mouseY)
 {
     Point topLeft = new Point(mouseX, mouseY);
     Point topRight = new Point(mouseX + size, mouseY);
     Point bottomLeft = new Point(mouseX, mouseY + size);
     Point bottomRight = new Point(mouseX + size, mouseY + size);
     Point top = new Point(mouseX + (size / 2), mouseY - (int)(size * 0.5));
     Point doorBottomLeft = new Point(bottomLeft.X + (int)(size * 0.2), bottomLeft.Y);
     Point doorBottomRight = new Point(bottomLeft.X + (int)(size * 0.5), bottomLeft.Y);
     Point doorTopLeft = new Point(doorBottomLeft.X, doorBottomLeft.Y - (int)(size * 0.6));
     Point doorTopRight = new Point(doorBottomRight.X, doorBottomRight.Y - (int)(size * 0.6));
     Point window1TopLeft = new Point(doorTopLeft.X, bottomLeft.Y - (int)(size * 0.9));
     Point window2TopLeft = new Point(bottomLeft.X + (int)(size * 0.6), window1TopLeft.Y);
     Point sunOrigin = new Point(topRight.X + (int)(size * 0.3), topRight.Y - (int)(size * 0.5));
     Size windowSize = new Size((int)(size * 0.3), (int)(size * 0.2));
     Size sunSize = new Size((int)(size * 0.4), (int)(size * 0.4));
     Rectangle window1 = new Rectangle(window1TopLeft, windowSize);
     Rectangle window2 = new Rectangle(window2TopLeft, windowSize);
     Rectangle sun = new Rectangle(sunOrigin, sunSize);
     Point[] square = new Point[] { topLeft, topRight, bottomRight, bottomLeft, topLeft, top, topRight };
     Point[] door = new Point[] { doorBottomLeft, doorTopLeft, doorTopRight, doorBottomRight };
     g.DrawLines(myPen, square);
     g.DrawLines(myPen, door);
     g.DrawRectangle(myPen, window1);
     g.DrawRectangle(myPen, window2);
     g.FillRectangle(myBrush, window1);
     g.FillRectangle(myBrush, window2);
     g.DrawEllipse(myPen, sun);
     g.FillEllipse(yellow, sun);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="graphics">Graphics reference</param>
        /// <param name="labelPoint">Label placement</param>
        /// <param name="offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="viewport"></param>
        public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
        {
            SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
            labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
            if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
            {
                graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
                graphics.RotateTransform((float)rotation);
                graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                var path = new GraphicsPath();
                path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
            }
            else
            {
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);

                var path = new GraphicsPath();

                //Arial hack
                path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
        //------------------------------------------------------------------------------//
        // Movement Bitmap OnPaint()
        //------------------------------------------------------------------------------//
        public override void MyOnPaint(Graphics GraphicsObject)
        {
            base.MyOnPaint(GraphicsObject);
            int i;
            Point p1, p2;

            GraphicsObject.FillRectangle(m_hashAreaBrush, m_displayRect);
            GraphicsObject.FillRectangle(m_waterBrush, m_dataRect);
            GraphicsObject.DrawImage(m_bitmap, m_dataRect.X, m_dataRect.Y);


            // Draw Y (latitude) hashmarks and hashmark string values.
            for(i = 0; i < m_hashMarkArrayYLeft.Length; i++)
            {
                p1 = p2 = m_hashMarkArrayYLeft[i].point;
                p1.X -= 5;
                GraphicsObject.DrawLine(m_borderPen, p1, p2);
                GraphicsObject.DrawString(m_hashMarkArrayYLeft[i].sz, m_textFont, m_textBrush, p1.X - 25, p2.Y - 7);
            }

            // Draw X (longitude) hashmarks and hashmarks string values
            for(i = 0; i < m_hashMarkArrayXBottom.Length; i++)
            {
                p1 = p2 = m_hashMarkArrayXBottom[i].point;
                p1.Y += 5;
                GraphicsObject.DrawLine(m_borderPen, p1, p2);
                GraphicsObject.DrawString(m_hashMarkArrayXBottom[i].sz, m_textFont, m_textBrush, p1.X - 10, p2.Y + 7);
            }
        }
Ejemplo n.º 22
0
        public void GraphicsIsVisibleRectangleF(Graphics g)
        {
            Pen myPen = new Pen(Color.FromArgb(196, 0xC3, 0xC9, 0xCF), (float)0.6);
            SolidBrush myBrush = new SolidBrush(Color.FromArgb(127, 0xDD, 0xDD, 0xF0));

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            Region myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            bool contained = myRegion.IsVisible(regionRect2);

            // Display the result.
            Font myFont = new Font("Arial", 8);
            SolidBrush txtBrush = new SolidBrush(Color.Black);
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));

            regionRect1.Y += 120;
            regionRectF2.Y += 120;
            regionRectF2.X += 41;

            myPen.Color = Color.FromArgb (196, 0xC3, 0xC9, 0xCF);
            myBrush.Color = Color.FromArgb(127, 0xDD, 0xDD, 0xF0);

            // Create the first rectangle and draw it to the screen in blue.
            g.DrawRectangle(myPen, regionRect1);
            g.FillRectangle (myBrush, regionRect1);

            // Create the second rectangle and draw it to the screen in red.
            myPen.Color = Color.FromArgb(196, 0xF9, 0xBE, 0xA6);
            myBrush.Color = Color.FromArgb(127, 0xFF, 0xE0, 0xE0);

            g.DrawRectangle(myPen, Rectangle.Round(regionRectF2));
            g.FillRectangle (myBrush, Rectangle.Round (regionRectF2));

            // Create a region using the first rectangle.
            myRegion = new Region(regionRect1);

            // Determine if myRect is contained in the region.
            contained = myRegion.IsVisible(regionRectF2);

            // Display the result.
            g.DrawString("contained = " + contained.ToString(),
                myFont,
                txtBrush,
                new PointF(regionRectF2.Right + 10, regionRectF2.Top));
        }
Ejemplo n.º 23
0
		public override void Paint(Graphics g, Rectangle rect)
		{
			if (rect.Width <= 0 || rect.Height <= 0) {
				return;
			}
			HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");
			HighlightColor foldLineColor          = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
			
			
			for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) {
				Rectangle markerRectangle = new Rectangle(DrawingPosition.X,
				                                          DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder,
				                                          DrawingPosition.Width,
				                                          textArea.TextView.FontHeight);
				
				if (rect.IntersectsWith(markerRectangle)) {
					// draw dotted separator line
					if (textArea.Document.TextEditorProperties.ShowLineNumbers) {
						g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder),
						                new Rectangle(markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));
						
						g.DrawLine(BrushRegistry.GetDotPen(lineNumberPainterColor.Color, lineNumberPainterColor.BackgroundColor),
						           base.drawingPosition.X,
						           markerRectangle.Y,
						           base.drawingPosition.X,
						           markerRectangle.Bottom);
					} else {
						g.FillRectangle(BrushRegistry.GetBrush(textArea.Enabled ? lineNumberPainterColor.BackgroundColor : SystemColors.InactiveBorder), markerRectangle);
					}
					
					int currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(textArea.TextView.FirstVisibleLine) + y);
					PaintFoldMarker(g, currentLine, markerRectangle);
				}
			}
		}
Ejemplo n.º 24
0
 protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
 {
     Rectangle bounds = GetBounds(designer, activated);
     graphics.FillRectangle(AmbientTheme.FadeBrush, bounds);
     graphics.FillRectangle(ambientTheme.CommentIndicatorBrush, bounds);
     graphics.DrawRectangle(ambientTheme.CommentIndicatorPen, bounds);
 }
        //прави таблото на играта като обхожда всеки ред и колона;рисува и 2те коли
        private void DrawGameBoard(Graphics gameBoard)
        {
            for (int row = 0; row < rows; row++)
            {
                for (int col = 0; col < cols; col++)
                {
                    gameBoard.DrawRectangle(new Pen(Brushes.Brown), startX + col * elementSize, startY + row * elementSize,
                        elementSize, elementSize);
                    //оцветява първата кола
                    if (matrixGame[row, col] == 1)
                    {
                        gameBoard.FillRectangle(Brushes.Black, startX + col * elementSize, startY + row * elementSize,
                            elementSize, elementSize);
                        //оцветява втората кола
                    }
                    if (matrixGame[row, col] == 2)
                    {
                        gameBoard.FillRectangle(Brushes.Purple, startX + col * elementSize, startY + row * elementSize,
                            elementSize, elementSize);

                    }
                    if (matrixGame[row, col] == 3)
                    {
                        gameBoard.FillRectangle(Brushes.Beige, startX + col * elementSize, startY + row * elementSize,
                            elementSize, elementSize);

                    }
                }
            }
        }
Ejemplo n.º 26
0
        protected override void PaintRestore(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled)
        {
            SmoothingMode sm = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.None;

            Size s = new Size(10, 10);
            Rectangle rm = GetSignRect(r, s);
            Region oldClip = g.Clip;

            LinearGradientColorTable buttonTable = isEnabled ? ct.Foreground : new LinearGradientColorTable(GetDisabledColor(ct.Foreground.Start), GetDisabledColor(ct.Foreground.End), ct.Foreground.GradientAngle);
            using (Brush fill = DisplayHelp.CreateBrush(rm, ct.Foreground))
            {
                Rectangle inner = new Rectangle(rm.X + 4, rm.Y + 2, 6, 4);
                g.SetClip(inner, CombineMode.Exclude);
                g.SetClip(new Rectangle(rm.X + 1, rm.Y + 5, 6, 4), CombineMode.Exclude);

                g.FillRectangle(fill, rm.X + 3, rm.Y, 8, 7);
                g.ResetClip();

                inner = new Rectangle(rm.X + 1, rm.Y + 5, 6, 4);
                g.SetClip(inner, CombineMode.Exclude);
                g.FillRectangle(fill, rm.X, rm.Y + 3, 8, 7);
                g.ResetClip();
            }
            if (oldClip != null)
            {
                g.Clip = oldClip;
                oldClip.Dispose();
            }
            g.SmoothingMode = sm;
        }
 public static void DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft)
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (backgroundImageLayout == ImageLayout.Tile)
     {
         using (TextureBrush brush = new TextureBrush(backgroundImage, WrapMode.Tile))
         {
             if (scrollOffset != Point.Empty)
             {
                 Matrix transform = brush.Transform;
                 transform.Translate((float) scrollOffset.X, (float) scrollOffset.Y);
                 brush.Transform = transform;
             }
             g.FillRectangle(brush, clipRect);
             return;
         }
     }
     Rectangle rect = CalculateBackgroundImageRectangle(bounds, backgroundImage, backgroundImageLayout);
     if ((rightToLeft == RightToLeft.Yes) && (backgroundImageLayout == ImageLayout.None))
     {
         rect.X += clipRect.Width - rect.Width;
     }
     using (SolidBrush brush2 = new SolidBrush(backColor))
     {
         g.FillRectangle(brush2, clipRect);
     }
     if (!clipRect.Contains(rect))
     {
         if ((backgroundImageLayout == ImageLayout.Stretch) || (backgroundImageLayout == ImageLayout.Zoom))
         {
             rect.Intersect(clipRect);
             g.DrawImage(backgroundImage, rect);
         }
         else if (backgroundImageLayout == ImageLayout.None)
         {
             rect.Offset(clipRect.Location);
             Rectangle destRect = rect;
             destRect.Intersect(clipRect);
             Rectangle rectangle3 = new Rectangle(Point.Empty, destRect.Size);
             g.DrawImage(backgroundImage, destRect, rectangle3.X, rectangle3.Y, rectangle3.Width, rectangle3.Height, GraphicsUnit.Pixel);
         }
         else
         {
             Rectangle rectangle4 = rect;
             rectangle4.Intersect(clipRect);
             Rectangle rectangle5 = new Rectangle(new Point(rectangle4.X - rect.X, rectangle4.Y - rect.Y), rectangle4.Size);
             g.DrawImage(backgroundImage, rectangle4, rectangle5.X, rectangle5.Y, rectangle5.Width, rectangle5.Height, GraphicsUnit.Pixel);
         }
     }
     else
     {
         ImageAttributes imageAttr = new ImageAttributes();
         imageAttr.SetWrapMode(WrapMode.TileFlipXY);
         g.DrawImage(backgroundImage, rect, 0, 0, backgroundImage.Width, backgroundImage.Height, GraphicsUnit.Pixel, imageAttr);
         imageAttr.Dispose();
     }
 }
Ejemplo n.º 28
0
        public override void drawnShap(Graphics pe)
        {

            Brush CurrentBrush = initBrush();
            if (this.State.Shift1 == true)
            {
                calcShift();

                //Tính toán lại điểm kết thúc
                findSecondPointWhenShift();

                pe.DrawRectangle(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);

                if (State.IsBrushFill)
                {
                    pe.FillRectangle(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Width1);
                }

            }
            else
            {
                calcHeightWidth();
                pe.DrawRectangle(new Pen(State.CurrentColor, State.LineWidth), State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                if (State.IsBrushFill)
                {
                    pe.FillRectangle(CurrentBrush, State.StartPoint.X, State.StartPoint.Y, State.Width1, State.Height1);
                }

            }

        }
Ejemplo n.º 29
0
		static  public void Draw3DRect(Graphics g, int x, int y, int width, int height, Color topLeft, Color bottomRight)
		{
			g.FillRectangle(new SolidBrush(topLeft), x, y, width - 1, 1);
			g.FillRectangle(new SolidBrush(topLeft), x, y, 1, height - 1);
			g.FillRectangle(new SolidBrush(bottomRight), x + width, y, -1, height);
			g.FillRectangle(new SolidBrush(bottomRight), x, y + height, width, -1);
		}
Ejemplo n.º 30
0
        public void DrawFormBackgroud(Graphics g, Rectangle r)
        {
            drawing = new Bitmap(this.Width, AnimSize, g);
            gg = Graphics.FromImage(drawing);

            Rectangle shadowRect = new Rectangle(r.X, r.Y, r.Width, 10);
            Rectangle gradRect = new Rectangle(r.X, r.Y + 9, r.Width, AnimSize-9);
            LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 61), Color.FromArgb(47, colorR, colorR), LinearGradientMode.Vertical);
            //LinearGradientBrush shadow = new LinearGradientBrush(shadowRect, Color.FromArgb(30, 61, 41), Color.FromArgb(47, colorR, 64), LinearGradientMode.Vertical);
            LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.FromArgb(47, 64, 94), Color.FromArgb(49, 66, 95), LinearGradientMode.Vertical);
            //LinearGradientBrush grad = new LinearGradientBrush(gradRect, Color.Green, Color.DarkGreen, LinearGradientMode.Vertical);
            ColorBlend blend = new ColorBlend();

            // Set multi-color gradient
            blend.Positions = new[] { 0.0f, 0.35f, 0.5f, 0.65f, 0.95f,1f };
            blend.Colors = new[] { Color.FromArgb(47, colorR, colorR), Color.FromArgb(64, colorR + 22, colorR + 32), Color.FromArgb(66, colorR + 20, colorR + 35), Color.FromArgb(64, colorR + 20, colorR + 32), Color.FromArgb(49, colorR, colorR + 1), SystemColors.Control };
            //blend.Colors = new[] { Color.FromArgb(47, colorR, 64), Color.FromArgb(64, colorR + 32, 88), Color.FromArgb(66, colorR + 35, 90), Color.FromArgb(64, colorR + 32, 88), Color.FromArgb(49, colorR + 1, 66),SystemColors.Control };
            grad.InterpolationColors = blend;
            Font myf = new System.Drawing.Font(this.Font.FontFamily, 16);
            // Draw basic gradient and shadow
            //gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            gg.FillRectangle(grad, gradRect);
            gg.FillRectangle(shadow, shadowRect);
            gg.TextRenderingHint = TextRenderingHint.AntiAlias;
            gg.DrawString("Поиск по ресурсам сети", myf, Brushes.GhostWhite, new PointF(55, 15));
            gg.DrawImage(Properties.Resources.search1.ToBitmap(), 10, 10,32,32);

            g.DrawImageUnscaled(drawing, 0, 0);
            gg.Dispose();

            // Draw checkers
            //g.FillRectangle(checkers, r);
        }