Ads development
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Microsoft.Advertising.WinRT.UI;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace FoxTube.Controls.Adverts
|
||||
{
|
||||
/// <summary>
|
||||
/// Advert which is looks similar to video cards
|
||||
/// </summary>
|
||||
public sealed partial class CardAdvert : UserControl
|
||||
{
|
||||
NativeAdV2 advert;
|
||||
public CardAdvert(NativeAdV2 ad)
|
||||
{
|
||||
InitializeComponent();
|
||||
advert = ad;
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
title.Text = advert.Title;
|
||||
image.Source = new BitmapImage(advert.MainImages.First().Url.ToUri());
|
||||
if (advert.AdIcon == null)
|
||||
contentGrid.ColumnDefinitions[0].Width = new GridLength(0);
|
||||
else
|
||||
icon.ProfilePicture = advert.AdIcon.Source;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(advert.SponsoredBy))
|
||||
sponsor.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
sponsor.Text = advert.SponsoredBy;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(advert.Rating))
|
||||
info.Text += $" {advert.Rating}";
|
||||
|
||||
if (string.IsNullOrWhiteSpace(advert.CallToActionText) && string.IsNullOrWhiteSpace(advert.Price))
|
||||
desc.Visibility = Visibility.Collapsed;
|
||||
else if (!string.IsNullOrWhiteSpace(advert.CallToActionText))
|
||||
desc.Text = advert.CallToActionText;
|
||||
else
|
||||
desc.Text = advert.Price;
|
||||
}
|
||||
|
||||
private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
Height = e.NewSize.Width * 0.75;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user