public AboutWindow(Channel channel) { InitializeComponent(); this.channel=channel; homepageUrl=channel.HomepageUrl; if (homepageUrl == null) { homepageIcon.Visibility=Visibility.Collapsed; homepageLink.Visibility=Visibility.Collapsed; } DataContext=this; }
public MainWindow() : this(null) {} // Konstruktors Visual Studio dizainerim. #endif public MainWindow(Channel firstChannel) { InitializeComponent(); this.channel=firstChannel; this.Loaded+=Window_Loaded; this.Closing+=Window_Closing; mutedIcon=(BitmapImage)Resources["MutedIcon"]; unmutedIcon=(BitmapImage)Resources["UnmutedIcon"]; ShowMuteStateInTaskBar(true); this.CommandBindings.Add(new CommandBinding(MediaCommands.MuteVolume, MuteCmd_Executed)); this.CommandBindings.Add(new CommandBinding(MediaCommands.IncreaseVolume, IncreaseCmd_Executed)); this.CommandBindings.Add(new CommandBinding(MediaCommands.DecreaseVolume, DecreaseCmd_Executed)); appMenuMask.Freeze(); channelMenuMask.Freeze(); guideMenuMask.Freeze(); guidedMenuMask.Freeze(); guidedChannelMenuMask.Freeze(); }
public async Task SetChannel(Channel newChannel) { if (stateChanging) return; stateChanging=true; if (newChannel == null) newChannel=new EmptyChannel(); bool hadGuide=false; if (channel != null && notFirstChannel) { if (!(channel is EmptyChannel)) { newChannel.IsMuted=channel.IsMuted; newChannel.Volume=channel.Volume; hadGuide=channel.Guide != null; if (hadGuide) { if (guidePanel.Visibility == Visibility.Visible) StopGuide(); channel.Guide.CurrentBroadcastChanged-=guide_BroadcastChanged; if (channel.Guide.Menu != null) for (int n=0; n < channel.Guide.Menu.Items.Count; n++) MenuHelper.Delete((uint)(MenuHelper.GuideIdOffset+n)); } } if (channel.Menu != null) for (int n=0; n < channel.Menu.Items.Count; n++) MenuHelper.Delete((uint)(MenuHelper.ChannelIdOffset+n)); ProperWindow.CloseAll(); channel.Stop(); channel.Dispose(); } Title=newChannel.Caption; // Šiem jāsakrīt, jo to izmanto EmptyChannel loga pogas atrašanai. if (Settings.Default.ShowClock) { // channel piešķiršanas secību nosaka UpdateClock nepieciešamā instance. if (newChannel.Timezone == null) { HideClock(); channel=newChannel; } else { channel=newChannel; ShowClock(); } } else channel=newChannel; if (newChannel.Menu != null) newChannel.Menu.Items.AddToMenu(MenuHelper.SystemMenuHandle, 1, MenuHelper.ChannelIdOffset); // Tā kā raidījumu saraksta ielāde var prasīt laiku, nomaina izskatu pirms tā. await Dispatcher.InvokeAsync(() => { System.Windows.Controls.Grid.SetColumnSpan(logoBackground, channel.Brand.HasSharedBackground ? 2:1); channel.Brand.Focused=this.IsActive; DataContext=channel; // Parāda kanālu pirms raidījumu saraksta ielādes, lai tas nebremzē pārslēgšanas uztveri. }); if (newChannel.HasGuide && Settings.Default.UseGuide) { InitGuide(); if (!hadGuide) ShowGuide(); await StartGuide(true).ConfigureAwait(false); } else HideGuide(); await Dispatcher.InvokeAsync(() => { ShowMuteStateInTaskBar(channel.IsMuted); UpdateMenuButtonMask(); // Atkarīgs no raidījum saraksta pieejamības un notiek saskarnes pavedienā. }); channel.Play(); stateChanging=false; }