void PaintThisControl(Graphics g) { NavigateBarHelper.PaintGradientControl(this, g, navigateBar.NavigateBarColorTable.CaptionDescBegin, navigateBar.NavigateBarColorTable.CaptionDescEnd, navigateBar.NavigateBarColorTable.PaintAngle); // Gradient olarak boyama işlemi // Paint gradient // Yazıyı yazma // Draw caption description text int capWidth = (int)g.MeasureString(Caption, SystemFonts.DialogFont).Width; g.DrawString(Caption, new Font(SystemFonts.DialogFont.Name, 8, FontStyle.Regular), new SolidBrush(navigateBar.NavigateBarColorTable.TextColor), (this.NavigateBar.RightToLeft == RightToLeft.Yes ? this.Width - capWidth - 8 : 8), (this.Height - SystemFonts.DialogFont.Height) / 2); // Etrafın çizgisi // Draw rectangle g.DrawRectangle(new Pen(navigateBar.NavigateBarColorTable.BorderColor), new Rectangle(0, 0, Width - 1, Height - 1)); }
protected override void OnPaintBackground(PaintEventArgs e) { if (this.Controls.Count == 0 && !this.DesignMode) { base.OnPaintBackground(e); NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonNormalBegin, navigateBar.NavigateBarColorTable.ButtonNormalEnd, navigateBar.NavigateBarColorTable.PaintAngle); } }
/// <summary> /// Paint Gradient /// </summary> /// <param name="tControl">Painting control</param> /// <param name="tGraphics">Graphic object</param> /// <param name="tColorTable">NavigataBarColorTable inherited object</param> /// <param name="tPaintType">Paint type</param> public static void PaintGradientBack(Control tControl, Graphics tGraphics, NavigateBarColorTable tColorTable, PaintType tPaintType) { if (tControl.ClientRectangle.IsEmpty) { return; } #region Color Select Color cTopColorBegin = tColorTable.ButtonNormalBegin; Color cTopColorEnd = tColorTable.ButtonNormalMiddleBegin; Color cBottomColorBegin = tColorTable.ButtonNormalMiddleEnd; Color cBottomColorEnd = tColorTable.ButtonNormalEnd; switch (tPaintType) { case PaintType.Selected: { cTopColorBegin = tColorTable.ButtonSelectedBegin; cTopColorEnd = tColorTable.ButtonSelectedMiddleBegin; cBottomColorBegin = tColorTable.ButtonSelectedMiddleEnd; cBottomColorEnd = tColorTable.ButtonSelectedEnd; break; } case PaintType.MouseOver: { cTopColorBegin = tColorTable.ButtonMouseOverBegin; cTopColorEnd = tColorTable.ButtonMouseOverMiddleBegin; cBottomColorBegin = tColorTable.ButtonMouseOverMiddleEnd; cBottomColorEnd = tColorTable.ButtonMouseOverEnd; break; } case PaintType.Pressed: { cTopColorBegin = tColorTable.ButtonSelectedEnd; cTopColorEnd = tColorTable.ButtonSelectedMiddleBegin; cBottomColorBegin = tColorTable.ButtonSelectedMiddleEnd; cBottomColorEnd = tColorTable.ButtonSelectedMiddleEnd; break; } } #endregion NavigateBarHelper.PaintGradientControl(tControl, tGraphics, cTopColorBegin, cTopColorEnd, cBottomColorBegin, cBottomColorEnd, tColorTable.PaintAngle, tColorTable.PaintRatio); }
protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); // Paint if (IsSelected) { NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonSelectedBegin, navigateBar.NavigateBarColorTable.ButtonSelectedBegin, navigateBar.NavigateBarColorTable.PaintAngle); } else if (isMouseOver && !IsSelected) { NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonMouseOverBegin, navigateBar.NavigateBarColorTable.ButtonMouseOverBegin, navigateBar.NavigateBarColorTable.PaintAngle); } else { NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.ButtonNormalBegin, navigateBar.NavigateBarColorTable.ButtonNormalBegin, navigateBar.NavigateBarColorTable.PaintAngle); } //if (!(this.IsSelected || isMouseOver)) //{ // Pen pen = new Pen(Color.White); // // | // e.Graphics.DrawLine(pen, new Point(0, 0), new Point(0, this.Height)); // // ___ // e.Graphics.DrawLine(pen, new Point(0, this.CaptionBand.Height), new Point(this.Width - 1, this.CaptionBand.Height)); //} float leftPoss = 0, rightPoss = 0; Font font = new Font(SystemFonts.CaptionFont.FontFamily, 16, FontStyle.Bold); // Vertical Text e.Graphics.TranslateTransform(0, this.ClientSize.Height); e.Graphics.RotateTransform(270F); SizeF sf = e.Graphics.MeasureString(this.ContentText, font); leftPoss = (this.ClientSize.Height - sf.Width - CaptionBand.Height) / 2; rightPoss = (this.ClientSize.Width - sf.Height) / 2; e.Graphics.DrawString(this.ContentText, font, new SolidBrush(navigateBar.NavigateBarColorTable.CaptionTextColor), leftPoss, rightPoss); // }
protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); if (navigateBar == null) { return; } Rectangle splitRectangle = this.ClientRectangle; Brush darkColor = new SolidBrush(navigateBar.NavigateBarColorTable.BorderColor); Brush lightColor = new SolidBrush(navigateBar.NavigateBarColorTable.SeparatorLight); NavigateBarHelper.PaintGradientControl(this, e.Graphics, navigateBar.NavigateBarColorTable.SeparatorLight, navigateBar.NavigateBarColorTable.SeparatorDark, navigateBar.NavigateBarColorTable.PaintAngle); // Point Position int pointWidth = 4, pointHeight = 2; int firstPointPos = (splitRectangle.Width - (splitterPointCount * pointWidth + this.splitterPointCount)) / 2; int Y = (int)((splitRectangle.Height - 1) / 2); // Draw Points for (int i = 0; i < this.splitterPointCount; i++) { e.Graphics.FillRectangle(darkColor, firstPointPos, Y, pointHeight, pointHeight); e.Graphics.FillRectangle(lightColor, firstPointPos + 1, Y + 1, pointHeight, pointHeight); e.Graphics.FillRectangle(SystemBrushes.GrayText, firstPointPos + 1, Y, pointHeight, pointHeight); firstPointPos += pointWidth + 1; } splitRectangle.Width--; e.Graphics.DrawRectangle(new Pen(navigateBar.NavigateBarColorTable.BorderColor), splitRectangle); }
void PaintThisControl(Graphics g) { // Gradient olarak boyama işlemi // Paint gradient NavigateBarHelper.PaintGradientControl(this, g, NavigateBar.NavigateBarColorTable.CaptionBegin, NavigateBar.NavigateBarColorTable.CaptionEnd, NavigateBar.NavigateBarColorTable.PaintAngle); // Size imgSize = new Size(16, 16); Pen penBorder = new Pen(navigateBar.NavigateBarColorTable.BorderColor); // Image if (image != null) { int halfHeight = ((this.Height - imgSize.Height) / 2); if (this.NavigateBar.RightToLeft == RightToLeft.Yes) { g.DrawImage(image, new Rectangle(new Point(this.Width - imgSize.Width - SPLIT_WIDTH - 2, halfHeight), imgSize)); } else { g.DrawImage(image, new Rectangle(new Point(SPLIT_WIDTH + 2, halfHeight), imgSize)); } } // Yazıyı yazma // Draw caption text int capWidth = (int)g.MeasureString(this.Caption, m_font).Width; //this.Height = Convert.ToInt32((int)g.MeasureString(this.Caption, m_font).Height + ((int)g.MeasureString(this.Caption, m_font).Height * .1)); Brush captionColor = new SolidBrush(navigateBar.NavigateBarColorTable.CaptionTextColor); if (this.NavigateBar.RightToLeft == RightToLeft.Yes) { g.DrawString(this.Caption, m_font, captionColor, this.Width - capWidth - SPLIT_WIDTH * 2 - (image == null ? SPLIT_WIDTH * 2 : imgSize.Width + SPLIT_WIDTH), (this.Height - m_font.GetHeight()) / 2); } else { g.DrawString(this.Caption, m_font, captionColor, image == null ? SPLIT_WIDTH * 2 : imgSize.Width + SPLIT_WIDTH * 2, (this.Height - m_font.GetHeight()) / 2); } // Etrafın çizgisi // Draw rectangle if (this.CollapseMode) // Sadece başlık durumunda // only caption { if (navigateBar.SelectedButton != null) { g.DrawRectangle(penBorder, new Rectangle(0, 0, Width - 1, Height - (navigateBar.SelectedButton.IsShowCaptionDescription ? 0 : 1))); } else { g.DrawRectangle(penBorder, new Rectangle(0, 0, Width - 1, Height - 1)); } } else // Başlık ve Daraltılmış durumda // Collapse and caption { g.DrawRectangle(penBorder, new Rectangle(-1, 0, Width + 1, Height - 1)); } }