本文整理汇总了C#中System.Windows.Forms.VisualStyles.VisualStyleRenderer.GetPartSize方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStyleRenderer.GetPartSize方法的具体用法?C# VisualStyleRenderer.GetPartSize怎么用?C# VisualStyleRenderer.GetPartSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.VisualStyles.VisualStyleRenderer
的用法示例。
在下文中一共展示了VisualStyleRenderer.GetPartSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBoxColumnHeaderHandler
/// ------------------------------------------------------------------------------------
/// <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;
}
示例2: CheckBoxColumnHeaderHandler
/// ------------------------------------------------------------------------------------
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);
}
}
示例3: SearchBox
public SearchBox()
: base()
{
this.TextChanged += this.SearchBox_TextChanged;
this.Resize += this.SearchBox_Resize;
this.Paint += this.SearchBox_Paint;
this.HandleCreated += this.SearchBox_HandleCreated;
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
// Create the child textbox control for the user to type in, without a border
this.textBox = new TextBox();
this.themeHeight = this.textBox.Height + 2;
this.textBox.BorderStyle = BorderStyle.None;
this.Controls.Add(this.textBox);
this.textBox.MouseEnter += this.TextBox_MouseEnter;
this.textBox.MouseLeave += this.TextBox_MouseLeave;
this.textBox.GotFocus += this.TextBox_GotFocus;
this.textBox.LostFocus += this.TextBox_LostFocus;
this.textBox.TextChanged += this.TextBox_TextChanged;
this.textBox.KeyDown += this.TextBox_KeyDown;
// Create a picturebox to display the search icon and cancel 'button'
this.button = new PictureBox();
this.button.BackColor = Color.Transparent;
this.button.Image = Properties.Resources.search_icon;
this.button.SizeMode = PictureBoxSizeMode.AutoSize;
this.Controls.Add(this.button);
this.button.MouseEnter += this.Button_MouseEnter;
this.button.MouseLeave += this.Button_MouseLeave;
this.button.MouseDown += this.Button_MouseDown;
this.button.MouseUp += this.Button_MouseUp;
this.button.MouseClick += this.Button_MouseClick;
// Work out the height that the search box should be displayed
if (OsUtils.WinVistaOrLater() && VisualStyleRenderer.IsSupported)
{
VisualStyleRenderer sizeStyle = new VisualStyleRenderer(NativeMethods.SEARCHBOX, NativeMethods.SBBACKGROUND, NativeMethods.SBB_NORMAL);
using (Graphics sizeGraphics = this.CreateGraphics())
{
this.themeHeight = sizeStyle.GetPartSize(sizeGraphics, ThemeSizeType.True).Height;
}
}
}
示例4: DrawButton
/// ------------------------------------------------------------------------------------
/// <summary>
/// Draws the button in the cell.
/// </summary>
/// ------------------------------------------------------------------------------------
private void DrawButton(Graphics g, Rectangle rcbtn, int rowIndex)
{
if (!InternalShowButton(rowIndex))
return;
bool paintComboButton = (OwningButtonColumn == null ? false :
OwningButtonColumn.UseComboButtonStyle);
VisualStyleElement element = (paintComboButton ?
GetVisualStyleComboButton() : GetVisualStylePushButton());
if (PaintingHelper.CanPaintVisualStyle(element))
{
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
if (!OwningButtonColumn.DrawDefaultComboButtonWidth)
renderer.DrawBackground(g, rcbtn);
else
{
Rectangle rc = rcbtn;
Size sz = renderer.GetPartSize(g, rc, ThemeSizeType.True);
rc.Width = sz.Width + 2;
rc.X = (rcbtn.Right - rc.Width);
renderer.DrawBackground(g, rc);
}
}
else
{
ButtonState state = (m_mouseDownOnButton && m_mouseOverButton && m_enabled ?
ButtonState.Pushed : ButtonState.Normal);
if (!m_enabled)
state |= ButtonState.Inactive;
if (paintComboButton)
ControlPaint.DrawComboButton(g, rcbtn, state);
else
ControlPaint.DrawButton(g, rcbtn, state);
}
string buttonText = (OwningButtonColumn == null ? null : OwningButtonColumn.ButtonText);
if (string.IsNullOrEmpty(buttonText))
return;
Font buttonFont = (OwningButtonColumn == null ?
SystemInformation.MenuFont : OwningButtonColumn.ButtonFont);
// Draw text
TextFormatFlags flags = TextFormatFlags.HorizontalCenter |
TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine |
TextFormatFlags.NoPrefix | TextFormatFlags.EndEllipsis |
TextFormatFlags.NoPadding | TextFormatFlags.PreserveGraphicsClipping;
Color clrText = (m_enabled ? SystemColors.ControlText : SystemColors.GrayText);
TextRenderer.DrawText(g, buttonText, buttonFont, rcbtn, clrText, flags);
}
示例5: SetLayout
private void SetLayout()
{
if (isMin6 && Application.RenderWithVisualStyles)
{
VisualStyleRenderer theme;
using (Graphics g = this.CreateGraphics())
{
// Back button
theme = new VisualStyleRenderer(VisualStyleElementEx.Navigation.BackButton.Normal);
Size bbSize = theme.GetPartSize(g, ThemeSizeType.Draw);
// Title
theme.SetParameters(VisualStyleElementEx.AeroWizard.TitleBar.Active);
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.Margin = theme.GetMargins2(g, MarginProperty.ContentMargins);
headerLabel.ForeColor = theme.GetColor(ColorProperty.TextColor);
// Content
theme.SetParameters(VisualStyleElementEx.AeroWizard.ContentArea.Normal);
this.BackColor = theme.GetColor(ColorProperty.FillColor);
Padding 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[2].Width = contentArea.ColumnStyles[2].Width = cp.Right;
}
}
else
{
backButton.Size = new Size(Properties.Resources.BackBtnStrip.Width, Properties.Resources.BackBtnStrip.Height / 4);
}
}
示例6: DrawGlyph
private void DrawGlyph( Graphics g, Point p, bool expanded )
{
if( VisualStyleRenderer.IsSupported )
{
VisualStyleElement vse = expanded ? VisualStyleElement.TreeView.Glyph.Opened : VisualStyleElement.TreeView.Glyph.Closed;
VisualStyleRenderer vsr = new VisualStyleRenderer( vse );
Size ecSize = vsr.GetPartSize( g, ThemeSizeType.Draw );
vsr.DrawBackground( g, new Rectangle( p.X, p.Y, ecSize.Width, ecSize.Height ) );
}
else
{
g.FillRectangle( SystemBrushes.Window, new Rectangle( p.X, p.Y, 8, 8 ) );
using( Pen pen = new Pen( Color.FromArgb( 128, 128, 128 ) ))
{
g.DrawRectangle( pen, new Rectangle( p.X, p.Y, 8, 8 ) );
}
using( Pen pen = new Pen( Color.Black ) )
{
g.DrawLine( pen, new Point( p.X + 2, p.Y + 4 ), new Point( p.X + 6, p.Y + 4 ) );
if( !expanded )
{
g.DrawLine( pen, new Point( p.X + 4, p.Y + 2 ), new Point( p.X + 4, p.Y + 6 ) );
}
}
}
}
示例7: GetSizeBoxSize
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);
}
示例8: DrawStatusBarSizingGrip
protected override void DrawStatusBarSizingGrip (Graphics dc, Rectangle clip, StatusBar sb, Rectangle area)
{
if (!RenderClientAreas) {
base.DrawStatusBarSizingGrip (dc, clip, sb, area);
return;
}
VisualStyleElement element = VisualStyleElement.Status.Gripper.Normal;
if (!VisualStyleRenderer.IsElementDefined (element)) {
base.DrawStatusBarSizingGrip (dc, clip, sb, area);
return;
}
VisualStyleRenderer renderer = new VisualStyleRenderer (element);
Rectangle sizing_grip_rectangle = new Rectangle (Point.Empty, renderer.GetPartSize (dc, ThemeSizeType.True));
sizing_grip_rectangle.X = sb.Width - sizing_grip_rectangle.Width;
sizing_grip_rectangle.Y = sb.Height - sizing_grip_rectangle.Height;
renderer.DrawBackground (dc, sizing_grip_rectangle, clip);
}
示例9: GetCloseButtonSize
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);
}
示例10: OnPaint
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);
}
}
}
示例11: GetCloseButtonRect
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;
}
示例12: OnRenderImageMargin
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);
}
}
示例13: MeasureTreeNode
public Size MeasureTreeNode( Graphics g, SuperTree.ITreeInfo treeInfo, SuperTree.TreeNode treeNode, bool needsWidth, bool needsHeight )
{
string text = treeNode.Text.Replace( "&", "&&" );
Size textSize = WinFormsUtility.Drawing.GdiPlusEx.MeasureString( g, text, treeNode.Font, int.MaxValue );
Size ecSize;
if( VisualStyleRenderer.IsSupported )
{
VisualStyleElement vse = VisualStyleElement.TreeView.Glyph.Opened;
VisualStyleRenderer vsr = new VisualStyleRenderer( vse );
ecSize = vsr.GetPartSize( g, ThemeSizeType.Draw );
}
else
{
ecSize = new Size( 9, 9 );
}
int width = (int) textSize.Width + _leftSep + _ecSep + ecSize.Width + _rightSep + 16;
int height = (int) textSize.Height;
if( treeNode.Icon != null )
{
width += _imageSep + treeNode.Icon.Size.Width;
height = Math.Max( height, treeNode.Icon.Size.Height );
}
height += _verticalSep;
return new Size( width, height );
}
示例14: CalcSize
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); //���̃T�C�Y�ł͐ݒ�ɂ���Ă̓_������
_markSizeLeftRight = new Size(16, 16);
}
}
示例15: GetTopPointingThumbSize
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);
}