Blame mono/Diagram/Shapes.cs

Ivan Mahonin 777717
/*
Ivan Mahonin 777717
    ......... 2015 Ivan Mahonin
Ivan Mahonin 777717
Ivan Mahonin 777717
    This program is free software: you can redistribute it and/or modify
Ivan Mahonin 777717
    it under the terms of the GNU General Public License as published by
Ivan Mahonin 777717
    the Free Software Foundation, either version 3 of the License, or
Ivan Mahonin 777717
    (at your option) any later version.
Ivan Mahonin 777717
Ivan Mahonin 777717
    This program is distributed in the hope that it will be useful,
Ivan Mahonin 777717
    but WITHOUT ANY WARRANTY; without even the implied warranty of
Ivan Mahonin 777717
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Ivan Mahonin 777717
    GNU General Public License for more details.
Ivan Mahonin 777717
Ivan Mahonin 777717
    You should have received a copy of the GNU General Public License
Ivan Mahonin 777717
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
Ivan Mahonin 777717
*/
Ivan Mahonin 777717
Ivan Mahonin 777717
using System;
Ivan Mahonin 8cb222
using System.Drawing;
Ivan Mahonin 8cb222
Ivan Mahonin 8cb222
namespace Diagram {
Ivan Mahonin 8cb222
    public class Shapes {
Ivan Mahonin 8cb222
        public static void drawRoundRect(Graphics g, RectangleF rect, float radius, Pen pen, Brush brush) {
Ivan Mahonin 8cb222
            radius = Math.Min(radius, 0.5f*rect.Width);
Ivan Mahonin 8cb222
            radius = Math.Min(radius, 0.5f*rect.Height);
Ivan Mahonin 8cb222
            float d = 2f*radius;
Ivan Mahonin 8cb222
Ivan Mahonin 8cb222
            g.FillPie(brush, rect.Left,    rect.Top,      d, d, -180f, 90f);
Ivan Mahonin 8cb222
            g.FillPie(brush, rect.Right-d, rect.Top,      d, d,  -90f, 90f);
Ivan Mahonin 8cb222
            g.FillPie(brush, rect.Right-d, rect.Bottom-d, d, d,    0f, 90f);
Ivan Mahonin 8cb222
            g.FillPie(brush, rect.Left,    rect.Bottom-d, d, d,   90f, 90f);
Ivan Mahonin 8cb222
            g.FillRectangle(brush, rect.Left+radius, rect.Top, rect.Width-d, rect.Height);
Ivan Mahonin 8cb222
            g.FillRectangle(brush, rect.Left, rect.Top+radius, rect.Width, rect.Height-d);
Ivan Mahonin 8cb222
Ivan Mahonin 8cb222
            g.DrawArc(pen, rect.Left,    rect.Top,      d, d, -180f, 90f);
Ivan Mahonin 8cb222
            g.DrawArc(pen, rect.Right-d, rect.Top,      d, d,  -90f, 90f);
Ivan Mahonin 8cb222
            g.DrawArc(pen, rect.Right-d, rect.Bottom-d, d, d,    0f, 90f);
Ivan Mahonin 8cb222
            g.DrawArc(pen, rect.Left,    rect.Bottom-d, d, d,   90f, 90f);
Ivan Mahonin 8cb222
            g.DrawLine(pen, rect.Left+radius, rect.Top, rect.Right-radius, rect.Top);
Ivan Mahonin 8cb222
            g.DrawLine(pen, rect.Left+radius, rect.Bottom, rect.Right-radius, rect.Bottom);
Ivan Mahonin 8cb222
            g.DrawLine(pen, rect.Left, rect.Top+radius, rect.Left, rect.Bottom-radius);
Ivan Mahonin 8cb222
            g.DrawLine(pen, rect.Right, rect.Top+radius, rect.Right, rect.Bottom-radius);
Ivan Mahonin 8cb222
        }
Ivan Mahonin 8cb222
    }
Ivan Mahonin 8cb222
}
Ivan Mahonin 8cb222