using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Sched.CustomClasses;

namespace Sched
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    /// 

    public partial class App : Application
    {
        public const string AppName = "Schedule Editor";
        //public const string DBFile = "URI=file:Database/SchedDB.db";
        public static string DBFile = System.Configuration.ConfigurationManager.ConnectionStrings["SchedDB"].ConnectionString;
        public static string _languageISOCode = "en-US";
        public static int _languageResDictIndex = 0;

        public void UpdateLanguage(string langISOCode)
        {
            for (int i = Application.Current.Resources.MergedDictionaries.Count - 1; i >= 0; i--)
            {
                var ResDict = Application.Current.Resources.MergedDictionaries[i];

                if ((string)ResDict["languageISOCode"] == langISOCode)
                {                   
                    Application.Current.Resources.MergedDictionaries.RemoveAt(i);
                    Application.Current.Resources.MergedDictionaries.Add(ResDict);
                    _languageISOCode = langISOCode;
                    _languageResDictIndex = Application.Current.Resources.MergedDictionaries.Count - 1;
                    break;
                }

            }
        }
    }
}
