public void Initialize() { if (!(DataContext is ViewModel)) { return; } InitializeComponent(); InputBindings.AddRange(new[] { new InputBinding(new DelegateCommand(() => Model.GoCommand.Execute(AssistsViewModel.Instance)), new KeyGesture(Key.G, ModifierKeys.Control)) }); var acObject = Model.AcObject; if (acObject.LastSelectedTimestamp == 0) { if (_ignoreIntroId != acObject.Id) { new UserChampionshipIntro(acObject).ShowDialog(); } acObject.LastSelectedTimestamp = DateTime.Now.ToMillisecondsTimestamp(); } }
public void OnUri(Uri uri) { DataContext = new OnlineViewModel(uri.GetQueryParam("Filter"), ShowDetails); SetHideIcon(); InputBindings.AddRange(new[] { new InputBinding(Model.AddNewServerCommand, new KeyGesture(Key.A, ModifierKeys.Control)), new InputBinding(new DelegateCommand(() => OnScrollToSelectedButtonClick(null, null)), new KeyGesture(Key.V, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(Model.RefreshCommand, new KeyGesture(Key.R, ModifierKeys.Control)), }); InitializeComponent(); ResizingStuff(); var pack = Model.Pack; pack.SubscribeWeak(OnPackPropertyChanged); this.OnActualUnload(() => pack.UnsubscribeWeak(OnPackPropertyChanged)); BigButtonsParent.AddWidthCondition(430).Add(FilteringComboBox); }
protected void InitializeAcObjectPage([NotNull] ISelectedAcObjectViewModel model) { SelectedAcObject = model.SelectedAcObject; InputBindings.Clear(); InputBindings.AddRange(new[] { new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control)), // TODO: why doesn’t work after quick switching? new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)), new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift)) { CommandParameter = @"name" }, new InputBinding(SelectedAcObject.CopyIdCommand, new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Alt)) { CommandParameter = @"path" }, new InputBinding(SelectedAcObject.ViewInExplorerCommand, new KeyGesture(Key.F, ModifierKeys.Control)), new InputBinding(SelectedAcObject.ReloadCommand, new KeyGesture(Key.R, ModifierKeys.Control)), new InputBinding(SelectedAcObject.ReloadCommand, new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Shift)) { CommandParameter = @"full" }, new InputBinding(SelectedAcObject.ToggleCommand, new KeyGesture(Key.D, ModifierKeys.Control)), new InputBinding(SelectedAcObject.SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)), new InputBinding(model.ChangeIdCommand, new KeyGesture(Key.F2, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(model.CloneCommand, new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(model.FindInformationCommand, new KeyGesture(Key.I, ModifierKeys.Control)), new InputBinding(SelectedAcObject.DeleteCommand, new KeyGesture(Key.Delete, ModifierKeys.Control)) }); DataContext = model; if (!_set) { _set = true; Loaded += OnLoaded; Unloaded += OnUnloaded; } UpdateBindingsLaterAsync().Forget(); }
public ModernMenu() { InputBindings.AddRange(new[] { new InputBinding(new DelegateCommand(NewTab), new KeyGesture(Key.T, ModifierKeys.Control)), new InputBinding(new DelegateCommand(CloseTab), new KeyGesture(Key.W, ModifierKeys.Control)), new InputBinding(new DelegateCommand(CloseTab), new KeyGesture(Key.F4, ModifierKeys.Control)), new InputBinding(new DelegateCommand(RestoreTab), new KeyGesture(Key.T, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(new DelegateCommand(FocusCurrentTab), new KeyGesture(Key.F6)), new InputBinding(new DelegateCommand(FocusCurrentTab), new KeyGesture(Key.L, ModifierKeys.Control)), new InputBinding(new DelegateCommand(NextTab), new KeyGesture(Key.Tab, ModifierKeys.Control)), new InputBinding(new DelegateCommand(PreviousTab), new KeyGesture(Key.Tab, ModifierKeys.Control | ModifierKeys.Shift)) }); foreach (var i in Enumerable.Range(0, 9)) { InputBindings.Add(new InputBinding(new DelegateCommand(() => SwitchTab(i, false)), new KeyGesture(Key.D1 + i, ModifierKeys.Control))); InputBindings.Add(new InputBinding(new DelegateCommand(() => SwitchSection(i, false)), new KeyGesture(Key.D1 + i, ModifierKeys.Alt | ModifierKeys.Control))); } Loaded += OnLoaded; }
public void Initialize() { DataContext = new ViewModel(null, true, _selectNextCar, _selectNextCarSkinId, _selectNextTrack); _current = new WeakReference <QuickDrive>(this); InitializeComponent(); InputBindings.AddRange(new[] { new InputBinding(Model.GoCommand, new KeyGesture(Key.G, ModifierKeys.Control)), new InputBinding(Model.ShareCommand, new KeyGesture(Key.PageUp, ModifierKeys.Control)), new InputBinding(UserPresetsControl.SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)), new InputBinding(Model.RandomizeCommand, new KeyGesture(Key.R, ModifierKeys.Alt)), new InputBinding(Model.RandomCarSkinCommand, new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomCarCommand, new KeyGesture(Key.D1, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTrackCommand, new KeyGesture(Key.D2, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTimeCommand, new KeyGesture(Key.D3, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomWeatherCommand, new KeyGesture(Key.D4, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTemperatureCommand, new KeyGesture(Key.D5, ModifierKeys.Control | ModifierKeys.Alt)), }); _selectNextCar = null; _selectNextCarSkinId = null; _selectNextTrack = null; }
private FloatingWindow(DockPanel dockPanel) { Root = dockPanel; ShowInTaskbar = false; WindowStyle = WindowStyle.ToolWindow; WindowStartupLocation = WindowStartupLocation.Manual; m_dockOver = new List <IDockable>(); Loaded += FloatingWindow_Loaded; Closing += FloatingWindow_Closing; MouseMove += FloatingWindow_MouseMove; MouseUp += FloatingWindow_MouseUp; MouseLeave += FloatingWindow_MouseLeave; Activated += FloatingWindow_Activated; LocationChanged += FloatingWindow_LocationChanged; SizeChanged += FloatingWindow_SizeChanged; // Allow floating windows to handle shortcut keys var window = Application.Current.MainWindow; if ((window != null) && (window.InputBindings != null)) { InputBindings.AddRange(window.InputBindings); } }
private void SetModel() { _model?.Unload(); InitializeAcObjectPage(_model = new ViewModel(_object)); InputBindings.AddRange(new[] { new InputBinding(_model.UpdatePreviewsCommand, new KeyGesture(Key.P, ModifierKeys.Control)), new InputBinding(_model.UpdatePreviewsOptionsCommand, new KeyGesture(Key.P, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(_model.UpdatePreviewsManuallyCommand, new KeyGesture(Key.P, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(_model.DriveCommand, new KeyGesture(Key.G, ModifierKeys.Control)), new InputBinding(_model.DriveOptionsCommand, new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(_model.OpenInShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Control)), new InputBinding(_model.OpenInShowroomOptionsCommand, new KeyGesture(Key.H, ModifierKeys.Control | ModifierKeys.Shift)), new InputBinding(_model.OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt)), new InputBinding(_model.OpenInCustomShowroomCommand, new KeyGesture(Key.H, ModifierKeys.Alt | ModifierKeys.Control)), new InputBinding(_model.ManageSkinsCommand, new KeyGesture(Key.K, ModifierKeys.Control)), new InputBinding(_model.ManageSetupsCommand, new KeyGesture(Key.U, ModifierKeys.Control)), new InputBinding(_model.PackDataCommand, new KeyGesture(Key.J, ModifierKeys.Control)), new InputBinding(_model.ReadDataCommand, new KeyGesture(Key.J, ModifierKeys.Alt)), }); }
private void InitControleurs() { //Controleurs = new List<IValueControleur>() // { // new FaderValueControleur(KeyboardControlMapping.AQ_KeyboardLine()), // new FaderValueControleur(KeyboardControlMapping.ZS_KeyboardLine()), // new FaderValueControleur(KeyboardControlMapping.ED_KeyboardLine()), // new FaderValueControleur(KeyboardControlMapping.RF_KeyboardLine()), // new FaderValueControleur(KeyboardControlMapping.TG_KeyboardLine()), // new FaderValueControleur(KeyboardControlMapping.YH_KeyboardLine()), // //new FaderValueControleur(KeyboardControlMapping.UJ_KeyboardLine()), // //new FaderValueControleur(KeyboardControlMapping.IK_KeyboardLine()), // //new FaderValueControleur(KeyboardControlMapping.OL), // //new FaderValueControleur(KeyboardControlMapping.PM) // //new AnimationValueControleur(new KeyGesture(Key.NumPad0)) { Value = 1, CurveDirection = CurveDirection.Descendant, Duration = new Duration(TimeSpan.FromSeconds(3)), EasingFunction = new BounceEase() { Bounciness = 5, Bounces = 4, EasingMode = EasingMode.EaseOut } } // }; Projectors = new List <object>(); var rgb = new LightRgbProvider(3, 4, 5); var r = new LightManualSimpleFader(new FaderValueControleur(KeyboardLineControlMapping.YH_KeyboardLine()), rgb.Red, "Rouge"); var g = new LightManualSimpleFader(new FaderValueControleur(KeyboardLineControlMapping.YH_KeyboardLine()), rgb.Green, "Vert"); var mult = new LightManualMultipleFader(new FaderValueControleur(KeyboardLineControlMapping.UJ_KeyboardLine()), new[] { new LightProvider(1), new LightProvider(2), rgb.Blue }); var manF1 = new LightManualSimpleFader(new FaderValueControleur(KeyboardLineControlMapping.OL_KeyboardLine(KeyboardLineControlMode.ThreeThirds)), mult.LightProviders[0]); manF3 = new LightManualSimpleFader(new FaderValueControleur(KeyboardLineControlMapping.IK_KeyboardLine()), mult.LightProviders[1]); var manF2 = new LightManualSimpleFader(new FaderValueControleur(KeyboardLineControlMapping.PM_KeyboardLine()), manF1); autoManF3 = new LightActionAnimation(new AnimationValueControleur(new KeyGesture(Key.NumPad1)) { Value = 1, CurveDirection = CurveDirection.Descendant, Duration = new Duration(TimeSpan.FromSeconds(3)), EasingFunction = new BounceEase() { Bounciness = 5, Bounces = 8, EasingMode = EasingMode.EaseOut } }, manF2); LightControllers = new List <ILightController> { //new LightActionAnimation(new AnimationValueControleur(Key.NumPad0), new LightProvider(2)), //new LightProvider(3), mult, r, g, //new LightTimeAnimation(new LightProvider(4)), manF1, manF2, manF3, autoManF3 }; AudioControllers = new List <IAudioProvider>(); foreach (var lightProvider in LightControllers) { var manValCtl = lightProvider as LightManualSimpleFader; var multValCtl = lightProvider as LightManualMultipleFader; var animValCtl = lightProvider as LightActionAnimation; if (manValCtl != null) { InputBindings.AddRange(manValCtl.ValueControleur.InputBindings); } if (multValCtl != null) { InputBindings.AddRange(multValCtl.ValueControleur.InputBindings); } //if (animValCtl != null) //{ // InputBindings.AddRange(animValCtl.AnimControleur.InputBindings); //} } Projectors.Add(new BulbProjector(autoManF3, Colors.DarkOrange)); Projectors.Add(new BulbProjector(manF3)); Projectors.Add(new RgbProjector(r, g, mult.LightProviders[2])); }
public void Initialize() { OnSizeChanged(null, null); DataContext = new ViewModel(null, true, _selectNextCar, _selectNextCarSkinId, track: _selectNextTrack, trackSkin: _selectNextTrackSkin, weatherId: _selectNextWeather?.Id, mode: _selectNextMode); WeakEventManager <INotifyPropertyChanged, PropertyChangedEventArgs> .AddHandler(Model.TrackState, nameof(INotifyPropertyChanged.PropertyChanged), OnTrackStateChanged); this.OnActualUnload(() => { WeakEventManager <INotifyPropertyChanged, PropertyChangedEventArgs> .RemoveHandler(Model.TrackState, nameof(INotifyPropertyChanged.PropertyChanged), OnTrackStateChanged); }); _current = new WeakReference <QuickDrive>(this); InitializeComponent(); InputBindings.AddRange(new[] { new InputBinding(Model.GoCommand, new KeyGesture(Key.G, ModifierKeys.Control)), new InputBinding(Model.ShareCommand, new KeyGesture(Key.PageUp, ModifierKeys.Control)), new InputBinding(UserPresetsControl.SaveCommand, new KeyGesture(Key.S, ModifierKeys.Control)), new InputBinding(new DelegateCommand(() => { CustomShowroomWrapper.StartAsync(Model.SelectedCar, Model.SelectedCar.SelectedSkin); }), new KeyGesture(Key.H, ModifierKeys.Alt)), new InputBinding(new DelegateCommand(() => { CarOpenInShowroomDialog.Run(Model.SelectedCar, Model.SelectedCar.SelectedSkin?.Id); }), new KeyGesture(Key.H, ModifierKeys.Control)), new InputBinding(new DelegateCommand(() => { new CarOpenInShowroomDialog(Model.SelectedCar, Model.SelectedCar.SelectedSkin?.Id).ShowDialog(); }), new KeyGesture(Key.H, ModifierKeys.Control | ModifierKeys.Shift)), #if DEBUG new InputBinding(new AsyncCommand(() => LapTimesManager.Instance.AddEntry( Model.SelectedCar.Id, Model.SelectedTrack.IdWithLayout, DateTime.Now, TimeSpan.FromSeconds(MathUtils.Random(10d, 20d)))), new KeyGesture(Key.T, ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift)), #endif new InputBinding(Model.RandomizeCommand, new KeyGesture(Key.R, ModifierKeys.Alt)), new InputBinding(Model.RandomCarSkinCommand, new KeyGesture(Key.R, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomCarCommand, new KeyGesture(Key.D1, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTrackCommand, new KeyGesture(Key.D2, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTimeCommand, new KeyGesture(Key.D3, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomWeatherCommand, new KeyGesture(Key.D4, ModifierKeys.Control | ModifierKeys.Alt)), new InputBinding(Model.RandomTemperatureCommand, new KeyGesture(Key.D5, ModifierKeys.Control | ModifierKeys.Alt)), }); _selectNextCar = null; _selectNextCarSkinId = null; _selectNextTrack = null; _selectNextTrackSkin = null; _selectNextWeather = null; _selectNextMode = null; this.OnActualUnload(() => { Model.Unload(); }); }
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 }
public StandardView() { InitializeComponent(); runner = Application.Current.Resources["Runner"] as ModelViewRunner; Dictionary <Button, HotKeyWrapper> bottomButtons = new Dictionary <Button, HotKeyWrapper>() { [BottomButton0] = runner.Button1Hotkey, [BottomButton1] = runner.Button2Hotkey, [BottomButton2] = runner.Button3Hotkey, [BottomButton3] = runner.Button4Hotkey, [BottomButton4] = runner.Button5Hotkey, [BottomButton5] = runner.Button6Hotkey, [BottomButton6] = runner.Button7Hotkey, [BottomButton7] = runner.Button8Hotkey, [BottomButton8] = runner.Button9Hotkey, [BottomButton9] = runner.Button10Hotkey, [BottomButton10] = runner.Button11Hotkey, [BottomButton11] = runner.Button12Hotkey, [BottomButton12] = runner.Button13Hotkey, [BottomButton13] = runner.Button14Hotkey, [BottomButton14] = runner.Button15Hotkey, }; hotKeys = new List <KeyBinding>(); foreach (var pair in bottomButtons) { Binding keyBind = new Binding() { Source = pair.Value, Path = new PropertyPath(nameof(pair.Value.primaryGesture) + "." + nameof(pair.Value.primaryGesture.key)), Mode = BindingMode.OneWay, FallbackValue = Key.None, }; Binding modifierBind = new Binding() { Source = pair.Value, Path = new PropertyPath(nameof(pair.Value.primaryGesture) + "." + nameof(pair.Value.primaryGesture.modifier)), Mode = BindingMode.OneWay, FallbackValue = ModifierKeys.None, }; KeyBinding keyBinding = new KeyBinding() { Command = new RelayCommand(() => pair.Key.Command?.Execute(this), () => pair.Key.Command?.CanExecute(this) == true) }; BindingOperations.SetBinding(keyBinding, KeyBinding.KeyProperty, keyBind); BindingOperations.SetBinding(keyBinding, KeyBinding.ModifiersProperty, modifierBind); hotKeys.Add(keyBinding); keyBind = new Binding() { Source = pair.Value, Path = new PropertyPath(nameof(pair.Value.secondaryGesture) + "." + nameof(pair.Value.secondaryGesture.key)), Mode = BindingMode.OneWay, FallbackValue = Key.None, }; modifierBind = new Binding() { Source = pair.Value, Path = new PropertyPath(nameof(pair.Value.secondaryGesture) + "." + nameof(pair.Value.secondaryGesture.modifier)), Mode = BindingMode.OneWay, FallbackValue = ModifierKeys.None, }; keyBinding = new KeyBinding() { Command = new RelayCommand(() => pair.Key.Command?.Execute(this), () => pair.Key.Command?.CanExecute(this) == true) }; //keyBinding = new KeyBinding() //{ // Command = new RelayCommand(TestCommand, () => true) //}; BindingOperations.SetBinding(keyBinding, KeyBinding.KeyProperty, keyBind); BindingOperations.SetBinding(keyBinding, KeyBinding.ModifiersProperty, modifierBind); hotKeys.Add(keyBinding); } //RelayCommand commandMaker(ICommand cmd) => new RelayCommand(() => cmd?.Execute(this), () => cmd?.CanExecute(this) == true); //Pair<KeyBinding> bindingMaker(HotKeyWrapper hotKey) //{ // KeyBinding first, second; // first = new KeyBinding() { Key = hotKey.primaryGesture.Key, Modifiers = ModifierKeys.} // new Pair<KeyBinding>(new hotKey.primaryGesture) //} MainContent.InputField.IsKeyboardFocusedChanged += InputField_IsKeyboardFocusedChanged; InputBindings.AddRange(hotKeys); }
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 }
private void NameBox_OnLostFocus(object sender, RoutedEventArgs e) { InputBindings.AddRange(_bindings); _bindings.Clear(); }
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 }