// Repaint the waveform bitmap. protected override void OnPaint(PaintEventArgs pe) { if (this.bitmap != null) { pe.Graphics.DrawImage(this.bitmap, new Point(0, 0)); } AudioBlock block = Parent as AudioBlock; if (block != null) { AudioSelection selection = block.Selection as AudioSelection; if (selection != null) { int from = block.XForTime(selection.From); if (selection.IsRange) { int to = block.XForTime(selection.To); pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(from < to ? from : to, 0, from < to ? to - from : from - to, Height)); pe.Graphics.DrawLine(block.Colors.AudioSelectionPen, new Point(to, 0), new Point(to, Height - 1)); } pe.Graphics.DrawLine(block.Colors.AudioSelectionPen, new Point(from, 0), new Point(from, Height - 1)); } if (block.Playing) { int at = block.XForTime(block.PlayingTime); pe.Graphics.DrawLine(block.Colors.AudioPlaybackPen, new Point(at, 0), new Point(at, Height - 1)); } } base.OnPaint(pe); }
protected override void OnPaint(PaintEventArgs pe) { AudioBlock block = Parent as AudioBlock; if (block != null) { AudioSelection selection = block.Selection as AudioSelection; if (selection != null) { int from = block.XForTime(selection.From < selection.To ? selection.From : selection.To); int to = block.XForTime(selection.To > selection.From ? selection.To : selection.From); if (selection.IsRange) { pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(from, 0, to - from + 1, Height)); } else { pe.Graphics.FillRectangle(block.Colors.AudioSelectionBrush, new Rectangle(block.XForTime(selection.At) - Height / 2, 0, Height, Height)); } } if (block.Playing) { int at = block.XForTime(block.PlayingTime); Point[] points = new Point[3]; points[0] = new Point(at, 0); points[1] = new Point(at + Height / 2, Height / 2); points[2] = new Point(at, Height); pe.Graphics.DrawLine(block.Colors.AudioPlaybackPen, new Point(at, 0), new Point(at, Height)); pe.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; pe.Graphics.FillPolygon(block.Colors.AudioPlaybackBrush, points); } } // Calling the base class OnPaint base.OnPaint(pe); }