Exemplo n.º 1
0
        public MainWindow()
        {
            if (Application.Current.Properties.Contains("FileToLoad"))
            {
                isApplyingTranslationOnStartup = true;
                settingsPath = (string)Application.Current.Properties["FileToLoad"];
            }

            InitializeComponent();

            buttonApplyAll.Content = Settings.Strings["MainWindow_Button_ApplyAll"];
            buttonSaveConfig.Content = Settings.Strings["MainWindow_Button_SaveConfig"];

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.FileName = "Content.ggpk";
            try
            {
                ofd.Filter = Settings.Strings["Load_GGPK_Filter"];

            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Settings.Strings["MainWindow_InvalidFileFilter"], ex.Message), Settings.Strings["Error"], MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }
            ofd.CheckFileExists = true;

            if (ofd.ShowDialog() == true)
            {
                ggpkPath = ofd.FileName;
            }
            else
            {
                return;
            }

            listBoxFiles.Items.SortDescriptions.Clear();
            listBoxFiles.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Key", System.ComponentModel.ListSortDirection.Ascending));

            Thread driverThread = new Thread(new ThreadStart(() =>
            {
                backend = new Backend(Output, settingsPath);
                backend.ReloadAllData(ggpkPath);
                OnBackendLoaded();
            }));

            driverThread.Start();
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            if (Application.Current.Properties.Contains("FileToLoad"))
            {
                isApplyingTranslationOnStartup = true;
                settingsPath = (string)Application.Current.Properties["FileToLoad"];
            }

            InitializeComponent();

            buttonApplyAll.Content       = Settings.Strings["MainWindow_Button_ApplyAll"];
            buttonSaveConfig.Content     = Settings.Strings["MainWindow_Button_SaveConfig"];
            buttonApplyAllToFile.Content = Settings.Strings["MainWindow_Button_ApplyAllToFile"];
            buttonSerialize.Content      = Settings.Strings["MainWindow_Button_Serialize"];

            OpenFileDialog ofd = new OpenFileDialog
            {
                AddExtension    = true,
                CheckFileExists = true,
                DefaultExt      = "ggpk",
                FileName        = "Content.ggpk",
            };

            try
            {
                ofd.Filter = Settings.Strings["Load_GGPK_Filter"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Settings.Strings["MainWindow_InvalidFileFilter"], ex.Message), Settings.Strings["Error"], MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (ofd.ShowDialog() == true)
            {
                if (System.IO.Path.GetExtension(ofd.FileName).ToLower() == ".bin")
                {
                    binPath      = ofd.FileName;
                    ofd.FileName = "Content.ggpk";
                    if (ofd.ShowDialog() == true)
                    {
                        ggpkPath = ofd.FileName;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    ggpkPath = ofd.FileName;
                }
            }
            else
            {
                return;
            }

            listBoxFiles.Items.SortDescriptions.Clear();
            listBoxFiles.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Key", System.ComponentModel.ListSortDirection.Ascending));

            Thread driverThread = new Thread(new ThreadStart(() =>
            {
                backend = new Backend(Output, settingsPath);
                if (binPath != null)
                {
                    backend.ReloadAllData(ggpkPath, binPath);
                }
                else
                {
                    backend.ReloadAllData(ggpkPath);
                }
                OnBackendLoaded();
            }));

            driverThread.Start();
        }