Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CommonUI / System / Drawing / Printing / TriState.cs / 1305376 / TriState.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Printing {
using System.ComponentModel;
using System.Diagnostics;
using System;
[Serializable]
internal struct TriState {
private byte value; // 0 is "default", not false
public static readonly TriState Default = new TriState(0);
public static readonly TriState False = new TriState(1);
public static readonly TriState True = new TriState(2);
private TriState(byte value) {
this.value = value;
}
public bool IsDefault {
get { return this == Default;}
}
public bool IsFalse {
get { return this == False;}
}
public bool IsNotDefault {
get { return this != Default;}
}
public bool IsTrue {
get { return this == True;}
}
public static bool operator ==(TriState left, TriState right) {
return left.value == right.value;
}
public static bool operator !=(TriState left, TriState right) {
return !(left == right);
}
public override bool Equals( object o ) {
TriState state = (TriState)o;
return this.value == state.value;
}
public override int GetHashCode() {
return value;
}
public static implicit operator TriState(bool value) {
return(value) ? True : False;
}
public static explicit operator bool(TriState value) {
if (value.IsDefault)
throw new InvalidCastException(SR.GetString(SR.TriStateCompareError));
else
return(value == TriState.True);
}
///
///
///
///
/// Provides some interesting information about the TriState in
/// String form.
///
///
public override string ToString() {
if (this == Default) return "Default";
else if (this == False) return "False";
else return "True";
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Drawing.Printing {
using System.ComponentModel;
using System.Diagnostics;
using System;
[Serializable]
internal struct TriState {
private byte value; // 0 is "default", not false
public static readonly TriState Default = new TriState(0);
public static readonly TriState False = new TriState(1);
public static readonly TriState True = new TriState(2);
private TriState(byte value) {
this.value = value;
}
public bool IsDefault {
get { return this == Default;}
}
public bool IsFalse {
get { return this == False;}
}
public bool IsNotDefault {
get { return this != Default;}
}
public bool IsTrue {
get { return this == True;}
}
public static bool operator ==(TriState left, TriState right) {
return left.value == right.value;
}
public static bool operator !=(TriState left, TriState right) {
return !(left == right);
}
public override bool Equals( object o ) {
TriState state = (TriState)o;
return this.value == state.value;
}
public override int GetHashCode() {
return value;
}
public static implicit operator TriState(bool value) {
return(value) ? True : False;
}
public static explicit operator bool(TriState value) {
if (value.IsDefault)
throw new InvalidCastException(SR.GetString(SR.TriStateCompareError));
else
return(value == TriState.True);
}
///
///
///
///
/// Provides some interesting information about the TriState in
/// String form.
///
///
public override string ToString() {
if (this == Default) return "Default";
else if (this == False) return "False";
else return "True";
}
}
}
// 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
- OpenTypeCommon.cs
- ParseNumbers.cs
- TemplateControl.cs
- SystemParameters.cs
- ProfilePropertySettingsCollection.cs
- Stack.cs
- SocketAddress.cs
- HtmlShim.cs
- BackStopAuthenticationModule.cs
- SqlGenericUtil.cs
- WebServiceData.cs
- SignatureDescription.cs
- DelegatingTypeDescriptionProvider.cs
- HostUtils.cs
- HtmlFormWrapper.cs
- ProfilePropertyNameValidator.cs
- InvalidDataException.cs
- ObjectResult.cs
- ReferencedType.cs
- HttpPostedFileWrapper.cs
- Encoder.cs
- ExtentJoinTreeNode.cs
- XamlPathDataSerializer.cs
- MemberRelationshipService.cs
- ClipboardProcessor.cs
- FreeFormDragDropManager.cs
- BitmapCodecInfoInternal.cs
- ListViewContainer.cs
- EncryptedXml.cs
- SymbolEqualComparer.cs
- InheritanceUI.cs
- MatrixKeyFrameCollection.cs
- TriState.cs
- ExtensionQuery.cs
- SecurityAccessDeniedException.cs
- basecomparevalidator.cs
- KeyValuePair.cs
- FixedSOMElement.cs
- BrushConverter.cs
- DescendantOverDescendantQuery.cs
- ProcessHost.cs
- SerializationFieldInfo.cs
- DataServiceHostWrapper.cs
- PageBuildProvider.cs
- DbConnectionPoolGroup.cs
- RepeatInfo.cs
- CodeParameterDeclarationExpression.cs
- VideoDrawing.cs
- PrinterSettings.cs
- DataColumnCollection.cs
- CommandConverter.cs
- Vector3dCollection.cs
- TargetPerspective.cs
- EntityUtil.cs
- PeerNodeTraceRecord.cs
- ServiceSecurityAuditElement.cs
- FramingFormat.cs
- IsolatedStorageFileStream.cs
- PageMediaType.cs
- ManagedFilter.cs
- IgnoreDeviceFilterElement.cs
- DataTableTypeConverter.cs
- SoapAttributeAttribute.cs
- SafeLibraryHandle.cs
- FrameworkTextComposition.cs
- Int64AnimationBase.cs
- ImageMapEventArgs.cs
- CompoundFileDeflateTransform.cs
- QuaternionAnimation.cs
- GlyphingCache.cs
- BrushMappingModeValidation.cs
- UIntPtr.cs
- EpmSourceTree.cs
- WebPartAddingEventArgs.cs
- RefreshPropertiesAttribute.cs
- AdornerDecorator.cs
- ParameterElement.cs
- ImageFormat.cs
- ColumnResizeAdorner.cs
- TextBox.cs
- HttpCookieCollection.cs
- TextContainer.cs
- MultiDataTrigger.cs
- ConsoleCancelEventArgs.cs
- XamlGridLengthSerializer.cs
- NotifyIcon.cs
- TextCollapsingProperties.cs
- ChangeBlockUndoRecord.cs
- DataGridColumnCollectionEditor.cs
- UIAgentMonitorHandle.cs
- IDQuery.cs
- QuadraticBezierSegment.cs
- TrackingProfileSerializer.cs
- ParsedAttributeCollection.cs
- RawTextInputReport.cs
- Brush.cs
- StreamGeometry.cs
- OdbcConnectionString.cs
- MemoryStream.cs
- IdleTimeoutMonitor.cs