//This gets the size of the X and the border of the form private void GetElementsSize() { var g = this.CreateGraphics(); // Get the size of the close button. if (SetRenderer(VisualStyleElement.Window.CloseButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the minimize button. if (this.MinimizeBox && SetRenderer(VisualStyleElement.Window.MinButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the maximize button. if (this.MaximizeBox && SetRenderer(VisualStyleElement.Window.MaxButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the icon. if (this.ShowIcon) { AllButtonsAndPadding += this.Icon.Width; } // Get the thickness of the left, bottom, // and right window frame. if (SetRenderer(VisualStyleElement.Window.FrameLeft.Active)) { AllButtonsAndPadding += (renderer.GetPartSize(g, ThemeSizeType.True).Width) * 2; //Borders on both side } }
//This gets the size of the X and the border of the form private void GetElementsSize() { var g = this.CreateGraphics(); // Get the size of the close button. if (SetRenderer(VisualStyleElement.Window.CloseButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the minimize button. if (this.MinimizeBox && SetRenderer(VisualStyleElement.Window.MinButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the maximize button. if (this.MaximizeBox && SetRenderer(VisualStyleElement.Window.MaxButton.Normal)) { AllButtonsAndPadding += renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the icon only if it is actually going to be displayed. if (this.ShowIcon && this.ControlBox && (this.FormBorderStyle == FormBorderStyle.Fixed3D || this.FormBorderStyle == FormBorderStyle.Sizable || this.FormBorderStyle == FormBorderStyle.FixedSingle)) { AllButtonsAndPadding += this.Icon.Width; } // Get the thickness of the left and right window frame. if (SetRenderer(VisualStyleElement.Window.FrameLeft.Active)) { AllButtonsAndPadding += (renderer.GetPartSize(g, ThemeSizeType.True).Width) * 2; //Borders on both side } }
private static void CalcSize(Graphics g) { if (VisualStyleInformation.IsEnabledByUser) { VisualStyleRenderer renderer = new VisualStyleRenderer(_elementTop.VSElement); _markSizeTopBottom = renderer.GetPartSize(g, ThemeSizeType.True); renderer.SetParameters(_elementLeft.VSElement); _markSizeLeftRight = renderer.GetPartSize(g, ThemeSizeType.True); } else { _markSizeTopBottom = new Size(16, 16); //このサイズでは設定によってはダメかも _markSizeLeftRight = new Size(16, 16); } }
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) { if (e.ToolStrip.IsDropDown && IsSupported) { var renderer = new VisualStyleRenderer("menu", 13, 0); var themeMargins = renderer.GetMargins(e.Graphics, MarginProperty.CaptionMargins); themeMargins.Right += 2; int num = e.ToolStrip.Width - e.ToolStrip.DisplayRectangle.Width - themeMargins.Left - themeMargins.Right - 1 - e.AffectedBounds.Width; var bounds = e.AffectedBounds; bounds.Y += 2; bounds.Height -= 4; int width = renderer.GetPartSize(e.Graphics, ThemeSizeType.True).Width; if (e.ToolStrip.RightToLeft == RightToLeft.Yes) { bounds = new Rectangle(bounds.X - num, bounds.Y, width, bounds.Height); bounds.X += width; } else { bounds = new Rectangle(bounds.Width + num - width, bounds.Y, width, bounds.Height); } renderer.DrawBackground(e.Graphics, bounds); } else { base.OnRenderImageMargin(e); } }
/// ------------------------------------------------------------------------------------ public CheckBoxColumnHeaderHandler(DataGridViewColumn col) { Debug.Assert(col != null); Debug.Assert(col is DataGridViewCheckBoxColumn); Debug.Assert(col.DataGridView != null); _col = col; _owningGrid = col.DataGridView; _owningGrid.HandleDestroyed += HandleHandleDestroyed; _owningGrid.CellPainting += HandleHeaderCellPainting; _owningGrid.CellMouseMove += HandleHeaderCellMouseMove; _owningGrid.CellMouseClick += HandleHeaderCellMouseClick; _owningGrid.CellContentClick += HandleDataCellCellContentClick; _owningGrid.Scroll += HandleGridScroll; _owningGrid.RowsAdded += HandleGridRowsAdded; _owningGrid.RowsRemoved += HandleGridRowsRemoved; if (!BetterGrid.CanPaintVisualStyle()) { _szCheckBox = new Size(13, 13); } else { var element = VisualStyleElement.Button.CheckBox.CheckedNormal; var renderer = new VisualStyleRenderer(element); using (var g = _owningGrid.CreateGraphics()) _szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor. /// </summary> /// ------------------------------------------------------------------------------------ public CheckBoxColumnHeaderHandler(DataGridViewColumn col) { Debug.Assert(col != null); Debug.Assert(col is DataGridViewCheckBoxColumn); Debug.Assert(col.DataGridView != null); m_col = col; m_grid = col.DataGridView; m_grid.HandleDestroyed += HandleHandleDestroyed; m_grid.CellPainting += HandleHeaderCellPainting; m_grid.CellMouseMove += HandleHeaderCellMouseMove; m_grid.ColumnHeaderMouseClick += HandleHeaderCellMouseClick; m_grid.CellContentClick += HandleDataCellCellContentClick; m_grid.Scroll += HandleGridScroll; m_grid.RowsAdded += HandleGridRowsAdded; m_grid.RowsRemoved += HandleGridRowsRemoved; if (!Application.RenderWithVisualStyles) { m_szCheckBox = new Size(13, 13); } else { var element = VisualStyleElement.Button.CheckBox.CheckedNormal; var renderer = new VisualStyleRenderer(element); using (var g = m_grid.CreateGraphics()) m_szCheckBox = renderer.GetPartSize(g, ThemeSizeType.True); } m_stringFormat = new StringFormat(StringFormat.GenericTypographic); m_stringFormat.Alignment = StringAlignment.Center; m_stringFormat.LineAlignment = StringAlignment.Center; m_stringFormat.Trimming = StringTrimming.EllipsisCharacter; m_stringFormat.FormatFlags |= StringFormatFlags.NoWrap; }
public static Size GetTopPointingThumbSize(Graphics g, TrackBarThumbState state) { if (!IsSupported) { throw new InvalidOperationException(); } VisualStyleRenderer vsr; switch (state) { case TrackBarThumbState.Disabled: vsr = new VisualStyleRenderer(VisualStyleElement.TrackBar.ThumbTop.Disabled); break; case TrackBarThumbState.Hot: vsr = new VisualStyleRenderer(VisualStyleElement.TrackBar.ThumbTop.Hot); break; case TrackBarThumbState.Normal: default: vsr = new VisualStyleRenderer(VisualStyleElement.TrackBar.ThumbTop.Normal); break; case TrackBarThumbState.Pressed: vsr = new VisualStyleRenderer(VisualStyleElement.TrackBar.ThumbTop.Pressed); break; } return(vsr.GetPartSize(g, ThemeSizeType.Draw)); }
private void SetLayout() { if (isMin6 && Application.RenderWithVisualStyles) { using (var g = CreateGraphics()) { // Back button var theme = new VisualStyleRenderer(VisualStyleElementEx.Navigation.BackButton.Normal); var bbSize = theme.GetPartSize(g, ThemeSizeType.Draw); // Title theme.SetParameters(VisualStyleElementEx.AeroWizard.TitleBar.Active); title.Font = theme.GetFont2(g); titleBar.Height = Math.Max(theme.GetMargins2(g, MarginProperty.ContentMargins).Top, bbSize.Height + 2); titleBar.ColumnStyles[0].Width = bbSize.Width + 4F; titleBar.ColumnStyles[1].Width = titleImageIcon != null ? titleImageList.ImageSize.Width + 4F : 0; backButton.Size = bbSize; // Header theme.SetParameters(VisualStyleElementEx.AeroWizard.HeaderArea.Normal); headerLabel.Font = theme.GetFont2(g); headerLabel.Margin = theme.GetMargins2(g, MarginProperty.ContentMargins); headerLabel.ForeColor = theme.GetColor(ColorProperty.TextColor); // Content theme.SetParameters(VisualStyleElementEx.AeroWizard.ContentArea.Normal); BackColor = theme.GetColor(ColorProperty.FillColor); contentArea.Font = theme.GetFont2(g); var cp = theme.GetMargins2(g, MarginProperty.ContentMargins); contentArea.ColumnStyles[0].Width = cp.Left; contentArea.RowStyles[1].Height = cp.Bottom; // Command theme.SetParameters(VisualStyleElementEx.AeroWizard.CommandArea.Normal); cp = theme.GetMargins2(g, MarginProperty.ContentMargins); commandArea.RowStyles[0].Height = cp.Top; commandArea.RowStyles[2].Height = cp.Bottom; commandArea.ColumnStyles[1].Width = contentArea.ColumnStyles[contentCol + 1].Width = cp.Right; commandAreaBorder.Height = 0; theme.SetParameters(VisualStyleElementEx.AeroWizard.Button.Normal); var btnHeight = theme.GetInteger(IntegerProperty.Height); commandAreaButtonFlowLayout.MinimumSize = new Size(0, btnHeight); var btnFont = theme.GetFont2(g); foreach (Control ctrl in commandAreaButtonFlowLayout.Controls) { ctrl.Font = btnFont; ctrl.Height = btnHeight; //ctrl.MaximumSize = new Size(0, btnHeight); } themePropsSet = true; } } else { commandAreaBorder.Height = 1; backButton.Size = new Size(GetUnthemedBackButtonImage().Width, GetUnthemedBackButtonImage().Height / 4); BackColor = UseAeroStyle ? SystemColors.Window : SystemColors.Control; } }
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) { if (EnsureRenderer()) { if (e.ToolStrip.IsDropDown) { renderer.SetParameters(MenuClass, (int)MenuParts.PopupGutter, 0); // The AffectedBounds is usually too small, way too small to look right. Instead of using that, // use the AffectedBounds but with the right width. Then narrow the rectangle to the correct edge // based on whether or not it's RTL. (It doesn't need to be narrowed to an edge in LTR mode, but let's // do that anyway.) // Using the DisplayRectangle gets roughly the right size so that the separator is closer to the text. Padding margins = GetThemeMargins(e.Graphics, MarginTypes.Sizing); int extraWidth = (e.ToolStrip.Width - e.ToolStrip.DisplayRectangle.Width - margins.Left - margins.Right - 1) - e.AffectedBounds.Width; Rectangle rect = e.AffectedBounds; rect.Y += 2; rect.Height -= 4; int sepWidth = renderer.GetPartSize(e.Graphics, ThemeSizeType.True).Width; if (e.ToolStrip.RightToLeft == RightToLeft.Yes) { rect = new Rectangle(rect.X - extraWidth, rect.Y, sepWidth, rect.Height); rect.X += sepWidth; } else { rect = new Rectangle(rect.Width + extraWidth - sepWidth, rect.Y, sepWidth, rect.Height); } renderer.DrawBackground(e.Graphics, rect); } } else { base.OnRenderImageMargin(e); } }
public static Size GetGlyphSize(Graphics g, RadioButtonState state) { if (RenderWithVisualStyles) { InitializeRenderer((int)state); return(visualStyleRenderer.GetPartSize(g, ThemeSizeType.Draw)); } return(new Size(13, 13)); }
protected override Size GetExpanderSize(Graphics graphics, KTreeNode node) { // Get glyph size if needed if (!_glyphSize.HasValue) { _glyphSize = _treeViewGlyphOpened.GetPartSize(graphics, ThemeSizeType.True); } return(_glyphSize.Value); }
public static Rectangle GetCloseButtonRect(IDeviceContext dc, Rectangle rect, Padding padding, ToolTipBalloonCloseButtonState buttonState) { VisualStyleElement btn = GetCloseButtonVS(buttonState); VisualStyleRenderer renderer = new VisualStyleRenderer(btn); Size btnSize = renderer.GetPartSize(dc, ThemeSizeType.True); Point btnPos = new Point(rect.Right - padding.Right - btnSize.Width, rect.Top + padding.Top); Rectangle btnRect = new Rectangle(btnPos, btnSize); return(btnRect); }
private void InitRects(Graphics g) { if (_rectsInitialized) { return; } int totalButtonWidth = _buttonSize.Width * 3; int startX = (((VisualStyleRenderer.IsSupported ? this.Width : this.ClientSize.Width) - totalButtonWidth) / 2); int iconX = (_buttonSize.Width - 16) / 2; int iconY = (_buttonSize.Height - 16) / 2; int buttonY = VisualStyleRenderer.IsSupported ? (this.Height - _buttonSize.Height) : (this.ClientSize.Height - _buttonSize.Height); if (VisualStyleRenderer.IsSupported && _aeroEnabled) { _rectClient = new Rectangle( _dwmMargins.cxLeftWidth, _dwmMargins.cyTopHeight, Width - _dwmMargins.cxRightWidth - _dwmMargins.cxLeftWidth, Height - _dwmMargins.cyBottomHeight - _dwmMargins.cyTopHeight ); } else { _rectClient = this.ClientRectangle; } _Panel.Top = _rectClient.Top; _Panel.Left = _rectClient.Left; _rectPrev = new Rectangle(startX, buttonY, _buttonSize.Width, _buttonSize.Height); startX += _buttonSize.Width; _rectInbox = new Rectangle(startX, buttonY, _buttonSize.Width, _buttonSize.Height); startX += _buttonSize.Width; _rectNext = new Rectangle(startX, buttonY, _buttonSize.Width, _buttonSize.Height); Size closeSize; if (VisualStyleRenderer.IsSupported) { VisualStyleRenderer renderer = new VisualStyleRenderer(_elementClose); closeSize = renderer.GetPartSize(g, ThemeSizeType.True); } else { closeSize = new Size(16, 14); } _rectClose = new Rectangle(Width - _dwmMargins.cxLeftWidth - closeSize.Width, 8, closeSize.Width, closeSize.Height); }
protected override void OnPaint(PaintEventArgs e) { if (VisualStyleRenderer.IsSupported && VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Normal) && VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Hot) && VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Pressed)) { VisualStyleElement element; if (!this.ShowGreyed && IsMouseOver(this.ClientRectangle)) { element = IsLeftMouseButtonPressed() ? VisualStyleElement.ExplorerBar.HeaderClose.Pressed : VisualStyleElement.ExplorerBar.HeaderClose.Hot; } else { element = VisualStyleElement.ExplorerBar.HeaderClose.Normal; } VisualStyleRenderer renderer = new VisualStyleRenderer(element); Size size = renderer.GetPartSize(e.Graphics, this.ClientRectangle, ThemeSizeType.True); using (Bitmap bmp = new Bitmap(size.Width, size.Height)) { using (Graphics g = Graphics.FromImage(bmp)) { renderer.DrawBackground(g, this.ClientRectangle); } e.Graphics.DrawImage(bmp, this.ClientRectangle); } } else { const int lineWidth = 2; if (this.ShowGreyed) { ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Inactive); } else if (IsMouseOver(this.ClientRectangle) && IsLeftMouseButtonPressed()) { ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Pushed); } else { ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Normal); } using (Pen p = new Pen(this.ShowGreyed ? SystemBrushes.GrayText : SystemBrushes.ControlText, lineWidth)) { Rectangle crossBounds = this.ClientRectangle; crossBounds.Location += new Size(2 * lineWidth, 2 * lineWidth); crossBounds.Size -= new Size(4 * lineWidth + 1, 4 * lineWidth + 1); e.Graphics.DrawLine(p, crossBounds.Left, crossBounds.Top, crossBounds.Right, crossBounds.Bottom); e.Graphics.DrawLine(p, crossBounds.Left, crossBounds.Bottom, crossBounds.Right, crossBounds.Top); } } }
// <Snippet10> // Get the sizes and offsets for the window parts as specified // by the visual style. private void GetPartDetails() { // Do nothing further if visual styles are not enabled. if (!Application.RenderWithVisualStyles) { return; } using (Graphics g = this.CreateGraphics()) { // Get the size and offset of the close button. if (SetRenderer(windowElements["windowClose"])) { closeButtonSize = renderer.GetPartSize(g, ThemeSizeType.True); closeButtonOffset = renderer.GetPoint(PointProperty.Offset); } // Get the height of the window caption. if (SetRenderer(windowElements["windowCaption"])) { captionHeight = renderer.GetPartSize(g, ThemeSizeType.True).Height; } // Get the thickness of the left, bottom, // and right window frame. if (SetRenderer(windowElements["windowLeft"])) { frameThickness = renderer.GetPartSize(g, ThemeSizeType.True).Width; } // Get the size of the resizing gripper. if (SetRenderer(windowElements["statusGripper"])) { gripperSize = renderer.GetPartSize(g, ThemeSizeType.True); } } }
public static Size GetGlyphSize(Graphics g, RadioButtonState state) { if (!VisualStyleRenderer.IsSupported) { return(new Size(13, 13)); } VisualStyleRenderer vsr = GetRadioButtonRenderer(state); return(vsr.GetPartSize(g, ThemeSizeType.Draw)); }
public static Size GetSizeBoxSize(Graphics g, ScrollBarState state) { if (!IsSupported) { throw new InvalidOperationException(); } VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ScrollBar.SizeBox.LeftAlign); return(vsr.GetPartSize(g, ThemeSizeType.Draw)); }
internal static Size GetGlyphSize(Graphics g, CheckBoxState state, IntPtr hWnd) { if (RenderWithVisualStyles) { InitializeRenderer((int)state); return(visualStyleRenderer.GetPartSize(g, ThemeSizeType.Draw, hWnd)); } return(new Size(13, 13)); }
public static Size_ GetGlyphSize(Graphics g, CheckBoxState state) { if (!VisualStyleRenderer.IsSupported) { return(new Size_(13, 13)); } VisualStyleRenderer vsr = GetCheckBoxRenderer(state); return(vsr.GetPartSize(g, ThemeSizeType.Draw)); }
internal static Size GetGlyphSize(Gdi32.HDC hdc, CheckBoxState state, IntPtr hwnd) { if (RenderWithVisualStyles) { InitializeRenderer((int)state); return(t_visualStyleRenderer.GetPartSize(hdc, ThemeSizeType.Draw, hwnd)); } return(new Size(13, 13)); }
public static Size GetThumbGripSize(Graphics g, ScrollBarState state) { if (!IsSupported) { throw new InvalidOperationException(); } VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ScrollBar.GripperVertical.Normal); return(vsr.GetPartSize(g, ThemeSizeType.Draw)); }
public override void Layout(GraphicsSettings settings, Size maximumSize) { int width = 0; int height = 0; SyncSectionsToColumns(HeaderColumnSection.DisplayMode.Header); Point pt = new Point(Location.X, Location.Y); int reservedSpace = LayoutController == null ? 0 : LayoutController.ReservedNearSpace; bool first = true; foreach (Section hcs in Children) { hcs.Location = pt; hcs.Layout(settings, new Size(maximumSize.Width - pt.X, _isVisible ? maximumSize.Height - pt.Y : 0)); if (first) { hcs.Size = new Size(hcs.Size.Width + reservedSpace, hcs.Size.Height); first = false; } pt = new Point(hcs.Rectangle.Right, pt.Y); width += hcs.Rectangle.Width; if (hcs.Size.Height > height) { height = hcs.Size.Height; } } if (height == 0 && _isVisible) { if (VisualStyleRenderer.IsSupported) { VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal); height = renderer.GetPartSize(settings.Graphics, ThemeSizeType.True).Height; } else { height = SystemFonts.DialogFont.Height + 6; } } _idealWidth = width; if (height < MinimumHeight) { height = MinimumHeight; } Size = new Size(Math.Max(maximumSize.Width, _idealWidth), height); if (LayoutController != null) { LayoutController.HeaderLayedOut(); } }
protected override SizeF OnMeasureContent(MeasureHelper measure, SizeF maxSize) { if (SortStyle != HeaderSortStyle.None && Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetSortElement())) { VisualStyleRenderer renderer = GetRenderer(GetSortElement()); return(renderer.GetPartSize(measure.Graphics, ThemeSizeType.Draw)); } else { return(base.OnMeasureContent(measure, maxSize)); } }
// Set the element to draw. void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { // Clear the element description. elementDescription.Remove(0, elementDescription.Length); // If the user clicked a first-level node, disable drawing. if (e.Node.Nodes.Count > 0) { drawElement = false; elementDescription.Append("No element is selected"); domainUpDown1.Enabled = false; } // The user clicked an element node. else { // Add the element name to the description. elementDescription.Append(e.Node.Text); // Get the element that corresponds to the selected // node's name. String key = e.Node.Name; element = elementDictionary[key]; // Disable resizing if the element is not defined. if (!VisualStyleRenderer.IsElementDefined(element)) { drawElement = false; elementDescription.Append(" is not defined."); domainUpDown1.Enabled = false; } else { // Set the element to the renderer. drawElement = true; renderer.SetParameters(element); elementDescription.Append(" is defined."); // Get the system-defined size of the element. Graphics g = this.CreateGraphics(); currentTrueSize = renderer.GetPartSize(g, ThemeSizeType.True); g.Dispose(); displayRect.Size = currentTrueSize; domainUpDown1.Enabled = true; domainUpDown1.SelectedIndex = 2; } } Invalidate(); }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { Rectangle bounds; if (colorTable.PopupForeColor != ToolStripSystemColorTable.DefaultPopupForeColor) { bounds = new Rectangle(Point.Empty, e.Item.Size); //We should probably use the PopupBorderColor for the separator, but in the specific //context of the dark skin, that color is not contrasty enough, so to keep things simple, //we just blend the fore color and the back color. DrawClassicSeparatorInternal( e.Graphics, Core.Utilities.ColorUtils.BlendColors(colorTable.PopupForeColor, 1, colorTable.PopupBackColor, 3), bounds); } else if (ToolStripManager.VisualStylesEnabled) { VisualStyleElement vsElement = VisualStyleElement.CreateElement(vsClass, 15, 0); if (VisualStyleRenderer.IsElementDefined(vsElement)) { VisualStyleRenderer vsRenderer = GetVisualStyleRenderer(vsElement); int partHeight = vsRenderer.GetPartSize(e.Graphics, ThemeSizeType.True).Height; int y = (e.Item.Height - partHeight) / 2; //Vertical center bounds = new Rectangle(0, y, e.Item.Width, partHeight); //here, the rect is full width, and we shrink it when we check for RightToLeft. ToolStripDropDownMenu dropDownMenu = e.Item.GetCurrentParent() as ToolStripDropDownMenu; if (dropDownMenu != null) { if (dropDownMenu.RightToLeft == RightToLeft.No) { bounds.X += dropDownMenu.ImageScalingSize.Width + 6; bounds.Width = dropDownMenu.Width - bounds.X; } else { bounds.X -= 6; bounds.Width = dropDownMenu.Width - bounds.X - dropDownMenu.ImageScalingSize.Width; } } vsRenderer.DrawBackground(e.Graphics, bounds); } else { base.OnRenderSeparator(e); } } else { base.OnRenderSeparator(e); } }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { Color tableColor; Color defaultColor; if (e.Item.Enabled) { if (e.Item.Selected) { tableColor = colorTable.HighlightForeColor; defaultColor = ToolStripSystemColorTable.DefaultHighlightForeColor; } else { tableColor = colorTable.HighlightForeColor; defaultColor = ToolStripSystemColorTable.DefaultHighlightForeColor; } } else { tableColor = colorTable.DisabledForeColor; defaultColor = ToolStripSystemColorTable.DefaultDisabledForeColor; } if (tableColor != defaultColor) { ControlPaint.DrawMenuGlyph(e.Graphics, e.ArrowRectangle, MenuGlyph.Arrow, tableColor, Color.Transparent); } else if (ToolStripManager.VisualStylesEnabled) { VisualStyleElement vsElement = GetMenuGlyphVSElement(MenuGlyph.Arrow, e.Item.Enabled); if (VisualStyleRenderer.IsElementDefined(vsElement)) { VisualStyleRenderer vsRenderer = GetVisualStyleRenderer(vsElement); //Creates the appropriate rectangle for the arrow (e.ArrowRectangle is too big!) Rectangle arrowRect = new Rectangle(e.ArrowRectangle.Location, vsRenderer.GetPartSize(e.Graphics, ThemeSizeType.True)); //Centers the rectangle vertically arrowRect.Y = e.ArrowRectangle.Y + (e.ArrowRectangle.Height - arrowRect.Height) / 2 + 1; //+1 is just a quick empirical adjustement. vsRenderer.DrawBackground(e.Graphics, arrowRect); } else { base.OnRenderArrow(e); } } else { base.OnRenderArrow(e); } }
public Size?GetPartSize(Graphics graphics, StateTypeId state) { VisualStyleRenderer renderer = GetRenderer(state); if (renderer == null) { return(null); } Size size = renderer.GetPartSize(graphics, ThemeSizeType.True); return(size.AddHorizontally(_paddingLeft?.GetPartSize(graphics, state), _paddingRight?.GetPartSize(graphics, state))); }
private void measureButtonWidth() { if (!Application.RenderWithVisualStyles) { buttonWidth = 21; // TODO: measure } else { var renderer = new VisualStyleRenderer("DATEPICKER", 3, 1); using (var gr = CreateGraphics()) { buttonWidth = renderer.GetPartSize(gr, ThemeSizeType.True).Height; } } }
protected override Size GetCloseButtonSize(Graphics dc, TooltipCloseButtonState buttonState) { VisualStyleElement btn = GetCloseButtonVS(buttonState); if (IsDefined(btn)) { VisualStyleRenderer renderer = new VisualStyleRenderer(btn); return(renderer.GetPartSize(dc, ThemeSizeType.True)); } else { return(new Size(10, 10)); } }
/// ------------------------------------------------------------------------------------ protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); if (!Application.RenderWithVisualStyles) { return; } var renderer = new VisualStyleRenderer(VisualStyleElement.Button.CheckBox.UncheckedNormal); _glyphColor = renderer.GetColor(ColorProperty.BorderColor); using (var g = CreateGraphics()) _chkBoxSize = renderer.GetPartSize(g, ThemeSizeType.Draw); }