public void DrawArrow(Graphics gr) { int _size = 1; RibbonColor __color = new RibbonColor(Color.FromArgb(R0, G0, B0)); RibbonColor forecolor = new RibbonColor(this.ForeColor); Color _forecolor; if (__color.GetBrightness() > 50) { forecolor.BC = 1; forecolor.SC = 80; } else { forecolor.BC = 99; forecolor.SC = 20; } _forecolor = forecolor.GetColor(); switch (_arrow) { case e_arrow.ToDown: if (_imagelocation == e_imagelocation.Left) { Point[] points = new Point[3]; points[0] = new Point(this.Width - 8 * _size - _imageoffset, this.Height / 2 - _size / 2); points[1] = new Point(this.Width - 2 * _size - _imageoffset, this.Height / 2 - _size / 2); points[2] = new Point(this.Width - 5 * _size - _imageoffset, this.Height / 2 + _size * 2); gr.FillPolygon(new SolidBrush(_forecolor), points); } else if (_imagelocation == e_imagelocation.Top) { Point[] points = new Point[3]; points[0] = new Point(this.Width / 2 + 8 * _size - _imageoffset, this.Height - _imageoffset - 5 * _size); points[1] = new Point(this.Width / 2 + 2 * _size - _imageoffset, this.Height - _imageoffset - 5 * _size); points[2] = new Point(this.Width / 2 + 5 * _size - _imageoffset, this.Height - _imageoffset - 2 * _size); gr.FillPolygon(new SolidBrush(_forecolor), points); } break; case e_arrow.ToRight: if (_imagelocation == e_imagelocation.Left) { int arrowxpos = this.Width - _splitdistance + 2 * _imageoffset; Point[] points = new Point[3]; points[0] = new Point(arrowxpos + 4, this.Height / 2 - 4 * _size); points[1] = new Point(arrowxpos + 8, this.Height / 2); points[2] = new Point(arrowxpos + 4, this.Height / 2 + 4 * _size); gr.FillPolygon(new SolidBrush(_forecolor), points); } break; default: break; } }
public void ColorUpdate() { RibbonColor color = new RibbonColor(255,Convert.ToUInt16(H.Text), Convert.ToUInt16(S.Text), Convert.ToUInt16(B.Text)); switch (_colorsection) { case ColorSection.Base: BasePanel.BackColor = color.GetColor(); foreach (Control control in this.Controls) { if (control.GetType() == typeof(RibbonStyle.RibbonMenuButton)) { int alpha = ((RibbonStyle.RibbonMenuButton)control).ColorBase.A; ((RibbonStyle.RibbonMenuButton)control).ColorBase = Color.FromArgb(alpha, BasePanel.BackColor); } } break; case ColorSection.On: OnPanel.BackColor = color.GetColor(); foreach (Control control in this.Controls) { if (control.GetType() == typeof(RibbonStyle.RibbonMenuButton)) { int alpha = ((RibbonStyle.RibbonMenuButton)control).ColorOn.A; ((RibbonStyle.RibbonMenuButton)control).ColorOn = Color.FromArgb(alpha, OnPanel.BackColor); } } break; case ColorSection.Press: PressPanel.BackColor = color.GetColor(); foreach (Control control in this.Controls) { if (control.GetType() == typeof(RibbonStyle.RibbonMenuButton)) { int alpha = ((RibbonStyle.RibbonMenuButton)control).ColorPress.A; ((RibbonStyle.RibbonMenuButton)control).ColorPress = Color.FromArgb(alpha, PressPanel.BackColor); } } break; default: BackPanel.BackColor = color.GetColor(); this.BackColor = Color.FromArgb(BackPanel.BackColor.R,BackPanel.BackColor.G,BackPanel.BackColor.B); break; } this.Refresh(); }
public Color GetColorIncreased(Color color, int h, int s, int b) { RibbonColor _color = new RibbonColor(color); int ss = _color.GetSaturation(); float vc = b + _color.GetBrightness(); float hc = h + _color.GetHue(); float sc = s + ss; _color.VC = vc; _color.HC = hc; _color.SC = sc; return(_color.GetColor()); }
public void DrawString(Graphics gr) { if (this.Text != "") { int textwidth = (int)gr.MeasureString(this.Text, this.Font).Width; int textheight = (int)gr.MeasureString(this.Text, this.Font).Height; int extraoffset = 0; Font fontb = new Font(this.Font, FontStyle.Bold); if (_title != "") { extraoffset = textheight / 2; } string s1 = this.Text; string s2 = ""; int jump = this.Text.IndexOf("\\n"); if (jump != -1) { s2 = s1.Substring(jump + 3); s1 = s1.Substring(0, jump); } #region Calc Color Brightness RibbonColor __color = new RibbonColor(Color.FromArgb(R0, G0, B0)); RibbonColor forecolor = new RibbonColor(this.ForeColor); Color _forecolor; if (__color.GetBrightness() > 50) { forecolor.BC = 1; forecolor.SC = 80; } else { forecolor.BC = 99; forecolor.SC = 20; } _forecolor = forecolor.GetColor(); #endregion switch (_imagelocation) { case e_imagelocation.Left: if (this.Title != "") { gr.DrawString(this.Title, fontb, new SolidBrush(_forecolor), new PointF(offsetx + imagewidth + 4, this.Font.Size / 2)); gr.DrawString(s1, this.Font, new SolidBrush(_forecolor), new PointF(offsetx + imagewidth + 4, 2 * this.Font.Size + 1)); gr.DrawString(s2, this.Font, new SolidBrush(_forecolor), new PointF(offsetx + imagewidth + 4, 3 * this.Font.Size + 4)); } else { gr.DrawString(s1, this.Font, new SolidBrush(_forecolor), new PointF(offsetx + imagewidth + 4, this.Height / 2 - this.Font.Size + 1)); } break; case e_imagelocation.Right: gr.DrawString(this.Title, fontb, new SolidBrush(_forecolor), new PointF(offsetx, this.Height / 2 - this.Font.Size + 1 - extraoffset)); gr.DrawString(this.Text, this.Font, new SolidBrush(_forecolor), new PointF(offsetx, extraoffset + this.Height / 2 - this.Font.Size + 1)); break; case e_imagelocation.Top: gr.DrawString(this.Text, this.Font, new SolidBrush(_forecolor), new PointF(this.Width / 2 - textwidth / 2 - 1, offsety + imageheight)); break; case e_imagelocation.Bottom: gr.DrawString(this.Text, this.Font, new SolidBrush(_forecolor), new PointF(this.Width / 2 - textwidth / 2 - 1, this.Height - imageheight - textheight - 1)); break; default: break; } fontb.Dispose(); } }
public Color GetColorIncreased(Color color, int h, int s, int b) { RibbonColor _color = new RibbonColor(color); int ss = _color.GetSaturation(); float vc = b + _color.GetBrightness(); float hc = h + _color.GetHue(); float sc = s + ss; _color.VC = vc; _color.HC = hc; _color.SC = sc; return _color.GetColor(); }
public void ShowValues(Color onload) { RibbonColor color = new RibbonColor(onload); H.Text = color.GetHue().ToString(); S.Text = color.GetSaturation().ToString(); B.Text = color.GetBrightness().ToString(); HueTrack.Value = (int) color.GetHue(); SatTrack.Value = (int) color.GetSaturation(); BriTrack.Value = (int) color.GetBrightness(); }