public void debug_Step2_ColorCodeChanged()
        {
            TextBox code = m_control.code;
            Color color = Color.Black;
            ToolTip tip = m_control.tip;
            string text = code.Text;

            bool success = Utils.ArgbColorFromHexString(text, ref color);
            if (!success)
            {
                code.BackColor = Color.Red;
                tip.SetToolTip(code, "Use color format RGBA hexadecimal FFFFFFFF");
                return;
            }

            // Reset control to normal colors.
            code.BackColor = SystemColors.Window;
            tip.SetToolTip(code, null);

            m_control.Settings.SetColor(color);
            RefreshColorHelper helper = new RefreshColorHelper();
            helper.Step1_SetArgbColorControl(m_control);
            helper.Step2_ChangeAlpha(true);
            helper.Step3_Refresh();
        }
        public void Step2_AlphaTextChanged()
        {
            TextBox alphaTextBox = m_control.alphaTextBox;
            ColorDialogSettings settings = m_control.Settings;
            ToolTip tip = m_control.tip;
            PictureBox alpha = m_control.alpha;

            try
            {
                // Parse alue from alpha text box.
                int a = int.Parse(alphaTextBox.Text, c);
                if (a < 0 || a > 255)
                    throw new Exception("Alpha must be in range 0 and 255");
                settings.AlphaValue = (float)a/255f;
                alphaTextBox.BackColor = SystemColors.Window;
                tip.SetToolTip(alphaTextBox, null);

                RefreshColorHelper helper = new RefreshColorHelper();
                helper.Step1_SetArgbColorControl(m_control);
                helper.Step2_ChangeColorCode(true);
                helper.Step3_Refresh();
            }
            catch (Exception ex)
            {
                alphaTextBox.BackColor = Color.Red;
                tip.SetToolTip(alphaTextBox, ex.Message);
            }
        }
        public void Step2_ChangedText()
        {
            TextBox brightnessTextBox = m_control.brightnessTextBox;
            ColorDialogSettings settings = m_control.Settings;
            ToolTip tip = m_control.tip;
            PictureBox brightness = m_control.brightness;

            // Set brightness by text.
            try
            {
                int val = int.Parse(brightnessTextBox.Text, c);
                if (val < 0 || val > 255)
                    throw new Exception("Brightness must be in range 0 to 255");
                settings.Brightness = val/255f;

                RefreshColorHelper helper = new RefreshColorHelper();
                helper.Step1_SetArgbColorControl(m_control);
                helper.Step2_ChangeColorCode(true);
                helper.Step3_Refresh();

                brightnessTextBox.BackColor = SystemColors.Window;
                tip.SetToolTip(brightnessTextBox, null);
            }
            catch (Exception ex)
            {
                brightnessTextBox.BackColor = Color.Red;
                tip.SetToolTip(brightnessTextBox, ex.Message);
            }
        }
        public void Step2_ChangeByMousePos(float x)
        {
            PictureBox brightness = m_control.brightness;
            ColorDialogSettings settings = m_control.Settings;
            TextBox brightnessTextBox = m_control.brightnessTextBox;

            // Sets the brightness from user click or dragging.
            x /= brightness.Width;
            x = x < 0 ? 0 : x > 1 ? 1 : x;
            settings.Brightness = x;

            RefreshColorHelper helper = new RefreshColorHelper();
            helper.Step1_SetArgbColorControl(m_control);
            helper.Step2_ChangeColorCode(true);
            helper.Step3_Refresh();

            brightnessTextBox.Text = ((int)(x*255)).ToString();
        }
        public void Step2_SetHsv(float x, float y)
        {
            PictureBox hsvBox = m_control.hsvBox;
            ColorDialogSettings settings = m_control.Settings;
            TextBox brightnessTextBox = m_control.brightnessTextBox;
            PictureBox brightness = m_control.brightness;
            PictureBox alpha = m_control.alpha;

            x /= hsvBox.Width;
            y /= hsvBox.Height;
            x = x < 0 ? 0 : x > 1 ? 1 : x;
            y = y < 0 ? 0 : y > 1 ? 1 : y;
            settings.Hue = x*360;
            settings.Saturation = y;
            settings.Brightness = settings.Brightness == 0 ? 1 : settings.Brightness;
            brightnessTextBox.Text = ((int)(settings.Brightness*255)).ToString();

            RefreshColorHelper helper = new RefreshColorHelper();
            helper.Step1_SetArgbColorControl(m_control);
            helper.Step2_ChangeColorCode(true);
            helper.Step3_Refresh();
        }
        public void Step2_ColorCodeChanged()
        {
            TextBox code = m_control.code;
            Color color = Color.Black;
            ToolTip tip = m_control.tip;
            string text = code.Text;

            bool success = Utils.ColorFromHexString(text, ref color);
            if (!success)
            {
                code.BackColor = Color.Red;
                tip.SetToolTip(code, "Use color format hexadecimal FFFFFF");
                return;
            }

            code.BackColor = SystemColors.Window;
            tip.SetToolTip(code, null);

            m_control.Settings.SetColor(Color.FromArgb(m_control.Color.A, color));
            RefreshColorHelper helper = new RefreshColorHelper();
            helper.Step1_SetArgbColorControl(m_control);
            helper.Step2_ChangeColorCode(false);
            helper.Step3_Refresh();
        }
        // Handles all colors.
        void C1x1Click(object sender, EventArgs e)
        {
            Label colorLabel = (Label)sender;
            this.Color = colorLabel.BackColor;

            RefreshColorHelper helper = new RefreshColorHelper();
            helper.Step1_SetArgbColorControl(this);
            helper.Step2_ChangeColorCode(true);
            helper.Step3_Refresh();
        }