#pragma once

using namespace System;
using namespace System::Drawing;
using namespace System::Collections::Generic;

namespace CLIMulticube {

	/// <summary>
	/// Description résumée de FontFormatUtility
	/// </summary>
	public ref class FontFormatUtility 
	{	
	public:
        #pragma region GetFontNames
        static array<String^> ^ GetFontNames()
        {
            List<String^> ^ fontnames = gcnew List<String^>();            
            fontnames->Add("Arial");
            fontnames->Add("Calibri");
            fontnames->Add("Courier New");
            fontnames->Add("Microsoft Sans Serif");
            fontnames->Add("Times New Roman");            

            return fontnames->ToArray();
        } 
        #pragma endregion

        #pragma region GetFontSizes
		static array<String^> ^ GetFontSizes()
        {
            List<String^> ^ fontnames = gcnew List<String^>();
            fontnames->Add("24");
            fontnames->Add("20");
            fontnames->Add("16");
            fontnames->Add("14");
            fontnames->Add("12");
            fontnames->Add("11");
            fontnames->Add("8");
            fontnames->Add("6");

            return fontnames->ToArray();         
	    }
        #pragma endregion

        #pragma region GetFormats
        static array<String^> ^ GetFormats()
        {
            List<String^> ^ fontnames = gcnew List<String^>();
            fontnames->Add("Automatique");
            fontnames->Add("Nombre");
            fontnames->Add("Pourcentage");
            fontnames->Add("Date");
            fontnames->Add("Texte");
            fontnames->Add("Personnalisé");

            return fontnames->ToArray();
        } 
        #pragma endregion        

        #pragma region ToggleFontBold	
		static Font^ ToggleFontBold(Font^ p)
        {
            bool isItalic, isUnderline;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isItalic = false;
                isUnderline = false;
            }
            else
            {
                isItalic = p->Italic;
                isUnderline = p->Underline;
            }

            Font^ f;
            if (!p->Bold)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Bold |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isItalic ? (int)FontStyle::Italic : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isItalic ? (int)FontStyle::Italic : 0)));
            }
            return f;
        } 
        #pragma endregion

        #pragma region ToggleFontItalic
        static Font^ ToggleFontItalic(Font^ p)
        {
            bool isBold, isUnderline;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isBold = false;
                isUnderline = false;
            }
            else
            {
                isBold = p->Bold;
                isUnderline = p->Underline;
            }

            Font^ f;
            if (!p->Italic)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Italic |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            return f;
        } 
        #pragma endregion

        #pragma region ToggleFontUnderline
        static Font^ ToggleFontUnderline(Font^ p)
        {
            bool isBold, isItalic;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isBold = false;
                isItalic = false;
            }
            else
            {
                isBold = p->Bold;
                isItalic = p->Italic;
            }

            Font^ f;
            if (!p->Underline)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Underline |
                                   (isItalic ? (int)FontStyle::Italic : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isItalic ? (int)FontStyle::Italic : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            return f;
        } 
        #pragma endregion

        #pragma region SetFontBold
        static Font^ SetFontBold(Font^ p,bool isBold)
        {
            bool isItalic, isUnderline;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isItalic = false;
                isUnderline = false;
            }
            else
            {
                isItalic = p->Italic;
                isUnderline = p->Underline;
            }

            Font^ f;
            if (isBold)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Bold |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isItalic ? (int)FontStyle::Italic : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isItalic ? (int)FontStyle::Italic : 0)));
            }
            return f;
        }
        #pragma endregion

        #pragma region SetFontItalic
        static Font^ SetFontItalic(Font^ p,bool isItalic)
        {
            bool isBold, isUnderline;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isBold = false;
                isUnderline = false;
            }
            else
            {
                isBold = p->Bold;
                isUnderline = p->Underline;
            }

            Font^ f;
            if (isItalic)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Italic |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isUnderline ? (int)FontStyle::Underline : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            return f;
        }
        #pragma endregion

        #pragma region SetFontUnderline
        static Font^ SetFontUnderline(Font^ p,bool isUnderlined)
        {
            bool isBold, isItalic;

            if (p == nullptr)
            {
                p = gcnew Font("Arial", 10);
                isBold = false;
                isItalic = false;
            }
            else
            {
                isBold = p->Bold;
                isItalic = p->Italic;
            }

            Font^ f;
            if (isUnderlined)
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Underline |
                                   (isItalic ? (int)FontStyle::Italic : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            else
            {
                f = gcnew Font(p, (FontStyle)((int)FontStyle::Regular |
                                   (isItalic ? (int)FontStyle::Italic : 0) |
                                   (isBold ? (int)FontStyle::Bold : 0)));
            }
            return f;
        }
        #pragma endregion

	};
}
