private InstallAdditionalContentDialog()
 {
     DataContext = this;
     InitializeComponent();
     ArgumentsHandler.HandlePasteEvent(this);
     Buttons = new[] {
         CreateExtraDialogButton(AppStrings.MainWindow_Downloads_RemoveCompleted, ContentInstallationManager.Instance.RemoveCompletedCommand),
         IsAlone ? CloseButton : CreateCloseDialogButton(UiStrings.Toolbar_Hide, true, false, MessageBoxResult.None)
     };
 }
Beispiel #2
0
        public MainWindow()
        {
            Owner = null;

            var app = Application.Current;

            if (app != null)
            {
                app.MainWindow = this;
            }

            _cancelled = false;

            if (_testGameDialog != null)
            {
                Logging.Write("Testing mode");
                var ui = new GameDialog();
                ui.ShowDialogAsync().Forget();
                ((IGameUi)ui).OnResult(JsonConvert.DeserializeObject <Game.Result>(FileUtils.ReadAllText(_testGameDialog)), null);
                _cancelled = true;
            }

            if (_cancelled)
            {
                Close();
                return;
            }

            InitializeSubGroups();

            var downloadsNavigateCommand = new NavigateCommand(this, new Uri("/Pages/Miscellaneous/DownloadsList.xaml", UriKind.Relative));

            DataContext = new ViewModel();
            InputBindings.AddRange(new[] {
                new InputBinding(new NavigateCommand(this, "drive"), new KeyGesture(Key.F1)),
                new InputBinding(new NavigateCommand(this, "lapTimes"), new KeyGesture(Key.F2)),
                new InputBinding(new NavigateCommand(this, "stats"), new KeyGesture(Key.F3)),
                new InputBinding(new NavigateCommand(this, "media"), new KeyGesture(Key.F4)),

                // Second group, Ctrl+F…
                new InputBinding(new NavigateCommand(this, new Uri("/Pages/Lists/CarsListPage.xaml", UriKind.Relative)),
                                 new KeyGesture(Key.F1, ModifierKeys.Control)),
                InternalUtils.IsAllRight ? new InputBinding(new NavigateCommand(this, new Uri("/Pages/Lists/ServerPresetsListPage.xaml", UriKind.Relative)),
                                                            new KeyGesture(Key.F2, ModifierKeys.Control)) : null,

                // Downloads hotkey
                new InputBinding(new DelegateCommand(() => {
                    if (AppAppearanceManager.Instance.DownloadsInSeparatePage)
                    {
                        downloadsNavigateCommand.Execute();
                    }
                    else
                    {
                        this.RequireChild <Popup>("DownloadsPopup").IsOpen = true;
                    }
                }), new KeyGesture(Key.J, ModifierKeys.Control)),

                // Settings, Alt+F…
                new InputBinding(new NavigateCommand(this, new Uri("/Pages/Settings/SettingsPage.xaml", UriKind.Relative)),
                                 new KeyGesture(Key.F1, ModifierKeys.Alt)),
                new InputBinding(new NavigateCommand(this, new Uri("/Pages/AcSettings/AcSettingsPage.xaml", UriKind.Relative)),
                                 new KeyGesture(Key.F2, ModifierKeys.Alt)),
                new InputBinding(new NavigateCommand(this, new Uri("/Pages/Settings/PythonAppsSettings.xaml", UriKind.Relative)),
                                 new KeyGesture(Key.F3, ModifierKeys.Alt)),
            }.NonNull().ToList());

            InitializeComponent();
            ModsWebBrowser.Instance.RebuildLinksNow();
            ArgumentsHandler.HandlePasteEvent(this);

            if (SteamStarter.IsInitialized)
            {
                OverlayContentCell.Children.Add((FrameworkElement)FindResource(@"SteamOverlayFix"));
            }

            LinkNavigator.Commands.Add(new Uri("cmd://enterKey"), Model.EnterKeyCommand);
            InternalUtils.Launch(this);

            foreach (var result in MenuLinkGroups.OfType <LinkGroupFilterable>()
                     .Where(x => x.Source.OriginalString.Contains(@"/online.xaml", StringComparison.OrdinalIgnoreCase)))
            {
                result.LinkChanged += OnlineLinkChanged;
            }

            foreach (var result in MenuLinkGroups.OfType <LinkGroupFilterable>()
                     .Where(x => x.Source.OriginalString.Contains(@"/laptimes_table.xaml", StringComparison.OrdinalIgnoreCase)))
            {
                result.LinkChanged += LapTimesLinkChanged;
            }

            foreach (var result in MenuLinkGroups.OfType <LinkGroupFilterable>()
                     .Where(x => x.GroupKey == "media" || x.GroupKey == "content"))
            {
                result.LinkChanged += ContentLinkChanged;
            }

            UpdateLiveTabs();
            SettingsHolder.Live.PropertyChanged += OnLiveSettingsPropertyChanged;

            UpdateTitleLinks();
            AppAppearanceManager.Instance.PropertyChanged += OnAppAppearancePropertyChanged;

            UpdateMinoratingLink();
            SettingsHolder.Online.PropertyChanged += OnOnlineSettingsPropertyChanged;

            _defaultOnlineGroupCount = OnlineGroup.FixedLinks.Count;

            if (FileBasedOnlineSources.IsInitialized())
            {
                UpdateOnlineSourcesLinks();
            }

            FileBasedOnlineSources.Instance.Update += OnOnlineSourcesUpdate;

            Activated += OnActivated;

            if (SettingsHolder.Drive.SelectedStarterType != SettingsHolder.DriveSettings.SteamStarterType)
            {
                TitleLinks.Remove(OriginalLauncher);
            }
            else
            {
                LinkNavigator.Commands.Add(new Uri("cmd://originalLauncher"), new DelegateCommand(SteamStarter.StartOriginalLauncher));
            }

            ContentInstallationManager.Instance.TaskAdded += OnContentInstallationTaskAdded;
            UpdateDiscordRichPresence();

#if DEBUG
            LapTimesGrid.Source = new Uri("/Pages/Miscellaneous/LapTimes_Grid.xaml", UriKind.Relative);
#else
            // MenuLinkGroups.Remove(BrowserLinkGroup);
#endif
        }