/// <summary> /// Adds the given channel as a favorite. /// </summary> /// <param name="channel">channel to add</param> /// <param name="snapshot">Snapshot to display. Set to null to load from disk (if available)</param> public void Add(Channel channel, Snapshot snapshot) { try { int i = CurrentFavorites.Add(channel); if (i == -1) { UpdateSnapshot(channel, snapshot); return; } InsertThumbnail(i, CreateThumbnail(channel, snapshot)); UpdateUIControls(); //if the channel being added is logically equal to the one we're being tuned to //auto-highlight it. if (channel.CompareTo(Channel) == 0) { this.Channel = channel; //invoke the setter } } catch (Exception ex) { ErrorLogger.DumpToDebug(ex); } }
/// <summary> /// Makes the UI controls reflect the current state of the control /// </summary> private void UpdateUIControls() { btnAddFavorite.Enabled = !CurrentFavorites.Contains(this.Channel); btnClear.Enabled = CurrentFavorites.Count > 0; btnScan.Enabled = btnClear.Enabled; cbInterval.Enabled = btnClear.Enabled; }
/// <summary> /// Removes a channel from the CurrentFavorites collection /// </summary> /// <param name="channel">channel to remove</param> public void Remove(Channel channel) { RemoveThumbmnnail(GetThumbnailAt(CurrentFavorites.IndexOf(channel))); CurrentFavorites.Remove(channel); UpdateUIControls(); }
/// <summary> /// Clears all of the currently displayed favorites /// </summary> public void Clear() { this.Scanning = false; foreach (FavoriteChannelThumbnail ct in panelThumbnails.Controls) { ReleaseThumbnail(ct); } panelThumbnails.Controls.Clear(); panelThumbnails.RowCount = 0; CurrentFavorites.Clear(); UpdateUIControls(); }
/// <summary> /// Updates the snapshot for a given channel. /// Does nothing if the channel does not exist. /// Does nothing if the snapshot is null. /// </summary> /// <param name="channel">channel to update</param> /// <param name="snapshot">new snapshot to display</param> public void UpdateSnapshot(Channel channel, Snapshot snapshot) { if (snapshot == null) { return; } FavoriteChannelThumbnail t = GetThumbnailAt(CurrentFavorites.IndexOf(channel)); if (t != null) { t.Image = snapshot.DIBBitmap; } }
/// <summary> /// Returns true if the given channel is a favorite. /// </summary> /// <param name="channel">channel to check</param> /// <returns>Returns true if the logical channel is a favorite, false if not.</returns> public bool IsFavorite(Channel channel) { return(CurrentFavorites.Contains(channel)); }