Click here to Skip to main content
15,886,578 members
Articles / Desktop Programming / Windows Forms

Farsi Library - Working with Dates, Calendars, and DatePickers

Rate me:
Please Sign up or sign in to vote.
4.93/5 (236 votes)
21 Nov 2007MIT8 min read 2.9M   95.1K   202  
A library to work with "Persian Calendar", "Hijri Calendar", and "Gregorian Calendar" with WinForms GUI controls designed for Persian (Farsi) or Arabic language applications in mind, but usable in any Windows application that makes use of calendars and dates.
using System.Drawing;

namespace FarsiLibrary.Win.Drawing
{
    /// <summary>
    /// Base painter for all painter classes. You should inherit this class to implement a new painter.
    /// </summary>
    public class FAPainterBase
    {
        #region Fields

        #endregion

        #region Props

        #endregion

        #region Base Drawing Parts

        public Rectangle DrawArrow(Graphics g, Rectangle rc, bool isLeft, bool isDisabled, int arrowSize)
        {
            int xLeft, xRight, yTop, yMidd, yBott;

            xLeft = rc.Left + 1;
            xRight = xLeft + arrowSize;
            yMidd = rc.Top + (rc.Height / 2);
            yTop = yMidd - arrowSize;
            yBott = yMidd + arrowSize;

            Point[] array;

            if (isLeft)
            {
                array = new Point[]
					{
						new Point(new Size(xLeft, yMidd)),
						new Point(new Size(xRight, yTop)),
						new Point(new Size(xRight, yBott))
					};
            }
            else
            {
                array = new Point[]
					{
						new Point(new Size(xLeft, yTop)),
						new Point(new Size(xLeft, yBott)),
						new Point(new Size(xRight, yMidd))
					};
            }

            g.DrawPolygon((isDisabled ? SystemPens.GrayText : SystemPens.WindowText), array);
            g.FillPolygon((isDisabled ? SystemBrushes.GrayText : SystemBrushes.WindowText), array);

            return new Rectangle(xLeft - 2, yTop - 2, arrowSize + 4, arrowSize * 2 + 4);
        }

        public Rectangle DrawVerticalArrow(Graphics g, Rectangle rc, bool isLeft, bool isDisabled, int arrowSize)
        {
            int middle = rc.Height / 2;
            Point[] pntArrow = new Point[3];
            SolidBrush br;

            if (isLeft)
            {
                pntArrow[0] = new Point(rc.Width - 11, middle - 1);
                pntArrow[1] = new Point(rc.Width - 9, middle + 2);
                pntArrow[2] = new Point(rc.Width - 6, middle - 1);
            }
            else
            {
                pntArrow[0] = new Point(rc.Left + 6, middle - 1);
                pntArrow[1] = new Point(rc.Left + 8, middle + 2);
                pntArrow[2] = new Point(rc.Left + 11, middle - 1);
            }

            if (isDisabled)
            {
                br = new SolidBrush(Color.DarkGray);
            }
            else
            {
                br = new SolidBrush(Color.Black);
            }

            g.FillPolygon(br, pntArrow);
            br.Dispose();

            return rc;
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) Readify
Australia Australia
Working on both Java and .NET Technology, I have developed various enterprise level applications on both platforms. Currently, I am working as a Senior Software Developer at Readify which is a leading company on .NET technology in Australia.

Comments and Discussions