コード例 #1
0
 public void AddDownload(object key, string text)
 {
     if (this.m_cancelledDownloads.Contains(key))
     {
         this.m_cancelledDownloads.Remove(key);
     }
     if (!this.m_downloadLookup.ContainsKey(key))
     {
         DownloadViewItem item = this.CreateDownloadViewItem(text);
         this.m_downloadLookup.Add(key, item);
         this.tblMain.RowCount++;
         this.tblMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100f));
         this.tblMain.RowStyles[this.tblMain.RowStyles.Count - 2].SizeType = SizeType.Absolute;
         this.tblMain.RowStyles[this.tblMain.RowStyles.Count - 2].Height   = s_rowHeight;
         this.tblMain.Controls.Add(item, 0, this.tblMain.RowStyles.Count - 2);
         this.UpdateSize();
     }
     else
     {
         DownloadViewItem             control             = this.m_downloadLookup[key];
         DownloadViewItem             item3               = this.CreateDownloadViewItem(text);
         TableLayoutPanelCellPosition positionFromControl = this.tblMain.GetPositionFromControl(control);
         this.tblMain.Controls.Remove(control);
         this.tblMain.Controls.Add(item3, positionFromControl.Column, positionFromControl.Row);
         this.m_downloadLookup.Remove(key);
         this.m_downloadLookup.Add(key, item3);
     }
 }
コード例 #2
0
        public void AddDownload(object key, string text)
        {
            if (m_cancelledDownloads.Contains(key))
            {
                m_cancelledDownloads.Remove(key);
            }

            if (!m_downloadLookup.ContainsKey(key))
            {
                DpiScale         dpiScale = new DpiScale(CreateGraphics());
                DownloadViewItem item     = CreateDownloadViewItem(text);
                m_downloadLookup.Add(key, item);

                tblMain.RowCount++;
                tblMain.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                tblMain.RowStyles[tblMain.RowStyles.Count - 2].SizeType = SizeType.Absolute;
                tblMain.RowStyles[tblMain.RowStyles.Count - 2].Height   = dpiScale.ScaleIntY(s_rowHeight);
                tblMain.Controls.Add(item, 0, tblMain.RowStyles.Count - 2);

                UpdateSize();
            }
            else
            {
                DownloadViewItem itemOld = m_downloadLookup[key];
                DownloadViewItem item    = CreateDownloadViewItem(text);

                TableLayoutPanelCellPosition pos = tblMain.GetPositionFromControl(itemOld);
                tblMain.Controls.Remove(itemOld);
                tblMain.Controls.Add(item, pos.Column, pos.Row);

                m_downloadLookup.Remove(key);
                m_downloadLookup.Add(key, item);
            }
        }
コード例 #3
0
 public void UpdateDownload(object key, string text)
 {
     if (m_downloadLookup.ContainsKey(key))
     {
         DownloadViewItem item = m_downloadLookup[key];
         item.DisplayText = text;
     }
 }
コード例 #4
0
        private void item_Cancelled(object sender, EventArgs e)
        {
            DownloadViewItem item = sender as DownloadViewItem;

            if (item != null)
            {
                this.HandleItemCancel(item);
            }
        }
コード例 #5
0
 public void RemoveDownload(object key)
 {
     if (this.m_downloadLookup.ContainsKey(key))
     {
         DownloadViewItem item = this.m_downloadLookup[key];
         this.m_downloadLookup.Remove(key);
         this.RemoveDownloadRow(item);
         this.UpdateSize();
     }
 }
コード例 #6
0
        private void cancelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem sourceControl = this.menuOptions.SourceControl as DownloadViewItem;

            this.SelectedItem = sourceControl;
            if (sourceControl != null)
            {
                this.HandleItemCancel(sourceControl);
            }
        }
コード例 #7
0
        private void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem sourceControl = this.menuOptions.SourceControl as DownloadViewItem;

            this.SelectedItem = sourceControl;
            if (((sourceControl != null) && (this.UserPlay != null)) && (sourceControl.ProgressValue == 100))
            {
                this.UserPlay(this, new EventArgs());
            }
        }
コード例 #8
0
 private object GetKey(DownloadViewItem item)
 {
     foreach (KeyValuePair <object, DownloadViewItem> pair in this.m_downloadLookup)
     {
         if (pair.Value == item)
         {
             return(pair.Key);
         }
     }
     return(null);
 }
コード例 #9
0
        private void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem item = menuOptions.SourceControl as DownloadViewItem;

            SelectedItem = item;

            if (item != null && UserPlay != null && item.ProgressValue == 100)
            {
                UserPlay(this, new EventArgs());
            }
        }
コード例 #10
0
        private void cancelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem item = menuOptions.SourceControl as DownloadViewItem;

            SelectedItem = item;

            if (item != null)
            {
                HandleItemCancel(item);
            }
        }
コード例 #11
0
        private DownloadViewItem CreateDownloadViewItem(string text)
        {
            DownloadViewItem item1 = new DownloadViewItem {
                Dock        = DockStyle.Fill,
                Key         = text,
                DisplayText = text
            };

            item1.Cancelled       += new EventHandler(this.item_Cancelled);
            item1.ContextMenuStrip = this.menuOptions;
            return(item1);
        }
コード例 #12
0
        private object GetKey(DownloadViewItem item)
        {
            foreach (KeyValuePair <object, DownloadViewItem> kvp in m_downloadLookup)
            {
                if (kvp.Value == item)
                {
                    return(kvp.Key);
                }
            }

            return(null);
        }
コード例 #13
0
 public void UpdateDownload(object key, int percent)
 {
     if (this.m_downloadLookup.ContainsKey(key))
     {
         DownloadViewItem item = this.m_downloadLookup[key];
         item.ProgressValue = percent;
         if (percent == 100)
         {
             item.CancelVisible = false;
         }
     }
 }
コード例 #14
0
        private DownloadViewItem CreateDownloadViewItem(string text)
        {
            DownloadViewItem item = new DownloadViewItem();

            item.Dock        = DockStyle.Fill;
            item.Key         = text;
            item.DisplayText = text;
            item.Cancelled  += item_Cancelled;

            item.ContextMenuStrip = menuOptions;

            return(item);
        }
コード例 #15
0
        private void removeFromHistoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem sourceControl = this.menuOptions.SourceControl as DownloadViewItem;

            if (sourceControl != null)
            {
                this.RemoveDownloadRow(sourceControl);
                object key = this.GetKey(sourceControl);
                if (key != null)
                {
                    this.m_downloadLookup.Remove(key);
                }
            }
        }
コード例 #16
0
        private void removeFromHistoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DownloadViewItem item = menuOptions.SourceControl as DownloadViewItem;

            if (item != null)
            {
                RemoveDownloadRow(item);
                object key = GetKey(item);

                if (key != null)
                {
                    m_downloadLookup.Remove(key);
                }
            }
        }
コード例 #17
0
 private void HandleItemCancel(DownloadViewItem item)
 {
     if (item.ProgressValue != 100)
     {
         item.ProgressValue = 0;
     }
     if (this.DownloadCancelled != null)
     {
         object key = this.GetKey(item);
         if (key != null)
         {
             this.m_cancelledDownloads.Add(key);
             this.DownloadCancelled(this, new EventArgs());
         }
     }
 }
コード例 #18
0
        private void RemoveDownloadRow(DownloadViewItem item)
        {
            int row = this.tblMain.GetRow(item);

            if (row > -1)
            {
                this.tblMain.Controls.Remove(item);
                this.tblMain.RowStyles.RemoveAt(row);
                for (int i = row + 1; i < this.tblMain.RowCount; i++)
                {
                    DownloadViewItem item2 = this.GetItem(i);
                    if (item2 != null)
                    {
                        this.tblMain.Controls.Remove(item2);
                        this.tblMain.Controls.Add(item2, 0, i - 1);
                    }
                }
            }
        }
コード例 #19
0
        private void RemoveDownloadRow(DownloadViewItem item)
        {
            int row = tblMain.GetRow(item);

            if (row > -1)
            {
                tblMain.Controls.Remove(item);
                tblMain.RowStyles.RemoveAt(row);

                for (int i = row + 1; i < tblMain.RowCount; i++) //have to shift the controls up (TableLayoutPanel is dumb)
                {
                    DownloadViewItem itemMove = GetItem(i);

                    if (itemMove != null)
                    {
                        tblMain.Controls.Remove(itemMove);
                        tblMain.Controls.Add(itemMove, 0, i - 1);
                    }
                }
            }
        }