Exemplo n.º 1
0
        /// <summary>
        /// Removes the thumbnail specified
        /// </summary>
        /// <param name="thumb">index of the channel being removed</param>
        private void RemoveThumbmnnail(FavoriteChannelThumbnail thumb)
        {
            if (thumb == null)
            {
                return;
            }

            panelThumbnails.Visible = false;

            int removeAt = panelThumbnails.GetRow(thumb);

            panelThumbnails.Controls.Remove(thumb);

            //Shift existing controls down
            foreach (Control existing in panelThumbnails.Controls)
            {
                if (panelThumbnails.GetRow(existing) >= removeAt)
                {
                    panelThumbnails.SetRow(existing, panelThumbnails.GetRow(existing) - 1);
                }
            }

            panelThumbnails.RowCount--;

            //repaint
            panelThumbnails.Visible = true;
            panelThumbnails.Invalidate();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts a thumbnail control into the list at a given positon
        /// </summary>
        /// <param name="i">index to insert at</param>
        /// <param name="thumb">thumbnail to insert</param>
        private void InsertThumbnail(int i, FavoriteChannelThumbnail thumb)
        {
            //hide control to avoid repainting
            panelThumbnails.Visible = false;

            //Insert new RowStyles corresponding to new row
            RowStyle newRow = new RowStyle();

            newRow.SizeType = SizeType.AutoSize;
            panelThumbnails.RowStyles.Insert(i, newRow);

            panelThumbnails.RowCount++;

            //Shift existing controls down
            foreach (Control existing in panelThumbnails.Controls)
            {
                if (panelThumbnails.GetRow(existing) >= i)
                {
                    panelThumbnails.SetRow(existing, panelThumbnails.GetRow(existing) + 1);
                }
            }

            //insert thumbnail in the correct position
            panelThumbnails.Controls.Add(thumb, 0, i);

            //repaint
            panelThumbnails.Visible = true;
            panelThumbnails.Invalidate();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when the user clicks on the "X" button on the favorite. This causes the favorite to be deleted.
        /// </summary>
        private void Item_DeleteClick(object sender, EventArgs e)
        {
            FavoriteChannelThumbnail t = sender as FavoriteChannelThumbnail;

            if (t == null)
            {
                return;
            }

            this.Remove(t.Channel);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called when the user clicks on the snapshot. This causes the favorite to be tuned.
        /// </summary>
        private void Item_SnapshotClick(object sender, EventArgs e)
        {
            FavoriteChannelThumbnail t = sender as FavoriteChannelThumbnail;

            if (t == null)
            {
                return;
            }

            this.Scanning = false;
            FireTuneFavoriteChannel(t.Channel);
        }
Exemplo n.º 5
0
        /// <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;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a thumbnail
        /// </summary>
        /// <param name="channel">channel to bind to</param>
        /// <param name="snapshot">snapshot to display. Specify null to try to load from memory/disk</param>
        private FavoriteChannelThumbnail CreateThumbnail(Channel channel, Snapshot snapshot)
        {
            FavoriteChannelThumbnail t = new FavoriteChannelThumbnail();

            t.Channel = channel;
            if (snapshot != null)
            {
                t.Image = snapshot.DIBBitmap;
            }
            else
            {
                t.LoadThumbnailImage(FavoritesStoreRoot + "\\" + CurrentTVSource.ToString());
            }
            t.SnapshotClick += new EventHandler(Item_SnapshotClick);
            t.DeleteClick   += new EventHandler(Item_DeleteClick);
            return(t);
        }
Exemplo n.º 7
0
 /// <summary>
 /// releases a thumbnail so it can be removed from the Controls collection and actually get disposed
 /// </summary>
 /// <param name="thumb">thumbnail to release</param>
 private void ReleaseThumbnail(FavoriteChannelThumbnail thumb)
 {
     thumb.SnapshotClick -= new EventHandler(Item_SnapshotClick);
     thumb.DeleteClick   -= new EventHandler(Item_DeleteClick);
     thumb.Dispose();
 }