/// <summary> /// Ovverides the Paint to create the solid colored backcolor /// </summary> protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.Clear(BackColor); // Calc title Rect Rectangle titleRect = new Rectangle( LEFT_RIGHT_PADDING, 0, Width - (2 * LEFT_RIGHT_PADDING), _header_Height); //Draw title using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { // Draw header text NativeText.DrawTransparentText( _title, SkinManager.getLogFontByType(MaterialSkinManager.fontType.H6), SkinManager.TextHighEmphasisColor, titleRect.Location, titleRect.Size, NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Bottom); } // Calc text Rect int TextWidth = TextRenderer.MeasureText(_text, SkinManager.getFontByType(MaterialSkinManager.fontType.Body1)).Width; int RectWidth = Width - (2 * LEFT_RIGHT_PADDING) - BUTTON_PADDING; int RectHeight = ((TextWidth / RectWidth) + 1) * 19; Rectangle textRect = new Rectangle( LEFT_RIGHT_PADDING, _header_Height + 17, RectWidth, RectHeight + 19); //Draw Text using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { // Draw header text NativeText.DrawMultilineTransparentText( _text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1), SkinManager.TextHighEmphasisColor, textRect.Location, textRect.Size, NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(Parent.BackColor); // Draw Text if (AlternativeForeColor != Color.Black) { using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { NativeText.DrawMultilineTransparentText( Text, SkinManager.getLogFontByType(_fontType), AlternativeForeColor, ClientRectangle.Location, ClientRectangle.Size, Alignment); } } else { using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { NativeText.DrawMultilineTransparentText( Text, SkinManager.getLogFontByType(_fontType), Enabled ? HighEmphasis ? UseAccent ? SkinManager.ColorScheme.AccentColor : // High emphasis, accent SkinManager.ColorScheme.PrimaryColor : // High emphasis, primary SkinManager.TextHighEmphasisColor : // Normal SkinManager.TextDisabledOrHintColor, // Disabled ClientRectangle.Location, ClientRectangle.Size, Alignment); } } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(Parent.BackColor); // Draw Text using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { NativeText.DrawMultilineTransparentText( Text, SkinManager.getLogFontByType(_fontType, RightToLeft), Enabled ? HighEmphasis ? UseAccent ? SkinManager.ColorScheme.AccentColor : // High emphasis, accent (SkinManager.Theme == MaterialSkin.MaterialSkinManager.Themes.LIGHT) ? SkinManager.ColorScheme.PrimaryColor : // High emphasis, primary Light theme SkinManager.ColorScheme.PrimaryColor.Lighten(0.25f) : // High emphasis, primary Dark theme SkinManager.TextHighEmphasisColor : // Normal SkinManager.TextDisabledOrHintColor, // Disabled ClientRectangle.Location, ClientRectangle.Size, Alignment); } }
protected override void OnPaint(PaintEventArgs e) { var g = e.Graphics; g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.Clear(SkinManager.ColorScheme.PrimaryColor); if (_baseTabControl == null) { return; } if (!_animationManager.IsAnimating() || _tabRects == null || _tabRects.Count != _baseTabControl.TabCount) { UpdateTabRects(); } var animationProgress = _animationManager.GetProgress(); //Click feedback if (_animationManager.IsAnimating()) { var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationProgress * 50)), Color.White)); var rippleSize = (int)(animationProgress * _tabRects[_baseTabControl.SelectedIndex].Width * 1.75); g.SetClip(_tabRects[_baseTabControl.SelectedIndex]); g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X - rippleSize / 2, _animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); g.ResetClip(); rippleBrush.Dispose(); } //Draw tab headers if (_tab_over_index >= 0) { //Change mouse over tab background color g.FillRectangle(SkinManager.BackgroundHoverBrush, _tabRects[_tab_over_index].X, _tabRects[_tab_over_index].Y, _tabRects[_tab_over_index].Width, _tabRects[_tab_over_index].Height - _tab_indicator_height); } foreach (TabPage tabPage in _baseTabControl.TabPages) { var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); if (_tabLabel != TabLabelStyle.Icon) { // Text using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { Size textSize = TextRenderer.MeasureText(_baseTabControl.TabPages[currentTabIndex].Text, Font); Rectangle textLocation = new Rectangle(_tabRects[currentTabIndex].X + (TAB_HEADER_PADDING / 2), _tabRects[currentTabIndex].Y, _tabRects[currentTabIndex].Width - (TAB_HEADER_PADDING), _tabRects[currentTabIndex].Height); if (_tabLabel == TabLabelStyle.IconAndText) { textLocation.Y = 46; textLocation.Height = 10; } if (((TAB_HEADER_PADDING * 2) + textSize.Width < TAB_WIDTH_MAX)) { NativeText.DrawTransparentText( tabPage.Text.ToUpper(), Font, Color.FromArgb(CalculateTextAlpha(currentTabIndex, animationProgress), SkinManager.ColorScheme.TextColor), textLocation.Location, textLocation.Size, NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); } else { if (_tabLabel == TabLabelStyle.IconAndText) { textLocation.Y = 40; textLocation.Height = 26; } NativeText.DrawMultilineTransparentText( tabPage.Text.ToUpper(), SkinManager.getFontByType(MaterialSkinManager.fontType.Body2), Color.FromArgb(CalculateTextAlpha(currentTabIndex, animationProgress), SkinManager.ColorScheme.TextColor), textLocation.Location, textLocation.Size, NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); } } } if (_tabLabel != TabLabelStyle.Text) { // Icons if (_baseTabControl.ImageList != null && (!String.IsNullOrEmpty(tabPage.ImageKey) | tabPage.ImageIndex > -1)) { Rectangle iconRect = new Rectangle( _tabRects[currentTabIndex].X + (_tabRects[currentTabIndex].Width / 2) - (ICON_SIZE / 2), _tabRects[currentTabIndex].Y + (_tabRects[currentTabIndex].Height / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); if (_tabLabel == TabLabelStyle.IconAndText) { iconRect.Y = 12; } g.DrawImage(!String.IsNullOrEmpty(tabPage.ImageKey) ? _baseTabControl.ImageList.Images[tabPage.ImageKey]: _baseTabControl.ImageList.Images[tabPage.ImageIndex], iconRect); } } } //Animate tab indicator var previousSelectedTabIndexIfHasOne = _previousSelectedTabIndex == -1 ? _baseTabControl.SelectedIndex : _previousSelectedTabIndex; var previousActiveTabRect = _tabRects[previousSelectedTabIndexIfHasOne]; var activeTabPageRect = _tabRects[_baseTabControl.SelectedIndex]; var y = activeTabPageRect.Bottom - _tab_indicator_height; var x = previousActiveTabRect.X + (int)((activeTabPageRect.X - previousActiveTabRect.X) * animationProgress); var width = previousActiveTabRect.Width + (int)((activeTabPageRect.Width - previousActiveTabRect.Width) * animationProgress); g.FillRectangle(SkinManager.ColorScheme.AccentBrush, x, y, width, _tab_indicator_height); }