public RadioApp(Dictionary <string, Station> stations) { Stations = stations; foreach (var station in Stations.Values) { var dyn = station as DynamicStation; if (dyn != null) { dyn.ChannelsChanged = station_ChannelsChanged; } } RadioIcon = IconLoader.LoadAssemblyIcon(this.GetType().Assembly.Location, 0); icons = new Dictionary <string, BitmapSource>(stations.Count); ignoredChannels = Settings.Default.IgnoredChannels.Split(new[] { ChannelSeparator }, StringSplitOptions.RemoveEmptyEntries); // Aizpilda raidstaciju pārslēgšanas sarakstu. jumpList = new JumpList(); jumpList.JumpItemsRemovedByUser += jumpList_JumpItemsRemovedByUser; FillJumpList(); // Palaiž raidstaciju pārslēgšanas pakalpojumu. switchService = new ServiceHost(typeof(RadioSwitch), new Uri(RadioSwitch.ServiceUrl)); switchService.AddServiceEndpoint(typeof(IRadioSwitch), new NetNamedPipeBinding(), string.Empty); switchService.Open(); InitializeComponent(); }
/// <summary>Atgriež kanālu pēc tā identifikatora.</summary> /// <param name="id">Kanāla identifikators formā {stacijas nosaukums}.{kanāla numurs}</param> public Channel GetChannel(string id) { if (string.IsNullOrWhiteSpace(id)) { return(null); } var idParts = id.Split(ChannelIdSeparator); Station station; uint number; if (!Stations.TryGetValue(idParts[0].ToLower(), out station) || !uint.TryParse(idParts[1], out number)) { throw new ChannelNotFoundException(id); } var channel = station.GetChannel(number); var channelData = station.Channels[number]; string iconId = idParts[0].ToLower() + channelData.Item2; // Aizpilda kanāla parametrus, kuri zināmi tikai šeit. channel.Id = id; channel.Station = station; channel.Number = number; channel.Caption = channelData.Item1; // Ikona attēlošanai uz programmas ikonas uzdevumu joslā. // Formāts Windows Icon, izmērs 16x16 pikseļi. BitmapSource icon; if (!icons.TryGetValue(iconId, out icon)) { try { icon = IconLoader.LoadAssemblyIcon(station.GetType().Assembly.Location, channelData.Item2); } catch { icon = RadioIcon; } icons.Add(iconId, icon); } channel.Icon = icon; return(channel); }