FigRhombus.cs 1.21 KB
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace flowchart
{
    class FigRhombus : FigBase
    {
        // 프로세스 마름모를 그리는 클래스(FigureBase를 상속)
        // Draw 함수에서 마름모를 그린다.

        // 생성자도 상속해서 사용.
        public FigRhombus(Point location, Size size) : base(location, size)
        {

        }

        public override void Draw(Graphics g)
        {
            using (Pen pen = new Pen(Color.Red, 1))
            {
                //Rectangle rect = new Rectangle(this.Location, this.Size);
                int x1, x2, x3, y1, y2, y3;
                x1 = Location.X;
                x2 = Location.X + Size.Width / 2;
                x3 = Location.X + Size.Width;
                y1 = Location.Y;
                y2 = Location.Y + Size.Height / 2;
                y3 = Location.Y + Size.Height;

                g.DrawLine(pen, x1, y2, x2, y1);
                g.DrawLine(pen, x2, y1, x3, y2);
                g.DrawLine(pen, x3, y2, x2, y3);
                g.DrawLine(pen, x2, y3, x1, y2);
            }

            base.Draw(g);
        }
    }
}