public override void OnApplyTemplate() { base.OnApplyTemplate(); 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.FullscreenListItemCoverObject)), IsAsync = mainModel.AppSettings.Fullscreen.AsyncImageLoading, Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.DefaultFullscreenListItemCoverObject)), Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); BindingOperations.SetBinding(ImageCover, Image.SourceProperty, sourceBinding); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, ApplicationMode.Fullscreen, this, $"DataContext.{nameof(GamesCollectionViewEntry.Game)}"); }
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)}"); }
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(); 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)}"); }
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)}"); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); PanelHost = Template.FindName("PART_PanelHost", this) as FrameworkElement; if (PanelHost != null) { if (!DesignerProperties.GetIsInDesignMode(this)) { var mBinding = new MouseBinding(mainModel.StartGameCommand, new MouseGesture(MouseAction.LeftDoubleClick)); BindingTools.SetBinding(mBinding, MouseBinding.CommandParameterProperty, nameof(GamesCollectionViewEntry.Game)); PanelHost.InputBindings.Add(mBinding); PanelHost.ContextMenu = new GameMenu(mainModel) { ShowStartSection = true }; BindingTools.SetBinding(PanelHost.ContextMenu, Button.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGames)); } } ImageIcon = Template.FindName("PART_ImageIcon", this) as Image; if (ImageIcon != null) { BindingTools.SetBinding(ImageIcon, Image.VisibilityProperty, mainModel.AppSettings, nameof(PlayniteSettings.ShowIconsOnList), converter: new BooleanToVisibilityConverter()); var sourceBinding = new PriorityBinding(); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.DetailsListIconObjectCached)), IsAsync = mainModel.AppSettings.AsyncImageLoading, Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.DefaultDetailsListIconObjectCached)), Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); BindingOperations.SetBinding(ImageIcon, Image.SourceProperty, sourceBinding); } 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.GridViewCoverObjectCached)), IsAsync = mainModel.AppSettings.AsyncImageLoading, Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(nameof(GamesCollectionViewEntry.DefaultGridViewCoverObjectCached)), Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); BindingOperations.SetBinding(ImageCover, Image.SourceProperty, sourceBinding); } ButtonPlay = Template.FindName("PART_ButtonPlay", this) as Button; if (ButtonPlay != null) { ButtonPlay.Command = mainModel.StartGameCommand; BindingTools.SetBinding(ButtonPlay, Button.CommandParameterProperty, nameof(GamesCollectionViewEntry.Game)); } ButtonInfo = Template.FindName("PART_ButtonInfo", this) as Button; if (ButtonInfo != null) { ButtonInfo.Command = mainModel.ShowGameSideBarCommand; BindingTools.SetBinding(ButtonInfo, Button.CommandParameterProperty, string.Empty); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, ApplicationMode.Desktop, this, $"DataContext.{nameof(GamesCollectionViewEntry.Game)}"); }
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.OpenGameMenuCommand; } 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); } ImageBackground = Template.FindName("PART_ImageBackground", this) as FadeImage; if (ImageBackground != null) { BindingTools.SetBinding(ImageBackground, FadeImage.SourceProperty, nameof(GamesCollectionViewEntry.DisplayBackgroundImageObject)); } HtmlDescription = Template.FindName("PART_HtmlDescription", this) as HtmlTextView; if (HtmlDescription != null) { BindingTools.SetBinding(HtmlDescription, HtmlTextView.HtmlTextProperty, nameof(GamesCollectionViewEntry.Description)); HtmlDescription.TemplatePath = ThemeFile.GetFilePath("DescriptionView.html"); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, ApplicationMode.Fullscreen, mainModel, $"{nameof(FullscreenAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); } }
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.OpenMainMenuCommand, Key = Key.F1 }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.PrevFilterViewCommand, Key = Key.F2 }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.NextFilterViewCommand, Key = Key.F3 }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.OpenSearchCommand, Key = Key.Y }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.ToggleFiltersCommand, Key = Key.F }); ViewHost.InputBindings.Add(new KeyBinding() { Command = mainModel.SwitchToDesktopCommand, Key = Key.F11 }); ViewHost.InputBindings.Add(new XInputBinding(mainModel.PrevFilterViewCommand, XInputButton.LeftShoulder)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.NextFilterViewCommand, XInputButton.RightShoulder)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.OpenSearchCommand, XInputButton.Y)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.ToggleFiltersCommand, XInputButton.RightStick)); ViewHost.InputBindings.Add(new XInputBinding(mainModel.OpenMainMenuCommand, XInputButton.Back)); } MainHost = Template.FindName("PART_MainHost", this) as FrameworkElement; if (MainHost != null) { BindingTools.SetBinding(MainHost, FrameworkElement.WidthProperty, mainModel, nameof(FullscreenAppViewModel.ViewportWidth)); BindingTools.SetBinding(MainHost, FrameworkElement.HeightProperty, mainModel, nameof(FullscreenAppViewModel.ViewportHeight)); } AssignButtonWithCommand(ref ButtonProgramUpdate, "PART_ButtonProgramUpdate", mainModel.OpenUpdatesCommand); AssignButtonWithCommand(ref ButtonMainMenu, "PART_ButtonMainMenu", mainModel.OpenMainMenuCommand); AssignButtonWithCommand(ref ButtonNotifications, "PART_ButtonNotifications", mainModel.OpenNotificationsMenuCommand); if (ButtonProgramUpdate != null) { BindingTools.SetBinding(ButtonProgramUpdate, Button.VisibilityProperty, mainModel, nameof(mainModel.UpdatesAvailable), converter: new Converters.BooleanToVisibilityConverter()); } ImageBackground = Template.FindName("PART_ImageBackground", this) as FadeImage; if (ImageBackground != null) { SetBackgroundBinding(); SetBackgroundEffect(); } TextClock = Template.FindName("PART_TextClock", this) as TextBlock; if (TextClock != null) { BindingTools.SetBinding(TextClock, TextBlock.TextProperty, mainModel.CurrentTime, nameof(ObservableTime.Time)); BindingTools.SetBinding( TextClock, TextBlock.VisibilityProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.ShowClock), converter: new Converters.BooleanToVisibilityConverter()); } TextBatteryPercentage = Template.FindName("PART_TextBatteryPercentage", this) as TextBlock; if (TextBatteryPercentage != null) { BindingTools.SetBinding(TextBatteryPercentage, TextBlock.TextProperty, mainModel.PowerStatus, nameof(ObservablePowerStatus.PercentCharge), stringFormat: "{0}%"); BindingTools.SetBinding(TextBatteryPercentage, TextBlock.VisibilityProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.ShowBatteryPercentage), converter: new Converters.BooleanToVisibilityConverter()); } ElemBatteryStatus = Template.FindName("PART_ElemBatteryStatus", this) as FrameworkElement; if (ElemBatteryStatus != null) { BindingTools.SetBinding( ElemBatteryStatus, TextBlock.VisibilityProperty, mainModel.AppSettings.Fullscreen, nameof(FullscreenSettings.ShowBattery), converter: new Converters.BooleanToVisibilityConverter()); } TextProgressTooltip = Template.FindName("PART_TextProgressTooltip", this) as TextBlock; if (TextProgressTooltip != null) { BindingTools.SetBinding(TextProgressTooltip, TextBlock.TextProperty, mainModel, nameof(FullscreenAppViewModel.ProgressStatus)); BindingTools.SetBinding(TextProgressTooltip, TextBlock.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.ProgressActive), converter: new Converters.BooleanToVisibilityConverter()); } ElemProgressIndicator = Template.FindName("PART_ElemProgressIndicator", this) as FrameworkElement; if (ElemProgressIndicator != null) { BindingTools.SetBinding(ElemProgressIndicator, ToggleButton.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.ProgressActive), converter: new Converters.BooleanToVisibilityConverter()); } ElemExtraFilterActive = Template.FindName("PART_ElemExtraFilterActive", this) as FrameworkElement; if (ElemExtraFilterActive != null) { BindingTools.SetBinding(ElemExtraFilterActive, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.IsExtraFilterActive), converter: new Converters.BooleanToVisibilityConverter()); } ElemSearchActive = Template.FindName("PART_ElemSearchActive", this) as FrameworkElement; if (ElemSearchActive != null) { BindingTools.SetBinding(ElemSearchActive, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.IsSearchActive), converter: new Converters.BooleanToVisibilityConverter()); } ListGameItems = Template.FindName("PART_ListGameItems", this) as ListBox; if (ListGameItems != null) { XNamespace pns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"; ListGameItems.ItemsPanel = Xaml.FromString <ItemsPanelTemplate>(new XDocument( new XElement(pns + nameof(ItemsPanelTemplate), new XElement(pns + nameof(FullscreenTilePanel), new XAttribute(nameof(FullscreenTilePanel.Rows), "{Settings Fullscreen.Rows}"), new XAttribute(nameof(FullscreenTilePanel.Columns), "{Settings Fullscreen.Columns}"), new XAttribute(nameof(FullscreenTilePanel.UseHorizontalLayout), "{Settings Fullscreen.HorizontalLayout}"), new XAttribute(nameof(FullscreenTilePanel.ItemAspectRatio), "{Settings CoverAspectRatio}"), new XAttribute(nameof(FullscreenTilePanel.ItemSpacing), "{Settings FullscreenItemSpacing}"))) ).ToString()); ListGameItems.ItemTemplate = Xaml.FromString <DataTemplate>(new XDocument( new XElement(pns + nameof(DataTemplate), new XElement(pns + nameof(GameListItem), new XAttribute(nameof(GameListItem.Style), "{StaticResource ListGameItemTemplate}"))) ).ToString()); ListGameItems.SetResourceReference(ListBoxEx.ItemContainerStyleProperty, "ListGameItemStyle"); BindingTools.SetBinding(ListGameItems, ListBox.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.GameListVisible), converter: new Converters.BooleanToVisibilityConverter()); BindingTools.SetBinding(ListGameItems, ListBox.SelectedItemProperty, mainModel, nameof(FullscreenAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGameItems, ListBox.ItemsSourceProperty, mainModel, $"{nameof(FullscreenAppViewModel.GamesView)}.{nameof(FullscreenCollectionView.CollectionView)}"); BindingTools.SetBinding(ListGameItems, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.GameListFocused)); } AssignButtonWithCommand(ref ButtonInstall, "PART_ButtonInstall", mainModel.ActivateSelectedCommand); if (ButtonInstall != null) { BindingTools.SetBinding( ButtonInstall, ButtonBase.VisibilityProperty, mainModel, $"{nameof(FullscreenAppViewModel.SelectedGame)}.{nameof(GamesCollectionViewEntry.IsInstalled)}", converter: new InvertedBooleanToVisibilityConverter(), fallBackValue: Visibility.Collapsed); } AssignButtonWithCommand(ref ButtonPlay, "PART_ButtonPlay", mainModel.ActivateSelectedCommand); if (ButtonPlay != null) { ButtonPlay.Command = mainModel.ActivateSelectedCommand; BindingTools.SetBinding( ButtonPlay, ButtonBase.VisibilityProperty, mainModel, $"{nameof(FullscreenAppViewModel.SelectedGame)}.{nameof(GamesCollectionViewEntry.IsInstalled)}", converter: new Converters.BooleanToVisibilityConverter(), fallBackValue: Visibility.Collapsed); } AssignButtonWithCommand(ref ButtonDetails, "PART_ButtonDetails", mainModel.ToggleGameDetailsCommand); if (ButtonDetails != null) { BindingTools.SetBinding( ButtonDetails, ButtonBase.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.GameDetailsButtonVisible), converter: new Converters.BooleanToVisibilityConverter()); } AssignButtonWithCommand(ref ButtonGameOptions, "PART_ButtonGameOptions", mainModel.OpenGameMenuCommand); if (ButtonGameOptions != null) { BindingTools.SetBinding( ButtonGameOptions, ButtonBase.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.GameDetailsButtonVisible), converter: new Converters.BooleanToVisibilityConverter()); ButtonGameOptions.SetResourceReference(ButtonEx.InputHintProperty, "ButtonPromptStart"); } AssignButtonWithCommand(ref ButtonSearch, "PART_ButtonSearch", mainModel.OpenSearchCommand); ButtonSearch?.SetResourceReference(ButtonEx.InputHintProperty, "ButtonPromptY"); AssignButtonWithCommand(ref ButtonFilter, "PART_ButtonFilter", mainModel.ToggleFiltersCommand); ButtonFilter?.SetResourceReference(ButtonEx.InputHintProperty, "ButtonPromptRS"); ElemFilters = Template.FindName("PART_ElemFilters", this) as FrameworkElement; if (ElemFilters != null) { BindingTools.SetBinding(ElemFilters, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.FilterPanelVisible), converter: new Converters.BooleanToVisibilityConverter()); } ElemFiltersAdditional = Template.FindName("PART_ElemFiltersAdditional", this) as FrameworkElement; if (ElemFiltersAdditional != null) { BindingTools.SetBinding(ElemFiltersAdditional, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.FilterAdditionalPanelVisible), converter: new Converters.BooleanToVisibilityConverter()); } ContentFilterItems = Template.FindName("PART_ContentFilterItems", this) as ContentControl; if (ContentFilterItems != null) { BindingTools.SetBinding(ContentFilterItems, ContentControl.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.SubFilterVisible), converter: new Converters.BooleanToVisibilityConverter()); BindingTools.SetBinding(ContentFilterItems, ContentControl.ContentProperty, mainModel, nameof(FullscreenAppViewModel.SubFilterControl)); } ElemGameDetails = Template.FindName("PART_ElemGameDetails", this) as FrameworkElement; if (ElemGameDetails != null) { BindingTools.SetBinding(ElemGameDetails, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.GameDetailsVisible), converter: new Converters.BooleanToVisibilityConverter()); BindingTools.SetBinding(ElemGameDetails, FrameworkElement.DataContextProperty, mainModel, nameof(FullscreenAppViewModel.SelectedGame)); } ElemGameStatus = Template.FindName("PART_ElemGameStatus", this) as FrameworkElement; if (ElemGameStatus != null) { BindingTools.SetBinding(ElemGameStatus, FrameworkElement.VisibilityProperty, mainModel, nameof(FullscreenAppViewModel.GameStatusVisible), converter: new Converters.BooleanToVisibilityConverter()); BindingTools.SetBinding(ElemGameStatus, FrameworkElement.DataContextProperty, mainModel, nameof(FullscreenAppViewModel.SelectedGame)); } SetListCommandBindings(); ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, ApplicationMode.Fullscreen, mainModel, $"{nameof(FullscreenAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ButtonPlayAction = Template.FindName("PART_ButtonPlayAction", this) as Button; if (ButtonPlayAction != null) { BindingTools.SetBinding(ButtonPlayAction, Button.CommandProperty, nameof(GameDetailsViewModel.PlayCommand)); BindingTools.SetBinding(ButtonPlayAction, Button.ContentProperty, nameof(GameDetailsViewModel.ContextActionDescription)); BindingTools.SetBinding(ButtonPlayAction, Button.VisibilityProperty, nameof(GameDetailsViewModel.IsPlayAvailable), converter: new BooleanToVisibilityConverter()); } ButtonContextAction = Template.FindName("PART_ButtonContextAction", this) as Button; if (ButtonContextAction != null) { BindingTools.SetBinding(ButtonContextAction, Button.CommandProperty, nameof(GameDetailsViewModel.ContextActionCommand)); BindingTools.SetBinding(ButtonContextAction, Button.ContentProperty, nameof(GameDetailsViewModel.ContextActionDescription)); BindingTools.SetBinding(ButtonContextAction, Button.VisibilityProperty, nameof(GameDetailsViewModel.IsContextAvailable), converter: new BooleanToVisibilityConverter()); } ButtonMoreActions = Template.FindName("PART_ButtonMoreActions", this) as Button; if (ButtonMoreActions != null) { LeftClickContextMenuBehavior.SetEnabled(ButtonMoreActions, true); if (!DesignerProperties.GetIsInDesignMode(this)) { ButtonMoreActions.ContextMenu = new GameMenu(mainModel) { ShowStartSection = false, Placement = PlacementMode.Relative }; BindingTools.SetBinding(ButtonMoreActions.ContextMenu, Button.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame)); } } ButtonEditGame = Template.FindName("PART_ButtonEditGame", this) as Button; if (ButtonEditGame != null) { BindingTools.SetBinding(ButtonEditGame, Button.CommandProperty, nameof(GameDetailsViewModel.EditGameCommand)); } HtmlDescription = Template.FindName("PART_HtmlDescription", this) as HtmlTextView; if (HtmlDescription != null) { BindingTools.SetBinding(HtmlDescription, HtmlTextView.HtmlTextProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.Description))); BindingTools.SetBinding(HtmlDescription, HtmlTextView.VisibilityProperty, nameof(GameDetailsViewModel.DescriptionVisibility)); HtmlDescription.TemplatePath = ThemeFile.GetFilePath("DescriptionView.html"); } TextNotes = Template.FindName("PART_TextNotes", this) as TextBox; if (TextNotes != null) { BindingTools.SetBinding(TextNotes, TextBox.TextProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.Notes))); BindingTools.SetBinding(TextNotes, TextBox.VisibilityProperty, nameof(GameDetailsViewModel.NotesVisibility)); } ImageCover = Template.FindName("PART_ImageCover", this) as Image; if (ImageCover != null) { BindingTools.SetBinding(ImageCover, Image.SourceProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.CoverImageObject)), converter: new NullToDependencyPropertyUnsetConverter(), mode: BindingMode.OneWay); BindingTools.SetBinding(ImageCover, Image.VisibilityProperty, nameof(GameDetailsViewModel.CoverVisibility), mode: BindingMode.OneWay); } ImageIcon = Template.FindName("PART_ImageIcon", this) as Image; if (ImageIcon != null) { var sourceBinding = new PriorityBinding(); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(GetGameBindingPath(nameof(GamesCollectionViewEntry.IconObject))), Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); sourceBinding.Bindings.Add(new Binding() { Path = new PropertyPath(GetGameBindingPath(nameof(GamesCollectionViewEntry.DefaultIconObject))), Converter = new NullToDependencyPropertyUnsetConverter(), Mode = BindingMode.OneWay }); BindingOperations.SetBinding(ImageIcon, Image.SourceProperty, sourceBinding); BindingTools.SetBinding(ImageIcon, Image.VisibilityProperty, nameof(GameDetailsViewModel.IconVisibility), mode: BindingMode.OneWay); } ImageBackground = Template.FindName("PART_ImageBackground", this) as FadeImage; if (ImageBackground != null) { SetBackgroundBinding(); BindingTools.SetBinding(ImageBackground, Image.VisibilityProperty, nameof(GameDetailsViewModel.BackgroundVisibility), mode: BindingMode.OneWay); BindingTools.SetBinding(ImageBackground, FadeImage.AnimationEnabledProperty, mainModel.AppSettings, nameof(PlayniteSettings.BackgroundImageAnimation), mode: BindingMode.OneWay); } SetElemVisibility(ref ElemPlayTime, "PART_ElemPlayTime", nameof(GameDetailsViewModel.PlayTimeVisibility)); SetElemVisibility(ref ElemLastPlayed, "PART_ElemLastPlayed", nameof(GameDetailsViewModel.LastPlayedVisibility)); SetElemVisibility(ref ElemCompletionStatus, "PART_ElemCompletionStatus", nameof(GameDetailsViewModel.CompletionStatusVisibility)); SetElemVisibility(ref ElemLibrary, "PART_ElemLibrary", nameof(GameDetailsViewModel.SourceLibraryVisibility)); SetElemVisibility(ref ElemPlatform, "PART_ElemPlatform", nameof(GameDetailsViewModel.PlatformVisibility)); SetElemVisibility(ref ElemGenres, "PART_ElemGenres", nameof(GameDetailsViewModel.GenreVisibility)); SetElemVisibility(ref ElemDevelopers, "PART_ElemDevelopers", nameof(GameDetailsViewModel.DeveloperVisibility)); SetElemVisibility(ref ElemPublishers, "PART_ElemPublishers", nameof(GameDetailsViewModel.PublisherVisibility)); SetElemVisibility(ref ElemReleaseDate, "PART_ElemReleaseDate", nameof(GameDetailsViewModel.ReleaseDateVisibility)); SetElemVisibility(ref ElemTags, "PART_ElemTags", nameof(GameDetailsViewModel.TagVisibility)); SetElemVisibility(ref ElemFeatures, "PART_ElemFeatures", nameof(GameDetailsViewModel.FeatureVisibility)); SetElemVisibility(ref ElemCategories, "PART_ElemCategories", nameof(GameDetailsViewModel.CategoryVisibility)); SetElemVisibility(ref ElemLinks, "PART_ElemLinks", nameof(GameDetailsViewModel.LinkVisibility)); SetElemVisibility(ref ElemDescription, "PART_ElemDescription", nameof(GameDetailsViewModel.DescriptionVisibility)); SetElemVisibility(ref ElemAgeRating, "PART_ElemAgeRating", nameof(GameDetailsViewModel.AgeRatingVisibility)); SetElemVisibility(ref ElemSeries, "PART_ElemSeries", nameof(GameDetailsViewModel.SeriesVisibility)); SetElemVisibility(ref ElemRegion, "PART_ElemRegion", nameof(GameDetailsViewModel.RegionVisibility)); SetElemVisibility(ref ElemSource, "PART_ElemSource", nameof(GameDetailsViewModel.SourceVisibility)); SetElemVisibility(ref ElemVersion, "PART_ElemVersion", nameof(GameDetailsViewModel.VersionVisibility)); SetElemVisibility(ref ElemCommunityScore, "PART_ElemCommunityScore", nameof(GameDetailsViewModel.CommunityScoreVisibility)); SetElemVisibility(ref ElemCriticScore, "PART_ElemCriticScore", nameof(GameDetailsViewModel.CriticScoreVisibility)); SetElemVisibility(ref ElemUserScore, "PART_ElemUserScore", nameof(GameDetailsViewModel.UserScoreVisibility)); SetElemVisibility(ref ElemNotes, "PART_ElemNotes", nameof(GameDetailsViewModel.NotesVisibility)); SetGameItemButtonBinding(ref ButtonLibrary, "PART_ButtonLibrary", nameof(GameDetailsViewModel.SetLibraryFilterCommand), GetGameBindingPath(nameof(GamesCollectionViewEntry.PluginId)), GetGameBindingPath($"{nameof(GamesCollectionViewEntry.LibraryPlugin)}.{nameof(GamesCollectionViewEntry.LibraryPlugin.Name)}"), nameof(GameDetailsViewModel.SourceLibraryVisibility)); SetGameItemButtonBinding(ref ButtonReleaseDate, "PART_ButtonReleaseDate", nameof(GameDetailsViewModel.SetReleaseDateFilterCommand), GetGameBindingPath(nameof(GamesCollectionViewEntry.ReleaseDate)), GetGameBindingPath(nameof(GamesCollectionViewEntry.ReleaseDate)), nameof(GameDetailsViewModel.ReleaseDateVisibility)); SetGameItemButtonBinding(ref ButtonVersion, "PART_ButtonVersion", nameof(GameDetailsViewModel.SetVersionFilterCommand), GetGameBindingPath(nameof(GamesCollectionViewEntry.Version)), GetGameBindingPath(nameof(GamesCollectionViewEntry.Version)), nameof(GameDetailsViewModel.VersionVisibility)); SetGameItemButtonBinding(ref ButtonSource, "PART_ButtonSource", nameof(GameDetailsViewModel.SetSourceFilterCommand), GetGameBindingPath(nameof(GamesCollectionViewEntry.Source)), GetGameBindingPath($"{nameof(GamesCollectionViewEntry.Source)}.{nameof(GamesCollectionViewEntry.Source.Name)}"), nameof(GameDetailsViewModel.SourceVisibility)); SetGameItemTextBinding(ref TextPlayTime, "PART_TextPlayTime", nameof(GameDetailsViewModel.Game.Playtime), nameof(GameDetailsViewModel.PlayTimeVisibility), new PlayTimeToStringConverter()); SetGameItemTextBinding(ref TextLastActivity, "PART_TextLastActivity", nameof(GameDetailsViewModel.Game.LastActivity), nameof(GameDetailsViewModel.LastPlayedVisibility), new DateTimeToLastPlayedConverter()); SetGameItemButtonBinding(ref ButtonCompletionStatus, "PART_ButtonCompletionStatus", nameof(GameDetailsViewModel.SetCompletionStatusFilterCommand), GetGameBindingPath(nameof(GamesCollectionViewEntry.CompletionStatus)), GetGameBindingPath($"{nameof(GamesCollectionViewEntry.CompletionStatus)}.{nameof(GamesCollectionViewEntry.CompletionStatus.Name)}"), nameof(GameDetailsViewModel.CompletionStatusVisibility)); SetGameItemTextBinding(ref TextCommunityScore, "PART_TextCommunityScore", nameof(GameDetailsViewModel.Game.CommunityScore), nameof(GameDetailsViewModel.CommunityScoreVisibility)); if (TextCommunityScore != null) { BindingTools.SetBinding(TextCommunityScore, TextBlock.TagProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.CommunityScoreRating))); } SetGameItemTextBinding(ref TextCriticScore, "PART_TextCriticScore", nameof(GameDetailsViewModel.Game.CriticScore), nameof(GameDetailsViewModel.CriticScoreVisibility)); if (TextCriticScore != null) { BindingTools.SetBinding(TextCriticScore, TextBlock.TagProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.CriticScoreRating))); } SetGameItemTextBinding(ref TextUserScore, "PART_TextUserScore", nameof(GameDetailsViewModel.Game.UserScore), nameof(GameDetailsViewModel.UserScoreVisibility)); if (TextUserScore != null) { BindingTools.SetBinding(TextUserScore, TextBlock.TagProperty, GetGameBindingPath(nameof(GamesCollectionViewEntry.UserScoreRating))); } SetItemsControlBinding(ref ItemsGenres, "PART_ItemsGenres", nameof(GameDetailsViewModel.SetGenreFilterCommand), nameof(GamesCollectionViewEntry.Genres), nameof(GameDetailsViewModel.GenreVisibility)); SetItemsControlBinding(ref ItemsDevelopers, "PART_ItemsDevelopers", nameof(GameDetailsViewModel.SetDeveloperFilterCommand), nameof(GamesCollectionViewEntry.Developers), nameof(GameDetailsViewModel.DeveloperVisibility)); SetItemsControlBinding(ref ItemsPublishers, "PART_ItemsPublishers", nameof(GameDetailsViewModel.SetPublisherFilterCommand), nameof(GamesCollectionViewEntry.Publishers), nameof(GameDetailsViewModel.PublisherVisibility)); SetItemsControlBinding(ref ItemsCategories, "PART_ItemsCategories", nameof(GameDetailsViewModel.SetCategoryFilterCommand), nameof(GamesCollectionViewEntry.Categories), nameof(GameDetailsViewModel.CategoryVisibility)); SetItemsControlBinding(ref ItemsTags, "PART_ItemsTags", nameof(GameDetailsViewModel.SetTagFilterCommand), nameof(GamesCollectionViewEntry.Tags), nameof(GameDetailsViewModel.TagVisibility)); SetItemsControlBinding(ref ItemsFeatures, "PART_ItemsFeatures", nameof(GameDetailsViewModel.SetFeatureFilterCommand), nameof(GamesCollectionViewEntry.Features), nameof(GameDetailsViewModel.FeatureVisibility)); SetItemsControlBinding(ref ItemsLinks, "PART_ItemsLinks", nameof(GameDetailsViewModel.OpenLinkCommand), nameof(GamesCollectionViewEntry.Links), nameof(GameDetailsViewModel.LinkVisibility), nameof(Link.Url)); SetItemsControlBinding(ref ItemsPlatforms, "PART_ItemsPlatforms", nameof(GameDetailsViewModel.SetPlatformFilterCommand), nameof(GamesCollectionViewEntry.Platforms), nameof(GameDetailsViewModel.PlatformVisibility)); SetItemsControlBinding(ref ItemsAgeRatings, "PART_ItemsAgeRatings", nameof(GameDetailsViewModel.SetAgeRatingFilterCommand), nameof(GamesCollectionViewEntry.AgeRatings), nameof(GameDetailsViewModel.AgeRatingVisibility)); SetItemsControlBinding(ref ItemsSeries, "PART_ItemsSeries", nameof(GameDetailsViewModel.SetSeriesFilterCommand), nameof(GamesCollectionViewEntry.Series), nameof(GameDetailsViewModel.SeriesVisibility)); SetItemsControlBinding(ref ItemsRegions, "PART_ItemsRegions", nameof(GameDetailsViewModel.SetRegionFilterCommand), nameof(GamesCollectionViewEntry.Regions), nameof(GameDetailsViewModel.RegionVisibility)); ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }