Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Documents / FixedSOMGroup.cs / 1 / FixedSOMGroup.cs
/*++
File: FixedSOMGroup.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
A concrete container that can be used to put together to group different or same types of containers
History:
06/17/2005: agurcan - Created
--*/
namespace System.Windows.Documents
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Media;
using System.Globalization;
internal class FixedSOMGroup :FixedSOMPageElement, IComparable
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
public FixedSOMGroup(FixedSOMPage page) : base(page)
{
}
#endregion Constructors
#region IComparable
int IComparable.CompareTo(object comparedObj)
{
int result = Int32.MinValue;
FixedSOMGroup compared = comparedObj as FixedSOMGroup;
Debug.Assert(compared != null);
if (compared == null)
{
throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, comparedObj.GetType(), typeof(FixedSOMGroup)), "comparedObj");
}
bool RTL = this.IsRTL && compared.IsRTL;
SpatialComparison compareHor = base._CompareHorizontal(compared, RTL);
SpatialComparison compareVer = base._CompareVertical(compared);
Debug.Assert(compareHor != SpatialComparison.None);
Debug.Assert(compareVer != SpatialComparison.None);
switch (compareVer)
{
case SpatialComparison.Before:
result = -1;
break;
case SpatialComparison.After:
result = 1;
break;
case SpatialComparison.OverlapBefore:
if ((int)compareHor <= (int)SpatialComparison.Equal)
{
result = -1;
}
else
{
result = 1;
}
break;
case SpatialComparison.OverlapAfter:
if ((int)compareHor >= (int)SpatialComparison.Equal)
{
result = 1;
}
else
{
result = -1;
}
break;
case SpatialComparison.Equal:
switch (compareHor)
{
case SpatialComparison.After:
case SpatialComparison.OverlapAfter:
result = 1;
break;
case SpatialComparison.Before:
case SpatialComparison.OverlapBefore:
result = -1;
break;
case SpatialComparison.Equal:
result = 0;
break;
default:
Debug.Assert(false);
break;
}
break;
default:
//Shouldn't happen
Debug.Assert(false);
break;
}
return result;
}
#endregion
#region Public methods
//-------------------------------------------------------------------
//
// Public methods
//
//---------------------------------------------------------------------
public void AddContainer(FixedSOMPageElement pageElement)
{
FixedSOMFixedBlock block = pageElement as FixedSOMFixedBlock;
if (block == null || (!block.IsFloatingImage && !block.IsWhiteSpace))
{
if (pageElement.IsRTL)
{
_RTLCount++;
}
else
{
_LTRCount++;
}
}
_semanticBoxes.Add(pageElement);
if (_boundingRect.IsEmpty)
{
_boundingRect = pageElement.BoundingRect;
}
else
{
_boundingRect.Union(pageElement.BoundingRect);
}
}
#if DEBUG
public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual)
{
Pen pen = new Pen(Brushes.Maroon, 3);
Rect rect = _boundingRect;
rect.Inflate(5,5);
dc.DrawRectangle(null, pen , rect);
if (label != null)
{
if (this.IsRTL)
{
label += "R";
}
base.RenderLabel(dc, label);
}
foreach (FixedSOMSemanticBox box in _semanticBoxes)
{
box.Render(dc, "", debugVisual);
}
}
#endif
#endregion Public methods
#region Public Properties
public override bool IsRTL
{
get
{
return _RTLCount > _LTRCount;
}
}
#endregion Public Properties
#region Private fields
private int _RTLCount;
private int _LTRCount;
#endregion Private fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
/*++
File: FixedSOMGroup.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
A concrete container that can be used to put together to group different or same types of containers
History:
06/17/2005: agurcan - Created
--*/
namespace System.Windows.Documents
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Media;
using System.Globalization;
internal class FixedSOMGroup :FixedSOMPageElement, IComparable
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
public FixedSOMGroup(FixedSOMPage page) : base(page)
{
}
#endregion Constructors
#region IComparable
int IComparable.CompareTo(object comparedObj)
{
int result = Int32.MinValue;
FixedSOMGroup compared = comparedObj as FixedSOMGroup;
Debug.Assert(compared != null);
if (compared == null)
{
throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, comparedObj.GetType(), typeof(FixedSOMGroup)), "comparedObj");
}
bool RTL = this.IsRTL && compared.IsRTL;
SpatialComparison compareHor = base._CompareHorizontal(compared, RTL);
SpatialComparison compareVer = base._CompareVertical(compared);
Debug.Assert(compareHor != SpatialComparison.None);
Debug.Assert(compareVer != SpatialComparison.None);
switch (compareVer)
{
case SpatialComparison.Before:
result = -1;
break;
case SpatialComparison.After:
result = 1;
break;
case SpatialComparison.OverlapBefore:
if ((int)compareHor <= (int)SpatialComparison.Equal)
{
result = -1;
}
else
{
result = 1;
}
break;
case SpatialComparison.OverlapAfter:
if ((int)compareHor >= (int)SpatialComparison.Equal)
{
result = 1;
}
else
{
result = -1;
}
break;
case SpatialComparison.Equal:
switch (compareHor)
{
case SpatialComparison.After:
case SpatialComparison.OverlapAfter:
result = 1;
break;
case SpatialComparison.Before:
case SpatialComparison.OverlapBefore:
result = -1;
break;
case SpatialComparison.Equal:
result = 0;
break;
default:
Debug.Assert(false);
break;
}
break;
default:
//Shouldn't happen
Debug.Assert(false);
break;
}
return result;
}
#endregion
#region Public methods
//-------------------------------------------------------------------
//
// Public methods
//
//---------------------------------------------------------------------
public void AddContainer(FixedSOMPageElement pageElement)
{
FixedSOMFixedBlock block = pageElement as FixedSOMFixedBlock;
if (block == null || (!block.IsFloatingImage && !block.IsWhiteSpace))
{
if (pageElement.IsRTL)
{
_RTLCount++;
}
else
{
_LTRCount++;
}
}
_semanticBoxes.Add(pageElement);
if (_boundingRect.IsEmpty)
{
_boundingRect = pageElement.BoundingRect;
}
else
{
_boundingRect.Union(pageElement.BoundingRect);
}
}
#if DEBUG
public override void Render(DrawingContext dc, string label, DrawDebugVisual debugVisual)
{
Pen pen = new Pen(Brushes.Maroon, 3);
Rect rect = _boundingRect;
rect.Inflate(5,5);
dc.DrawRectangle(null, pen , rect);
if (label != null)
{
if (this.IsRTL)
{
label += "R";
}
base.RenderLabel(dc, label);
}
foreach (FixedSOMSemanticBox box in _semanticBoxes)
{
box.Render(dc, "", debugVisual);
}
}
#endif
#endregion Public methods
#region Public Properties
public override bool IsRTL
{
get
{
return _RTLCount > _LTRCount;
}
}
#endregion Public Properties
#region Private fields
private int _RTLCount;
private int _LTRCount;
#endregion Private fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MetroSerializationManager.cs
- Point3D.cs
- MailAddress.cs
- RegistrySecurity.cs
- PerformanceCounterTraceRecord.cs
- DataMisalignedException.cs
- Table.cs
- WindowsAuthenticationEventArgs.cs
- OledbConnectionStringbuilder.cs
- Drawing.cs
- SafeRightsManagementSessionHandle.cs
- LinkClickEvent.cs
- FileDialogCustomPlace.cs
- SBCSCodePageEncoding.cs
- TypeToken.cs
- DashStyles.cs
- RightNameExpirationInfoPair.cs
- DataConnectionHelper.cs
- StaticFileHandler.cs
- FlowPanelDesigner.cs
- Visitor.cs
- SQLDouble.cs
- ListViewContainer.cs
- PageRequestManager.cs
- HMACSHA256.cs
- PeerName.cs
- Dump.cs
- ByteStack.cs
- StrokeRenderer.cs
- ArrayList.cs
- SimpleTextLine.cs
- updateconfighost.cs
- UIElementHelper.cs
- SmiEventSink.cs
- LowerCaseStringConverter.cs
- FunctionNode.cs
- SqlMethods.cs
- ObjectStateFormatter.cs
- DiscoveryRequestHandler.cs
- VBIdentifierName.cs
- Track.cs
- MatrixConverter.cs
- CommentGlyph.cs
- Normalizer.cs
- DataRowChangeEvent.cs
- TrustLevel.cs
- XmlParserContext.cs
- RoutedUICommand.cs
- RecognitionEventArgs.cs
- SessionParameter.cs
- fixedPageContentExtractor.cs
- RSAOAEPKeyExchangeFormatter.cs
- CredentialManagerDialog.cs
- ZipIOCentralDirectoryFileHeader.cs
- DiagnosticsConfiguration.cs
- PointLight.cs
- AppliedDeviceFiltersEditor.cs
- MaskPropertyEditor.cs
- NotCondition.cs
- Invariant.cs
- Stopwatch.cs
- HybridDictionary.cs
- FunctionUpdateCommand.cs
- ISO2022Encoding.cs
- AttributeProviderAttribute.cs
- rsa.cs
- SqlProcedureAttribute.cs
- OleDbCommandBuilder.cs
- SQLBytes.cs
- XmlILCommand.cs
- Context.cs
- WindowsClientCredential.cs
- QueryCorrelationInitializer.cs
- _NetworkingPerfCounters.cs
- NopReturnReader.cs
- WebPartMenu.cs
- DoubleCollectionValueSerializer.cs
- _NestedSingleAsyncResult.cs
- Math.cs
- StrokeCollection2.cs
- MappingModelBuildProvider.cs
- ShapingEngine.cs
- Accessible.cs
- ConfigurationLockCollection.cs
- ObjectAnimationUsingKeyFrames.cs
- ActivityUtilities.cs
- PersistenceProviderFactory.cs
- DefaultValueAttribute.cs
- HttpValueCollection.cs
- ConfigurationManager.cs
- PanelDesigner.cs
- ResourceSetExpression.cs
- RegionInfo.cs
- SourceFileBuildProvider.cs
- IISMapPath.cs
- SchemaMapping.cs
- ThrowHelper.cs
- BitmapMetadata.cs
- DeferredReference.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs