Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FoxTube/FoxTube/Controls/Advert.xaml.cs
T
2018-11-04 15:15:57 +03:00

71 lines
1.7 KiB
C#

using System.Diagnostics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace FoxTube.Controls
{
public sealed partial class Advert : UserControl
{
public string AdUnitId { get; set; } = "test";
public string AppId => "3f83fe91-d6be-434d-a0ae-7351c5a997f1";
public bool OverrideSize { get; set; } = false;
public new double Height
{
get { return ad.Height; }
set
{
ad.Height = value;
OverrideSize = true;
}
}
public new double Width
{
get { return ad.Width; }
set
{
ad.Width = value;
OverrideSize = true;
}
}
public Advert()
{
this.InitializeComponent();
if (!SecretsVault.AdsDisabled)
Visibility = Visibility.Visible;
else
Visibility = Visibility.Collapsed;
SecretsVault.NotPurchased += () => Visibility = Visibility.Visible;
}
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (OverrideSize)
return;
if(grid.ActualWidth >= 728)
{
ad.Width = 728;
ad.Height = 90;
}
else if (grid.ActualWidth >= 640)
{
ad.Width = 640;
ad.Height = 100;
}
else if (grid.ActualWidth >= 320)
{
ad.Width = 320;
ad.Height = 50;
}
else
{
ad.Width = 300;
ad.Height = 50;
}
}
}
}