Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / FontStyle.cs / 1305600 / FontStyle.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: FontStyle structure. // // History: // 01/25/2005 mleonov - Converted FontStyle from enum to a value type and moved it to a separate file. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Diagnostics; namespace System.Windows { ////// FontStyle structure describes the style of a font face, such as Normal, Italic or Oblique. /// [TypeConverter(typeof(FontStyleConverter))] [Localizability(LocalizationCategory.None)] public struct FontStyle : IFormattable { internal FontStyle(int style) { Debug.Assert(0 <= style && style <= 2); _style = style; } ////// Checks whether two font weight objects are equal. /// /// First object to compare. /// Second object to compare. ///Returns true when the font weight values are equal for both objects, /// and false otherwise. public static bool operator ==(FontStyle left, FontStyle right) { return left._style == right._style; } ////// Checks whether two font weight objects are not equal. /// /// First object to compare. /// Second object to compare. ///Returns false when the font weight values are equal for both objects, /// and true otherwise. public static bool operator !=(FontStyle left, FontStyle right) { return !(left == right); } ////// Checks whether the object is equal to another FontStyle object. /// /// FontStyle object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public bool Equals(FontStyle obj) { return this == obj; } ////// Checks whether an object is equal to another character hit object. /// /// FontStyle object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public override bool Equals(object obj) { if (!(obj is FontStyle)) return false; return this == (FontStyle)obj; } ////// Compute hash code for this object. /// ///A 32-bit signed integer hash code. public override int GetHashCode() { return _style; } ////// Creates a string representation of this object based on the current culture. /// ////// A string representation of this object. /// public override string ToString() { // Delegate to the internal method which implements all ToString calls. return ConvertToString(null, null); } ////// Creates a string representation of this object based on the format string /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// ////// A string representation of this object. /// string IFormattable.ToString(string format, IFormatProvider provider) { // Delegate to the internal method which implements all ToString calls. return ConvertToString(format, provider); } ////// This method is used only in type converter for construction via reflection. /// ///THe value of _style member. internal int GetStyleForInternalConstruction() { Debug.Assert(0 <= _style && _style <= 2); return _style; } ////// Creates a string representation of this object based on the format string /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// ////// A string representation of this object. /// private string ConvertToString(string format, IFormatProvider provider) { if (_style == 0) return "Normal"; if (_style == 1) return "Oblique"; Debug.Assert(_style == 2); return "Italic"; } private int _style; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // Description: FontStyle structure. // // History: // 01/25/2005 mleonov - Converted FontStyle from enum to a value type and moved it to a separate file. // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Diagnostics; namespace System.Windows { ////// FontStyle structure describes the style of a font face, such as Normal, Italic or Oblique. /// [TypeConverter(typeof(FontStyleConverter))] [Localizability(LocalizationCategory.None)] public struct FontStyle : IFormattable { internal FontStyle(int style) { Debug.Assert(0 <= style && style <= 2); _style = style; } ////// Checks whether two font weight objects are equal. /// /// First object to compare. /// Second object to compare. ///Returns true when the font weight values are equal for both objects, /// and false otherwise. public static bool operator ==(FontStyle left, FontStyle right) { return left._style == right._style; } ////// Checks whether two font weight objects are not equal. /// /// First object to compare. /// Second object to compare. ///Returns false when the font weight values are equal for both objects, /// and true otherwise. public static bool operator !=(FontStyle left, FontStyle right) { return !(left == right); } ////// Checks whether the object is equal to another FontStyle object. /// /// FontStyle object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public bool Equals(FontStyle obj) { return this == obj; } ////// Checks whether an object is equal to another character hit object. /// /// FontStyle object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public override bool Equals(object obj) { if (!(obj is FontStyle)) return false; return this == (FontStyle)obj; } ////// Compute hash code for this object. /// ///A 32-bit signed integer hash code. public override int GetHashCode() { return _style; } ////// Creates a string representation of this object based on the current culture. /// ////// A string representation of this object. /// public override string ToString() { // Delegate to the internal method which implements all ToString calls. return ConvertToString(null, null); } ////// Creates a string representation of this object based on the format string /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// ////// A string representation of this object. /// string IFormattable.ToString(string format, IFormatProvider provider) { // Delegate to the internal method which implements all ToString calls. return ConvertToString(format, provider); } ////// This method is used only in type converter for construction via reflection. /// ///THe value of _style member. internal int GetStyleForInternalConstruction() { Debug.Assert(0 <= _style && _style <= 2); return _style; } ////// Creates a string representation of this object based on the format string /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// ////// A string representation of this object. /// private string ConvertToString(string format, IFormatProvider provider) { if (_style == 0) return "Normal"; if (_style == 1) return "Oblique"; Debug.Assert(_style == 2); return "Italic"; } private int _style; } } // 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
- DefaultAsyncDataDispatcher.cs
- EditingCommands.cs
- TemplateControl.cs
- PackagingUtilities.cs
- CodeAttributeArgumentCollection.cs
- ComplexType.cs
- SqlFunctionAttribute.cs
- HtmlInputPassword.cs
- BaseHashHelper.cs
- CfgParser.cs
- ItemCheckEvent.cs
- PointAnimationUsingPath.cs
- MemoryRecordBuffer.cs
- RSAProtectedConfigurationProvider.cs
- IntSecurity.cs
- IntegerFacetDescriptionElement.cs
- ZipIOLocalFileBlock.cs
- Identifier.cs
- ItemList.cs
- MembershipValidatePasswordEventArgs.cs
- FrameworkContentElement.cs
- UpdateManifestForBrowserApplication.cs
- ButtonStandardAdapter.cs
- RemotingConfigParser.cs
- HtmlWindow.cs
- AxisAngleRotation3D.cs
- DependencyObjectProvider.cs
- AuthenticatedStream.cs
- DataGridViewCellLinkedList.cs
- ValidationEventArgs.cs
- SHA512Cng.cs
- PasswordTextContainer.cs
- UrlAuthorizationModule.cs
- DesignerAutoFormatStyle.cs
- SamlSubject.cs
- HttpCacheVary.cs
- BookmarkUndoUnit.cs
- SQLGuid.cs
- HandoffBehavior.cs
- X509SecurityTokenAuthenticator.cs
- SerialPinChanges.cs
- WebPartConnectionsConnectVerb.cs
- ExpressionVisitor.cs
- ActiveXSite.cs
- SocketAddress.cs
- HtmlInputImage.cs
- CollectionChangedEventManager.cs
- FrameDimension.cs
- CompressionTransform.cs
- CodeIndexerExpression.cs
- Constants.cs
- M3DUtil.cs
- NetworkCredential.cs
- SqlWebEventProvider.cs
- Interlocked.cs
- TextRunCacheImp.cs
- TableAutomationPeer.cs
- ComponentEditorForm.cs
- ExtendedPropertyDescriptor.cs
- SafeCryptHandles.cs
- EntityCommandDefinition.cs
- DataGridColumnHeadersPresenter.cs
- FormViewDeleteEventArgs.cs
- SymmetricSecurityProtocolFactory.cs
- FileDialogCustomPlace.cs
- TableLayoutStyle.cs
- CellParagraph.cs
- ActiveXHelper.cs
- DesignerLoader.cs
- ColumnBinding.cs
- DataGridTextBox.cs
- BrowsableAttribute.cs
- NamedObject.cs
- TemplateKeyConverter.cs
- XmlSchemaException.cs
- GifBitmapDecoder.cs
- EntityModelSchemaGenerator.cs
- FileStream.cs
- CultureData.cs
- XmlTypeMapping.cs
- CustomValidator.cs
- HttpStreams.cs
- Italic.cs
- DataGridViewRowsRemovedEventArgs.cs
- PartialTrustHelpers.cs
- WindowsAuthenticationEventArgs.cs
- OleDbError.cs
- GlyphShapingProperties.cs
- mediaeventargs.cs
- InvalidWMPVersionException.cs
- srgsitem.cs
- EncoderNLS.cs
- DataServiceRequest.cs
- XsdDateTime.cs
- Block.cs
- EnumBuilder.cs
- InstanceOwnerQueryResult.cs
- CommentGlyph.cs
- DecoderNLS.cs
- Light.cs