Exemple #1
0
 public void SelectedItemsToCommand(ecProto.ecPacket cmd)
 {
     foreach (ListViewItem i in SelectedItems)
     {
         DownloadQueueItem it  = i.Tag as DownloadQueueItem;
         ecProto.ecTagMD5  tag = new ecProto.ecTagMD5(ECTagNames.EC_TAG_PARTFILE, it.ID);
         cmd.AddSubtag(tag);
     }
 }
Exemple #2
0
        public void UpdateItem(object i)
        {
            DownloadQueueItem it = i as DownloadQueueItem;

            if (InvokeRequired)
            {
                ItemCallback d = new ItemCallback(DoUpdateItem);
                Invoke(d, it);
            }
            else
            {
                DoUpdateItem(it);
            }
        }
Exemple #3
0
        override protected void OnColumnWidthChanged(ColumnWidthChangedEventArgs e)
        {
            int status_index = m_column_index[(int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID];

            if ((e.ColumnIndex == status_index) && m_settings.StatusVisible)
            {
                int new_size = Columns[status_index].Width + 1;
                m_item_container.NewItemStatusLineLength = new_size;

                foreach (ListViewItem i in Items)
                {
                    DownloadQueueItem it = i.Tag as DownloadQueueItem;
                    it.AllocColorLine(new_size);
                    it.DrawLine();
                }
            }
        }
Exemple #4
0
        void DoUpdateItem(DownloadQueueItem i)
        {
            ListViewItem it  = i.UiItem as ListViewItem;
            int          idx = m_column_index[(int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID];

            if (it.SubItems[idx].Text != i.PercentDone)
            {
                it.SubItems[idx].Text = i.PercentDone;
            }
            idx = (int)DOWNLOAD_CTRL_COL_ID.COL_COMPLETED_ID;
            if (it.SubItems[idx].Text != i.SizeDone)
            {
                it.SubItems[idx].Text = i.SizeDone;
            }
            idx = (int)DOWNLOAD_CTRL_COL_ID.COL_SPEED_ID;
            if (it.SubItems[idx].Text != i.Speed)
            {
                it.SubItems[idx].Text = i.Speed;
            }
            //Items
        }
Exemple #5
0
 void amuleDownloadStatusList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
 {
     if ((e.ColumnIndex == m_column_index[(int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID]) &&
         m_settings.StatusVisible)
     {
         // status is colored bar
         Rectangle         r  = e.Bounds;
         DownloadQueueItem it = e.Item.Tag as DownloadQueueItem;
         DrawStatusBar(it, e.Graphics, r);
         e.DrawDefault = false;
     }
     else
     {
         e.DrawBackground();
     }
     e.DrawText();
     if (e.Item.Selected)
     {
         e.DrawFocusRectangle(e.Bounds);
     }
 }
Exemple #6
0
        unsafe void DrawStatusBar(DownloadQueueItem it, Graphics g, Rectangle posR)
        {
            //
            // Bitmap is created as 32bpp (rgb+alpha)
            //
            Bitmap status_bmp = new Bitmap(posR.Width, posR.Height,
                                           System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            System.Drawing.Imaging.BitmapData bmd = status_bmp.LockBits(
                new Rectangle(0, 0, status_bmp.Width, status_bmp.Height),
                System.Drawing.Imaging.ImageLockMode.ReadWrite,
                System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            RGB[]  item_color_line = it.ColorLine;
            byte[] modifiers       = DownloadQueueItem.Get_3D_Modifiers();

            for (int y = 0; y < bmd.Height; y++)
            {
                byte *row = (byte *)bmd.Scan0 + (y * bmd.Stride);

                for (int x = 0; x < bmd.Width; x++)
                {
                    UInt32 *pixel_ptr = (UInt32 *)(row + x * 4);
                    //row[x * 3 + 2] = 255;
                    //*pixel_ptr = 0xff0000; //RED
                    //*pixel_ptr = 0x00ff00; //GREEN
                    //*pixel_ptr = 0x1f0000ff; // BLUE
                    //*pixel_ptr = item_color_line[x] | (x << 24);
                    item_color_line[x].WriteToBuffWithModifier(pixel_ptr, modifiers[y]);
                }
            }

            status_bmp.UnlockBits(bmd);

            g.DrawImage(status_bmp, posR);
            status_bmp.Dispose();
        }
Exemple #7
0
        ///
        // interface to core
        ///
        void DoInsertItem(DownloadQueueItem i)
        {
            string first_col_txt;

            if (m_settings.FilenameVisible)
            {
                first_col_txt = i.Name;
            }
            else if (m_settings.StatusVisible)
            {
                first_col_txt = i.PercentDone;
            }
            else if (m_settings.SizeVisible)
            {
                first_col_txt = i.Size;
            }
            else if (m_settings.CompletedVisible)
            {
                first_col_txt = i.SizeDone;
            }
            else if (m_settings.SpeedVisible)
            {
                first_col_txt = i.Speed;
            }
            else if (m_settings.SourcesVisible)
            {
                first_col_txt = i.Sources;
            }
            else
            {
                first_col_txt = "all columns hidden";
            }

            ListViewItem it = new ListViewItem(first_col_txt);

            if (m_settings.StatusVisible)
            {
                it.SubItems.Add(new ListViewItem.ListViewSubItem(it, i.PercentDone));
            }
            if (m_settings.SizeVisible)
            {
                it.SubItems.Add(new ListViewItem.ListViewSubItem(it, i.Size));
            }
            if (m_settings.CompletedVisible)
            {
                it.SubItems.Add(new ListViewItem.ListViewSubItem(it, i.SizeDone));
            }
            if (m_settings.SpeedVisible)
            {
                it.SubItems.Add(new ListViewItem.ListViewSubItem(it, i.Speed));
            }
            if (m_settings.SourcesVisible)
            {
                it.SubItems.Add(new ListViewItem.ListViewSubItem(it, i.Sources));
            }

            if (m_settings.StatusVisible)
            {
                it.SubItems[m_column_index[(int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID]].ForeColor = Color.White;
                Columns[(int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID].TextAlign = HorizontalAlignment.Center;
            }
            it.Tag = i;

            Items.Add(it);

            i.UiItem = it;
        }
Exemple #8
0
        public amuleDownloadStatusList()
        {
            OwnerDraw = true;

            DrawColumnHeader +=
                new DrawListViewColumnHeaderEventHandler(amuleDownloadStatusList_DrawColumnHeader);

            DrawSubItem += new DrawListViewSubItemEventHandler(amuleDownloadStatusList_DrawSubItem);
            DownloadQueueItem.InitDraw3DModifiers(FontHeight + 1);

            MouseClick  += new MouseEventHandler(amuleDownloadStatusList_MouseClickHandler);
            ColumnClick += new ColumnClickEventHandler(amuleDownloadStatusList_ColumtClickHandler);

            m_ctx_menu.Opening += new System.ComponentModel.CancelEventHandler(cms_Opening);
            m_ctx_menu.Items.Add(new ToolStripLabel("Downloads"));
            m_ctx_menu.Items.Add(new ToolStripSeparator());

            ToolStripButton it_pause = new ToolStripButton("Pause");

            it_pause.Click += new EventHandler(it_pause_Click);
            m_ctx_menu.Items.Add(it_pause);
            ContextMenuStrip = m_ctx_menu;

            ToolStripButton it_resume = new ToolStripButton("Resume");

            it_resume.Click += new EventHandler(it_resume_Click);
            m_ctx_menu.Items.Add(it_resume);

            ToolStripButton it_cancel = new ToolStripButton("Cancel");

            it_cancel.Click += new EventHandler(it_cancel_Click);
            m_ctx_menu.Items.Add(it_cancel);

            m_ctx_menu.Items.Add(new ToolStripSeparator());
            //
            // Init columns
            //
            m_column_index = new int[(int)DOWNLOAD_CTRL_COL_ID.COL_LAST_ID];
            UpdateColumnIndexes();
            // File name
            if (m_settings.FilenameVisible)
            {
                CreateColumtAt("File name", m_settings.FilenameWidth,
                               (int)DOWNLOAD_CTRL_COL_ID.COL_FILENAME_ID);
            }
            AppendItemToCtxMenu(m_ctx_menu, "File name", DOWNLOAD_CTRL_COL_ID.COL_FILENAME_ID,
                                m_settings.FilenameVisible, new EventHandler(column_Click));
            // Status
            if (m_settings.StatusVisible)
            {
                CreateColumtAt("Status", m_settings.StatusWidth,
                               (int)DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID);
            }
            AppendItemToCtxMenu(m_ctx_menu, "Status", DOWNLOAD_CTRL_COL_ID.COL_STATUS_ID,
                                m_settings.StatusVisible, new EventHandler(column_Click));
            // Size
            if (m_settings.SizeVisible)
            {
                CreateColumtAt("Size", m_settings.SizeWidth,
                               (int)DOWNLOAD_CTRL_COL_ID.COL_SIZE_ID);
            }
            AppendItemToCtxMenu(m_ctx_menu, "Size", DOWNLOAD_CTRL_COL_ID.COL_SIZE_ID,
                                m_settings.SizeVisible, new EventHandler(column_Click));
            // Completed size
            if (m_settings.CompletedVisible)
            {
                CreateColumtAt("Completed", m_settings.CompletedWidth,
                               (int)DOWNLOAD_CTRL_COL_ID.COL_COMPLETED_ID);
            }
            AppendItemToCtxMenu(m_ctx_menu, "Completed", DOWNLOAD_CTRL_COL_ID.COL_COMPLETED_ID,
                                m_settings.CompletedVisible, new EventHandler(column_Click));
            // Speed
            if (m_settings.SpeedVisible)
            {
                CreateColumtAt("Speed", m_settings.SpeedWidth,
                               (int)DOWNLOAD_CTRL_COL_ID.COL_SPEED_ID);
            }
            AppendItemToCtxMenu(m_ctx_menu, "Speed", DOWNLOAD_CTRL_COL_ID.COL_SPEED_ID,
                                m_settings.SpeedVisible, new EventHandler(column_Click));
            // Sources
            if (m_settings.SourcesVisible)
            {
                CreateColumtAt("Sources", m_settings.SourcesWidth,
                               m_column_index[(int)DOWNLOAD_CTRL_COL_ID.COL_SOURCES_ID]);
            }
            AppendItemToCtxMenu(m_ctx_menu, "Sources", DOWNLOAD_CTRL_COL_ID.COL_SOURCES_ID,
                                m_settings.SizeVisible, new EventHandler(column_Click));

            ContextMenuStrip = m_ctx_menu;
        }