示例#1
0
        public FormMain()
        {
            InitializeComponent();

            InitializeTextChangedEvent();
            InitializeFontChangedEvent();
            InitializeAdjustButtonEvent();
            InitializeResetButtonEvent();

            InitializeDefaults();

            language = Program.language;

            if (!language.id.Equals("default"))
            {
                InitializeLanguage();
            }

            ChangeLabelVisibility(false);

            openFileDialog.Filter = "Image Files|*.png";
            openFileDialog.Title  = "Load Card Image";

            saveFileDialog.Filter = "png|*.png";
        }
示例#2
0
 // Handles updating the language of all buttons. Gets the language from the Program static class and then re-initializes the buttons and labels.
 public void UpdateLanguage()
 {
     if (!language.id.Equals(Program.language.id))
     {
         language = Program.language;
         InitializeLanguage();
     }
 }
示例#3
0
        static void Main()
        {
            // Initialize our handlers and necessary stuff.
            language            = new LangFileObject();
            localizationHandler = new LocalizationHandler(); // Loads the language files on construction
            configHandler       = new ConfigHandler();

            // Load the config file.
            configHandler.LoadConfigFile();
            // Load the default language based on the config file loaded in.
            localizationHandler.LoadDefaultLanguage(configHandler.GetDefaultLanguage());

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());
        }
        // Returns a language file object by its ID
        public LangFileObject GetLanguageById(string id)
        {
            LangFileObject lang = null;

            if (CheckLanguageWithIdIsValid(id))
            {
                foreach (LangFileObject fi in languageFiles)
                {
                    if (fi.id.Equals(id))
                    {
                        lang = fi;
                        break;
                    }
                }
            }
            return(lang);
        }
        // Loads all languages in the /languages folder.
        public void LoadLanguages()
        {
            LangFileObject languageFile;

            //Console.WriteLine(string.Format("Language files found: {0}", Directory.GetFiles(JsonIO.LANGUAGE_PATH).Length)); // Debug garbage.

            // checks to see if the directory exists. If not, we will create it.
            if (!Directory.Exists(JsonIO.LANGUAGE_PATH))
            {
                Directory.CreateDirectory(JsonIO.LANGUAGE_PATH);
            }

            try {
                // We'll clear the list of languages first, in case we're reloading.
                languageFiles.Clear();

                // We run through the list of language JSON files in the languages folder.
                foreach (string path in Directory.GetFiles(JsonIO.LANGUAGE_PATH))
                {
                    if (path.Contains(".json")) // If it's a .json file...
                    {
                        // Create a new language object. If this isn't here, the languageFile data and ID are never updated.
                        languageFile = new LangFileObject();
                        // Console.WriteLine("Language file: {0}", path); // Debug garbage.
                        languageFile.data = JsonIO.ReadJsonFile(path, false).data;
                        languageFile.id   = languageFile.GetValue(LanguageFileConsts.KEY_LANGUAGE);

                        // Make sure we're not loading a duplicate.
                        if (!CheckLanguageWithIdIsValid(languageFile.id))
                        {
                            languageFiles.Add(languageFile);
                        }
                        else
                        {
                            Console.WriteLine("Language file with this ID already exists.");
                        }
                    }
                }
            } catch (Exception e)
            {
                Console.WriteLine(string.Format("Unable to load language files. Error: {0}", e));
            }
        }