/// <summary> /// Goes to the next lowest known channel /// </summary> public virtual void ChannelDown() { int i = KnownChannels.IndexOf(this.Channel); if (i == 0) { this.Channel = KnownChannels.Items[KnownChannels.Count - 1]; } else if (i > 0) { this.Channel = KnownChannels.Items[i - 1]; } else if (KnownChannels.Count > 0) { this.Channel = KnownChannels.Items[0]; } }
/// <summary> /// Goes to the next highest known channel. /// </summary> public virtual void ChannelUp() { int i = KnownChannels.IndexOf(this.Channel); if (i == (KnownChannels.Count - 1)) { this.Channel = KnownChannels.Items[0]; } else if (i >= 0) { this.Channel = KnownChannels.Items[i + 1]; } else if (KnownChannels.Count > 0) { this.Channel = KnownChannels.Items[0]; } }
protected virtual Channel GetCurrentChannel() { if (!channelSet || (this.State != GraphState.Running)) { return(new Channel()); } // Debug.WriteLine("null -> get_TuneRequest"); ITuneRequest request; int hr = tuner.get_TuneRequest(out request); // Debug.WriteLine(hr.ToString("X8")); DsError.ThrowExceptionForHR(hr); // Debug.WriteLine("ITuneRequest -> IATSCChannelTuneRequest"); IATSCChannelTuneRequest atscRequest = (IATSCChannelTuneRequest)request; ILocator locator; // Debug.WriteLine("null -> get_Locator"); hr = atscRequest.get_Locator(out locator); // Debug.WriteLine(hr.ToString("X8")); DsError.ThrowExceptionForHR(hr); // Debug.WriteLine("ILocator -> IATSCLocator"); IATSCLocator atscLocator = (IATSCLocator)locator; int freq, channel, major, minor; hr = atscLocator.get_CarrierFrequency(out freq); hr = atscLocator.get_PhysicalChannel(out channel); hr = atscRequest.get_Channel(out major); hr = atscRequest.get_MinorChannel(out minor); Channel known = KnownChannels.FindClosest(new Channel(-1, -1, major, minor)); if (known != null) { if ((known.MajorChannel == major) && (known.MinorChannel == minor)) { return(known); } } return(new Channel(freq, channel, major, minor)); }
/// <summary> /// Called when the KnownChannels collection should be saved. /// </summary> public virtual void SaveKnownChannels() { try { if (CurrentChannelIndex != Config.AppUser.Current.ChannelIndex) { Config.AppUser.Current.ChannelIndex = CurrentChannelIndex; } if (KnownChannels != null) { KnownChannels.SaveToFile(GetKnownChannelsStoreFilename()); } } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); } }