예제 #1
0
 internal static Brush GetBrush(string name,
                                Color foreColor, Color backColor,
                                NamedHatchStyles nhs, NamedTextureStyles nts)
 {
     if (nhs != null)
     {
         HatchStyle?hatch = nhs.GetHatchStyle(name);
         if (hatch.HasValue)
         {
             return(new HatchBrush(hatch.Value, foreColor, backColor));
         }
     }
     if (nts != null)
     {
         Picture pic = nts.GetTexture(name);
         if (pic != null)
         {
             Image img = pic.GetImage();
             if (img != null)
             {
                 return(new TextureBrush(img));
             }
         }
     }
     return(new SolidBrush(foreColor));
 }
예제 #2
0
파일: Ghost.cs 프로젝트: xuanximoming/key
 public void Draw(Graphics g, NamedTextureStyles nts)
 {
     g.SmoothingMode = SmoothingMode.AntiAlias;
     if (Shape.Data.Enable)
     {
         Shape.Draw(g, nts);
     }
     Point[] pts = Shape.Data.Points;
     if (pts != null && pts.Length > 0)
     {
         Rectangle[] rects = new Rectangle[pts.Length];
         Rectangle   rect;
         Point       pt;
         Size        s = new Size(5, 5);
         for (int i = 0; i < pts.Length; i++)
         {
             pt   = pts[i];
             rect = new Rectangle(pt, s);
             rect.Offset(-2, -2);
             rects[i] = rect;
         }
         g.FillRectangles(Brushes.White, rects);
         g.DrawRectangles(Pens.Black, rects);
     }
     if (!Shape.Data.Bounds.IsEmpty)
     {
         g.DrawRectangle(Pens.Blue, Shape.Data.Bounds);
     }
     _dirty = false;
 }
예제 #3
0
        public override void Draw(Graphics g, NamedTextureStyles nts)
        {
            if (Data.Points == null ||
                Data.Points.Length < MinPoints)
            {
                return;
            }
            int x1, x2, y1, y2;

            x1 = Data.Points[0].X;
            y1 = Data.Points[0].Y;
            x2 = Data.Points[1].X;
            y2 = Data.Points[1].Y;
            Rectangle rect = Rectangle.FromLTRB(
                Math.Min(x1, x2), Math.Min(y1, y2),
                Math.Max(x1, x2), Math.Max(y1, y2));

            if (Data.IsFillColor)
            {
                using (Brush br = base.GetBrush(nts))
                    g.FillEllipse(br, rect);
            }

            using (Pen pen = new Pen(Data.DrawColor, Data.LineWidth))
                g.DrawEllipse(pen, rect);
        }
예제 #4
0
        public override void Draw(Graphics g, NamedTextureStyles nts)
        {
            if (Data.Points == null ||
                Data.Points.Length < MinPoints)
            {
                return;
            }
            int x1, x2, y1, y2;

            x1 = Data.Points[0].X;
            y1 = Data.Points[0].Y;
            x2 = Data.Points[1].X;
            y2 = Data.Points[1].Y;
            RectangleF rect = RectangleF.FromLTRB(Math.Min(x1, x2), Math.Min(y1, y2),
                                                  Math.Max(x1, x2), Math.Max(y1, y2));

            if (Data.IsFillColor)
            {
                using (Brush br = base.GetBrush(nts))
                    g.FillRectangle(br, rect);
            }
            try
            {
                //Font = new Font(Font.FontFamily, rect.Height, GraphicsUnit.Pixel);
                using (Brush brush = new SolidBrush(Data.DrawColor))
                {
                    g.DrawString(Data.Text, Font, brush,
                                 rect, new StringFormat());
                }
            }
            catch { return; }
        }
예제 #5
0
 public override void Draw(Graphics g, NamedTextureStyles nts)
 {
     if (Data.Points == null ||
         Data.Points.Length < MinPoints)
     {
         return;
     }
     using (Pen pen = new Pen(Data.DrawColor, Data.LineWidth))
         g.DrawCurve(pen, Data.Points);
 }
예제 #6
0
        public override void Draw(Graphics g, NamedTextureStyles nts)
        {
            if (Data.Points == null ||
                Data.Points.Length < MinPoints)
            {
                return;
            }

            if (Data.IsFillColor)
            {
                using (Brush br = base.GetBrush(nts))
                    g.FillClosedCurve(br, Data.Points);
            }

            using (Pen pen = new Pen(Data.DrawColor, Data.LineWidth))
                g.DrawClosedCurve(pen, Data.Points);
        }
예제 #7
0
        private static void DrawHatchItem(
            DrawItemEventArgs e, IList items, Font font,
            NamedHatchStyles nhs, NamedTextureStyles nts)
        {
            e.DrawBackground();
            Rectangle rectangle1 = e.Bounds;

            if (e.Index == -1)
            {
                return;
            }
            string    text1      = (string)items[e.Index];
            Rectangle rectangle2 = rectangle1;

            rectangle2.Width = rectangle2.Left + 0x19;
            rectangle1.X     = rectangle2.Right;
            using (Brush brush1 = UICommon.GetBrush(text1, e.ForeColor, e.BackColor, nhs, nts))
            {
                e.Graphics.FillRectangle(brush1, rectangle2);
            }
            StringFormat format1 = new StringFormat();

            format1.Alignment = StringAlignment.Near;
            using (SolidBrush brush2 = new SolidBrush(Color.White))
            {
                if ((e.State & DrawItemState.Focus) == DrawItemState.None)
                {
                    brush2.Color = SystemColors.Window;
                    e.Graphics.FillRectangle(brush2, rectangle1);
                    brush2.Color = SystemColors.WindowText;
                    e.Graphics.DrawString(text1, font, brush2, (RectangleF)rectangle1, format1);
                }
                else
                {
                    brush2.Color = SystemColors.Highlight;
                    e.Graphics.FillRectangle(brush2, rectangle1);
                    brush2.Color = SystemColors.HighlightText;
                    e.Graphics.DrawString(text1, font, brush2, (RectangleF)rectangle1, format1);
                }
            }
            e.DrawFocusRectangle();
        }
예제 #8
0
 protected Brush GetBrush(NamedTextureStyles nts)
 {
     if (Data.IsHatch)
     {
         return(new HatchBrush(Data.Hatch, Data.FillColor, Color.White));
     }
     if (Data.IsTexture)
     {
         Picture pic = nts.GetTexture(Data.TextureName);
         if (pic != null)
         {
             Image img = pic.GetImage();
             if (img != null)
             {
                 return(new TextureBrush(img));
             }
         }
     }
     return(new SolidBrush(Data.FillColor));
 }
예제 #9
0
        public override void Draw(Graphics g, NamedTextureStyles nts)
        {
            if (Data.Points == null ||
                Data.Points.Length < MinPoints)
            {
                return;
            }
            Point pt0, pt1, pt2, pt3;

            switch (Data.Points.Length)
            {
            case 2:
                pt0 = Data.Points[0];
                pt1 = Data.Points[1];
                pt2 = Data.Points[0];
                pt3 = Data.Points[1];
                break;

            case 3:
                pt0 = Data.Points[0];
                pt1 = Data.Points[1];
                pt2 = Data.Points[2];
                pt3 = Data.Points[2];
                break;

            case 4:
            default:
                pt0 = Data.Points[0];
                pt1 = Data.Points[1];
                pt2 = Data.Points[2];
                pt3 = Data.Points[3];
                break;
            }
            using (Pen pen = new Pen(Data.DrawColor, Data.LineWidth))
                g.DrawBezier(pen, pt0, pt2, pt3, pt1);
        }
예제 #10
0
 public void Load(Picture background, Size size,
                  NamedHatchStyles namedHatchStyle,
                  NamedTextureStyles namedTextureStyle,
                  IEnumerable <IShape> shapes)
 {
     Clear();
     OnLoading(EventArgs.Empty);
     _size = size;
     CheckSize(true);
     _background = background;
     if (shapes == null)
     {
         ShapesPrivate = new ShapeList();
     }
     else
     {
         ShapesPrivate = new ShapeList(shapes);
     }
     _namedHatchStyle   = namedHatchStyle;
     _namedTextureStyle = namedTextureStyle;
     RedrawCore();
     _isLoaded = true;
     OnLoaded(EventArgs.Empty);
 }
예제 #11
0
 void IShape.Draw(Graphics g, NamedTextureStyles nts)
 {
 }
예제 #12
0
파일: Ghost.cs 프로젝트: xuanximoming/key
 public void Draw(Graphics g, NamedTextureStyles nts)
 {
 }
예제 #13
0
 public override void Draw(Graphics g, NamedTextureStyles nts)
 {
 }
예제 #14
0
 public abstract void Draw(Graphics g, NamedTextureStyles nts);