Beispiel #1
0
        public static Rectangle2 Inflate(Rectangle2 rect, float x, float y)
        {
            Rectangle2 r = rect;

            r.Inflate(x, y);
            return(r);
        }
Beispiel #2
0
        public static void PaintOverview(IGraphics g, SizeI2 totalSize, RectangleI2 visibleWin,
                                         Func <int, int, Bitmap2> getOverviewBitmap, float zoomFactorX, float zoomFactorY)
        {
            Size2      overview = CalcOverviewSize(visibleWin.Width, visibleWin.Height, totalSize.Width, totalSize.Height);
            Rectangle2 win      = CalcWin(overview, totalSize, visibleWin, zoomFactorX, zoomFactorY);

            g.FillRectangle(Brushes2.White, 0, visibleWin.Height - overview.Height, overview.Width, overview.Height);
            g.DrawImageUnscaled(getOverviewBitmap((int)overview.Width, (int)overview.Height), 0,
                                visibleWin.Height - overview.Height);
            Brush2 b = new Brush2(Color2.FromArgb(30, 0, 0, 255));

            if (win.X > 0)
            {
                g.FillRectangle(b, 0, visibleWin.Height - overview.Height, win.X, overview.Height);
            }
            if (overview.Width - win.X - win.Width > 0)
            {
                g.FillRectangle(b, win.X + win.Width, visibleWin.Height - overview.Height, overview.Width - win.X - win.Width,
                                overview.Height);
            }
            if (win.Y > 0)
            {
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height, win.Width, win.Y);
            }
            if (overview.Height - win.Y - win.Height > 0)
            {
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height + win.Y + win.Height - 1, win.Width,
                                overview.Height - win.Y - win.Height);
            }
            g.DrawRectangle(Pens2.Black, 0, visibleWin.Height - overview.Height - 1, overview.Width, overview.Height);
            g.DrawRectangle(Pens2.Blue, win.X, visibleWin.Height - overview.Height - 1 + win.Y, win.Width, win.Height);
        }
Beispiel #3
0
        public static Rectangle2 Union(Rectangle2 a, Rectangle2 b)
        {
            float x1 = Math.Min(a.X, b.X);
            float x2 = Math.Max(a.X + a.Width, b.X + b.Width);
            float y1 = Math.Min(a.Y, b.Y);
            float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);

            return(new Rectangle2(x1, y1, x2 - x1, y2 - y1));
        }
Beispiel #4
0
        public void Intersect(Rectangle2 rect)
        {
            Rectangle2 result = Intersect(rect, this);

            X      = result.X;
            Y      = result.Y;
            Width  = result.Width;
            Height = result.Height;
        }
Beispiel #5
0
        public override bool Equals(object obj)
        {
            if (!(obj is Rectangle2))
            {
                return(false);
            }
            Rectangle2 comp = (Rectangle2)obj;

            return((comp.X == X) && (comp.Y == Y) && (comp.Width == Width) && (comp.Height == Height));
        }
Beispiel #6
0
        public static Rectangle2 Intersect(Rectangle2 a, Rectangle2 b)
        {
            float x1 = Math.Max(a.X, b.X);
            float x2 = Math.Min(a.X + a.Width, b.X + b.Width);
            float y1 = Math.Max(a.Y, b.Y);
            float y2 = Math.Min(a.Y + a.Height, b.Y + b.Height);

            if (x2 >= x1 && y2 >= y1)
            {
                return(new Rectangle2(x1, y1, x2 - x1, y2 - y1));
            }
            return(Empty);
        }
Beispiel #7
0
        public static void PaintOverview(IGraphics g, SizeI2 totalSize, RectangleI2 visibleWin,
                                         Func <int, int, Bitmap2> getOverviewBitmap, float zoomFactorX, float zoomFactorY, bool overviewTopRight)
        {
            if (getOverviewBitmap == null)
            {
                return;
            }
            Size2      overview = CalcOverviewSize(visibleWin.Width, visibleWin.Height, totalSize.Width, totalSize.Height);
            Rectangle2 win      = CalcWin(overview, totalSize, visibleWin, zoomFactorX, zoomFactorY);
            float      xpos     = overviewTopRight ? visibleWin.Width - overview.Width - 1 : 0;
            float      ypos     = overviewTopRight ? 1 : visibleWin.Height - overview.Height;

            g.FillRectangle(Brushes2.White, xpos, ypos, overview.Width, overview.Height);
            Bitmap2 bm = getOverviewBitmap((int)overview.Width, (int)overview.Height);

            if (bm == null)
            {
                return;
            }
            g.DrawImageUnscaled(bm, xpos, ypos);
            Brush2 b = new Brush2(Color2.FromArgb(30, 0, 0, 255));

            if (win.X > 0)
            {
                g.FillRectangle(b, xpos, ypos, win.X, overview.Height);
            }
            if (overview.Width - win.X - win.Width > 0)
            {
                g.FillRectangle(b, xpos + win.X + win.Width, ypos, overview.Width - win.X - win.Width, overview.Height);
            }
            if (win.Y > 0)
            {
                g.FillRectangle(b, xpos + win.X, ypos, win.Width, win.Y);
            }
            if (overview.Height - win.Y - win.Height > 0)
            {
                g.FillRectangle(b, xpos + win.X, ypos + win.Y + win.Height - 1, win.Width, overview.Height - win.Y - win.Height);
            }
            g.DrawRectangle(Pens2.Black, xpos, ypos - 1, overview.Width, overview.Height);
            g.DrawRectangle(Pens2.Blue, xpos + win.X, ypos - 1 + win.Y, win.Width, win.Height);
            if (win.Width < 5 && win.Height < 5)
            {
                g.DrawLine(Pens2.Red, xpos + win.X, ypos + win.Y, xpos + win.X + 5, ypos + win.Y);
                g.DrawLine(Pens2.Red, xpos + win.X, ypos + win.Y, xpos + win.X, ypos + win.Y + 5);
                g.DrawLine(Pens2.Red, xpos + win.X, ypos + win.Y, xpos + win.X + 7, ypos + win.Y + 7);
            }
        }
Beispiel #8
0
 public bool Contains(Rectangle2 rect)
 {
     return (X <= rect.X) && (rect.X + rect.Width <= X + Width) && (Y <= rect.Y) &&
             (rect.Y + rect.Height <= Y + Height);
 }
Beispiel #9
0
 public static Rectangle2 Union(Rectangle2 a, Rectangle2 b)
 {
     float x1 = Math.Min(a.X, b.X);
     float x2 = Math.Max(a.X + a.Width, b.X + b.Width);
     float y1 = Math.Min(a.Y, b.Y);
     float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);
     return new Rectangle2(x1, y1, x2 - x1, y2 - y1);
 }
Beispiel #10
0
 public static Rectangle2 Intersect(Rectangle2 a, Rectangle2 b)
 {
     float x1 = Math.Max(a.X, b.X);
     float x2 = Math.Min(a.X + a.Width, b.X + b.Width);
     float y1 = Math.Max(a.Y, b.Y);
     float y2 = Math.Min(a.Y + a.Height, b.Y + b.Height);
     if (x2 >= x1 && y2 >= y1){
         return new Rectangle2(x1, y1, x2 - x1, y2 - y1);
     }
     return Empty;
 }
Beispiel #11
0
 public static Rectangle2 Inflate(Rectangle2 rect, float x, float y)
 {
     Rectangle2 r = rect;
     r.Inflate(x, y);
     return r;
 }
Beispiel #12
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     DrawString(s, font, brush, rectangleF, new StringFormat2());
 }
Beispiel #13
0
 public static Vector2F Center(Rectangle2 rectangle)
 {
     return new Vector2F(rectangle.Left + rectangle.Width/2, rectangle.Top + rectangle.Height/2);
 }
 private static void DoPaint(IGraphics g, TextBox textBox)
 {
     g.FillRectangle(new Brush2(GraphUtils.ToColor2(textBox.BackColor)), textBox.Location.X, textBox.Location.Y,
         textBox.Width - textBox.Margin.Left - textBox.Margin.Right,
         textBox.Height - textBox.Margin.Top - textBox.Margin.Bottom);
     Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(textBox.Location) , GraphUtils.ToSize2(textBox.Size));
     StringFormat2 format = new StringFormat2{Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near};
     g.DrawString(textBox.Text, GraphUtils.ToFont2(textBox.Font) , new Brush2(GraphUtils.ToColor2(textBox.ForeColor)), rect, format);
 }
Beispiel #15
0
 public bool IntersectsWith(Rectangle2 rect)
 {
     return((rect.X < X + Width) && (X < rect.X + rect.Width) && (rect.Y < Y + Height) && (Y < rect.Y + rect.Height));
 }
Beispiel #16
0
 public void SetClip(Rectangle2 rectangle)
 {
     //TODO
 }
Beispiel #17
0
 public void DrawArc(Pen2 pen, Rectangle2 rec, float startAngle, float sweepAngle)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public void SetClip(Rectangle2 rectangle)
 {
     template = topTemplate.CreateTemplate(rectangle.Width, rectangle.Height);
     topTemplate.AddTemplate(template, rectangle.X, topTemplate.Height - rectangle.Height - rectangle.Y);
     currentWidth = rectangle.Width;
     currentHeight = rectangle.Height;
 }
Beispiel #19
0
 public void Intersect(Rectangle2 rect)
 {
     Rectangle2 result = Intersect(rect, this);
     X = result.X;
     Y = result.Y;
     Width = result.Width;
     Height = result.Height;
 }
Beispiel #20
0
 public bool IntersectsWith(Rectangle2 rect)
 {
     return (rect.X < X + Width) && (X < rect.X + rect.Width) && (rect.Y < Y + Height) && (Y < rect.Y + rect.Height);
 }
Beispiel #21
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF)
 {
     DrawString(s, font, brush, rectangleF, null);
 }
 private static void DoPaint(IGraphics g, Label label)
 {
     Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(label.Location) , GraphUtils.ToSizeF2(label.Size) );
     g.FillRectangle(new Brush2(GraphUtils.ToColor2(label.BackColor)), rect.X, rect.Y, label.Width - label.Margin.Left - label.Margin.Right,
         label.Height - label.Margin.Top - label.Margin.Bottom);
     StringFormat2 format = new StringFormat2{Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near};
     g.DrawString(label.Text, GraphUtils.ToFont2(label.Font), new Brush2(GraphUtils.ToColor2(label.ForeColor)), rect, format);
 }
Beispiel #23
0
 public bool Contains(Rectangle2 rect)
 {
     return((X <= rect.X) && (rect.X + rect.Width <= X + Width) && (Y <= rect.Y) &&
            (rect.Y + rect.Height <= Y + Height));
 }
Beispiel #24
0
 /// <summary>
 /// Draws the specified text string at the specified location with the specified Brush and Font objects.
 /// </summary>
 /// <param name="s">String to draw.</param>
 /// <param name="font">Font that defines the text format of the string.</param>
 /// <param name="brush">Brush that determines the color and texture of the drawn text.</param>
 /// <param name="rectangleF">System.Drawing.RectangleF structure that specifies the location of the drawn text.</param>
 /// <param name="format">System.Drawing.StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.</param>
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF, StringFormat2 format)
 {
     if (format != null && rectangleF.Width > 0){
         switch (format.Alignment){
             case StringAlignment2.Center:
                 rectangleF.X += (rectangleF.Width - MeasureString(s, font, (int) rectangleF.Width, format).Width)*0.5f;
                 break;
             case StringAlignment2.Far:
                 rectangleF.X += rectangleF.Width - MeasureString(s, font, (int) rectangleF.Width, format).Width;
                 break;
         }
     }
     textList.Add(new Text{
         X = rectangleF.X,
         Y = rectangleF.Y + (font.Height*0.5f),
         FontFamily = font.Name,
         FontSize = font.Size*1.2f,
         FontWeight = font.Bold ? "bold" : "normal",
         Value = s,
         Fill = BrushColor(brush),
         Transform = Transform
     });
 }
Beispiel #25
0
 public void DrawString(string s, Font2 font, Brush2 brush, Rectangle2 rectangleF, StringFormat2 format)
 {
     template.BeginText();
     SetFont(font);
     SetBrush(brush);
     float x = rectangleF.X;
     float y = rectangleF.Y - 1;
     Size2 size = MeasureString(s, font);
     if (format != null){
         switch (format.Alignment){
             case StringAlignment2.Center:
                 x = x + (rectangleF.Width - size.Width)/2f;
                 break;
             case StringAlignment2.Near:
                 x = x + 2;
                 break;
             case StringAlignment2.Far:
                 x = x + (rectangleF.Width - size.Width) - 2;
                 break;
         }
         switch (format.LineAlignment){
             case StringAlignment2.Center:
                 y = y + font.Height/2f;
                 break;
             case StringAlignment2.Near:
                 y = y + 2;
                 break;
             case StringAlignment2.Far:
                 y = y + font.Height;
                 break;
         }
     }
     template.SetTextMatrix(x, currentHeight - y - (font.Height*0.5f*1.5f));
     template.ShowText(s.TrimStart().TrimEnd());
     template.EndText();
 }