public SubscriptionsPage() { InitializeComponent(); CheckForSubscriptionUpdatesCheckBox.IsChecked = GlobalConsts.CheckForSubscriptionUpdates; GlobalConsts.HideSubscriptionsButton(); GlobalConsts.ShowHelpButton(); GlobalConsts.ShowSettingsButton(); GlobalConsts.ShowHomeButton(); GlobalConsts.ShowAboutButton(); void UpdateSize(object s, SizeChangedEventArgs e) { GridScrollViewer.Height = Subscriptions.Count * 105; GridScrollViewer.MaxHeight = GlobalConsts.GetOffset() - 165; GridScrollViewer.UpdateLayout(); } GlobalConsts.Current.SizeChanged += UpdateSize; Unloaded += (s, e) => GlobalConsts.Current.SizeChanged -= UpdateSize; SubscriptionsUpdateDelayTextBox.Text = GlobalConsts.SubscriptionsUpdateDelay.TotalMinutes.ToString(); FillSubscriptions().ConfigureAwait(false); }
public MainPage() { InitializeComponent(); GlobalConsts.HideHomeButton(); GlobalConsts.ShowSettingsButton(); GlobalConsts.ShowAboutButton(); GlobalConsts.ShowHelpButton(); GlobalConsts.ShowSubscriptionsButton(); VideoList = new List <Video>(); client = GlobalConsts.YoutubeClient; void UpdateSize(object s, SizeChangedEventArgs e) { double height = GlobalConsts.GetOffset() - (HeadlineStackPanel.ActualHeight + 75); GridScrollViewer.Height = height; QueueScrollViewer.Height = height; BulkScrollViewer.Height = height - 110; GridScrollViewer.UpdateLayout(); QueueScrollViewer.UpdateLayout(); BulkScrollViewer.UpdateLayout(); } GlobalConsts.Current.SizeChanged += UpdateSize; Unloaded += (s, e) => GlobalConsts.Current.SizeChanged -= UpdateSize; GlobalConsts.MainPage = this; }
private async Task AddSubscriptionPanel(Subscription sub) { var channel = await sub.GetChannel(); _ = Dispatcher.InvokeAsync(() => { int row = SubscriptionsGrid.RowDefinitions.Count; RowDefinition rowDefinition = new RowDefinition { Height = GridLength.Auto, }; SubscriptionsGrid.RowDefinitions.Add(rowDefinition); Image logo = new Image { MaxWidth = 120, MaxHeight = 120, Width = 98, Height = 98, Margin = new Thickness(2), Source = new BitmapImage(new Uri(channel.LogoUrl)), VerticalAlignment = VerticalAlignment.Top }; Grid.SetColumn(logo, 0); Grid.SetRow(logo, row); SubscriptionsGrid.Children.Add(logo); TextBlock description = new TextBlock { Height = 40, Width = double.NaN, FontSize = 14, VerticalAlignment = VerticalAlignment.Top }; description.Inlines.Add(string.Concat(FindResource("PlaylistTitle"), channel.Title, "\n")); description.Inlines.Add(string.Concat(FindResource("LastVideoDownloadDate"), sub.LatestVideoDownloaded.ToLocalTime().ToShortDateString())); Grid.SetColumn(description, 1); Grid.SetRow(description, row); SubscriptionsGrid.Children.Add(description); StackPanel buttonsPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Center }; Grid.SetColumn(buttonsPanel, 2); Grid.SetRow(buttonsPanel, row); SubscriptionsGrid.Children.Add(buttonsPanel); Tile settingsButton = new Tile { Height = double.NaN, Width = double.NaN, Margin = new Thickness(2.5), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }, removeButton = new Tile { Height = double.NaN, Width = double.NaN, Margin = new Thickness(2.5), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; removeButton.Click += (s, e) => { rowDefinition.Height = new GridLength(0); Subscriptions.Remove(Subscriptions.FirstOrDefault(x => x.ChannelId.Equals(sub.ChannelId))); }; settingsButton.Click += (s, e) => { GlobalConsts.LoadFlyoutPage(new SubscriptionSettings(sub)); }; buttonsPanel.Children.Add(settingsButton); buttonsPanel.Children.Add(removeButton); WrapPanel settingsButtonWrapPanel = new WrapPanel(), removeButtonWrapPanel = new WrapPanel(); //Settings button PackIconModern settingsButtonIcon = new PackIconModern { Kind = PackIconModernKind.Cogs, Width = 35, Height = 35, Margin = new Thickness(5) }; TextBlock settingsButtonTextBlock = new TextBlock { Text = $"{FindResource("Settings")}", VerticalAlignment = VerticalAlignment.Center, FontSize = 16, Margin = new Thickness(2.5, 5, 7.5, 5) }; settingsButtonWrapPanel.Children.Add(settingsButtonIcon); settingsButtonWrapPanel.Children.Add(settingsButtonTextBlock); settingsButton.Content = settingsButtonWrapPanel; //Remove button PackIconModern removeButtonIcon = new PackIconModern { Kind = PackIconModernKind.Close, Width = 35, Height = 35, Margin = new Thickness(5) }; TextBlock removeButtonTextBlock = new TextBlock { Text = $"{FindResource("Remove")}", VerticalAlignment = VerticalAlignment.Center, FontSize = 16, Margin = new Thickness(2.5, 5, 7.5, 5) }; removeButtonWrapPanel.Children.Add(removeButtonIcon); removeButtonWrapPanel.Children.Add(removeButtonTextBlock); removeButton.Content = removeButtonWrapPanel; GridScrollViewer.Height = GlobalConsts.Current.ActualHeight - 300; GridScrollViewer.UpdateLayout(); }); }