Example #1
0
        private void PathChanged()
        {
            bool flag = RW.RWPath != null && System.IO.Directory.Exists(RW.RWPath);

            PathSelected.IsChecked = ScanRailworks.IsEnabled = flag;

            if (flag)
            {
                TotalProgress.Dispatcher.Invoke(() => TotalProgress.Value = 0);

                App.Railworks = new Railworks(RW.RWPath);
                App.Railworks.ProgressUpdated  += RW_ProgressUpdated;
                App.Railworks.RouteSaving      += RW_RouteSaving;
                App.Railworks.CrawlingComplete += RW_CrawlingComplete;

                RW = App.Railworks;

                App.PackageManager = new PackageManager(ApiUrl, this, RW.RWPath);
                PM = App.PackageManager;

                Title = $"Railworks DLS client v{App.Version} - " + RW.RWPath;

                LoadRoutes();
            }
        }
Example #2
0
        private void PathChanged()
        {
            bool flag = RW.RWPath != null && System.IO.Directory.Exists(RW.RWPath);

            ScanRailworks.IsEnabled = flag;
            crawlingComplete        = false;

            if (flag)
            {
                TotalProgress.Dispatcher.Invoke(() => TotalProgress.Value = 0);

                App.Railworks = new Railworks(RW.RWPath);
                App.Railworks.ProgressUpdated  += RW_ProgressUpdated;
                App.Railworks.RouteSaving      += RW_RouteSaving;
                App.Railworks.CrawlingComplete += RW_CrawlingComplete;

                RW = App.Railworks;

                App.PackageManager = new PackageManager(ApiUrl, this, RW.RWPath);
                PM = App.PackageManager;

                Title = $"Railworks DLS client v{App.Version} - " + RW.RWPath;

                LoadRoutes();

                RoutesCount.Content = string.Format(Localization.Strings.RoutesCountLabel, RW.Routes.Count);
            }
        }
Example #3
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());
                }
            }
        }