private void OnClosing(object sender, CancelEventArgs e)
        {
            if (!IsResultOk)
            {
                return;
            }

            foreach (var result in List.SelectedItems.OfType <ServerInformationComplete>())
            {
                FileBasedOnlineSources.AddToList(_key, result);
            }
        }
 public OnlineListsManager()
 {
     DataContext = new ViewModel();
     InitializeComponent();
     Buttons = new[] {
         CreateExtraDialogButton("Add New List", () => {
             var name = Prompt.Show("Name for a new servers list:", "Add New Servers List", required: true, maxLength: 255, watermark: @"?");
             if (!string.IsNullOrWhiteSpace(name))
             {
                 FileBasedOnlineSources.CreateList(name);
             }
         }),
         CloseButton
     };
 }
Example #3
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
        }
Example #4
0
        public MainWindow()
        {
            var app = Application.Current;

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

            _cancelled = false;

            if (AppArguments.Values.Any())
            {
                ProcessArguments();
            }

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

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

            DataContext = new ViewModel();
            InputBindings.AddRange(new[] {
                new InputBinding(new NavigateCommand(this, "about"), new KeyGesture(Key.F1, ModifierKeys.Alt)),
                new InputBinding(new NavigateCommand(this, "settings"), new KeyGesture(Key.F1, ModifierKeys.Control)),
                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))
            });
            InitializeComponent();

            LinkNavigator.Commands.Add(new Uri("cmd://enterkey"), Model.EnterKeyCommand);
            AppKeyHolder.ProceedMainWindow(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.GroupKey == "content"))
            {
                result.LinkChanged += ContentLinkChanged;
            }

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

            UpdateServerTab();
            UpdateMinoratingLink();
            SettingsHolder.Online.PropertyChanged += Online_PropertyChanged;

            if (!OfficialStarterNotification() && PluginsManager.Instance.HasAnyNew())
            {
                Toast.Show("Don’t forget to install plugins!", ""); // TODO?
            }

            EntryPoint.HandleSecondInstanceMessages(this, HandleMessagesAsync);

            _defaultOnlineGroupCount = OnlineGroup.FixedLinks.Count;

            if (FileBasedOnlineSources.IsInitialized())
            {
                UpdateOnlineSourcesLinks();
            }
            FileBasedOnlineSources.Instance.Update += OnOnlineSourcesUpdate;

            Activated += OnActivated;

#if DEBUG
            LapTimesGrid.Source = new Uri("/Pages/Miscellaneous/LapTimes_Grid.xaml", UriKind.Relative);
#endif
        }
Example #5
0
        public MainWindow()
        {
            var app = Application.Current;

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

            _cancelled = false;

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

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

            InitializeSubGroups();
            DataContext = new ViewModel();
            InputBindings.AddRange(new[] {
                new InputBinding(new NavigateCommand(this, "content"), new KeyGesture(Key.F1, ModifierKeys.Control)),
                new InputBinding(new NavigateCommand(this, "server"), new KeyGesture(Key.F2, ModifierKeys.Control)),
                new InputBinding(new NavigateCommand(this, "settings"), new KeyGesture(Key.F3, ModifierKeys.Control)),
                new InputBinding(new NavigateCommand(this, "about"), new KeyGesture(Key.F4, ModifierKeys.Control)),
                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)),
                new InputBinding(new DelegateCommand(() => {
                    if (Keyboard.FocusedElement is TextBoxBase || Keyboard.FocusedElement is CheckBox)
                    {
                        return;
                    }

                    try {
                        if (Clipboard.ContainsData(DataFormats.FileDrop))
                        {
                            var data = Clipboard.GetFileDropList().OfType <string>().ToList();
                            Dispatcher.InvokeAsync(() => {
                                ProcessDroppedFiles(data);
                            });
                        }
                        else if (Clipboard.ContainsData(DataFormats.UnicodeText))
                        {
                            var list = Clipboard.GetText().SplitLines();
                            Dispatcher.InvokeAsync(() => {
                                ProcessDroppedFiles(list);
                            });
                        }
                    } catch (Exception e) {
                        Logging.Warning(e);
                    }
                }), new KeyGesture(Key.V, ModifierKeys.Control)),
            });
            InitializeComponent();

            LinkNavigator.Commands.Add(new Uri("cmd://enterkey"), Model.EnterKeyCommand);
            AppKeyHolder.ProceedMainWindow(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;

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

            if (!OfficialStarterNotification() && PluginsManager.Instance.HasAnyNew())
            {
                Toast.Show("Don’t forget to install plugins!", ""); // TODO?
            }

            _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.PluginsNavigator = this;

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