using System.Collections.Generic;

namespace PostCardHitsuji.Global
{
    public class GlobalSettings
    {
        //DAOクラス
        public static readonly string yearDao_ = "PostCardHitsuji.DataClient.DAO.YearDao";
        public static readonly string colorDao_ = "PostCardHitsuji.DataClient.DAO.ColorDao";
        public static readonly string groupDao_ = "PostCardHitsuji.DataClient.DAO.GroupDao";
        public static readonly string fontDao_ = "PostCardHitsuji.DataClient.DAO.FontDao";
        public static readonly string addressDao_ = "PostCardHitsuji.DataClient.DAO.AddressDao";
        public static readonly string personDao_ = "PostCardHitsuji.DataClient.DAO.PersonDao";
        public static readonly string personImageDao_ = "PostCardHitsuji.DataClient.DAO.PersonImageDao";
        public static readonly string dbUtilDao_ = "PostCardHitsuji.DataClient.DAO.DbUtilDao";
        public static readonly string illLayoutDao_ = "PostCardHitsuji.DataClient.DAO.IllustLayoutDao";
        public static readonly string mappingLayoutDao_ = "PostCardHitsuji.DataClient.DAO.MappingLayoutDao";

        public static List<KeyValuePair<string, string>> NameSuffix = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("", ""),
                new KeyValuePair<string, string>("SAN", "さん"),
                new KeyValuePair<string, string>("SANHE", "さんへ"),
                new KeyValuePair<string, string>("SAMA", "様"),
                new KeyValuePair<string, string>("SAMAKATA", "様方"),
                new KeyValuePair<string, string>("SAMAHE", "様へ"),
                new KeyValuePair<string, string>("KUN", "君"),
                new KeyValuePair<string, string>("KUNHE", "君へ"),
                new KeyValuePair<string, string>("CHAN", "ちゃん"),
                new KeyValuePair<string, string>("CHANHE", "ちゃんへ"),
                new KeyValuePair<string, string>("DONO", "殿")
            };
        public static string getNameSuffixByKey(string key)
        {
            foreach (var kvp in NameSuffix) 
                if (kvp.Key.Equals(key)) return kvp.Value;
            return "";
        }

        public static List<KeyValuePair<string, string>> SizeItems = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("6", "６"   ),
                new KeyValuePair<string, string>("7", "７"   ),
                new KeyValuePair<string, string>("8", "８"   ),
                new KeyValuePair<string, string>("9", "９"   ),
                new KeyValuePair<string, string>("10", "１０"),
                new KeyValuePair<string, string>("11", "１１"),
                new KeyValuePair<string, string>("12", "１２"),
                new KeyValuePair<string, string>("13", "１３"),
                new KeyValuePair<string, string>("14", "１４"),
                new KeyValuePair<string, string>("15", "１５"),
                new KeyValuePair<string, string>("16", "１６"),
                new KeyValuePair<string, string>("17", "１７"),
                new KeyValuePair<string, string>("18", "１８"),
                new KeyValuePair<string, string>("19", "１９"),
                new KeyValuePair<string, string>("20", "２０"),
                new KeyValuePair<string, string>("21", "２１"),
                new KeyValuePair<string, string>("22", "２２"),
                new KeyValuePair<string, string>("23", "２３"),
                new KeyValuePair<string, string>("24", "２４"),
                new KeyValuePair<string, string>("25", "２５"),
                new KeyValuePair<string, string>("26", "２６"),
                new KeyValuePair<string, string>("27", "２７"),
                new KeyValuePair<string, string>("28", "２８"),
                new KeyValuePair<string, string>("29", "２９"),
                new KeyValuePair<string, string>("30", "３０")
            };

        public static List<KeyValuePair<string, string>> MultipleItems = new List<KeyValuePair<string, string>>
            {
                

                new KeyValuePair<string, string>("0.1", "x０.１"),
                new KeyValuePair<string, string>("0.2", "x０.２"),
                new KeyValuePair<string, string>("0.3", "x０.３"),
                new KeyValuePair<string, string>("0.4", "x０.４"),
                new KeyValuePair<string, string>("0.5", "x０.５"),
                new KeyValuePair<string, string>("0.6", "x０.６"),
                new KeyValuePair<string, string>("0.7", "x０.７"),
                new KeyValuePair<string, string>("0.8", "x０.８"),
                new KeyValuePair<string, string>("0.9", "x０.９"),
                new KeyValuePair<string, string>("1", "x１"),
                new KeyValuePair<string, string>("1.1", "x１.１"),
                new KeyValuePair<string, string>("1.2", "x１.２"),
                new KeyValuePair<string, string>("1.3", "x１.３"),
                new KeyValuePair<string, string>("1.4", "x１.４"),
                new KeyValuePair<string, string>("1.5", "x１.５"),
                new KeyValuePair<string, string>("1.6", "x１.６"),
                new KeyValuePair<string, string>("1.7", "x１.７"),
                new KeyValuePair<string, string>("1.8", "x１.８"),
                new KeyValuePair<string, string>("1.9", "x１.９"),
                new KeyValuePair<string, string>("2", "x２"),
                new KeyValuePair<string, string>("2.1", "x２.１"),
                new KeyValuePair<string, string>("2.2", "x２.２"),
                new KeyValuePair<string, string>("2.3", "x２.３"),
                new KeyValuePair<string, string>("2.4", "x２.４"),
                new KeyValuePair<string, string>("2.5", "x２.５"),
                new KeyValuePair<string, string>("2.6", "x２.６"),
                new KeyValuePair<string, string>("2.7", "x２.７"),
                new KeyValuePair<string, string>("2.8", "x２.８"),
                new KeyValuePair<string, string>("2.9", "x２.９"),
                new KeyValuePair<string, string>("3", "x３"     )
            };

        public static System.Drawing.Color RESEIVER_RECTABGLE_COLOR = System.Drawing.Color.LightGreen;
        public static System.Drawing.Color SENDER_RECTABGLE_COLOR = System.Drawing.Color.LightBlue;
        
        private const string RESEIVER = "（Ｒ）";
        private const string SENDER = "（Ｓ）";

        #region 宛先情報文字列

        public static KeyValuePair<string, string> RESEIVER_POSTAL = new KeyValuePair<string, string>("RESEIVER_POSTAL", "〒番号" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_ADDRESS1 = new KeyValuePair<string, string>("RESEIVER_ADDRESS1", "▼住所１" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_ADDRESS2 = new KeyValuePair<string, string>("RESEIVER_ADDRESS2", "▼住所２" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_ADDRESS3 = new KeyValuePair<string, string>("RESEIVER_ADDRESS3", "▼住所３" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_NAME1 = new KeyValuePair<string, string>("RESEIVER_NAME1", "★名前１" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_NAME2 = new KeyValuePair<string, string>("RESEIVER_NAME2", "★名前２" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_NAME3 = new KeyValuePair<string, string>("RESEIVER_NAME3", "★名前３" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_NAME4 = new KeyValuePair<string, string>("RESEIVER_NAME4", "★名前４" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_SUFFIX1  = new KeyValuePair<string, string>("RESEIVER_SUFFIX1", "敬称１" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_SUFFIX2  = new KeyValuePair<string, string>("RESEIVER_SUFFIX2", "敬称２" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_SUFFIX3  = new KeyValuePair<string, string>("RESEIVER_SUFFIX3", "敬称３" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_SUFFIX4  = new KeyValuePair<string, string>("RESEIVER_SUFFIX4", "敬称４" + RESEIVER);
        public static KeyValuePair<string, string> RESEIVER_PRE1     = new KeyValuePair<string, string>("RESEIVER_PRE1", "１");
        public static KeyValuePair<string, string> RESEIVER_PRE2     = new KeyValuePair<string, string>("RESEIVER_PRE2", "２");
        public static KeyValuePair<string, string> RESEIVER_PRE3     = new KeyValuePair<string, string>("RESEIVER_PRE3", "３");
        public static KeyValuePair<string, string> RESEIVER_POST1    = new KeyValuePair<string, string>("RESEIVER_POST1", "４");
        public static KeyValuePair<string, string> RESEIVER_POST2    = new KeyValuePair<string, string>("RESEIVER_POST2", "５");
        public static KeyValuePair<string, string> RESEIVER_POST3    = new KeyValuePair<string, string>("RESEIVER_POST3", "６");
        public static KeyValuePair<string, string> RESEIVER_POST4    = new KeyValuePair<string, string>("RESEIVER_POST4", "７");
        
        public static List<KeyValuePair<string, string>> ReseiverItems = new List<KeyValuePair<string, string>>
            {
                RESEIVER_POSTAL,
                RESEIVER_ADDRESS1,
                RESEIVER_ADDRESS2,
                RESEIVER_ADDRESS3,
                RESEIVER_NAME1,
                RESEIVER_NAME2,
                RESEIVER_NAME3,
                RESEIVER_NAME4,
                RESEIVER_SUFFIX1,
                RESEIVER_SUFFIX2,
                RESEIVER_SUFFIX3,
                RESEIVER_SUFFIX4,
                RESEIVER_PRE1,
                RESEIVER_PRE2,
                RESEIVER_PRE3,
                RESEIVER_POST1,
                RESEIVER_POST2,
                RESEIVER_POST3,
                RESEIVER_POST4
            };
        #endregion

        #region 発送者情報文字列

        public static KeyValuePair<string, string> SENDER_POSTAL = new KeyValuePair<string, string>("SENDER_POSTAL", "〒番号" + SENDER);
        public static KeyValuePair<string, string> SENDER_ADDRESS1 = new KeyValuePair<string, string>("SENDER_ADDRESS1", "▼住所１" + SENDER);
        public static KeyValuePair<string, string> SENDER_ADDRESS2 = new KeyValuePair<string, string>("SENDER_ADDRESS2", "▼住所２" + SENDER);
        public static KeyValuePair<string, string> SENDER_ADDRESS3 = new KeyValuePair<string, string>("SENDER_ADDRESS3", "▼住所３" + SENDER);
        public static KeyValuePair<string, string> SENDER_NAME1 = new KeyValuePair<string, string>("SENDER_NAME1", "★名前１" + SENDER);
        public static KeyValuePair<string, string> SENDER_NAME2 = new KeyValuePair<string, string>("SENDER_NAME2", "★名前２" + SENDER);
        public static KeyValuePair<string, string> SENDER_NAME3 = new KeyValuePair<string, string>("SENDER_NAME3", "★名前３" + SENDER);
        public static KeyValuePair<string, string> SENDER_NAME4 = new KeyValuePair<string, string>("SENDER_NAME4", "★名前４" + SENDER);
        public static KeyValuePair<string, string> SENDER_PRE1 = new KeyValuePair<string, string>("SENDER_PRE1", "１");
        public static KeyValuePair<string, string> SENDER_PRE2 = new KeyValuePair<string, string>("SENDER_PRE2", "２");
        public static KeyValuePair<string, string> SENDER_PRE3 = new KeyValuePair<string, string>("SENDER_PRE3", "３");
        public static KeyValuePair<string, string> SENDER_POST1 = new KeyValuePair<string, string>("SENDER_POST1", "４");
        public static KeyValuePair<string, string> SENDER_POST2 = new KeyValuePair<string, string>("SENDER_POST2", "５");
        public static KeyValuePair<string, string> SENDER_POST3 = new KeyValuePair<string, string>("SENDER_POST3", "６");
        public static KeyValuePair<string, string> SENDER_POST4 = new KeyValuePair<string, string>("SENDER_POST4", "７");
        public static KeyValuePair<string, string> SENDER_TEL = new KeyValuePair<string, string>("SENDER_TEL", "ＴＥＬ" + SENDER);
        
        public static List<KeyValuePair<string, string>> SenderItems = new List<KeyValuePair<string, string>>
            {
                SENDER_POSTAL,
                SENDER_ADDRESS1,
                SENDER_ADDRESS2,
                SENDER_ADDRESS3,
                SENDER_NAME1,
                SENDER_NAME2,
                SENDER_NAME3,
                SENDER_NAME4,
                SENDER_PRE1,
                SENDER_PRE2,
                SENDER_PRE3,
                SENDER_POST1,
                SENDER_POST2,
                SENDER_POST3,
                SENDER_POST4,
                SENDER_TEL
            };
        #endregion


        private static object locker_fontNames = new object();
        private static List<string> FontNames;
        //フォント名取得
        public static List<string> prepareFontNames()
        {
            lock (locker_fontNames)
            {
                if (FontNames != null)
                    return FontNames;

                var fs = new System.Drawing.Text.InstalledFontCollection().Families;
                FontNames = new List<string>();
                foreach (var font in fs)
                {
                    try
                    {// 対策：'Regular' サポート
                        new System.Drawing.Font(font.Name, 10);
                        FontNames.Add(font.Name);
                    }
                    catch (System.ArgumentException ex)
                    {
                        //System.Diagnostics.Debug.WriteLine(ex.ToString());
                    }
                }
            }
            return FontNames;
        }

        private static object locker = new object();
        private static Dictionary<string, System.Drawing.Printing.PaperSize> PaperSizes;
        //用紙サイズ名取得
        public static Dictionary<string, System.Drawing.Printing.PaperSize> preparePaperSizes()
        {
            lock (locker)
            {
                if (PaperSizes != null)
                    return PaperSizes;
                
                var PaperSizes_ = new Dictionary<string, System.Drawing.Printing.PaperSize>();
                System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
                var sizes = pd.PrinterSettings.PaperSizes;
                foreach(System.Drawing.Printing.PaperSize p in sizes)
                    PaperSizes_.Add(p.PaperName, p);
                PaperSizes = PaperSizes_;
                return PaperSizes;
            }
        }
        
        public class PaperVertical
        {
            /// <summary>
            /// はがきの長さ（短い方）
            /// </summary>
            public static int PAPER_WIDTH = 394;
            /// <summary>
            /// はがきの長さ（長い方）
            /// </summary>
            public static int PAPER_HEIGHT = 583;
        }

        public class PaperHorizonal
        {
            /// <summary>
            /// はがきの長さ（短い方）
            /// </summary>
            public static int PAPER_WIDTH = 583;
            /// <summary>
            /// はがきの長さ（長い方）
            /// </summary>
            public static int PAPER_HEIGHT = 394;
        }
    }
}
