/// <summary> /// Raises the paint event and draws the control /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Owner != null) { StringFormat f = StringFormatFactory.CenterNoWrap(StringTrimming.None); if (Site != null && Site.DesignMode) { Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, Site.Name, f)); } else { Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, this.Text, f)); if (ctl != null) { if (ctl.Parent != Canvas) { Canvas.Controls.Add(ctl); } //time to show our control ctl.Location = new System.Drawing.Point(Bounds.Left, (this.SizeMode == RibbonElementSizeMode.DropDown) ? Bounds.Top: Bounds.Top); ctl.Visible = true; ctl.BringToFront(); } } } }
public override void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Owner == null) { return; } Owner.Renderer.OnRenderRibbonItem(new RibbonItemRenderEventArgs(Owner, e.Graphics, Bounds, this)); if (ImageVisible) { Owner.Renderer.OnRenderRibbonItemImage(new RibbonItemBoundsEventArgs(Owner, e.Graphics, e.Clip, this, _imageBounds)); } using (StringFormat f = StringFormatFactory.NearCenterNoWrap(StringTrimming.None)) { Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, TextBoxTextBounds, TextBoxText, f)); if (LabelVisible) { f.Alignment = (StringAlignment)TextAlignment; Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, LabelBounds, Text, f)); } } }
/// <summary> /// Raises the paint event and draws the /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Owner != null) { base.Owner.Renderer.OnRenderRibbonItem(new RibbonItemRenderEventArgs(base.Owner, e.Graphics, base.Bounds, this)); StringFormat f = StringFormatFactory.CenterNoWrap(StringTrimming.None); f.Alignment = (StringAlignment)TextAlignment; Rectangle clipBounds = Rectangle.FromLTRB(Bounds.Left + 3, Bounds.Top + Owner.ItemMargin.Top, Bounds.Right - 3, Bounds.Bottom - Owner.ItemMargin.Bottom); base.Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, clipBounds, this.Text, f)); } }
public override void Paint(PaintEventArgs pe) { if (_ribbon.CaptionBarVisible && _ribbon.QuickAccessToolbar.Visible) { SmoothingMode smbuff = pe.Graphics.SmoothingMode; pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (SolidBrush b = new SolidBrush(Color.FromArgb(50, Color.Blue))) { pe.Graphics.FillEllipse(b, Bounds); } StringFormat sf = StringFormatFactory.Center(); pe.Graphics.DrawString("+", SystemFonts.DefaultFont, Brushes.White, Bounds, sf); pe.Graphics.SmoothingMode = smbuff; } }
public override void Paint(PaintEventArgs pe) { SmoothingMode smbuff = pe.Graphics.SmoothingMode; pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath p = RibbonProfessionalRenderer.RoundRectangle(Bounds, 2)) { using (SolidBrush b = new SolidBrush(Color.FromArgb(50, Color.Blue))) { pe.Graphics.FillPath(b, p); } } StringFormat sf = StringFormatFactory.Center(); pe.Graphics.DrawString("Add Tab", SystemFonts.DefaultFont, Brushes.White, Bounds, sf); pe.Graphics.SmoothingMode = smbuff; }
public override void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Owner == null) { return; } var f = StringFormatFactory.CenterNoWrap(StringTrimming.None); var design = ((Site?.DesignMode ?? false) || IsOpenInVisualStudioDesigner()); var args = new RibbonTextEventArgs(Owner, e.Graphics, Bounds, this, Bounds, design ? Site.Name : Text, f); Owner.Renderer.OnRenderRibbonItemText(args); if (design) { return; } if (_ctl == null) { return; } if ((_ctl.Parent != Canvas) && (Canvas != null)) { _ctlParent = _ctl.Parent; _ctlLocation = _ctl.Location; _ctlSize = _ctl.Size; Canvas.Controls.Add(_ctl); _ctl.Location = new Point(Bounds.Left, Bounds.Top); _ctl.Visible = true; _ctl.BringToFront(); } else { if ((_ctl.Location.X != Bounds.Left) || (_ctl.Location.Y != Bounds.Top)) { _ctl.Location = new Point(Bounds.Left, Bounds.Top); } if (_ctl.Visible) { return; } _ctl.Visible = true; _ctl.BringToFront(); } }
/// <summary> /// Renders text of the button /// </summary> /// <param name="e"></param> protected virtual void OnPaintText(RibbonElementPaintEventArgs e) { if (SizeMode != RibbonElementSizeMode.Compact) { StringFormat sf = StringFormatFactory.NearCenter(); if (this.Owner.AltPressed || this.Owner.OrbDropDown.MenuItems.Contains(this)) { sf.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show; } else { sf.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Hide; } if (SizeMode == RibbonElementSizeMode.Large) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Near; } if (Style == RibbonButtonStyle.DropDownListItem) { sf.LineAlignment = StringAlignment.Near; Owner.Renderer.OnRenderRibbonItemText( new RibbonTextEventArgs(Owner, e.Graphics, e.Clip, this, Bounds, Text, sf)); } else { var newText = Text; if (!String.IsNullOrEmpty(this.AltKey) && this.Text.Contains(AltKey)) { var regex = new Regex(Regex.Escape(this.AltKey), RegexOptions.IgnoreCase); newText = regex.Replace(this.Text.Replace("&", ""), "&" + this.AltKey, 1).Replace("&&", "&"); } Rectangle bounds = new Rectangle(TextBounds.X, TextBounds.Y + _padding.Top, TextBounds.Width, TextBounds.Height); Owner.Renderer.OnRenderRibbonItemText( new RibbonTextEventArgs(Owner, e.Graphics, e.Clip, this, bounds, newText, Color.Empty, _bold ? FontStyle.Bold : FontStyle.Regular, sf)); } } }
protected override void OnPaintText(RibbonElementPaintEventArgs e) { if (e.Mode == RibbonElementSizeMode.DropDown) { StringFormat sf = StringFormatFactory.NearCenter(); Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs( Owner, e.Graphics, e.Clip, this, TextBounds, Text, Color.Empty, FontStyle.Bold, sf)); sf.Alignment = StringAlignment.Near; Owner.Renderer.OnRenderRibbonItemText(new RibbonTextEventArgs( Owner, e.Graphics, e.Clip, this, DescriptionBounds, Description, sf)); } else { base.OnPaintText(e); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Ribbon.Renderer.OnRenderOrbDropDownBackground( new RibbonOrbDropDownEventArgs(Ribbon, this, e.Graphics, e.ClipRectangle)); foreach (RibbonItem item in AllItems) { item.OnPaint(this, new RibbonElementPaintEventArgs(e.ClipRectangle, e.Graphics, RibbonElementSizeMode.DropDown)); } if (RibbonInDesignMode) { using (SolidBrush b = new SolidBrush(Color.FromArgb(50, Color.Blue))) { e.Graphics.FillRectangle(b, ButtonsGlyphBounds); e.Graphics.FillRectangle(b, RecentGlyphBounds); e.Graphics.FillRectangle(b, OptionGlyphBounds); e.Graphics.FillRectangle(b, ButtonsSeparatorGlyphBounds); } using (StringFormat sf = StringFormatFactory.Center(StringTrimming.None)) { e.Graphics.DrawString("+", Font, Brushes.White, ButtonsGlyphBounds, sf); e.Graphics.DrawString("+", Font, Brushes.White, RecentGlyphBounds, sf); e.Graphics.DrawString("+", Font, Brushes.White, OptionGlyphBounds, sf); e.Graphics.DrawString("---", Font, Brushes.White, ButtonsSeparatorGlyphBounds, sf); } using (Pen p = new Pen(Color.Black)) { p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; e.Graphics.DrawRectangle(p, designerSelectedBounds); } //e.Graphics.DrawString("Press ESC to Hide", Font, Brushes.Black, Width - 100f, 2f); } }