Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / FlatButtonAppearance.cs / 1305376 / FlatButtonAppearance.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Drawing; using System.Globalization; using System.ComponentModel; using System.Windows.Forms.Layout; ////// /// [TypeConverter(typeof(FlatButtonAppearanceConverter))] public class FlatButtonAppearance { private ButtonBase owner; private int borderSize = 1; private Color borderColor = Color.Empty; private Color checkedBackColor = Color.Empty; private Color mouseDownBackColor = Color.Empty; private Color mouseOverBackColor = Color.Empty; internal FlatButtonAppearance(ButtonBase owner) { this.owner = owner; } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the size, in pixels of the border around the button. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonBorderSizeDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(1), ] public int BorderSize { get { return borderSize; } set { if (value < 0) throw new ArgumentOutOfRangeException("BorderSize", value, SR.GetString(SR.InvalidLowBoundArgumentEx, "BorderSize", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture))); if (borderSize != value) { borderSize = value; if (owner != null && owner.ParentInternal != null) { LayoutTransaction.DoLayoutIf(owner.AutoSize, owner.ParentInternal, owner, PropertyNames.FlatAppearanceBorderSize); } owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the border around the button. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonBorderColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color BorderColor { get { return borderColor; } set { if (value.Equals(Color.Transparent)) { throw new NotSupportedException(SR.GetString(SR.ButtonFlatAppearanceInvalidBorderColor)); } if (borderColor != value) { borderColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the button state is checked and the mouse cursor is NOT within the bounds of the control. /// [ Browsable(true), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonCheckedBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color CheckedBackColor { get { return checkedBackColor; } set { if (checkedBackColor != value) { checkedBackColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the mouse cursor is within the bounds of the control and the left button is pressed. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonMouseDownBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color MouseDownBackColor { get { return mouseDownBackColor; } set { if (mouseDownBackColor != value) { mouseDownBackColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client /// area of the button when the mouse cursor is within the bounds of the control. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonMouseOverBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color MouseOverBackColor { get { return mouseOverBackColor; } set { if (mouseOverBackColor != value) { mouseOverBackColor = value; owner.Invalidate(); } } } } internal sealed class ApplicableToButtonAttribute : Attribute { public ApplicableToButtonAttribute() { } } internal class FlatButtonAppearanceConverter : ExpandableObjectConverter { // Don't let the property grid display the full type name in the value cell public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { return ""; } return base.ConvertTo(context, culture, value, destinationType); } // Don't let the property grid display the CheckedBackColor property for Button controls public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (context != null && context.Instance is Button) { Attribute[] attributes2 = new Attribute[attributes.Length + 1]; attributes.CopyTo(attributes2, 0); attributes2[attributes.Length] = new ApplicableToButtonAttribute(); attributes = attributes2; } return TypeDescriptor.GetProperties(value, attributes); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms { using System; using System.Drawing; using System.Globalization; using System.ComponentModel; using System.Windows.Forms.Layout; ////// /// [TypeConverter(typeof(FlatButtonAppearanceConverter))] public class FlatButtonAppearance { private ButtonBase owner; private int borderSize = 1; private Color borderColor = Color.Empty; private Color checkedBackColor = Color.Empty; private Color mouseDownBackColor = Color.Empty; private Color mouseOverBackColor = Color.Empty; internal FlatButtonAppearance(ButtonBase owner) { this.owner = owner; } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the size, in pixels of the border around the button. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonBorderSizeDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(1), ] public int BorderSize { get { return borderSize; } set { if (value < 0) throw new ArgumentOutOfRangeException("BorderSize", value, SR.GetString(SR.InvalidLowBoundArgumentEx, "BorderSize", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture))); if (borderSize != value) { borderSize = value; if (owner != null && owner.ParentInternal != null) { LayoutTransaction.DoLayoutIf(owner.AutoSize, owner.ParentInternal, owner, PropertyNames.FlatAppearanceBorderSize); } owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the border around the button. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonBorderColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color BorderColor { get { return borderColor; } set { if (value.Equals(Color.Transparent)) { throw new NotSupportedException(SR.GetString(SR.ButtonFlatAppearanceInvalidBorderColor)); } if (borderColor != value) { borderColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the button state is checked and the mouse cursor is NOT within the bounds of the control. /// [ Browsable(true), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonCheckedBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color CheckedBackColor { get { return checkedBackColor; } set { if (checkedBackColor != value) { checkedBackColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client area /// of the button when the mouse cursor is within the bounds of the control and the left button is pressed. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonMouseDownBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color MouseDownBackColor { get { return mouseDownBackColor; } set { if (mouseDownBackColor != value) { mouseDownBackColor = value; owner.Invalidate(); } } } ////// /// For buttons whose FlatStyle is FlatStyle.Flat, this property specifies the color of the client /// area of the button when the mouse cursor is within the bounds of the control. /// [ Browsable(true), ApplicableToButton(), NotifyParentProperty(true), SRCategory(SR.CatAppearance), SRDescription(SR.ButtonMouseOverBackColorDescr), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(typeof(Color), ""), ] public Color MouseOverBackColor { get { return mouseOverBackColor; } set { if (mouseOverBackColor != value) { mouseOverBackColor = value; owner.Invalidate(); } } } } internal sealed class ApplicableToButtonAttribute : Attribute { public ApplicableToButtonAttribute() { } } internal class FlatButtonAppearanceConverter : ExpandableObjectConverter { // Don't let the property grid display the full type name in the value cell public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { return ""; } return base.ConvertTo(context, culture, value, destinationType); } // Don't let the property grid display the CheckedBackColor property for Button controls public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (context != null && context.Instance is Button) { Attribute[] attributes2 = new Attribute[attributes.Length + 1]; attributes.CopyTo(attributes2, 0); attributes2[attributes.Length] = new ApplicableToButtonAttribute(); attributes = attributes2; } return TypeDescriptor.GetProperties(value, attributes); } } } // 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
- DbQueryCommandTree.cs
- WorkflowServiceInstance.cs
- OracleMonthSpan.cs
- ObjectResult.cs
- SessionConnectionReader.cs
- SecurityKeyIdentifier.cs
- VBCodeProvider.cs
- WS2007FederationHttpBindingElement.cs
- Pointer.cs
- ISFTagAndGuidCache.cs
- LinqDataSourceInsertEventArgs.cs
- DtrList.cs
- FloaterBaseParagraph.cs
- Point3DKeyFrameCollection.cs
- SupportingTokenProviderSpecification.cs
- RichTextBoxAutomationPeer.cs
- SystemIPInterfaceStatistics.cs
- COSERVERINFO.cs
- DesignBindingConverter.cs
- XmlSchemaInferenceException.cs
- BordersPage.cs
- JavaScriptSerializer.cs
- DataGridRelationshipRow.cs
- PageWrapper.cs
- PartitionerStatic.cs
- WebPartTransformerAttribute.cs
- EntityKey.cs
- SoapInteropTypes.cs
- COM2IDispatchConverter.cs
- OverflowException.cs
- ToolStripItemClickedEventArgs.cs
- WebConfigurationHost.cs
- KeyInfo.cs
- Transactions.cs
- EraserBehavior.cs
- ListControl.cs
- ProfessionalColors.cs
- DbUpdateCommandTree.cs
- DirectoryGroupQuery.cs
- PointCollectionValueSerializer.cs
- ProgressBarHighlightConverter.cs
- HierarchicalDataSourceControl.cs
- WasHostedComPlusFactory.cs
- WebBrowserNavigatingEventHandler.cs
- SoapObjectInfo.cs
- PreProcessor.cs
- AnnotationHighlightLayer.cs
- ContentDisposition.cs
- WebPartConnectionsCloseVerb.cs
- RequestContext.cs
- DataControlField.cs
- XomlCompilerError.cs
- SoapAttributes.cs
- XmlElementAttribute.cs
- Dispatcher.cs
- Signature.cs
- SQLString.cs
- LinkedList.cs
- TransformerTypeCollection.cs
- DataTrigger.cs
- NotifyParentPropertyAttribute.cs
- ProtocolsConfiguration.cs
- ContractReference.cs
- DemultiplexingDispatchMessageFormatter.cs
- XamlTypeWithExplicitNamespace.cs
- HMACSHA512.cs
- RegexTree.cs
- AsyncInvokeContext.cs
- ChannelManager.cs
- RadioButtonPopupAdapter.cs
- AssemblyCache.cs
- MultiAsyncResult.cs
- SqlProviderServices.cs
- EncoderReplacementFallback.cs
- ColorContextHelper.cs
- CharStorage.cs
- TTSEngineProxy.cs
- RuleInfoComparer.cs
- StringInfo.cs
- BreakRecordTable.cs
- SchemaCollectionCompiler.cs
- XmlTypeMapping.cs
- EntityDesignerUtils.cs
- TypeUtil.cs
- Assert.cs
- HashSet.cs
- Mutex.cs
- DeclarativeCatalogPart.cs
- SmiMetaDataProperty.cs
- Size3D.cs
- GenerateTemporaryAssemblyTask.cs
- SafeRegistryKey.cs
- BindingFormattingDialog.cs
- XmlNamespaceMapping.cs
- DbConnectionStringBuilder.cs
- ToolStripScrollButton.cs
- LogEntrySerializationException.cs
- TransportSecurityBindingElement.cs
- ChannelSinkStacks.cs
- ObjectView.cs