public static void Open([NotNull] CarObject car, CarSetupsRemoteSource forceRemoteSource = CarSetupsRemoteSource.None, bool forceNewWindow = false)
        {
            if (forceNewWindow ||
                Keyboard.Modifiers == ModifierKeys.Control && !User32.IsAsyncKeyPressed(System.Windows.Forms.Keys.K) ||
                !(Application.Current?.MainWindow is MainWindow main) || !main.IsActive ||
                SettingsHolder.Interface.SkinsSetupsNewWindow)
            {
                CarSetupsDialog.Show(car, forceRemoteSource);
                return;
            }

            var remoteLinksStatus = GetRemoteLinksStatus();

            if (remoteLinksStatus != _remoteLinksStatus)
            {
                _remoteLinksStatus = remoteLinksStatus;
                main.MenuLinkGroups.RemoveRange(main.MenuLinkGroups.OfType <LinkGroupFilterable>().Where(x => x.GroupKey == "setups").ToList());
            }

            var existing = main.OpenSubGroup("setups", $"Setups for {car.DisplayName}",
                                             UriExtension.Create("/Pages/Lists/CarSetupsListPage.xaml?CarId={0}", car.Id), FilterHints.CarSetups);

            foreach (var link in GetRemoteLinks(car.Id))
            {
                existing.FixedLinks.Add(link);
            }
            if (forceRemoteSource != CarSetupsRemoteSource.None)
            {
                existing.SetSelected(GetRemoteSourceUri(car.Id, forceRemoteSource));
            }
        }
Exemple #2
0
        public static void NavigateToCareerPage([CanBeNull] KunosCareerObject kunosCareer)
        {
            var mainWindow = Application.Current?.MainWindow as MainWindow;
            var group      = mainWindow?.MenuLinkGroups.FirstOrDefault(x => x.GroupKey == "drive" && x.DisplayName == AppStrings.Main_Single);
            var links      = group?.Links;

            links?.Remove(links.OfType <CustomLink>().FirstOrDefault(x => x.Source?.OriginalString.StartsWith(@"/Pages/Drive/KunosCareer_SelectedPage.xaml") == true));

            if (kunosCareer == null)
            {
                mainWindow?.NavigateTo(new Uri("/Pages/Drive/KunosCareer.xaml", UriKind.RelativeOrAbsolute));
                return;
            }

            var uri = UriExtension.Create("/Pages/Drive/KunosCareer_SelectedPage.xaml?Id={0}", kunosCareer.Id);

            if (links == null)
            {
                LinkCommands.NavigateLink.Execute(uri, null);
                return;
            }

            var link = new CustomLink {
                DisplayName = kunosCareer.DisplayName,
                Source      = uri
            };

            links.Insert(2, link);
            mainWindow.NavigateTo(link.Source);
        }
        public static void NavigateToChampionshipPage(UserChampionshipObject championship)
        {
            var mainWindow = Application.Current?.MainWindow as MainWindow;
            var group      = mainWindow?.MenuLinkGroups.FirstOrDefault(x => x.GroupKey == "drive" && x.DisplayName == AppStrings.Main_Single);
            var links      = group?.Links;

            links?.Remove(links.OfType <CustomLink>().FirstOrDefault(x => x.Source.OriginalString.StartsWith(@"/Pages/Drive/UserChampionships_SelectedPage.xaml")));

            if (championship == null)
            {
                mainWindow?.NavigateTo(new Uri("/Pages/Drive/UserChampionships.xaml", UriKind.RelativeOrAbsolute));
                return;
            }

            var uri = UriExtension.Create("/Pages/Drive/UserChampionships_SelectedPage.xaml?Id={0}", championship.Id);

            if (links == null)
            {
                LinkCommands.NavigateLink.Execute(uri, null);
                return;
            }

            var link = new CustomLink {
                DisplayName = championship.DisplayName,
                Source      = uri
            };

            links.Insert(4, link);
            mainWindow.NavigateTo(link.Source);
        }
        public static void Open(CarObject car, CarSetupsRemoteSource forceRemoteSource = CarSetupsRemoteSource.None, bool forceNewWindow = false)
        {
            var main = Application.Current?.MainWindow as MainWindow;

            if (forceNewWindow || main == null || !main.IsActive || SettingsHolder.Interface.SkinsSetupsNewWindow)
            {
                CarSetupsDialog.Show(car, forceRemoteSource);
                return;
            }

            var remoteLinksStatus = GetRemoteLinksStatus();

            if (remoteLinksStatus != _remoteLinksStatus)
            {
                _remoteLinksStatus = remoteLinksStatus;
                main.MenuLinkGroups.RemoveRange(main.MenuLinkGroups.OfType <LinkGroupFilterable>().Where(x => x.GroupKey == "setups").ToList());
            }

            var existing = main.OpenSubGroup("setups", $"Setups for {car.DisplayName}",
                                             UriExtension.Create("/Pages/Lists/CarSetupsListPage.xaml?CarId={0}", car.Id));

            if (forceRemoteSource != CarSetupsRemoteSource.None)
            {
                existing.SetSelected(GetRemoteSourceUri(car.Id, forceRemoteSource));
            }
        }
Exemple #5
0
        Uri IAcObjectsUriProvider.GetUri(AcObjectNew obj)
        {
            switch (obj?.GetType().Name)
            {
            case nameof(CarObject):
                return(UriExtension.Create(
                           SettingsHolder.Content.OldLayout ? "/Pages/Selected/SelectedCarPage.xaml?Id={0}" :
                           "/Pages/Selected/SelectedCarPage_New.xaml?Id={0}",
                           obj.Id));

            case nameof(TrackObject):
            case nameof(TrackObjectBase):
            case nameof(TrackExtraLayoutObject):
                return(UriExtension.Create("/Pages/Selected/SelectedTrackPage.xaml?Id={0}", obj.Id));

            case nameof(ShowroomObject):
                return(UriExtension.Create("/Pages/Selected/SelectedShowroomPage.xaml?Id={0}", obj.Id));

            case nameof(WeatherObject):
                return(UriExtension.Create("/Pages/Selected/SelectedWeatherPage.xaml?Id={0}", obj.Id));

            case nameof(ReplayObject):
                return(UriExtension.Create("/Pages/Selected/SelectedReplayPage.xaml?Id={0}", obj.Id));

            case nameof(FontObject):
                return(UriExtension.Create("/Pages/Selected/SelectedFontPage.xaml?Id={0}", obj.Id));

            case nameof(DriverModelObject):
                return(UriExtension.Create("/Pages/Selected/SelectedDriverModelPage.xaml?Id={0}", obj.Id));

            case nameof(PpFilterObject):
                return(UriExtension.Create("/Pages/Selected/SelectedPpFilterPage.xaml?Id={0}", obj.Id));

            case nameof(PythonAppObject):
                return(UriExtension.Create("/Pages/Selected/SelectedPythonAppPage.xaml?Id={0}", obj.Id));

            case nameof(UserChampionshipObject):
                return(UriExtension.Create("/Pages/Selected/SelectedUserChampionship.xaml?Id={0}", obj.Id));

            case nameof(CarSkinObject):
                return(UriExtension.Create("/Pages/Selected/SelectedCarSkinPage.xaml?Id={0}&CarId={1}", obj.Id, ((CarSkinObject)obj).CarId));

            case nameof(CarSetupObject):
                return(UriExtension.Create("/Pages/Selected/SelectedCarSetupPage.xaml?Id={0}&CarId={1}", obj.Id, ((CarSetupObject)obj).CarId));

            case nameof(TrackSkinObject):
                return(UriExtension.Create("/Pages/Selected/SelectedTrackSkinPage.xaml?Id={0}&TrackId={1}", obj.Id, ((TrackSkinObject)obj).TrackId));

            case nameof(RemoteCarSetupObject):
                return(UriExtension.Create("/Pages/Selected/SelectedRemoteCarSetupPage.xaml?Id={0}&CarId={1}&RemoteSource={2}", obj.Id,
                                           ((RemoteCarSetupObject)obj).CarId, ((RemoteCarSetupObject)obj).Source));

            case nameof(ServerPresetObject):
                return(UriExtension.Create("/Pages/ServerPreset/SelectedPage.xaml?Id={0}", obj.Id));
            }

            throw new NotImplementedException("Not supported type: " + obj?.GetType().Name);
        }
        public static void Open(CarObject car)
        {
            var main = Application.Current?.MainWindow as MainWindow;

            if (main == null || SettingsHolder.Interface.SkinsSetupsNewWindow)
            {
                CarSkinsDialog.Show(car);
            }
            else
            {
                main.OpenSubGroup("skins", $"Skins for {car.DisplayName}",
                                  UriExtension.Create("/Pages/Lists/CarSkinsListPage.xaml?CarId={0}", car.Id));
            }
        }
Exemple #7
0
        public static void Open(TrackObject track)
        {
            var main = Application.Current?.MainWindow as MainWindow;

            if (main == null || SettingsHolder.Interface.SkinsSetupsNewWindow)
            {
                TrackSkinsDialog.Show(track);
            }
            else
            {
                main.OpenSubGroup("track skins", $"Skins for {track.DisplayNameWithoutCount}",
                                  UriExtension.Create("/Pages/Lists/TrackSkinsListPage.xaml?TrackId={0}", track.Id), 3);
            }
        }
Exemple #8
0
        private void UpdateOnlineSourcesLinks()
        {
            var list = OnlineGroup.FixedLinks;

            for (var i = list.Count - 1; i >= _defaultOnlineGroupCount; i--)
            {
                list.RemoveAt(i);
            }

            foreach (var source in FileBasedOnlineSources.Instance.GetVisibleSources().OrderBy(x => x.DisplayName))
            {
                list.Add(new Link {
                    DisplayName = $@"{source.DisplayName}",
                    Source      = UriExtension.Create("/Pages/Drive/Online.xaml?Filter=@{0}&Special=1", source.Id)
                });
            }
        }
Exemple #9
0
        protected override Uri GetPageAddress(SelectDlc dlc)
        {
            if (dlc.Information.Id == FakeKunosDlc.Id)
            {
                return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                           $"enabled+&k+&!dlc:", dlc.Information.DisplayName));
            }

            if (dlc.Information.Id == FakeModDlc.Id)
            {
                return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                           $"enabled+&k-", dlc.Information.DisplayName));
            }

            return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                       $"enabled+&dlc:{Filter.Encode(dlc.Information.ShortName)}", dlc.Information.DisplayName));
        }
Exemple #10
0
        bool INavigateUriHandler.NavigateTo(Uri uri)
        {
            Logging.Debug(uri);

            var s = uri.ToString();

            if (s.Contains("/Pages/AcSettings/") && !s.Contains("/Pages/AcSettings/AcSettingsPage.xaml"))
            {
                CurrentGroupKey = "settings";
                NavigateTo(UriExtension.Create("/Pages/AcSettings/AcSettingsPage.xaml?Uri={0}", uri));
                return(true);
            }

            if (s.Contains("/Pages/Settings/PythonAppsSettings.xaml"))
            {
                CurrentGroupKey = "settings";
                NavigateTo(uri);
                return(true);
            }

            if (s.Contains("/Pages/Settings/SettingsShadersPatch.xaml"))
            {
                CurrentGroupKey = "settings";
                NavigateTo(uri);
                return(true);
            }

            if (s.Contains("/Pages/Settings/") && !s.Contains("/Pages/Settings/SettingsPage.xaml"))
            {
                CurrentGroupKey = "settings";
                NavigateTo(UriExtension.Create("/Pages/Settings/SettingsPage.xaml?Uri={0}", uri));
                return(true);
            }

            if (s.Contains("/Pages/About/ImportantTipsPage.xaml"))
            {
                CurrentGroupKey = "about";
                NavigateTo(uri);
                return(true);
            }

            return(false);
        }
        public bool HandleUri(Uri uri)
        {
            Logging.Debug(uri);

            if (uri.ToString().Contains("/Pages/AcSettings/"))
            {
                SwitchGroup("settings");
                NavigateTo(UriExtension.Create("/Pages/AcSettings/AcSettingsPage.xaml?Uri={0}", uri));
                return(true);
            }

            if (uri.ToString().Contains("/Pages/Settings/"))
            {
                SwitchGroup("settings");
                NavigateTo(UriExtension.Create("/Pages/Settings/SettingsPage.xaml?Uri={0}", uri));
                return(true);
            }

            return(false);
        }
Exemple #12
0
        public SelectCarDialog(CarObject car, string defaultFilter = null)
        {
            _selectedCar = new DelayedPropertyWrapper <CarObject>(SelectedCarChanged);

            SelectedCar = car;
            _instance   = new WeakReference <SelectCarDialog>(this);

            DataContext = this;
            InputBindings.AddRange(new[] {
                new InputBinding(ToggleFavouriteCommand, new KeyGesture(Key.B, ModifierKeys.Control)),
                new InputBinding(OpenInShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Control)),
                new InputBinding(OpenInShowroomOptionsCommand, new KeyGesture(Key.H, ModifierKeys.Control | ModifierKeys.Shift)),
                new InputBinding(OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt)),
                new InputBinding(OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt | ModifierKeys.Control))
            });
            InitializeComponent();

            CarBlock.BrandArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = BrandUri(SelectedCar.Brand);
            };

            CarBlock.ClassArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = ClassUri(SelectedCar.CarClass);
            };

            CarBlock.YearArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = YearUri(SelectedCar.Year);
            };

            CarBlock.CountryArea.PreviewMouseLeftButtonDown += (sender, args) => {
                Tabs.SelectedSource = CountryUri(SelectedCar.Country);
            };

            Buttons = new [] { OkButton, CancelButton };

            if (defaultFilter != null)
            {
                Tabs.SavePolicy     = SavePolicy.SkipLoadingFlexible;
                Tabs.SelectedSource = UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={0}", defaultFilter);
            }
        }
Exemple #13
0
 public static Uri TagUri(string tag)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"enabled+&tag:{Filter.Encode(tag)}", tag));
 }
Exemple #14
0
 public static Uri ClassUri(string carClass)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"enabled+&class:{Filter.Encode(carClass)}", carClass.ToTitle()));
 }
Exemple #15
0
 public static Uri YearUri(int?year)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"enabled+&year:{Filter.Encode((year ?? 0).ToString())}", year != null ? year.ToString() : @"?"));
 }
Exemple #16
0
 public static Uri RatingUri(double rating)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"rating≥{Filter.Encode(rating.FloorToInt().ToInvariantString())} & rating<{Filter.Encode((rating.FloorToInt() + 1).ToInvariantString())}",
                                PluralizingConverter.PluralizeExt(rating.FloorToInt(), "{0} Star")));
 }
Exemple #17
0
 public static Uri BrandUri(string brand)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"enabled+&brand:{Filter.Encode(brand)}", brand));
 }
 private static Uri GetPageAddress(SelectCategoryDescription category)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=track&Filter={0}&Title={1}",
                                $"enabled+&({category.Filter})", category.Name));
 }
Exemple #19
0
 public static Uri FavouritesUri()
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter=fav+&Title={0}",
                                "Favourites"));
 }
        /*private static WeakReference<SelectTrackDialog> _instance;
         * public static SelectTrackDialog Instance => _instance == null ? null : _instance.TryGetTarget(out var result) ? result : null;*/

        public static Uri FavouritesUri()
        {
            return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=track&Filter=fav+&Title={0}",
                                       AppStrings.Online_Sorting_Favourites));
        }
Exemple #21
0
 private void ShowDetails(ServerEntry entry)
 {
     Model.ServerSelected = true;
     Frame.Source         = UriExtension.Create("/Pages/Drive/OnlineServer.xaml?Id={0}", entry.Id);
 }
 /// <summary>
 /// Return the extension for the URL path's page.
 /// </summary>
 public static UriExtension Extension(this HttpListenerContext context)
 {
     return(UriExtension.Create(context.Path().Value.RightOfRightmostOf('.').ToLower()));
 }
 public static Uri GetRemoteSourceUri(string carId, CarSetupsRemoteSource remoteSource)
 {
     return(UriExtension.Create("/Pages/Lists/CarSetupsListPage.xaml?CarId={0}&RemoteSource={1}&Special=1", carId, remoteSource));
 }
Exemple #24
0
 public static Uri CountryUri(string country)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=car&Filter={0}&Title={1}",
                                $"enabled+&country:{Filter.Encode(country)}", country));
 }
Exemple #25
0
 protected sealed override Uri GetPageAddress(SelectCategory category)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type={2}&Filter={0}&Title={1}",
                                $"enabled+&({category.Description.Filter})", category.DisplayName, GetUriType()));
 }
 private static Uri GetPageAddress(SelectCountry category)
 {
     return(UriExtension.Create("/Pages/Miscellaneous/AcObjectSelectList.xaml?Type=track&Filter={0}&Title={1}",
                                $"enabled+&country:{Filter.Encode(category.DisplayName)}", category.DisplayName));
 }