public Input(FullscreenAppViewModel mainModel) { InitializeComponent(); BindingTools.SetBinding( ToggleMouseCursor, ToggleButton.IsCheckedProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.HideMouserCursor), BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged); BindingTools.SetBinding( ToggleXInput, ToggleButton.IsCheckedProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.EnableXinputProcessing), BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged); BindingTools.SetBinding( ToggleSwapXA, ToggleButton.IsCheckedProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.SwapStartDetailsAction), BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged); }
private void SetViewActiveBindings() { if (mainModel.AppSettings.ViewSettings.GamesViewType == viewType || DesignerProperties.GetIsInDesignMode(this)) { if (ListGames != null) { BindingTools.SetBinding(ListGames, ExtendedListBox.ItemsSourceProperty, mainModel, $"{nameof(mainModel.GamesView)}.{nameof(DesktopCollectionView.CollectionView)}"); } if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } } else { if (ListGames != null) { ListGames.ItemsSource = null; } if (ControlGameView != null) { ControlGameView.DataContext = null; } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement; if (MenuHost != null) { MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleGameOptionsCommand, new KeyGesture(Key.Back))); MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleGameOptionsCommand, new KeyGesture(Key.Escape))); MenuHost.InputBindings.Add(new XInputBinding(mainModel.ToggleGameOptionsCommand, XInputButton.B)); BindingTools.SetBinding( MenuHost, Control.DataContextProperty, mainModel, nameof(FullscreenAppViewModel.SelectedGameDetails)); } ItemsHost = Template.FindName("PART_ItemsHost", this) as ItemsControl; if (ItemsHost != null) { BindingTools.SetBinding( ItemsHost, ItemsControl.ItemsSourceProperty, mainModel, $"{nameof(FullscreenAppViewModel.SelectedGameDetails)}.{nameof(FullscreenAppViewModel.SelectedGameDetails.GameItems)}"); BindingTools.SetBinding(ItemsHost, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.GameMenuVisible)); } } }
private void MainModel_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ItemsFilterPresets != null && e.PropertyName == nameof(MainViewModelBase.SortedFilterFullscreenPresets)) { ItemsFilterPresets.Items.Clear(); foreach (var preset in mainModel.SortedFilterFullscreenPresets) { var item = new CheckBoxEx { Style = ResourceProvider.GetResource <Style>("ItemFilterQuickPreset"), Command = mainModel.ApplyFilterPresetCommand, CommandParameter = preset, DataContext = preset }; BindingTools.SetBinding(item, CheckBox.IsCheckedProperty, mainModel, nameof(mainModel.ActiveFilterPreset), converter: new Converters.ObjectEqualityToBoolConverter(), converterParameter: preset, mode: BindingMode.OneWay); ItemsFilterPresets.Items.Add(item); } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ControlGameView = Template.FindName("PART_ControlGameView", this) as Control; if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox; if (ListGames != null) { SetListGamesBinding(); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); ScrollToSelectedBehavior.SetEnabled(ListGames, true); ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture)); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); Sidebar = Template.FindName("PART_Sidebar", this) as Sidebar; if (Sidebar != null) { BindingTools.SetBinding(Sidebar, Sidebar.VisibilityProperty, mainModel.AppSettings, nameof(PlayniteSettings.ShowSidebar), converter: new BooleanToVisibilityConverter()); } ContentView = Template.FindName("PART_ContentView", this) as ContentControl; if (ContentView != null) { BindingTools.SetBinding(ContentView, ContentControl.ContentProperty, mainModel, nameof(mainModel.ActiveView)); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); PanelSideBarItems = Template.FindName("PART_PanelSideBarItems", this) as Panel; if (PanelSideBarItems != null) { LoadSidebarItems(); } ElemMainMenu = Template.FindName("PART_ElemMainMenu", this) as FrameworkElement; if (ElemMainMenu != null) { LeftClickContextMenuBehavior.SetEnabled(ElemMainMenu, true); ElemMainMenu.ContextMenu = new MainMenu(mainModel) { StaysOpen = false, Placement = PlacementMode.Bottom }; ElemMainMenu.ContextMenu.SetResourceReference(ContextMenu.StyleProperty, "TopPanelMenu"); BindingTools.SetBinding(ElemMainMenu, FrameworkElement.VisibilityProperty, mainModel.AppSettings, nameof(PlayniteSettings.ShowMainMenuOnTopPanel), converter: new InvertedBooleanToVisibilityConverter()); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ElemSeachIcon = Template.FindName("PART_SeachIcon", this) as FrameworkElement; if (ElemSeachIcon != null) { } ElemClearTextIcon = Template.FindName("PART_ClearTextIcon", this) as FrameworkElement; if (ElemClearTextIcon != null) { ElemClearTextIcon.MouseUp += ClearImage_MouseUp; } TextInputText = Template.FindName("PART_TextInpuText", this) as TextBox; if (TextInputText != null) { TextInputText.TextChanged += TextFilter_TextChanged; TextInputText.KeyUp += TextFilter_KeyUp; TextInputText.GotFocus += TextInputText_GotFocus; TextInputText.LostFocus += TextInputText_GotFocus; BindingTools.SetBinding( TextInputText, TextBox.TextProperty, this, nameof(Text), mode: System.Windows.Data.BindingMode.OneWay, trigger: System.Windows.Data.UpdateSourceTrigger.PropertyChanged); } UpdateIconStates(); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); BindingTools.SetBinding(this, Button.CommandProperty, nameof(SidebarWrapperItem.Command)); BindingTools.SetBinding(this, ContentPresenter.ContentProperty, nameof(SidebarWrapperItem.IconObject)); BindingTools.SetBinding(this, ContentPresenter.VisibilityProperty, nameof(SidebarWrapperItem.Visible), converter: new BooleanToVisibilityConverter()); BindingTools.SetBinding(this, ContentPresenter.ToolTipProperty, nameof(SidebarWrapperItem.Title)); ProgressStatus = Template.FindName("PART_ProgressStatus", this) as ProgressBar; if (ProgressStatus != null) { BindingTools.SetBinding(ProgressStatus, ProgressBar.MaximumProperty, nameof(SidebarWrapperItem.ProgressMaximum)); BindingTools.SetBinding(ProgressStatus, ProgressBar.ValueProperty, nameof(SidebarWrapperItem.ProgressValue)); } }
private void SetBindingHandlerSettings(IBindingHandler <IBinding> bindingHandler) { bindingHandler.TipBinding = BindingTools.GetBinding(Settings.TipButton); bindingHandler.TipActivationPressure = Settings.TipActivationPressure; Log.Write("Settings", $"Tip Binding: '{(bindingHandler.TipBinding is IBinding binding ? binding.ToString() : "None")}'@{bindingHandler.TipActivationPressure}%"); if (Settings.PenButtons != null) { for (int index = 0; index < Settings.PenButtons.Count; index++) { bindingHandler.PenButtonBindings[index] = BindingTools.GetBinding(Settings.PenButtons[index]); } Log.Write("Settings", $"Pen Bindings: " + string.Join(", ", bindingHandler.PenButtonBindings)); } if (Settings.AuxButtons != null) { for (int index = 0; index < Settings.AuxButtons.Count; index++) { bindingHandler.AuxButtonBindings[index] = BindingTools.GetBinding(Settings.AuxButtons[index]); } Log.Write("Settings", $"Express Key Bindings: " + string.Join(", ", bindingHandler.AuxButtonBindings)); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement; if (MenuHost != null) { MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleNotificationsCommand, new KeyGesture(Key.Back))); MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleNotificationsCommand, new KeyGesture(Key.Escape))); MenuHost.InputBindings.Add(new XInputBinding(mainModel.ToggleNotificationsCommand, XInputButton.B)); } ButtonClear = Template.FindName("PART_ButtonClear", this) as ButtonBase; if (ButtonClear != null) { ButtonClear.Command = mainModel.ClearNotificationsCommand; BindingTools.SetBinding(ButtonClear, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.NotificationsVisible)); } ItemsHost = Template.FindName("PART_ItemsHost", this) as ItemsControl; if (ItemsHost != null) { BindingTools.SetBinding( ItemsHost, ItemsControl.ItemsSourceProperty, mainModel.PlayniteApi.Notifications, nameof(mainModel.PlayniteApi.Notifications.Messages)); } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ListGames = Template.FindName("PART_ListGames", this) as GamesGridView; if (ListGames != null) { SetListGamesBinding(); ListGames.AppSettings = mainModel.AppSettings; BindingTools.SetBinding(ListGames, GamesGridView.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, GamesGridView.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
private void Return <T>(T binding) where T : OpenTabletDriver.Plugin.IBinding { var str = BindingTools.GetBindingString(binding); var bindRef = BindingReference.FromString(str); Return(bindRef); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ButtonClose = Template.FindName("PART_ButtonClose", this) as ButtonBase; if (ButtonClose != null) { ButtonClose.Command = mainModel.CloseNotificationPanelCommand; } ButtonDismissAll = Template.FindName("PART_ButtonDismissAll", this) as ButtonBase; if (ButtonDismissAll != null) { ButtonDismissAll.Command = mainModel.ClearMessagesCommand; } ItemsMessages = Template.FindName("PART_ItemsMessages", this) as ItemsControl; if (ItemsMessages != null) { BindingTools.SetBinding(ItemsMessages, ItemsControl.ItemsSourceProperty, mainModel.PlayniteApi.Notifications, nameof(INotificationsAPI.Messages)); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); SelectFields = Template.FindName("PART_SelectFields", this) as Selector; if (SelectFields != null) { BindingTools.SetBinding(SelectFields, Selector.SelectedValueProperty, mainModel.DatabaseExplorer, nameof(DatabaseExplorer.SelectedField), BindingMode.TwoWay); BindingTools.SetBinding(SelectFields, Selector.ItemsSourceProperty, mainModel.DatabaseExplorer, nameof(DatabaseExplorer.Fields)); } SelectItems = Template.FindName("PART_SelectItems", this) as Selector; if (SelectItems != null) { SelectItems.DisplayMemberPath = nameof(DatabaseExplorer.SelectionObject.Name); BindingTools.SetBinding(SelectItems, Selector.SelectedItemProperty, mainModel.DatabaseExplorer, nameof(DatabaseExplorer.SelectedFieldObject), BindingMode.TwoWay); BindingTools.SetBinding(SelectItems, Selector.ItemsSourceProperty, mainModel.DatabaseExplorer, nameof(DatabaseExplorer.FieldValues)); } }
static async Task SetTipBinding(string name, string property, float threshold) { await ModifySettings(s => { s.TipButton = BindingTools.GetBindingString(name, property); s.TipActivationPressure = threshold; }); }
public static void InitializePluginControls( ExtensionFactory extensions, ControlTemplate template, FrameworkElement templateParent, ApplicationMode mode, object contextSource, string contextPath) { if (DesignerTools.IsInDesignMode) { return; } foreach (var p in extensions.CustomElementList) { foreach (var elemName in p.ElementList) { if (template.FindName($"{p.SourceName}_{elemName}", templateParent) is ContentControl elem) { Control plugControl = null; try { plugControl = p.Source.GetGameViewControl(new SDK.Plugins.GetGameViewControlArgs { Name = elemName, Mode = mode }); } catch (Exception e) when(!PlayniteEnvironment.ThrowAllErrors) { logger.Error(e, $"Failed to get plugin control: {p.Source}."); } if (plugControl == null) { continue; } if (contextSource == null) { BindingTools.SetBinding(plugControl, plugControl is PluginUserControl ? PluginUserControl.GameContextProperty : Control.DataContextProperty, contextPath); } else { BindingTools.SetBinding(plugControl, plugControl is PluginUserControl ? PluginUserControl.GameContextProperty : Control.DataContextProperty, contextSource, contextPath); } elem.Focusable = false; elem.Content = plugControl; } } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { ViewHost = Template.FindName("PART_ViewHost", this) as FrameworkElement; if (ViewHost != null) { ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.ToggleGameDetailsCommand, Key = Key.Back }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.ToggleGameDetailsCommand, Key = Key.Escape }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.SelectPrevGameCommand, Key = Key.F2 }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.SelectNextGameCommand, Key = Key.F3 }); ViewHost.InputBindings.Add(new XInputBinding(mainModel.ToggleGameDetailsCommand, XInputButton.B)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.SelectPrevGameCommand, XInputButton.LeftShoulder)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.SelectNextGameCommand, XInputButton.RightShoulder)); BindingTools.SetBinding(ViewHost, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.GameDetailsFocused)); } ButtonContext = Template.FindName("PART_ButtonContext", this) as ButtonBase; if (ButtonContext != null) { BindingTools.SetBinding( ButtonContext, ButtonBase.CommandProperty, mainModel, $"{nameof(mainModel.SelectedGameDetails)}.{nameof(mainModel.SelectedGameDetails.ContextActionCommand)}"); BindingTools.SetBinding( ButtonContext, ButtonBase.ContentProperty, mainModel, $"{nameof(mainModel.SelectedGameDetails)}.{nameof(mainModel.SelectedGameDetails.ContextActionDescription)}"); } ButtonOptions = Template.FindName("PART_ButtonOptions", this) as ButtonBase; if (ButtonOptions != null) { ButtonOptions.Command = mainModel.ToggleGameOptionsCommand; } } }
private void SetElemVisibility(ref FrameworkElement elem, string partId, string binding) { elem = Template.FindName(partId, this) as FrameworkElement; if (elem != null) { BindingTools.SetBinding(elem, FrameworkElement.VisibilityProperty, binding); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ImageBackground = Template.FindName("PART_ImageBackground", this) as FadeImage; if (ImageBackground != null) { BindingTools.SetBinding(ImageBackground, FadeImage.IsBlurEnabledProperty, mainModel.AppSettings, nameof(PlayniteSettings.BlurWindowBackgroundImage), mode: BindingMode.OneWay); BindingTools.SetBinding(ImageBackground, FadeImage.BlurAmountProperty, mainModel.AppSettings, nameof(PlayniteSettings.BackgroundImageBlurAmount), mode: BindingMode.OneWay); BindingTools.SetBinding(ImageBackground, FadeImage.HighQualityBlurProperty, mainModel.AppSettings, nameof(PlayniteSettings.HighQualityBackgroundBlur), mode: BindingMode.OneWay); BindingTools.SetBinding(ImageBackground, FadeImage.AnimationEnabledProperty, mainModel.AppSettings, nameof(PlayniteSettings.BackgroundImageAnimation), mode: BindingMode.OneWay); } ElemNoGamesNotif = Template.FindName("PART_ElemNoGamesNotif", this) as FrameworkElement; if (ElemNoGamesNotif != null) { BindingTools.SetBinding(ElemNoGamesNotif, Control.VisibilityProperty, mainModel, $"{nameof(mainModel.GamesView)}.{nameof(mainModel.GamesView.CollectionView)}.{nameof(mainModel.GamesView.Items.Count)}", converter: new IntToVisibilityConverter(), converterParameter: 0); } SetBackgroundBinding(); SetBackgroundEffect(); SetViewBinding(ref ViewDetails, "PART_ViewDetails", ViewType.Details); SetViewBinding(ref ViewGrid, "PART_ViewGrid", ViewType.Grid); SetViewBinding(ref ViewList, "PART_ViewList", ViewType.List); ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
private void SetToggleCount(ref ContentControl content, string partId, string binding) { content = Template.FindName(partId, this) as ContentControl; if (content != null) { BindingTools.SetBinding(content, ContentControl.ContentProperty, mainModel.GamesStats, binding); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template == null) { return; } ViewHost = Template.FindName("PART_ViewHost", this) as FrameworkElement; if (ViewHost != null) { BindingTools.SetBinding(ViewHost, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.GameStatusVisible)); } PanelActionButtons = Template.FindName("PART_PanelActionButtons", this) as Panel; if (PanelActionButtons != null) { var buttonClose = new ButtonEx(); buttonClose.Content = ResourceProvider.GetString(LOC.CloseLabel); buttonClose.SetResourceReference(ButtonEx.StyleProperty, "ButtonGameStatusAction"); buttonClose.Command = mainModel.CloseGameStatusCommand; PanelActionButtons.Children.Add(buttonClose); } TextStatus = Template.FindName("PART_TextStatus", this) as TextBlock; if (TextStatus != null) { BindingTools.SetBinding(TextStatus, TextBlock.TextProperty, mainModel, nameof(mainModel.GameStatusText)); } ImageCover = Template.FindName("PART_ImageCover", this) as Image; if (ImageCover != null) { var sourceBinding = new PriorityBinding(); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.CoverImageObject)), Converter = new NullToDependencyPropertyUnsetConverter() }); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.DefaultCoverImageObject)), Converter = new NullToDependencyPropertyUnsetConverter() }); BindingOperations.SetBinding(ImageCover, Image.SourceProperty, sourceBinding); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ControlGameView = Template.FindName("PART_ControlGameView", this) as Control; if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox; if (ListGames != null) { SetListGamesBinding(); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); ScrollToSelectedBehavior.SetEnabled(ListGames, true); if (!DesignerProperties.GetIsInDesignMode(this)) { ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture)); } ListGames.SelectionMode = SelectionMode.Extended; VirtualizingPanel.SetCacheLengthUnit(ListGames, VirtualizationCacheLengthUnit.Item); VirtualizingPanel.SetCacheLength(ListGames, new VirtualizationCacheLength(5)); VirtualizingPanel.SetScrollUnit(ListGames, ScrollUnit.Pixel); VirtualizingPanel.SetIsVirtualizingWhenGrouping(ListGames, true); VirtualizingPanel.SetVirtualizationMode(ListGames, VirtualizationMode.Recycling); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
private void SetToggleFilter(ref ToggleButton button, string partId, string binding) { button = Template.FindName(partId, this) as ToggleButton; if (button != null) { BindingTools.SetBinding(button, ToggleButton.IsCheckedProperty, mainModel.AppSettings.FilterSettings, binding, BindingMode.TwoWay); } }
private void SetLabelTag(ref FrameworkElement elem, string partId, string binding) { elem = Template.FindName(partId, this) as FrameworkElement; if (elem != null) { BindingTools.SetBinding(elem, FrameworkElement.TagProperty, mainModel.AppSettings.FilterSettings, $"{binding}.{nameof(FilterItemProperites.IsSet)}", fallBackValue: false); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement; if (MenuHost != null) { MenuHost.InputBindings.Add(new KeyBinding(mainModel.CloseAdditionalFiltersCommand, new KeyGesture(Key.Back))); MenuHost.InputBindings.Add(new KeyBinding(mainModel.CloseAdditionalFiltersCommand, new KeyGesture(Key.Escape))); MenuHost.InputBindings.Add(new KeyBinding() { Command = mainModel.ToggleFiltersCommand, Key = Key.F }); MenuHost.InputBindings.Add(new XInputBinding(mainModel.CloseAdditionalFiltersCommand, XInputButton.B)); } ButtonBack = Template.FindName("PART_ButtonBack", this) as ButtonBase; if (ButtonBack != null) { ButtonBack.Command = mainModel.CloseAdditionalFiltersCommand; BindingTools.SetBinding(ButtonBack, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.FilterAdditionalPanelVisible)); } ItemsHost = Template.FindName("PART_ItemsHost", this) as ItemsControl; if (ItemsHost != null) { AssignFilter("LOCGenreLabel", "PART_ButtonGenre", GameField.Genres, nameof(FilterSettings.Genre)); AssignFilter("LOCGameReleaseYearTitle", "PART_ButtonReleaseYear", GameField.ReleaseYear, nameof(FilterSettings.ReleaseYear)); AssignFilter("LOCDeveloperLabel", "PART_ButtonDeveloper", GameField.Developers, nameof(FilterSettings.Developer)); AssignFilter("LOCPublisherLabel", "PART_ButtonPublisher", GameField.Publishers, nameof(FilterSettings.Publisher)); AssignFilter("LOCFeatureLabel", "PART_ButtonFeature", GameField.Features, nameof(FilterSettings.Feature)); AssignFilter("LOCTagLabel", "PART_ButtonTag", GameField.Tags, nameof(FilterSettings.Tag)); AssignFilter("LOCTimePlayed", "PART_ButtonPlayTime", GameField.Playtime, nameof(FilterSettings.PlayTime)); AssignFilter("LOCCompletionStatus", "PART_ButtonCompletionStatus", GameField.CompletionStatus, nameof(FilterSettings.CompletionStatus)); AssignFilter("LOCSeriesLabel", "PART_ButtonSeries", GameField.Series, nameof(FilterSettings.Series)); AssignFilter("LOCRegionLabel", "PART_ButtonRegion", GameField.Region, nameof(FilterSettings.Region)); AssignFilter("LOCSourceLabel", "PART_ButtonSource", GameField.Source, nameof(FilterSettings.Source)); AssignFilter("LOCAgeRatingLabel", "PART_ButtonAgeRating", GameField.AgeRating, nameof(FilterSettings.AgeRating)); AssignFilter("LOCUserScore", "PART_ButtonUserScore", GameField.UserScore, nameof(FilterSettings.UserScore)); AssignFilter("LOCCommunityScore", "PART_ButtonCommunityScore", GameField.CommunityScore, nameof(FilterSettings.CommunityScore)); AssignFilter("LOCCriticScore", "PART_ButtonCriticScore", GameField.CriticScore, nameof(FilterSettings.CriticScore)); AssignFilter("LOCGameLastActivityTitle", "PART_ButtonLastActivity", GameField.LastActivity, nameof(FilterSettings.LastActivity)); AssignFilter("LOCAddedLabel", "PART_ButtonAdded", GameField.Added, nameof(FilterSettings.Added)); AssignFilter("LOCModifiedLabel", "PART_ButtonModified", GameField.Modified, nameof(FilterSettings.Modified)); } } }
private void SetFilterEnumSelectionBoxFilter(ref FilterEnumSelectionBox elem, string partId, string filterBinding, Type enumType) { elem = Template.FindName(partId, this) as FilterEnumSelectionBox; if (elem != null) { elem.EnumType = enumType; BindingTools.SetBinding(elem, FilterEnumSelectionBox.FilterPropertiesProperty, mainModel.AppSettings.FilterSettings, filterBinding, BindingMode.TwoWay); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); BindingTools.SetBinding(this, Button.CommandProperty, nameof(SideBarItem.Command)); BindingTools.SetBinding(this, Button.CommandParameterProperty, nameof(SideBarItem.CommandParameter)); BindingTools.SetBinding(this, ContentPresenter.ContentProperty, nameof(SideBarItem.ImageObject)); }
private void SetGameItemTextBinding(ref TextBlock text, string partId, string textContent, string visibility, IValueConverter converter = null) { text = Template.FindName(partId, this) as TextBlock; if (text != null) { BindingTools.SetBinding(text, TextBlock.TextProperty, GetGameBindingPath(textContent), converter: converter); BindingTools.SetBinding(text, TextBlock.VisibilityProperty, visibility); } }
private void SetItemsControlBinding(ref ItemsControl elem, string partId, string command, string listSource, string visibility, string tooltip = null) { elem = Template.FindName(partId, this) as ItemsControl; if (elem != null) { elem.ItemTemplate = GetFieldItemTemplate(command, tooltip); BindingTools.SetBinding(elem, ItemsControl.ItemsSourceProperty, GetGameBindingPath(listSource)); BindingTools.SetBinding(elem, TextBlock.VisibilityProperty, visibility); } }