Exemple #1
0
        public ConfigParser()
        {
            _configParser = this;
            Stream mainXmlStream = ResourcesUtils.GetEmbeddedResourceStream(null, "main.xml");

            if (mainXmlStream == null)
            {
                mainXmlStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("<Main><Products></Products></Main>"));
            }

            Stream configXmlStream = ResourcesUtils.GetEmbeddedResourceStream(null, "config.xml");

            if (configXmlStream == null)
            {
#if DEBUG
                Logger.GetLogger().Error("No resource called config.xml");
#endif
            }

            ReadXmlFiles(new Stream[] { mainXmlStream, configXmlStream });

            ReadResourcesToXml();
            ReadCmdToXml();
            ReadConfigSettings();

            SetFormDesign();
            SetPagesDesign();
        }
Exemple #2
0
        private void LoadEmbeddedResourceFont(string resourceName)
        {
            string fileName = tempFontsFolder + resourceName;

            if (ResourcesUtils.WriteResourceToFile(resourceName, fileName))
            {
                pfc.AddFontFile(fileName);
            }
        }
Exemple #3
0
        private void ReadResourcesToXml()
        {
            Dictionary <string, string> resourceSet = ResourcesUtils.GetPropertiesResources(null);

#if DEBUG
            Logger.GetLogger().Info("Adding dynamic config from resources.");
#endif
            foreach (KeyValuePair <string, string> entry in resourceSet)
            {
                SetConfigValue(entry.Key, entry.Value);
            }
        }
Exemple #4
0
        public void SetTaskbarIcon()
        {
            if (ResourcesUtils.EmbeddedResourceExists(null, ".ico"))
            {
                Icon = new System.Drawing.Icon(ResourcesUtils.GetEmbeddedResourceStream(null, ".ico"));
            }
            else
            {
#if DEBUG
                Logger.GetLogger().Warning("Set at least one icon as embedded resource so that it will be found by " + GetType().Name);
#endif
            }
        }
Exemple #5
0
        private CmdReader(string[] args)
        {
            CmdParams = ResourcesUtils.GetCmdAsDictionary(args);
            if (CmdParams.ContainsKey("log"))
            {
#if DEBUG
                if (CmdParams.ContainsKey("verbose"))
                {
                    Logger.GetLogger().ActivateLogger(CmdParams["log"], CmdParams["verbose"]);
                }
                else
                {
                    Logger.GetLogger().ActivateLogger(CmdParams["log"]);
                }
                Logger.GetLogger().Info("--- Command line args: " + string.Join(" ", args.ToArray()));
#endif
            }
        }
Exemple #6
0
        private void SetLocaleCode()
        {
            LocaleCode = GetConfigValue("DEFAULT_LOCALE", "en");
            string tmpLocale = LocaleCode;

            switch (GetConfigValue("LOCALE").ToLower())
            {
            case "oslang":
                CultureInfo ci = CultureInfo.CurrentUICulture;
                string      localeCodeCandidate = ci.TwoLetterISOLanguageName;
#if DEBUG
                Logger.GetLogger().Info("Detected OS display language code: " + localeCodeCandidate);
#endif
                if (ResourcesUtils.EmbeddedResourceExists(null, localeCodeCandidate + ".locale"))
                {
                    tmpLocale = localeCodeCandidate;
                }
                break;

            case "userselected":
                tmpLocale = (string.IsNullOrEmpty(userSelectedLocale)) ? tmpLocale : userSelectedLocale;
                break;
            }

            if (!ResourcesUtils.EmbeddedResourceExists(null, tmpLocale + ".locale"))
            {
#if DEBUG
                Logger.GetLogger().Info($"requested locale ({tmpLocale}) is missing from resources. default locale will be taken: {LocaleCode}");
#endif
                tmpLocale = LocaleCode;
            }
            LocaleCode = tmpLocale;
            Stream localeXmlStream = ResourcesUtils.GetEmbeddedResourceStream(null, LocaleCode + ".locale");
#if DEBUG
            Logger.GetLogger().Info($"Chosen locale: {LocaleCode}");
            if (localeXmlStream == null)
            {
                Logger.GetLogger().Fatal($"Chosen locale: {LocaleCode} is missing from resources");
            }
#endif
            ReadXmlFiles(new Stream[] { localeXmlStream });
        }
Exemple #7
0
 private bool IsFontEmbeddedResource(string resourceName)
 {
     return(ResourcesUtils.EmbeddedResourceExists(null, resourceName));
 }
Exemple #8
0
        public List <string> LoadLocaleList()
        {
            List <string> res = ResourcesUtils.GetEmbeddedResourceNames(null, ".locale");

            return(res);
        }