示例#1
0
        private void SetupSubViews()
        {
            _avatar = new AvatarImageView();

            _displayName = new UILabel {
                Font = iOS.Appearance.Fonts.LatoBoldWithSize(14.5f), TextColor = iOS.Appearance.Colors.DefaultTextColor, Text = "Display Name"
            };
            _timeAgo = new UILabel {
                Font = iOS.Appearance.Fonts.LatoWithSize(11.86f), TextColor = iOS.Appearance.Colors.SubTextColor, Text = "30 minutes ago"
            };

            //_text = new UILabel { Font = iOS.Appearance.Fonts.LatoWithSize(15), TextColor = iOS.Appearance.Colors.DefaultTextColor, Text = "Comment text", Lines = 0 };
            Text = new HtmlTextView();

            _contextButton = new UIButton();
            _contextButton.TouchUpInside += ContextButtonOnTouchUpInside;
            var contextButtonImage = UIImage.FromBundle("Icons/icon_more.png");

            _contextButton.SetImage(contextButtonImage, UIControlState.Normal);

            _bottomRuler = new UIView {
                BackgroundColor = iOS.Appearance.Colors.BarShadowColor
            };

            ContentView.AddSubviews(_avatar, _displayName, _timeAgo, Text, _bottomRuler, _contextButton);
        }
示例#2
0
        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.Bottom
                    };
                    BindingTools.SetBinding(ButtonMoreActions.ContextMenu,
                                            Button.DataContextProperty,
                                            mainModel,
                                            nameof(DesktopAppViewModel.SelectedGame));
                }
            }

            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));
            }

            ImageCover = Template.FindName("PART_ImageCover", this) as Image;
            if (ImageCover != null)
            {
                BindingTools.SetBinding(ImageCover,
                                        Image.SourceProperty,
                                        GetGameBindingPath(nameof(GamesCollectionViewEntry.CoverImageObject)),
                                        converter: new NullToDependencyPropertyUnsetConverter());
                BindingTools.SetBinding(ImageCover,
                                        Image.VisibilityProperty,
                                        nameof(GameDetailsViewModel.CoverVisibility));
            }

            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()
                });
                sourceBinding.Bindings.Add(new Binding()
                {
                    Path      = new PropertyPath(GetGameBindingPath(nameof(GamesCollectionViewEntry.DefaultIconObject))),
                    Converter = new NullToDependencyPropertyUnsetConverter()
                });

                BindingOperations.SetBinding(ImageIcon, Image.SourceProperty, sourceBinding);
                BindingTools.SetBinding(ImageIcon,
                                        Image.VisibilityProperty,
                                        nameof(GameDetailsViewModel.IconVisibility));
            }

            ImageBackground = Template.FindName("PART_ImageBackground", this) as FadeImage;
            if (ImageBackground != null)
            {
                SetBackgroundBinding();
                BindingTools.SetBinding(ImageBackground,
                                        Image.VisibilityProperty,
                                        nameof(GameDetailsViewModel.BackgroundVisibility));
            }

            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_ElemCategories", nameof(GameDetailsViewModel.CategoryVisibility));
            SetElemVisibility(ref ElemCategories, "PART_ElemTags", nameof(GameDetailsViewModel.TagVisibility));
            SetElemVisibility(ref ElemLinks, "PART_ElemLinks", nameof(GameDetailsViewModel.LinkVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemDescription", nameof(GameDetailsViewModel.DescriptionVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemAgeRating", nameof(GameDetailsViewModel.AgeRatingVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemSeries", nameof(GameDetailsViewModel.SeriesVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemRegion", nameof(GameDetailsViewModel.RegionVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemSource", nameof(GameDetailsViewModel.SourceVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemVersion", nameof(GameDetailsViewModel.VersionVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemCommunityScore", nameof(GameDetailsViewModel.CommunityScoreVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemCriticScore", nameof(GameDetailsViewModel.CriticScoreVisibility));
            SetElemVisibility(ref ElemDescription, "PART_ElemUserScore", nameof(GameDetailsViewModel.UserScoreVisibility));

            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 ButtonPlatform, "PART_ButtonPlatform",
                                     nameof(GameDetailsViewModel.SetPlatformFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Platform)),
                                     GetGameBindingPath($"{nameof(GamesCollectionViewEntry.Platform)}.{nameof(GamesCollectionViewEntry.Platform.Name)}"),
                                     nameof(GameDetailsViewModel.PlatformVisibility));

            SetGameItemButtonBinding(ref ButtonReleaseDate, "PART_ButtonReleaseDate",
                                     nameof(GameDetailsViewModel.SetReleaseDateFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.ReleaseDate)),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.ReleaseDate)),
                                     nameof(GameDetailsViewModel.ReleaseDateVisibility),
                                     new NullableDateToStringConverter());

            SetGameItemButtonBinding(ref ButtonVersion, "PART_ButtonVersion",
                                     nameof(GameDetailsViewModel.SetVersionFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Version)),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Version)),
                                     nameof(GameDetailsViewModel.VersionVisibility));

            SetGameItemButtonBinding(ref ButtonAgeRating, "PART_ButtonAgeRating",
                                     nameof(GameDetailsViewModel.SetAgeRatingCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.AgeRating)),
                                     GetGameBindingPath($"{nameof(GamesCollectionViewEntry.AgeRating)}.{nameof(GamesCollectionViewEntry.AgeRating.Name)}"),
                                     nameof(GameDetailsViewModel.AgeRatingVisibility));

            SetGameItemButtonBinding(ref ButtonSeries, "PART_ButtonSeries",
                                     nameof(GameDetailsViewModel.SetSeriesFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Series)),
                                     GetGameBindingPath($"{nameof(GamesCollectionViewEntry.Series)}.{nameof(GamesCollectionViewEntry.Series.Name)}"),
                                     nameof(GameDetailsViewModel.SeriesVisibility));

            SetGameItemButtonBinding(ref ButtonSource, "PART_ButtonSource",
                                     nameof(GameDetailsViewModel.SetSourceFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Source)),
                                     GetGameBindingPath($"{nameof(GamesCollectionViewEntry.Source)}.{nameof(GamesCollectionViewEntry.Source.Name)}"),
                                     nameof(GameDetailsViewModel.SourceVisibility));

            SetGameItemButtonBinding(ref ButtonRegion, "PART_ButtonRegion",
                                     nameof(GameDetailsViewModel.SetRegionFilterCommand),
                                     GetGameBindingPath(nameof(GamesCollectionViewEntry.Region)),
                                     GetGameBindingPath($"{nameof(GamesCollectionViewEntry.Region)}.{nameof(GamesCollectionViewEntry.Region.Name)}"),
                                     nameof(GameDetailsViewModel.RegionVisibility));

            SetGameItemTextBinding(ref TextPlayTime, "PART_TextPlayTime",
                                   nameof(GameDetailsViewModel.Game.Playtime),
                                   nameof(GameDetailsViewModel.PlayTimeVisibility),
                                   new LongToTimePlayedConverter());

            SetGameItemTextBinding(ref TextLastActivity, "PART_TextLastActivity",
                                   nameof(GameDetailsViewModel.Game.LastActivity),
                                   nameof(GameDetailsViewModel.LastPlayedVisibility),
                                   new DateTimeToLastPlayedConverter());

            SetGameItemTextBinding(ref TextCompletionStatus, "PART_TextCompletionStatus",
                                   nameof(GameDetailsViewModel.Game.CompletionStatus),
                                   nameof(GameDetailsViewModel.CompletionStatusVisibility),
                                   new ObjectToStringConverter());

            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 ItemsLinks, "PART_ItemsLinks",
                                   nameof(GameDetailsViewModel.OpenLinkCommand),
                                   nameof(GamesCollectionViewEntry.Links),
                                   nameof(GameDetailsViewModel.LinkVisibility),
                                   nameof(Link.Url));
        }
示例#3
0
        private void SetupSubViews()
        {
            BackgroundColor = iOS.Appearance.Colors.BackgroundColor;

            // Header
            _header = new UIImageView
            {
                BackgroundColor = UIColor.Black,
                ContentMode     = UIViewContentMode.ScaleAspectFill,
                ClipsToBounds   = true
            };

            _date = new UILabel
            {
                TextColor     = iOS.Appearance.Colors.DefaultTextColor,
                Font          = iOS.Appearance.Fonts.LatoWithSize(13),
                TextAlignment = UITextAlignment.Center
            };
            _dateBackPanel = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White
            };
            _dateBackPanel.Layer.CornerRadius = 4.0f;

            _infoContainer            = new UIView();
            _infoContainerPlaceHolder = new UIView();

            _title = new UILabel
            {
                TextColor     = iOS.Appearance.Colors.White,
                Font          = iOS.Appearance.Fonts.LatoBlackWithSize(24),
                Lines         = 2,
                LineBreakMode = UILineBreakMode.TailTruncation
            };
            _time = new UILabel {
                TextColor = iOS.Appearance.Colors.White, Font = iOS.Appearance.Fonts.LatoWithSize(15)
            };
            _location = new UILabel
            {
                TextColor     = iOS.Appearance.Colors.White,
                Font          = iOS.Appearance.Fonts.LatoWithSize(15),
                Lines         = 1,
                LineBreakMode = UILineBreakMode.TailTruncation
            };

            _attendButton = new BlueButton {
                Font = iOS.Appearance.Fonts.LatoBlackWithSize(18)
            };
            _attendButton.Layer.ShadowColor   = UIColor.Black.CGColor;
            _attendButton.Layer.ShadowRadius  = 10f;
            _attendButton.Layer.ShadowOpacity = 0.65f;
            _attendButton.Layer.ShadowOffset  = new CGSize(0, 5);

            _infoBackGround = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White
            };

            _attendingLabel = new UILabel
            {
                Font      = iOS.Appearance.Fonts.LatoWithSize(15),
                TextColor = iOS.Appearance.Colors.SubTextColor
            };
            _attendingCollection = new UICollectionView(ContentView.Frame,
                                                        new UICollectionViewFlowLayout
            {
                ItemSize                = new CGSize(31, 31),
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                MinimumInteritemSpacing = 0,
                MinimumLineSpacing      = 5
            })
            {
                AllowsSelection = false,
                ScrollEnabled   = false,
                BackgroundColor = UIColor.Clear,
            };

            _attendingCollection.RegisterClassForCell(typeof(CollectionUserCell), CollectionUserCell.Identifier);
            _attendingCollection.Source    =
                _attendingCollectionSource =
                    new MvxCollectionViewSource(_attendingCollection, CollectionUserCell.Identifier);

            _ruler = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };

            _eventInfoHeader = new UILabel
            {
                Font      = iOS.Appearance.Fonts.LatoWithSize(15),
                TextColor = iOS.Appearance.Colors.SubTextColor,
            };
            _eventDateLabel = new UILabel
            {
                TextColor = iOS.Appearance.Colors.DefaultTextColor,
                Font      = iOS.Appearance.Fonts.LatoBoldWithSize(14),
            };
            _eventDate = new UILabel
            {
                TextColor = iOS.Appearance.Colors.ChatMessageColor,
                Font      = iOS.Appearance.Fonts.LatoWithSize(14)
            };
            _eventTimeLabel = new UILabel
            {
                TextColor = iOS.Appearance.Colors.DefaultTextColor,
                Font      = iOS.Appearance.Fonts.LatoBoldWithSize(14),
            };
            _eventTime = new UILabel
            {
                TextColor = iOS.Appearance.Colors.ChatMessageColor,
                Font      = iOS.Appearance.Fonts.LatoWithSize(14)
            };
            _eventLocationLabel = new UILabel
            {
                TextColor = iOS.Appearance.Colors.DefaultTextColor,
                Font      = iOS.Appearance.Fonts.LatoBoldWithSize(14),
            };
            EventLocation = new UILabel
            {
                TextColor = iOS.Appearance.Colors.ChatMessageColor,
                Font      = iOS.Appearance.Fonts.LatoWithSize(14),
                Lines     = 0,
            };

            _infoBottomBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };

            _imageTopBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };
            _imageBackground = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White
            };
            _imageBottomBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };

            _imageCollection = new UICollectionView(ContentView.Frame,
                                                    new UICollectionViewFlowLayout
            {
                ItemSize                = new CGSize(105, 105),
                ScrollDirection         = UICollectionViewScrollDirection.Horizontal,
                MinimumInteritemSpacing = 0,
                MinimumLineSpacing      = 14
            })
            {
                AllowsSelection = true,
                ScrollEnabled   = true,
                BackgroundColor = UIColor.White,
                ShowsHorizontalScrollIndicator = false,
            };

            _imageCollection.RegisterClassForCell(typeof(ImageCollectionCell), ImageCollectionCell.Identifier);
            _imageCollection.Source = _imageCollectionSource = new GenericCollectionViewSource <IImage>(_imageCollection, ImageCollectionCell.Identifier)
            {
                ModifyCellFunc = (view, path, cell, item) =>
                {
                    var imageCollectionCell = cell as ImageCollectionCell;

                    if (imageCollectionCell != null)
                    {
                        imageCollectionCell.CornerRadius = 8f;
                    }
                }
            };

            _aboutBackground = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White
            };
            _aboutTopBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };
            _aboutRuler = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };

            _aboutHeaderLabel = new UILabel
            {
                Font      = iOS.Appearance.Fonts.LatoBoldWithSize(14),
                TextColor = iOS.Appearance.Colors.DefaultTextColor,
            };
            AboutText = new HtmlTextView();

            //_commentButton = new FeedButton { ImageTopSpacing = 3 };

            ContentView.AddSubviews(_header, _infoContainer, _infoContainerPlaceHolder, _title, _time, _location,
                                    _dateBackPanel, _date, _attendButton, _infoBackGround, _attendingLabel, _attendingCollection, _ruler,
                                    _eventInfoHeader, _eventDate, _eventDateLabel, _eventTime, _eventTimeLabel, _eventLocationLabel,
                                    EventLocation, _infoBottomBorder, _imageBackground, _imageCollection, _imageTopBorder,
                                    _imageBottomBorder,
                                    _aboutBackground, _aboutTopBorder, AboutText, _aboutHeaderLabel, _aboutRuler);//, _commentButton);
        }
示例#4
0
        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)}");
            }
        }
示例#5
0
        private void SetupSubViews()
        {
            BackgroundColor = iOS.Appearance.Colors.BackgroundColor;
            SelectionStyle  = UITableViewCellSelectionStyle.None;

            // Backpanel
            _backPanel = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White, AccessibilityIdentifier = "BackPanel"
            };
            _topBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.BackPanelBorderTop, AccessibilityIdentifier = "TopBorder"
            };
            _bottomBorder = new UIView {
                BackgroundColor = iOS.Appearance.Colors.BackPanelBorderBottom, AccessibilityIdentifier = "BottomBorder"
            };

            // Header
            _avatarImageView = new AvatarImageView {
                AccessibilityIdentifier = "AvatarImage"
            };
            _displayName = new UILabel {
                Font = iOS.Appearance.Fonts.LatoBoldWithSize(14.5f), TextColor = iOS.Appearance.Colors.DefaultTextColor, Text = "Display Name", AccessibilityIdentifier = "DisplayName"
            };
            _timeAgo = new UILabel {
                Font = iOS.Appearance.Fonts.LatoWithSize(11.86f), TextColor = iOS.Appearance.Colors.SubTextColor, Text = "30 minutes ago", AccessibilityIdentifier = "TimeAgo"
            };
            _contextButton = new UIButton();
            _contextButton.TouchUpInside += ContextButtonOnTouchUpInside;

            var contextButtonImage = UIImage.FromBundle("Icons/icon_more.png");

            _contextButton.SetImage(contextButtonImage, UIControlState.Normal);

            // Text
            _postText = new HtmlTextView(ShouldInteractWithUrl)
            {
                AccessibilityIdentifier = "PostText"
            };

            // Content
            _mainImage = new UIImageView {
                ContentMode = UIViewContentMode.ScaleAspectFill, ClipsToBounds = true, BackgroundColor = iOS.Appearance.Colors.BackgroundColor
            };

            // Text for events and other items
            _date = new UILabel {
                TextColor = iOS.Appearance.Colors.DefaultTextColor, Font = iOS.Appearance.Fonts.LatoWithSize(13), TextAlignment = UITextAlignment.Center
            };
            _dateBackPanel = new UIView {
                BackgroundColor = iOS.Appearance.Colors.White
            };
            _dateBackPanel.Layer.CornerRadius = 4.0f;

            _infoContainer            = new UIView();
            _infoContainerPlaceholder = new UIView();

            _title = new UILabel {
                TextColor = iOS.Appearance.Colors.White, Font = iOS.Appearance.Fonts.LatoBlackWithSize(24), Lines = 1, LineBreakMode = UILineBreakMode.TailTruncation
            };
            _time = new UILabel {
                TextColor = iOS.Appearance.Colors.White, Font = iOS.Appearance.Fonts.LatoWithSize(15)
            };
            _location = new UILabel {
                TextColor = iOS.Appearance.Colors.White, Font = iOS.Appearance.Fonts.LatoWithSize(15), Lines = 1, LineBreakMode = UILineBreakMode.TailTruncation
            };

            _leftSubImage = new UIImageView {
                ContentMode = UIViewContentMode.ScaleAspectFill, ClipsToBounds = true, BackgroundColor = iOS.Appearance.Colors.BackgroundColor
            };
            _rightSubImage = new UIImageView {
                ContentMode = UIViewContentMode.ScaleAspectFill, ClipsToBounds = true, BackgroundColor = iOS.Appearance.Colors.BackgroundColor
            };

            // Footer
            _ruler = new UIView {
                BackgroundColor = iOS.Appearance.Colors.RulerColor
            };
            _commentButton = new FeedButton {
                ImageTopSpacing = 3
            };
            _likeButton = new FeedButton {
                ImageBottomSpacing = 3
            };

            // Add views
            ContentView.AddSubviews(_backPanel, _topBorder, _bottomBorder, _avatarImageView, _displayName, _timeAgo, _postText, _mainImage, _infoContainer, _infoContainerPlaceholder, _title, _dateBackPanel, _date, _time, _location, _leftSubImage, _rightSubImage, _ruler, _commentButton, _likeButton, _contextButton);
        }