Пример #1
0
        //Methods

        public MainWindow()
        {
#if !DEBUG
            try
#endif
            {
                //Tooltip
                ToolTipService.ShowDurationProperty.OverrideMetadata(
                    typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue));

                //CultureInfo
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

                //Init window
                InitializeComponent();
                DataContext = this;

                //Load installinfo
                LoadInstallInfoZip();
                LoadDefaultBrushes();
                LoadTitleBarBrushes();

                //Load settings
                settings = Settings.GameDirXml.LoadSettings();

                //Find game dir, init fileIO
                InitGameDir();
                InitFileIO();

                //Init UI
                StateInit();
                UpdateUI();
            }
#if !DEBUG
            catch (Exception ex)
            {
                SaveErrorLog(ex.ToString());
                MessageBox.Show(String.Format("A fatal exception has occured and cannot be recovered from.\n\nException:\n{0}\n\n---------------------------------\nPlease note that this application requires .NET Framework 4.7 or greater, so ensure that you have that installed.", ex.ToString()), "Fatal Exception", MessageBoxButton.OK, MessageBoxImage.Stop);
                ShutdownApp();
            }
#endif
        }
Пример #2
0
        public static GameDirXml LoadSettings()
        {
            try
            {
                //Try to load the settings
                YAXSerializer serializer = new YAXSerializer(typeof(GameDirXml), YAXSerializationOptions.DontSerializeNullObjects);
                return((GameDirXml)serializer.DeserializeFromFile(GeneralInfo.SettingsPath));
            }
            catch
            {
                //If it fails, create a new instance and save it to disk.
                var newSettings = new GameDirXml()
                {
                    GameDirectory = null
                };

                newSettings.SaveSettings();

                return(newSettings);
            }
        }