Exemplo n.º 1
0
        public MainForm(LanguageCatalog languageCatalog, IEnumerable <IPatchTarget> containers)
        {
            InitializeComponent();

            this.languageCatalog = languageCatalog ?? throw new ArgumentNullException(nameof(languageCatalog));
            this.containers      = containers ?? throw new ArgumentNullException(nameof(containers));

            // Save the selected file text so we can set it again when resetting the form.
            defaultSelectedFileText = labelSelectedFile.Text;

            // Hide the newest version label and update button. They will be shown when the user clicks check update.
            labelNewestLangVersion.Visible = false;
            buttonLanguageUpdate.Visible   = false;

            // Load the translations from a file if it exists (downloaded via update) or the resource if not
            localLanguageFile = Path.Join(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                Properties.Resources.LanguageLocalFile
                );

            if (File.Exists(localLanguageFile))
            {
                languageCatalog.LoadTranslations(new FileInfo(localLanguageFile));
            }
            else
            {
                using var stream = new MemoryStream(Properties.Resources.LoTranslation);
                languageCatalog.LoadTranslations(stream);
            }

            Debug.WriteLine($"Loaded {languageCatalog.Catalog.Count:N0} language entries");

            // Display any translation catalog errors to the user. We continue so the user can attempt to update the
            // broken translations.
            if (languageCatalog.Errors.Any())
            {
                ErrorMessage(
                    Properties.Resources.ErrorModalTranslationParse,
                    string.Join("\r\n", languageCatalog.Errors)
                    );
            }

            patchWorker.OnComplete           += PatchWorker_OnComplete;
            languageUpdateChecker.OnComplete += LanguageUpdateChecker_OnComplete;
            languageUpdater.OnComplete       += LanguageUpdater_OnComplete;

            DragEnter += MainForm_DragEnter;
            DragDrop  += MainForm_DragDrop;

            ResetForm();
        }
Exemplo n.º 2
0
        private static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var languageCatalog = new LanguageCatalog();

            var targets = new List <IPatchTarget>()
            {
                new SerializedDataTarget(languageCatalog),
                new LocalizationPatchTarget(languageCatalog),
            };

            var containers = new List <IPatchTarget>()
            {
                new AssetBundleContainer(targets),
                new ExtractedAssetContainer(targets),
            };

            using var form = new MainForm(languageCatalog, containers);
            Application.Run(form);
        }