Accord.Controls.SliderControl.TurnControl_Paint C# (CSharp) Method

TurnControl_Paint() private method

private TurnControl_Paint ( object sender, PaintEventArgs e ) : void
sender object
e PaintEventArgs
return void
        private void TurnControl_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            int clientWidth = ClientRectangle.Width;
            int clientHeight = ClientRectangle.Height;

            if (isHorizontal)
            {
                // draw area
                g.FillRectangle((this.Enabled) ? negativeAreaBrush : disabledBrash, leftMargin, topMargin,
                   clientWidth / 2 - leftMargin, manipulatorHeight / 2);
                g.FillRectangle((this.Enabled) ? positiveAreaBrush : disabledBrash, clientWidth / 2, topMargin,
                   clientWidth / 2 - leftMargin, manipulatorHeight / 2);
                g.DrawRectangle(borderPen, leftMargin, topMargin,
                   clientWidth - 1 - leftMargin * 2, manipulatorHeight / 2);
                g.DrawLine(borderPen, clientWidth / 2, topMargin, clientWidth / 2, topMargin + manipulatorHeight / 2);

                // calculate manipulator's center point
                int ctrlManipulatorX = (int)(manipulatatorPosition * (clientWidth / 2 - leftMargin) + clientWidth / 2);

                // draw manipulator
                g.FillRectangle((this.Enabled) ? manipulatorBrush : disabledBrash, ctrlManipulatorX - manipulatorWidth / 2, 0,
                    manipulatorWidth, manipulatorHeight);
                g.DrawRectangle(borderPen, ctrlManipulatorX - manipulatorWidth / 2, 0,
                    manipulatorWidth, manipulatorHeight);
            }
            else
            {
                // draw area
                g.FillRectangle((this.Enabled) ? positiveAreaBrush : disabledBrash, leftMargin, topMargin,
                    manipulatorHeight / 2, clientHeight / 2 - topMargin);
                g.FillRectangle((this.Enabled) ? negativeAreaBrush : disabledBrash, leftMargin, clientHeight / 2,
                   manipulatorHeight / 2, clientHeight / 2 - topMargin);
                g.DrawRectangle(borderPen, leftMargin, topMargin,
                   manipulatorHeight / 2, clientHeight - 1 - topMargin * 2);
                g.DrawLine(borderPen, leftMargin, clientHeight / 2, leftMargin + manipulatorHeight / 2, clientHeight / 2);


                // calculate manipulator's center point
                int ctrlManipulatorY = (int)(-manipulatatorPosition * (clientHeight / 2 - topMargin) + clientHeight / 2);

                // draw manipulator
                g.FillRectangle((this.Enabled) ? manipulatorBrush : disabledBrash, 0, ctrlManipulatorY - manipulatorWidth / 2,
                    manipulatorHeight, manipulatorWidth);
                g.DrawRectangle(borderPen, 0, ctrlManipulatorY - manipulatorWidth / 2,
                    manipulatorHeight, manipulatorWidth);
            }
        }