private void pnlColorBar_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //Draw bar g.FillRectangle(_barBrush, pnlColorBar.ClientRectangle); //Draw indicator ARGBPixel p = ((ARGBPixel)(new HSVPixel(_hsv.H, 100, 100))).Inverse(); int y = (int)(_hsv.H / 360.0f * (pnlColorBar.Height - 1)); Rectangle r = new Rectangle(-1, y - 2, pnlColorBar.Width + 1, 4); using (Pen pen = new Pen((Color)p)) g.DrawRectangle(pen, r); r.Y += 1; r.Height -= 2; p = p.Lighten(64); using (Pen pen = new Pen((Color)p)) g.DrawRectangle(pen, r); }
private void pnlColorBox_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //Update brush if color changed if (_brushH != _hsv.H) { _boxColors[0] = _boxColors[4] = (Color)(new HSVPixel(_hsv.H, 100, 100)); _squareBrush.SurroundColors = _boxColors; _squareBrush.CenterColor = (Color)(new HSVPixel(_hsv.H, 50, 50)); _brushH = _hsv.H; } //Draw square //g.FillPath(_squareBrush, _squarePath); g.FillRectangle(_squareBrush, pnlColorBox.ClientRectangle); //Draw indicator int x = (int)(_hsv.V / 100.0f * pnlColorBox.Width); int y = (int)((100 - _hsv.S) / 100.0f * pnlColorBox.Height); Rectangle r = new Rectangle(x - 3, y - 3, 6, 6); ARGBPixel p = _rgb.Inverse(); p.A = 255; using (Pen pen = new Pen((Color)p)) g.DrawEllipse(pen, r); r.X -= 1; r.Y -= 1; r.Width += 2; r.Height += 2; p = p.Lighten(64); using (Pen pen = new Pen((Color)p)) g.DrawEllipse(pen, r); }
private void pnlAlpha_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //Draw bar g.FillRectangle(_alphaBrush, pnlAlpha.ClientRectangle); //Draw indicator byte col = (byte)(255 - _rgb.A); ARGBPixel p = new ARGBPixel(255, col, col, col); int y = (int)(col / 255.0f * (pnlAlpha.Height - 1)); Rectangle r = new Rectangle(-1, y - 2, pnlAlpha.Width + 1, 4); using (Pen pen = new Pen((Color)p)) g.DrawRectangle(pen, r); p.Lighten(64); r.Y += 1; r.Height -= 2; using (Pen pen = new Pen((Color)p)) g.DrawRectangle(pen, r); }