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(); }
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 } }
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 }); }