private void lvJobFiles_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { Rectangle rectangle; Brush gradientActiveCaption; BitsFile tag = (BitsFile)e.Item.Tag; BitsJob bitsJob = base.wrapper.BitsJob; Color windowText = SystemColors.WindowText; Font prototype = this.lvJobFiles.Font; TextFormatFlags flags = TextFormatFlags.LeftAndRightPadding | TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter; if (tag == null) { 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 num = (e.ColumnIndex == 0) ? 1 : 0; rectangle = new Rectangle(e.Bounds.X + num, e.Bounds.Y + 1, e.Bounds.Width - num, e.Bounds.Height - 2); if (this.lvJobFiles.Focused) { gradientActiveCaption = SystemBrushes.GradientActiveCaption; } else { gradientActiveCaption = SystemBrushes.GradientInactiveCaption; } e.Graphics.FillRectangle(gradientActiveCaption, rectangle); } if (e.SubItem.Name.Equals("BytesTotal")) { TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, e.Bounds, windowText, flags | TextFormatFlags.Right); } else if (e.SubItem.Name.Equals("BytesTransfered")) { TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, e.Bounds, windowText, flags | TextFormatFlags.Right); } else if (e.SubItem.Name == "Progress") { Rectangle rectangle2; 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); JobProgress progress = null; if (tag != null) { FileProgress progress2 = null; progress2 = tag.Progress; rectangle2 = CalcProgress(e.Bounds, progress2.BytesTotal, progress2.BytesTransferred); if (progress2.BytesTransferred > 0L) { if (progress2.Completed || (progress2.BytesTotal == progress2.BytesTransferred)) { gradientActiveCaption = new SolidBrush(Settings.Default.ProgressCompletedColor); } else { gradientActiveCaption = new LinearGradientBrush(rectangle, Settings.Default.ProgressDoneColor, Settings.Default.ProgressCompletedColor, LinearGradientMode.Horizontal); } } rectangle2 = Utils.CalculateProgress(rectangle, progress2.BytesTotal, progress2.BytesTransferred); } else { progress = bitsJob.Progress; rectangle2 = CalcProgress(e.Bounds, progress.BytesTotal, progress.BytesTransferred); if (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); } } rectangle2 = Utils.CalculateProgress(rectangle, progress.BytesTotal, progress.BytesTransferred); } e.Graphics.FillRectangle(gradientActiveCaption, rectangle2); 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 { TextRenderer.DrawText(e.Graphics, e.SubItem.Text, prototype, e.Bounds, windowText, flags); } }
/// <summary> /// Initializes a new instance of the <see cref="BitsError"/> class. /// </summary> /// <param name="bitsErrorAdapter">The bits error adapter.</param> internal BitsError( BitsErrorAdapter bitsErrorAdapter ) { ErrorAdapter = bitsErrorAdapter; File = new BitsFile( bitsErrorAdapter.File ); }