Example #1
0
        private void UpdateDCCFileProgress(DccFileStruct dcc)
        {
            if (this.InvokeRequired)
            {
                UpdateDCCFileProgressDelegate u = new UpdateDCCFileProgressDelegate(UpdateDCCFileProgress);
                this.Invoke(u, new object[] { dcc });
            }
            else
            {
                foreach (ListViewItem lvi in dccFileList.Items)
                {
                    if (lvi.Tag.ToString() == dcc.Thread.ManagedThreadId.ToString())
                    {
                        lvi.SubItems[2].Text = dcc.TotalBytesRead + "/" + dcc.FileSize;
                        if (dcc.TotalBytesRead.ToString() == dcc.FileSize)
                        {
                            lvi.SubItems[3].Text = "Completed";
                        }
                        else
                        {
                            lvi.SubItems[3].Text = "Downloading";
                        }

                        return;
                    }
                }
            }
        }
Example #2
0
        private void UpdateDCCFileProgress(DccFileStruct dcc)
        {
            if (this.InvokeRequired)
            {
                UpdateDCCFileProgressDelegate u = new UpdateDCCFileProgressDelegate(UpdateDCCFileProgress);
                this.Invoke(u, new object[] { dcc });
            }
            else
            {
                foreach (ListViewItem lvi in dccFileList.Items)
                {
                    if (lvi.Tag.ToString() == dcc.Thread.ManagedThreadId.ToString())
                    {
                        lvi.SubItems[2].Text = dcc.TotalBytesRead + "/" + dcc.FileSize;
                        if (dcc.TotalBytesRead.ToString() == dcc.FileSize)
                            lvi.SubItems[3].Text = "Completed";
                        else
                            lvi.SubItems[3].Text = "Downloading";

                        return;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Show the updated file progress in the DCC File List
        /// </summary>
        private void UpdateDCCFileProgress(DccFileStruct dcc)
        {
            if (this.InvokeRequired)
            {
                UpdateDCCFileProgressDelegate u = new UpdateDCCFileProgressDelegate(UpdateDCCFileProgress);
                this.Invoke(u, new object[] { dcc });
            }
            else
            {
                foreach (ListViewItem lvi in dccFileList.Items)
                {
                    if (lvi.Tag.ToString() == dcc.ListingTag.ToString())
                    {
                        lvi.SubItems[2].Text = dcc.TotalBytesRead + "/" + dcc.FileSize;

                        //calculate the bp/sec
                        long elasped = DateTime.Now.Ticks - dcc.StartTime;

                        if (elasped > 0 && (dcc.TotalBytesRead > dcc.StartFileSize))
                        {
                            float b = (elasped / 10000000f);
                            float bps = (dcc.TotalBytesRead - dcc.StartFileSize) / b;

                            System.Diagnostics.Debug.WriteLine(elasped + ":" + (dcc.TotalBytesRead - dcc.StartFileSize) + ":" + bps);

                            lvi.SubItems[3].Text = bps.ToString() + " b/s";
                            if (bps > 0)
                            {
                                //calculate speed and set to bytes/kb/mb/gb

                            }
                        }
                        else
                            lvi.SubItems[3].Text = "0 b/s";

                        if (dcc.StartTime == 0)
                            lvi.SubItems[4].Text = "";
                        else
                            lvi.SubItems[4].Text = GetDurationTicks(elasped);

                        if (dcc.TotalBytesRead == dcc.FileSize || dcc.Finished)
                            lvi.SubItems[5].Text = "Completed";
                        else if (dcc.Errored)
                            lvi.SubItems[5].Text = "ERROR";
                        else if (dcc.Resume)
                            lvi.SubItems[5].Text = "Resuming";
                        else
                            lvi.SubItems[5].Text = "Downloading";

                        return;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Show the updated file progress in the DCC File List
        /// </summary>
        private void UpdateDCCFileProgress(DccFileStruct dcc)
        {
            if (this.InvokeRequired)
            {
                UpdateDCCFileProgressDelegate u = new UpdateDCCFileProgressDelegate(UpdateDCCFileProgress);
                this.Invoke(u, new object[] { dcc });
            }
            else
            {
                foreach (ListViewItem lvi in dccFileList.Items)
                {
                    if (lvi.Tag.ToString() == dcc.ListingTag.ToString())
                    {
                        lvi.SubItems[2].Text = FormatBytes(dcc.TotalBytesRead) + "/" + FormatBytes(dcc.FileSize);

                        //calculate the bp/sec
                        long elasped = DateTime.Now.Ticks - dcc.StartTime;

                        if (elasped > 0 && (dcc.TotalBytesRead > dcc.StartFileSize))
                        {
                            float b = (elasped / 10000000f);
                            float bps = (dcc.TotalBytesRead - dcc.StartFileSize) / b;

                            lvi.SubItems[3].Text = FormatBytes(bps) +"/s";
                        }
                        else
                            lvi.SubItems[3].Text = "0 Bytes/s";

                        if (dcc.StartTime == 0)
                            lvi.SubItems[4].Text = "";
                        else
                            lvi.SubItems[4].Text = GetDurationTicks(elasped);

                        if (dcc.TotalBytesRead == dcc.FileSize || dcc.Finished)
                        {
                            lvi.SubItems[5].Text = "Completed";

                            //the dcc file download is completed
                            PluginArgs args = new PluginArgs(dcc.Connection);
                            args.fileName = dcc.FileName;
                            args.fileSize = dcc.FileSize;
                            args.dccPort = dcc.Ip;

                            foreach (Plugin p in FormMain.Instance.LoadedPlugins)
                            {
                                IceChatPlugin ipc = p as IceChatPlugin;
                                if (ipc != null)
                                {
                                    if (ipc.plugin.Enabled == true)
                                        ipc.plugin.DCCFileComplete(args);
                                }
                            }
                        }
                        else if (dcc.Errored)
                        {
                            if (dcc.Incomplete == true)
                                lvi.SubItems[5].Text = "INCOMPLETE";
                            else
                                lvi.SubItems[5].Text = "ERROR";

                            //the dcc file download has errored
                            PluginArgs args = new PluginArgs(dcc.Connection);
                            args.fileName = dcc.FileName;
                            args.fileSize = dcc.FileSize;
                            args.dccPort = dcc.Ip;

                            foreach (Plugin p in  FormMain.Instance.LoadedPlugins)
                            {
                                IceChatPlugin ipc = p as IceChatPlugin;
                                if (ipc != null)
                                {
                                    if (ipc.plugin.Enabled == true)
                                        ipc.plugin.DCCFileError(args);
                                }
                            }
                        }
                        else if (dcc.Resume)
                            lvi.SubItems[5].Text = "Resuming";
                        else
                            lvi.SubItems[5].Text = "Downloading";

                        return;
                    }
                }
            }
        }