Esempio n. 1
0
        /// <summary>
        /// Scan a directory for language xml files.
        /// </summary>
        /// <param name="path">the directory to scan</param>
        /// <returns>a list of available MLEs</returns>
        public static List <MultiLangEngine> ScanDirectory(string path)
        {
            List <MultiLangEngine> list = new List <MultiLangEngine>();

            if (Directory.Exists(path))
            {
                DirectoryInfo di = new DirectoryInfo(path);
                foreach (FileInfo fi in di.GetFiles())
                {
                    if (string.Compare(fi.Extension, ".xml", ignoreCase: true) == 0)
                    {
                        MultiLangEngine newLang = null;
                        try
                        {
                            System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                            using (FileStream fs = new FileStream(fi.FullName, System.IO.FileMode.Open))
                                using (StreamReader sr = new StreamReader(fs))
                                    xmldoc.LoadXml(sr.ReadToEnd());
                            newLang = new MultiLangEngine(xmldoc);
                        }
                        catch (Exception)
                        {
                            newLang = null;
                        }

                        if (newLang != null)
                        {
                            list.Add(newLang);
                        }
                    }
                }
            }
            return(list);
        }
        public MainWindow()
        {
            InitializeComponent();
            
            // init logger
            string logpath = System.AppDomain.CurrentDomain.BaseDirectory + @"\DWAS2.log";
            GeneralLogger.Initialize(logpath);

            // read and process configuration
            config.ReadConfig();
            ProcessConfig();

            // check hiding
            if (File.Exists(config.wpLandscape) && File.Exists(config.wpPortrait) && File.Exists(config.lcLandscape) && File.Exists(config.lcPortrait))
                this.shouldHideAtStartup = true;

            // read language
            languages = DWAS2LanguageManager.LoadLanguages();
            lang = DWAS2LanguageManager.SelectLanguage(languages, config.language);
            if(lang.Language.CompareTo(config.language) != 0)
            {
                config.language = lang.Language;
                config.SaveConfig();
            }
            // LANGUAGE IS PROCESSED IN WINDOW_LOADED EVENT HANDLER

            // read orientation
            lastOrientation = DWAS2Interop.GetDesktopOrientation(config.reverse);

            // notify icon
            InitNotifyIcon();

            // initial set
            UpdateDetection();

            // start timer
            InitTimer();
        }
 /// <summary>
 /// Extension method of String, provides a translation
 /// </summary>
 /// <param name="input">the string to translate</param>
 /// <param name="lang">the MultiLangEngine for translation</param>
 /// <returns>the translation of input</returns>
 public static string t(this string input, MultiLangEngine lang)
 {
     return lang.Translate(input);
 }
        /// <summary>
        /// Scan a directory for language xml files.
        /// </summary>
        /// <param name="path">the directory to scan</param>
        /// <returns>a list of available MLEs</returns>
        public static List<MultiLangEngine> ScanDirectory(string path)
        {
            List<MultiLangEngine> list = new List<MultiLangEngine>();
            if (Directory.Exists(path))
            {
                DirectoryInfo di = new DirectoryInfo(path);
                foreach (FileInfo fi in di.GetFiles())
                {
                    if (string.Compare(fi.Extension, ".xml", ignoreCase: true) == 0)
                    {
                        MultiLangEngine newLang = null;
                        try
                        {
                            System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                            using (FileStream fs = new FileStream(fi.FullName, System.IO.FileMode.Open))
                                using (StreamReader sr = new StreamReader(fs))
                                    xmldoc.LoadXml(sr.ReadToEnd());
                            newLang = new MultiLangEngine(xmldoc);
                        }
                        catch(Exception)
                        {
                            newLang = null;
                        }

                        if (newLang != null)
                            list.Add(newLang);
                    }
                }
            }
            return list;
        }
Esempio n. 5
0
 /// <summary>
 /// Extension method of String, provides a translation
 /// </summary>
 /// <param name="input">the string to translate</param>
 /// <param name="lang">the MultiLangEngine for translation</param>
 /// <returns>the translation of input</returns>
 public static string t(this string input, MultiLangEngine lang)
 {
     return(lang.Translate(input));
 }