using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ColorProgressBarDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void colorProgressBar1_ValueChanged(object sender, EventArgs e, int value)
        {
            ColorProgressBar senderCPB = sender as ColorProgressBar;
            if (value < 60)
            {
                senderCPB.ColorBegin = Color.Green;
                senderCPB.ColorEnd = Color.Lime;
            }
            if (value >= 60 && value < 90)
            {
                senderCPB.ColorBegin = Color.Olive;
                senderCPB.ColorEnd = Color.Yellow;
            }
            if (value >= 90)
            {
                senderCPB.ColorBegin = Color.Maroon;
                senderCPB.ColorEnd = Color.Red;
            }
        }

        private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            colorProgressBar1.Value = trackBar1.Value;
            colorProgressBar2.Value = trackBar1.Value;
        }
    }
}
