コード例 #1
0
 public override void InitControl(JobWrapper wrapper)
 {
     base.InitControl(wrapper);
     wrapper.BitsJob.OnJobError       += new EventHandler <JobErrorNotificationEventArgs>(this.BitsJob_OnJobErrorEvent);
     wrapper.BitsJob.OnJobTransferred += new EventHandler <JobNotificationEventArgs>(this.BitsJob_OnJobTransferredEvent);
     wrapper.Manager.OnInterfaceError += new EventHandler <BitsInterfaceNotificationEventArgs>(this.Manager_OnInterfaceError);
 }
コード例 #2
0
 public override void InitControl(JobWrapper wrapper)
 {
     base.InitControl(wrapper);
     wrapper.BitsJob.OnJobError       += new EventHandler <JobErrorNotificationEventArgs>(this.OnJobErrorEvent);
     wrapper.BitsJob.OnJobModified    += new EventHandler <JobNotificationEventArgs>(this.OnJobModifiedEvent);
     wrapper.BitsJob.OnJobTransferred += new EventHandler <JobNotificationEventArgs>(this.OnJobTransferredEvent);
 }
コード例 #3
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
        private void FillListViewItem(ListViewItem listItem, JobWrapper jobWrapper)
        {
            BitsJob bitsJob = jobWrapper.BitsJob;

            listItem.SubItems.Clear();
            listItem.ImageIndex  = (bitsJob.JobType == JobType.Download) ? 0 : 1;
            listItem.ToolTipText = string.IsNullOrEmpty(bitsJob.Description) ? bitsJob.DisplayName : bitsJob.Description;
            listItem.Text        = bitsJob.DisplayName;
            listItem.Name        = bitsJob.JobId.ToString();
            ListViewItem.ListViewSubItem item = new ListViewItem.ListViewSubItem(listItem, bitsJob.State.ToString());
            item.Name = ColumnNames.JobState;
            listItem.SubItems.Add(item);
            item      = new ListViewItem.ListViewSubItem(listItem, bitsJob.Progress.FilesTransferred.ToString() + "/" + bitsJob.Progress.FilesTotal.ToString());
            item.Name = ColumnNames.FileCount;
            listItem.SubItems.Add(item);
            item      = new ListViewItem.ListViewSubItem(listItem, Utils.Bytes2Size(bitsJob.Progress.BytesTransferred) + "/" + Utils.Bytes2Size(bitsJob.Progress.BytesTotal));
            item.Name = ColumnNames.ByteCount;
            listItem.SubItems.Add(item);
            item      = new ListViewItem.ListViewSubItem(listItem, Utils.Percentage(bitsJob.Progress.BytesTotal, bitsJob.Progress.BytesTransferred));
            item.Name = ColumnNames.Progress;
            listItem.SubItems.Add(item);
            if (bitsJob.JobType == JobType.Upload)
            {
                listItem.Group = this.lvJobList.Groups[1];
            }
            if (bitsJob.JobType == JobType.Download)
            {
                listItem.Group = this.lvJobList.Groups[0];
            }
            listItem.Tag = jobWrapper;
        }
コード例 #4
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void manager_OnJobTransferredEvent(object sender, NotificationEventArgs e)
 {
     if (base.InvokeRequired)
     {
         EventHandler <NotificationEventArgs> method = new EventHandler <NotificationEventArgs>(this.manager_OnJobTransferredEvent);
         base.Invoke(method, new object[] { sender, e });
     }
     else if (this.jobWrappers.ContainsKey(e.Job.JobId))
     {
         JobWrapper wrapper = this.jobWrappers[e.Job.JobId];
         if (wrapper.AutoComplete)
         {
             wrapper.BitsJob.Complete();
         }
         if ((wrapper.BitsJob.JobType == JobType.Upload) && wrapper.DeleteLocalFile)
         {
             try
             {
                 wrapper.BitsJob.EnumFiles();
                 string localName = wrapper.BitsJob.Files[0].LocalName;
                 File.SetAttributes(localName, FileAttributes.Normal);
                 File.Delete(localName);
             }
             catch (Exception exception)
             {
                 if (this.notificationEvent != null)
                 {
                     this.notificationEvent(exception.Message, MessageLevel.Error);
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void ctxdlPriority_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.lvJobList.SelectedItems.Count > 0)
     {
         JobWrapper tag = this.lvJobList.SelectedItems[0].Tag as JobWrapper;
         tag.BitsJob.Priority = (JobPriority)this.ctxdlPriority.SelectedIndex;
     }
 }
コード例 #6
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void lvJobList_AfterLabelEdit(object sender, LabelEditEventArgs e)
 {
     if (e.Label != null)
     {
         JobWrapper tag = this.lvJobList.Items[e.Item].Tag as JobWrapper;
         tag.BitsJob.DisplayName = e.Label;
     }
 }
コード例 #7
0
 public override void InitControl(JobWrapper wrapper)
 {
     this.jobDetailsControl.InitControl(wrapper);
     this.fileListControl.InitControl(wrapper);
     this.userAuthenticationControl.InitControl(wrapper);
     this.jobMessageControl.InitControl(wrapper);
     this.tcJobDetails.SelectedTab = this.tabDetails;
     base.InitControl(wrapper);
 }
コード例 #8
0
ファイル: JobDetailsForm.cs プロジェクト: 11RS/SharpBITS.NET
 // Methods
 public JobDetailsForm(JobWrapper wrapper)
 {
     this.wrapper = wrapper;
     this.manager = wrapper.Manager;
     this.job     = wrapper.BitsJob;
     this.InitializeComponent();
     this.bitsJobDetails.InitControl(wrapper);
     this.Text = this.job.DisplayName;
 }
コード例 #9
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
        private void CreateNewJob(JobType jobType, string[] files)
        {
            BitsJob job = null;

            job = this.bitsManager.CreateJob(jobType.ToString(), jobType);
            this.lvJobList.Items[job.JobId.ToString()].Selected = true;
            JobWrapper wrapper = this.jobWrappers[job.JobId];

            wrapper.FileList = files;
            this.ShowJobDetails(wrapper, true);
        }
コード例 #10
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void ctxmiResume_Click(object sender, EventArgs e)
 {
     if (this.lvJobList.SelectedItems.Count == 1)
     {
         JobWrapper tag     = this.lvJobList.SelectedItems[0].Tag as JobWrapper;
         BitsJob    bitsJob = tag.BitsJob;
         if ((bitsJob.State != JobState.Acknowledged) && (bitsJob.State != JobState.Canceled))
         {
             bitsJob.Resume();
         }
         this.ControlsFromJobState();
     }
 }
コード例 #11
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void ctxmiCancel_Click(object sender, EventArgs e)
 {
     if (this.lvJobList.SelectedItems.Count == 1)
     {
         JobWrapper tag     = this.lvJobList.SelectedItems[0].Tag as JobWrapper;
         BitsJob    bitsJob = tag.BitsJob;
         if (((MessageBox.Show(string.Format("Are you sure to delete job '{0}''", bitsJob.DisplayName), "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) && (bitsJob.State != JobState.Acknowledged)) && (bitsJob.State != JobState.Canceled))
         {
             bitsJob.Cancel();
         }
         this.ControlsFromJobState();
     }
 }
コード例 #12
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 private void ctxmiComplete_Click(object sender, EventArgs e)
 {
     if (this.lvJobList.SelectedItems.Count == 1)
     {
         JobWrapper tag     = this.lvJobList.SelectedItems[0].Tag as JobWrapper;
         BitsJob    bitsJob = tag.BitsJob;
         if ((((bitsJob.JobType == JobType.Download) && (bitsJob.State != JobState.Acknowledged)) && (bitsJob.State != JobState.Canceled)) || ((bitsJob.JobType == JobType.Upload) && (bitsJob.State == JobState.Transferred)))
         {
             bitsJob.Complete();
         }
         this.ControlsFromJobState();
     }
 }
コード例 #13
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
 public void ShowJobDetails(JobWrapper wrapper, bool newJob)
 {
     if (wrapper != null)
     {
         JobDetailsForm form = new JobDetailsForm(wrapper);
         if (form.ShowDialog(this, newJob) == DialogResult.Abort)
         {
             wrapper.BitsJob.Cancel();
             Thread.Sleep(0);
             this.UpdateControl();
         }
     }
 }
コード例 #14
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
        private void UpdateControl(JobWrapper wrapper)
        {
            ListViewItem item;

            if (!this.lvJobList.Items.ContainsKey(wrapper.JobId.ToString()))
            {
                item = new ListViewItem();
                this.FillListViewItem(item, wrapper);
                this.lvJobList.Items.Add(item);
            }
            else
            {
                item = this.lvJobList.Items[wrapper.JobId.ToString()];
                this.FillListViewItem(item, wrapper);
            }
        }
コード例 #15
0
ファイル: AddSimpleFile.cs プロジェクト: ARLM-Attic/sharpbits
        public override void InitControl(JobWrapper wrapper)
        {
            base.InitControl(wrapper);
            this.jobType = wrapper.BitsJob.JobType;
            this.chkDeleteLocalFile.Visible = this.jobType == JobType.Upload;
            if ((wrapper.FileList != null) && (wrapper.FileList.Length == 1))
            {
                Uri    uri;
                string path = wrapper.FileList[0];
                if (Uri.TryCreate(Settings.Default.DownloadDir0, UriKind.Absolute, out uri))
                {
                    this.tbLocalName.Text = uri.LocalPath;
                }
                if (Uri.TryCreate(Settings.Default.UploadDir0, UriKind.Absolute, out uri))
                {
                    this.tbRemoteName.Text = uri.ToString();
                }
                switch (this.jobType)
                {
                case JobType.Download:
                    this.tbRemoteName.Text = path;
                    if (Uri.TryCreate(Settings.Default.DownloadDir0, UriKind.Absolute, out uri))
                    {
                        uri = PathFromUri(uri, Path.GetFileName(path));
                        this.tbLocalName.Text = uri.LocalPath;
                    }
                    return;

                case JobType.Upload:
                    this.tbLocalName.Text = path;
                    if (Uri.TryCreate(Settings.Default.UploadDir0, UriKind.Absolute, out uri))
                    {
                        this.tbRemoteName.Text = PathFromUri(uri, Path.GetFileName(path)).ToString();
                    }
                    return;

                default:
                    return;
                }
            }
        }
コード例 #16
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
        private void ControlsFromJobState()
        {
            BitsJob bitsJob = null;

            if (this.lvJobList.SelectedItems.Count > 0)
            {
                JobWrapper tag = this.lvJobList.SelectedItems[0].Tag as JobWrapper;
                bitsJob = tag.BitsJob;
            }
            if (bitsJob == null)
            {
                this.ctxmiCancel.Visible        = false;
                this.ctxmiComplete.Visible      = false;
                this.ctxmiSuspend.Visible       = false;
                this.ctxmiResume.Visible        = false;
                this.ctxdlPriority.Visible      = false;
                this.ctxmiPriorityMap.Visible   = false;
                this.ctxmiJobProperties.Visible = false;
                this.ctxsepJob2.Visible         = this.ctxsepJob3.Visible = false;
            }
            else
            {
                this.ctxmiJobProperties.Visible = true;
                this.ctxmiCancel.Visible        = true;
                this.ctxmiComplete.Visible      = true;
                this.ctxmiSuspend.Visible       = true;
                this.ctxmiResume.Visible        = true;
                this.ctxmiPriorityMap.Visible   = true;
                this.ctxdlPriority.Visible      = true;
                this.ctxsepJob2.Visible         = this.ctxsepJob3.Visible = true;
                switch (bitsJob.State)
                {
                case JobState.Queued:
                    this.ctxmiResume.Enabled        = true;
                    this.ctxmiSuspend.Enabled       = true;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Connecting:
                    this.ctxmiResume.Enabled        = false;
                    this.ctxmiSuspend.Enabled       = true;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Transferring:
                    this.ctxmiResume.Enabled        = false;
                    this.ctxmiSuspend.Enabled       = true;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Suspended:
                    this.ctxmiResume.Enabled        = true;
                    this.ctxmiSuspend.Enabled       = false;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Error:
                    this.ctxmiResume.Enabled        = true;
                    this.ctxmiSuspend.Enabled       = true;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.TransientError:
                    this.ctxmiResume.Enabled        = true;
                    this.ctxmiSuspend.Enabled       = false;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Transferred:
                    this.ctxmiResume.Enabled        = false;
                    this.ctxmiSuspend.Enabled       = false;
                    this.ctxmiCancel.Enabled        = true;
                    this.ctxmiComplete.Enabled      = true;
                    this.ctxdlPriority.Enabled      = true;
                    this.ctxmiJobProperties.Enabled = true;
                    break;

                case JobState.Acknowledged:
                    this.ctxmiCancel.Enabled        = false;
                    this.ctxmiComplete.Enabled      = false;
                    this.ctxmiSuspend.Enabled       = false;
                    this.ctxmiResume.Enabled        = false;
                    this.ctxdlPriority.Enabled      = false;
                    this.ctxmiJobProperties.Enabled = false;
                    break;

                case JobState.Canceled:
                    this.ctxmiCancel.Enabled        = false;
                    this.ctxmiComplete.Enabled      = false;
                    this.ctxmiSuspend.Enabled       = false;
                    this.ctxmiResume.Enabled        = false;
                    this.ctxdlPriority.Enabled      = false;
                    this.ctxmiJobProperties.Enabled = false;
                    break;
                }
                this.ctxdlPriority.SelectedIndexChanged -= new EventHandler(this.ctxdlPriority_SelectedIndexChanged);
                this.ctxdlPriority.SelectedIndex         = (int)bitsJob.Priority;
                this.ctxdlPriority.SelectedIndexChanged += new EventHandler(this.ctxdlPriority_SelectedIndexChanged);
            }
        }
コード例 #17
0
 public override void InitControl(JobWrapper wrapper)
 {
     base.InitControl(wrapper);
     base.FindForm().AcceptButton = this.btnAddCredentials;
 }
コード例 #18
0
ファイル: JobListControl.cs プロジェクト: 11RS/SharpBITS.NET
        private void lvJobList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
        {
            Rectangle  rectangle;
            Brush      gradientActiveCaption;
            JobWrapper tag        = e.Item.Tag as JobWrapper;
            BitsJob    bitsJob    = tag.BitsJob;
            Color      windowText = SystemColors.WindowText;
            Font       prototype  = this.lvJobList.Font;
            int        num        = 0;

            if (e.SubItem.Name == bitsJob.JobId.ToString())
            {
                num = 0;
            }
            TextFormatFlags flags = TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter;

            if ((bitsJob.State == JobState.Suspended) || (bitsJob.State == JobState.Queued))
            {
                if (e.Item.Selected)
                {
                    windowText = SystemColors.ActiveCaptionText;
                }
                else
                {
                    windowText = SystemColors.InactiveCaptionText;
                }
                prototype = new Font(prototype, FontStyle.Italic);
            }
            else if ((bitsJob.State == JobState.Error) || (bitsJob.State == JobState.TransientError))
            {
                windowText = Color.Red;
            }
            else if ((bitsJob.State == JobState.Transferred) || (bitsJob.State == JobState.Acknowledged))
            {
                windowText = Settings.Default.ProgressCompletedColor;
                prototype  = new Font(prototype, FontStyle.Strikeout);
            }
            else if (bitsJob.State == JobState.Canceled)
            {
                if (e.Item.Selected)
                {
                    windowText = SystemColors.ActiveCaptionText;
                }
                else
                {
                    windowText = SystemColors.InactiveCaptionText;
                }
                prototype = new Font(prototype, FontStyle.Strikeout);
            }
            else if (bitsJob.State == JobState.Connecting)
            {
                windowText = Color.YellowGreen;
            }
            else if (bitsJob.State == JobState.Transferring)
            {
                windowText = Settings.Default.ProgressDoneColor;
            }
            if (e.Item.Selected)
            {
                int num2 = (e.ColumnIndex == 0) ? 1 : 0;
                rectangle = new Rectangle((e.Bounds.X + num) + num2, e.Bounds.Y + 1, (e.Bounds.Width - num) - num2, e.Bounds.Height - 2);
                if (this.lvJobList.Focused)
                {
                    gradientActiveCaption = SystemBrushes.GradientActiveCaption;
                }
                else
                {
                    gradientActiveCaption = SystemBrushes.GradientInactiveCaption;
                }
                e.Graphics.FillRectangle(gradientActiveCaption, rectangle);
            }
            if (e.SubItem.Name == ColumnNames.Progress)
            {
                StringFormat format = new StringFormat();
                format.Alignment      = StringAlignment.Center;
                gradientActiveCaption = new SolidBrush(Settings.Default.ProgressLeftColor);
                rectangle             = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                e.Graphics.FillRectangle(gradientActiveCaption, rectangle);
                if (bitsJob.Progress.BytesTransferred > 0L)
                {
                    if ((bitsJob.State == JobState.Transferred) || (bitsJob.State == JobState.Acknowledged))
                    {
                        gradientActiveCaption = new SolidBrush(Settings.Default.ProgressCompletedColor);
                    }
                    else
                    {
                        gradientActiveCaption = new LinearGradientBrush(rectangle, Settings.Default.ProgressDoneColor, Settings.Default.ProgressCompletedColor, LinearGradientMode.Horizontal);
                    }
                    Rectangle rect = Utils.CalculateProgress(rectangle, bitsJob.Progress.BytesTotal, bitsJob.Progress.BytesTransferred);
                    e.Graphics.FillRectangle(gradientActiveCaption, rect);
                }
                ControlPaint.DrawBorder(e.Graphics, rectangle, SystemColors.ActiveBorder, ButtonBorderStyle.Solid);
                windowText = SystemColors.InactiveCaptionText;
                TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, rectangle, windowText, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter);
            }
            else if (e.SubItem.Name == bitsJob.JobId.ToString())
            {
                Image image = this.imglDirection.Images[e.Item.ImageIndex];
                rectangle = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 1, image.Width, image.Height);
                e.Graphics.DrawImage(image, rectangle);
                rectangle = new Rectangle((e.Bounds.X + 2) + this.textDelta, e.Bounds.Y + 1, (e.Bounds.Width - 2) - this.textDelta, e.Bounds.Height);
                TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, rectangle, windowText, flags);
            }
            else if (e.SubItem.Name == ColumnNames.JobState)
            {
                TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, e.Bounds, windowText, flags);
            }
            else
            {
                TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, e.Bounds, windowText, flags | TextFormatFlags.Right);
            }
        }