Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / PropertyGridInternal / DropDownButton.cs / 1305376 / DropDownButton.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.PropertyGridInternal { using System.Diagnostics; using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; using System.Windows.Forms.ButtonInternal; using Microsoft.Win32; internal sealed class DropDownButton : Button { private bool useComboBoxTheme = false; private bool ignoreMouse; public DropDownButton() { SetStyle(ControlStyles.Selectable, true); this.AccessibleName = SR.GetString(SR.PropertyGridDropDownButtonAccessibleName); } // VSWhidbey 375220 - when the holder is open, we don't fire clicks // public bool IgnoreMouse { get { return ignoreMouse; } set { ignoreMouse = value; } } public bool UseComboBoxTheme { set { if (useComboBoxTheme != value) { useComboBoxTheme = value; Invalidate(); } } } protected override void OnClick(EventArgs e) { if (!IgnoreMouse) { base.OnClick(e); } } protected override void OnMouseUp(MouseEventArgs e) { if (!IgnoreMouse) { base.OnMouseUp(e); } } protected override void OnMouseDown(MouseEventArgs e) { if (!IgnoreMouse) { base.OnMouseDown(e); } } protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); if (Application.RenderWithVisualStyles & useComboBoxTheme) { ComboBoxState cbState = ComboBoxState.Normal; if (base.MouseIsDown) { cbState = ComboBoxState.Pressed; } else if (base.MouseIsOver) { cbState = ComboBoxState.Hot; } Rectangle dropDownButtonRect = new Rectangle(0, 0, Width, Height); if (cbState == ComboBoxState.Normal) { pevent.Graphics.FillRectangle(SystemBrushes.Window, dropDownButtonRect); } ComboBoxRenderer.DrawDropDownButton(pevent.Graphics, dropDownButtonRect, cbState); } } internal override ButtonBaseAdapter CreateStandardAdapter() { return new DropDownButtonAdapter(this); } } internal class DropDownButtonAdapter : ButtonStandardAdapter { internal DropDownButtonAdapter(ButtonBase control) : base(control) {} private void DDB_Draw3DBorder(System.Drawing.Graphics g, Rectangle r, bool raised) { if (Control.BackColor != SystemColors.Control && SystemInformation.HighContrast) { if (raised) { Color c = ControlPaint.LightLight(Control.BackColor); ControlPaint.DrawBorder(g, r, c, 1, ButtonBorderStyle.Outset, c, 1, ButtonBorderStyle.Outset, c, 2, ButtonBorderStyle.Inset, c, 2, ButtonBorderStyle.Inset); } else { ControlPaint.DrawBorder(g, r, ControlPaint.Dark(Control.BackColor), ButtonBorderStyle.Solid); } } else { if (raised) { Color c = ControlPaint.Light(Control.BackColor); ControlPaint.DrawBorder(g, r, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.Solid, Control.BackColor, 2, ButtonBorderStyle.Outset, Control.BackColor, 2, ButtonBorderStyle.Outset); Rectangle inside = r; inside.Offset(1,1); inside.Width -= 3; inside.Height -= 3; c = ControlPaint.LightLight(Control.BackColor); ControlPaint.DrawBorder(g, inside, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.None, c, 1, ButtonBorderStyle.None); } else { ControlPaint.DrawBorder(g, r, ControlPaint.Dark(Control.BackColor), ButtonBorderStyle.Solid); } } } internal override void PaintUp(PaintEventArgs pevent, CheckState state) { base.PaintUp(pevent, state); if (!Application.RenderWithVisualStyles) { DDB_Draw3DBorder(pevent.Graphics, Control.ClientRectangle, true); } else { Color c = SystemColors.Window; Rectangle rect = Control.ClientRectangle; rect.Inflate(0, -1); ControlPaint.DrawBorder(pevent.Graphics, rect, c, 1, ButtonBorderStyle.None, c, 1, ButtonBorderStyle.None, c, 1, ButtonBorderStyle.Solid, c, 1, ButtonBorderStyle.None); } } internal override void DrawImageCore(Graphics graphics, Image image, Rectangle imageBounds, Point imageStart, ButtonBaseAdapter.LayoutData layout) { ControlPaint.DrawImageReplaceColor(graphics, image, imageBounds, Color.Black, Control.ForeColor); //ControlPaint.DrawImageColorized(graphics, image, imageBounds , Control.ForeColor); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IndexedGlyphRun.cs
- HtmlMeta.cs
- ConfigXmlElement.cs
- MenuTracker.cs
- StrokeNodeData.cs
- CLSCompliantAttribute.cs
- Header.cs
- UpdateCommand.cs
- StreamGeometry.cs
- Tile.cs
- ScriptServiceAttribute.cs
- OrthographicCamera.cs
- NegatedCellConstant.cs
- StringArrayConverter.cs
- DocumentOrderQuery.cs
- ReflectPropertyDescriptor.cs
- MultiView.cs
- CryptoApi.cs
- ApplicationInfo.cs
- DesignTimeTemplateParser.cs
- ErrorRuntimeConfig.cs
- SchemaCollectionCompiler.cs
- BaseAsyncResult.cs
- ReadOnlyDictionary.cs
- FastEncoderStatics.cs
- followingquery.cs
- MatrixAnimationUsingKeyFrames.cs
- DropDownHolder.cs
- SymmetricAlgorithm.cs
- ExpressionConverter.cs
- ResourceSetExpression.cs
- StronglyTypedResourceBuilder.cs
- StringFormat.cs
- BrowserCapabilitiesCompiler.cs
- DataColumnMapping.cs
- DataGridViewRowPrePaintEventArgs.cs
- DbQueryCommandTree.cs
- XmlNamespaceMappingCollection.cs
- TextTreeTextBlock.cs
- DropDownList.cs
- ConfigXmlWhitespace.cs
- RegexMatch.cs
- WebHttpSecurity.cs
- ThicknessKeyFrameCollection.cs
- Point3D.cs
- CalendarModeChangedEventArgs.cs
- SqlParameter.cs
- SqlNode.cs
- Rfc4050KeyFormatter.cs
- IdentifierService.cs
- InfoCardCryptoHelper.cs
- EntityProviderFactory.cs
- AppDomainProtocolHandler.cs
- DataContractSerializerOperationBehavior.cs
- Error.cs
- VirtualizingStackPanel.cs
- Collection.cs
- cryptoapiTransform.cs
- TextBox.cs
- TraceLog.cs
- MatrixAnimationBase.cs
- PrintControllerWithStatusDialog.cs
- HttpWebResponse.cs
- FocusWithinProperty.cs
- ScopelessEnumAttribute.cs
- TableFieldsEditor.cs
- OracleRowUpdatedEventArgs.cs
- PresentationTraceSources.cs
- CodeArrayIndexerExpression.cs
- X509Certificate2Collection.cs
- ResourcesBuildProvider.cs
- ShapeTypeface.cs
- ServiceEndpointElement.cs
- ArrayExtension.cs
- Win32Interop.cs
- X509CertificateTrustedIssuerElement.cs
- WinCategoryAttribute.cs
- RbTree.cs
- CreateParams.cs
- WebPartConnectionsCancelVerb.cs
- SqlDependency.cs
- QueryOpeningEnumerator.cs
- MarkupCompiler.cs
- ControlUtil.cs
- RestHandler.cs
- PrePostDescendentsWalker.cs
- FacetValues.cs
- CompositeControl.cs
- Cursor.cs
- CollectionChangedEventManager.cs
- ToolStripCustomTypeDescriptor.cs
- SecurityHeaderElementInferenceEngine.cs
- CssStyleCollection.cs
- TreeNodeConverter.cs
- Model3DGroup.cs
- TreeNodeBinding.cs
- XPathDocument.cs
- EventProxy.cs
- KeyNotFoundException.cs
- securitycriticaldata.cs