public MainWindow()
        {
            Configuration.Load(false);
            Version.AddExternalChanges();

            // choose language
            if (!LanguageWindow.ShowSelection(Configuration.Language))
            {
                Close();
                return;
            }

            if (Configuration.Language != Localization.LanguageIndex)
            {
                Configuration.Language = Localization.LanguageIndex;
            }
            Version.AddExternalChanges();
            // init main window
            InitializeComponent();

            // set title
            this.Title = string.Format("{0} {1}", Localization.Get("Name"), Version.PatcherVersion);

            // set search path in ui
            SetBrowsePath();

            SetLocalizedUIElements();
            DisplayLicense();
        }
        public static bool ShowSelection()
        {
            LanguageWindow win = new LanguageWindow();
            ComboBox       cb  = win.comboBox;

            cb.ItemsSource = Localization.Translations.Select(t => t.Name);

            string culture = "en";

            CultureInfo info = CultureInfo.CurrentCulture;

            if (info != null)
            {
                for (int i = 0; i < 3; i++) // just to be safe, I don't know enough about cultureinfos
                {
                    CultureInfo parent = info.Parent;
                    if (parent == null || string.IsNullOrWhiteSpace(parent.Name))
                    {
                        break;
                    }
                    info = parent;
                }

                culture = info.Name;
            }

            cb.SelectedIndex = Localization.GetLangByCulture(culture);
            win.UpdateTexts();

            return(win.ShowDialog() == true);
        }
        public MainWindow()
        {
            // choose language
            if (!LanguageWindow.ShowSelection())
            {
                Close();
                return;
            }

            // init main window
            InitializeComponent();

            // set title
            this.Title = string.Format("{0} {1}", Localization.Get("Name"), Version.PatcherVersion);

            // check if we can already find the steam path
            const string key   = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 40970";
            RegistryKey  myKey = Registry.LocalMachine.OpenSubKey(key, false);

            if (myKey != null && myKey.GetValue("InstallLocation") is string path && !string.IsNullOrWhiteSpace(path))
            {
                pTextBoxPath.Text = path;
            }

            // fill setup options list
            FillTreeView(Version.Changes);

            // set translated ui elements
            pathBox.Text             = Localization.Get("ui_searchpath");
            pButtonCancel.Content    = Localization.Get("ui_cancel");
            pButtonContinue.Content  = Localization.Get("ui_continue");
            pButtonSearch.Content    = Localization.Get("ui_search");
            pButtonUninstall.Content = Localization.Get("ui_uninstall");
            iButtonBack.Content      = Localization.Get("ui_back");
            iButtonInstall.Content   = Localization.Get("ui_install");
            TextReferencer.SetText(linkLabel, "ui_welcometext");

            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            using (Stream stream = asm.GetManifestResourceStream("UnofficialCrusaderPatch.license.txt"))
                using (StreamReader sr = new StreamReader(stream))
                    linkLabel.Inlines.Add("\n\n\n\n\n\n" + sr.ReadToEnd());
        }
Esempio n. 4
0
        public MainWindow()
        {
            Configuration.LoadGeneral();
            Configuration.LoadChanges();

            // choose language
            if (!LanguageWindow.ShowSelection(Configuration.Language))
            {
                Close();
                return;
            }

            if (Configuration.Language != Localization.LanguageIndex)
            {
                Configuration.Language = Localization.LanguageIndex;
                Configuration.Save("Language");
            }

            // init main window
            InitializeComponent();

            // set title
            this.Title = string.Format("{0} {1}", Localization.Get("Name"), Version.PatcherVersion);

            if (!Directory.Exists(Configuration.Path))
            {
                // check if we can already find the steam path
                const string key   = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 40970";
                RegistryKey  myKey = Registry.LocalMachine.OpenSubKey(key, false);
                if (myKey != null && myKey.GetValue("InstallLocation") is string path &&
                    !string.IsNullOrWhiteSpace(path) && Patcher.CrusaderExists(path))
                {
                    pTextBoxPath.Text = path;
                }
                else if (Patcher.CrusaderExists(Environment.CurrentDirectory))
                {
                    pTextBoxPath.Text = Environment.CurrentDirectory;
                }
            }