Beispiel #1
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                Title = $"Railworks DLS client v{App.Version}";

                App.Window = this;

                try
                {
                    App.SteamManager = new SteamManager();
                }
                catch
                {
                    Debug.Assert(false, "Initialision of SteamManager failed!");
                }

                Closing += MainWindowDialog_Closing;

                string savedRWPath = Settings.Default.RailworksLocation;
                App.Railworks = new Railworks(string.IsNullOrWhiteSpace(savedRWPath) ? App.SteamManager.RWPath : savedRWPath);
                App.Railworks.ProgressUpdated  += RW_ProgressUpdated;
                App.Railworks.RouteSaving      += RW_RouteSaving;
                App.Railworks.CrawlingComplete += RW_CrawlingComplete;

                RW = App.Railworks;

                try
                {
                    Updater updater = new Updater();
#if !DEBUG
                    if (updater.CheckUpdates(ApiUrl))
                    {
                        Task.Run(async() =>
                        {
                            await updater.UpdateAsync();
                        });
                    }
                    else
                    {
#endif
                    if (string.IsNullOrWhiteSpace(RW.RWPath))
                    {
                        RailworksPathDialog rpd = new RailworksPathDialog();
                        rpd.ShowAsync();
                    }

                    if (string.IsNullOrWhiteSpace(Settings.Default.RailworksLocation) && !string.IsNullOrWhiteSpace(RW.RWPath))
                    {
                        Settings.Default.RailworksLocation = RW.RWPath;
                        Settings.Default.Save();
                    }

                    PathChanged();

                    Settings.Default.PropertyChanged += PropertyChanged;

                    DownloadDialog.Owner = this;

                    RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true).OpenSubKey("Classes", true).CreateSubKey("dls");
                    key.SetValue("URL Protocol", "");
                    //key.SetValue("DefaultIcon", "");
                    key.CreateSubKey(@"shell\open\command").SetValue("", $"\"{System.Reflection.Assembly.GetEntryAssembly().Location}\" \"%1\"");

                    if (RW.RWPath != null && System.IO.Directory.Exists(RW.RWPath))
                    {
                        Task.Run(async() =>
                        {
                            RW_CheckingDLC(false);
                            List <SteamManager.DLC> dlcList = App.SteamManager.GetInstalledDLCFiles();
                            await WebWrapper.ReportDLC(dlcList, ApiUrl);
                            RW_CheckingDLC(true);
                        });
                    }
#if !DEBUG
                }
#endif
                }
                catch (Exception e)
                {
                    Trace.Assert(false, $"Updater panic!\n{e}");
                }
            }
            catch (Exception e)
            {
                if (e.GetType() != typeof(ThreadInterruptedException) && e.GetType() != typeof(ThreadAbortException))
                {
                    Trace.Assert(false, e.ToString());
                }
            }
        }
Beispiel #2
0
        private void SelectRailworksLocation_Click(object sender, RoutedEventArgs e)
        {
            RailworksPathDialog rpd = new RailworksPathDialog();

            rpd.ShowAsync();
        }