protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(Color.Gray); int blocks = Warp.Keys.Count - 1; //Draw first slider DrawSlider(e.Graphics, Warp.Keys[0]); KeyMap beforeMap = Warp.Keys[0]; KeyMap afterMap = null; for (var i = 0; i < blocks; i++) { afterMap = Warp.Keys[i + 1]; //Get locations int start = GetLocation(beforeMap.WarpKey); int end = GetLocation(afterMap.WarpKey); //Get color float factor = (float)((afterMap.WarpKey - beforeMap.WarpKey) / (afterMap.RealKey - beforeMap.RealKey)); Brush brush = new SolidBrush(ColorHelper.BlendColors(mCompressColor, Color.White, factor)); if (factor > 1) { brush = new SolidBrush(ColorHelper.BlendColors(Color.White, mStechColor, Math.Min(5, (factor - .5) / 5))); } Rectangle Rect = new Rectangle(); Rect.X = start + SLIDERWIDTH + 1; Rect.Width = end - start - SLIDERWIDTH; Rect.Height = Height; e.Graphics.FillRectangle(brush, Rect); //Draw % if (Rect.Width > 20) { string txt = ((int)(1f / factor * 100)).ToString() + " %"; e.Graphics.DrawString(txt, Font, Brushes.Black, (float)(Rect.X - 13) + (float)Rect.Width / 2f, (float)Height / 5f); } //Draw end slider DrawSlider(e.Graphics, afterMap); beforeMap = Warp.Keys[i + 1]; } }