Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / FixedSOMContainer.cs / 1305600 / FixedSOMContainer.cs
/*++
File: FixedSOMContainer.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
Abstract class that provides a common base class for all semantic containers
History:
05/17/2005: agurcan - Created
--*/
namespace System.Windows.Documents
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Media;
internal abstract class FixedSOMContainer :FixedSOMSemanticBox, IComparable
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
protected FixedSOMContainer()
{
_semanticBoxes = new List();
}
#endregion Constructors
int IComparable.CompareTo(object comparedObj)
{
int result = Int32.MinValue;
FixedSOMPageElement compared = comparedObj as FixedSOMPageElement;
FixedSOMPageElement This = this as FixedSOMPageElement;
Debug.Assert(compared != null);
Debug.Assert(This != null);
if (compared == null)
{
throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, comparedObj.GetType(), typeof(FixedSOMContainer)), "comparedObj");
}
SpatialComparison compareHor = base._CompareHorizontal(compared, false);
SpatialComparison compareVer = base._CompareVertical(compared);
Debug.Assert(compareHor != SpatialComparison.None);
Debug.Assert(compareVer != SpatialComparison.None);
switch (compareHor)
{
case SpatialComparison.Before:
if (compareVer != SpatialComparison.After)
{
result = -1;
}
break;
case SpatialComparison.After:
if (compareVer != SpatialComparison.Before)
{
result = 1;
}
break;
case SpatialComparison.OverlapBefore:
if (compareVer == SpatialComparison.Before)
{
result = -1;
}
else if (compareVer == SpatialComparison.After)
{
result = 1;
}
break;
case SpatialComparison.OverlapAfter:
if (compareVer == SpatialComparison.After)
{
result = 1;
}
else if (compareVer == SpatialComparison.Before)
{
result = -1;
}
break;
case SpatialComparison.Equal:
switch (compareVer)
{
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;
}
if (result == Int32.MinValue)
{
//Indecisive. Does markup order help?
if (This.FixedNodes.Count == 0 || compared.FixedNodes.Count == 0)
{
result = 0;
}
else
{
FixedNode thisObjFirstNode = This.FixedNodes[0];
FixedNode thisObjLastNode = This.FixedNodes[This.FixedNodes.Count - 1];
FixedNode otherObjFirstNode = compared.FixedNodes[0];
FixedNode otherObjLastNode = compared.FixedNodes[compared.FixedNodes.Count - 1];
if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjFirstNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjLastNode) == 1)
{
result = -1;
}
else if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjLastNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjFirstNode) == 1)
{
result = 1;
}
else
{
//Indecisive. Whichever is below comes after; if same whichever is on the right comes after
int absVerComparison = _SpatialToAbsoluteComparison(compareVer);
result = absVerComparison != 0 ? absVerComparison : _SpatialToAbsoluteComparison(compareHor);
}
}
}
return result;
}
#region Protected Methods
protected void AddSorted(FixedSOMSemanticBox box)
{
int i=_semanticBoxes.Count-1;
for (; i>=0; i--)
{
if (box.CompareTo(_semanticBoxes[i]) == 1)
{
break;
}
}
_semanticBoxes.Insert(i+1, box);
_UpdateBoundingRect(box.BoundingRect);
}
protected void Add(FixedSOMSemanticBox box)
{
_semanticBoxes.Add(box);
_UpdateBoundingRect(box.BoundingRect);
}
#endregion
#region public Properties
internal virtual FixedElement.ElementType[] ElementTypes
{
get
{
return new FixedElement.ElementType[0];
}
}
public List SemanticBoxes
{
get
{
return _semanticBoxes;
}
set
{
_semanticBoxes = value;
}
}
public List FixedNodes
{
get
{
if (_fixedNodes == null)
{
_ConstructFixedNodes();
}
return _fixedNodes;
}
}
#endregion
#region Private methods
void _ConstructFixedNodes()
{
_fixedNodes = new List();
foreach (FixedSOMSemanticBox box in _semanticBoxes)
{
FixedSOMElement element = box as FixedSOMElement;
if (element != null)
{
_fixedNodes.Add(element.FixedNode);
}
else
{
FixedSOMContainer container = box as FixedSOMContainer;
Debug.Assert(container != null);
List nodes = container.FixedNodes;
foreach (FixedNode node in nodes)
{
_fixedNodes.Add(node);
}
}
}
}
void _UpdateBoundingRect(Rect rect)
{
if (_boundingRect.IsEmpty)
{
_boundingRect = rect;
}
else
{
_boundingRect.Union(rect);
}
}
#endregion Private methods
//-------------------------------------------------------------------
//
// Protected Fields
//
//---------------------------------------------------------------------
#region Protected Fields
protected List _semanticBoxes;
protected List _fixedNodes;
#endregion Protected Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
/*++
File: FixedSOMContainer.cs
Copyright (C) 2005 Microsoft Corporation. All rights reserved.
Description:
Abstract class that provides a common base class for all semantic containers
History:
05/17/2005: agurcan - Created
--*/
namespace System.Windows.Documents
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Media;
internal abstract class FixedSOMContainer :FixedSOMSemanticBox, IComparable
{
//--------------------------------------------------------------------
//
// Constructors
//
//---------------------------------------------------------------------
#region Constructors
protected FixedSOMContainer()
{
_semanticBoxes = new List();
}
#endregion Constructors
int IComparable.CompareTo(object comparedObj)
{
int result = Int32.MinValue;
FixedSOMPageElement compared = comparedObj as FixedSOMPageElement;
FixedSOMPageElement This = this as FixedSOMPageElement;
Debug.Assert(compared != null);
Debug.Assert(This != null);
if (compared == null)
{
throw new ArgumentException(SR.Get(SRID.UnexpectedParameterType, comparedObj.GetType(), typeof(FixedSOMContainer)), "comparedObj");
}
SpatialComparison compareHor = base._CompareHorizontal(compared, false);
SpatialComparison compareVer = base._CompareVertical(compared);
Debug.Assert(compareHor != SpatialComparison.None);
Debug.Assert(compareVer != SpatialComparison.None);
switch (compareHor)
{
case SpatialComparison.Before:
if (compareVer != SpatialComparison.After)
{
result = -1;
}
break;
case SpatialComparison.After:
if (compareVer != SpatialComparison.Before)
{
result = 1;
}
break;
case SpatialComparison.OverlapBefore:
if (compareVer == SpatialComparison.Before)
{
result = -1;
}
else if (compareVer == SpatialComparison.After)
{
result = 1;
}
break;
case SpatialComparison.OverlapAfter:
if (compareVer == SpatialComparison.After)
{
result = 1;
}
else if (compareVer == SpatialComparison.Before)
{
result = -1;
}
break;
case SpatialComparison.Equal:
switch (compareVer)
{
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;
}
if (result == Int32.MinValue)
{
//Indecisive. Does markup order help?
if (This.FixedNodes.Count == 0 || compared.FixedNodes.Count == 0)
{
result = 0;
}
else
{
FixedNode thisObjFirstNode = This.FixedNodes[0];
FixedNode thisObjLastNode = This.FixedNodes[This.FixedNodes.Count - 1];
FixedNode otherObjFirstNode = compared.FixedNodes[0];
FixedNode otherObjLastNode = compared.FixedNodes[compared.FixedNodes.Count - 1];
if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjFirstNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjLastNode) == 1)
{
result = -1;
}
else if (This.FixedSOMPage.MarkupOrder.IndexOf(otherObjLastNode) - This.FixedSOMPage.MarkupOrder.IndexOf(thisObjFirstNode) == 1)
{
result = 1;
}
else
{
//Indecisive. Whichever is below comes after; if same whichever is on the right comes after
int absVerComparison = _SpatialToAbsoluteComparison(compareVer);
result = absVerComparison != 0 ? absVerComparison : _SpatialToAbsoluteComparison(compareHor);
}
}
}
return result;
}
#region Protected Methods
protected void AddSorted(FixedSOMSemanticBox box)
{
int i=_semanticBoxes.Count-1;
for (; i>=0; i--)
{
if (box.CompareTo(_semanticBoxes[i]) == 1)
{
break;
}
}
_semanticBoxes.Insert(i+1, box);
_UpdateBoundingRect(box.BoundingRect);
}
protected void Add(FixedSOMSemanticBox box)
{
_semanticBoxes.Add(box);
_UpdateBoundingRect(box.BoundingRect);
}
#endregion
#region public Properties
internal virtual FixedElement.ElementType[] ElementTypes
{
get
{
return new FixedElement.ElementType[0];
}
}
public List SemanticBoxes
{
get
{
return _semanticBoxes;
}
set
{
_semanticBoxes = value;
}
}
public List FixedNodes
{
get
{
if (_fixedNodes == null)
{
_ConstructFixedNodes();
}
return _fixedNodes;
}
}
#endregion
#region Private methods
void _ConstructFixedNodes()
{
_fixedNodes = new List();
foreach (FixedSOMSemanticBox box in _semanticBoxes)
{
FixedSOMElement element = box as FixedSOMElement;
if (element != null)
{
_fixedNodes.Add(element.FixedNode);
}
else
{
FixedSOMContainer container = box as FixedSOMContainer;
Debug.Assert(container != null);
List nodes = container.FixedNodes;
foreach (FixedNode node in nodes)
{
_fixedNodes.Add(node);
}
}
}
}
void _UpdateBoundingRect(Rect rect)
{
if (_boundingRect.IsEmpty)
{
_boundingRect = rect;
}
else
{
_boundingRect.Union(rect);
}
}
#endregion Private methods
//-------------------------------------------------------------------
//
// Protected Fields
//
//---------------------------------------------------------------------
#region Protected Fields
protected List _semanticBoxes;
protected List _fixedNodes;
#endregion Protected 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
- ResourcePermissionBaseEntry.cs
- HttpRequestTraceRecord.cs
- TagPrefixAttribute.cs
- Dynamic.cs
- MatchSingleFxEngineOpcode.cs
- _SecureChannel.cs
- DbDataRecord.cs
- RoleManagerModule.cs
- XPathNodeHelper.cs
- PropertyEmitter.cs
- PageCodeDomTreeGenerator.cs
- GroupByQueryOperator.cs
- CompilerScopeManager.cs
- IsolatedStorageFile.cs
- Single.cs
- DotExpr.cs
- TextRenderer.cs
- Misc.cs
- WorkflowServiceNamespace.cs
- OuterGlowBitmapEffect.cs
- CodeDirectoryCompiler.cs
- X509Chain.cs
- CompatibleComparer.cs
- ADConnectionHelper.cs
- ProviderConnectionPointCollection.cs
- MonthCalendar.cs
- ConfigurationManager.cs
- ResXBuildProvider.cs
- unitconverter.cs
- BorderGapMaskConverter.cs
- HtmlTextArea.cs
- Privilege.cs
- DataObjectFieldAttribute.cs
- ObjRef.cs
- AnnotationService.cs
- DataServiceConfiguration.cs
- RectangleGeometry.cs
- SchemaTypeEmitter.cs
- DiagnosticTrace.cs
- ItemCheckedEvent.cs
- EntityDataSourceWizardForm.cs
- NoClickablePointException.cs
- WpfKnownMember.cs
- NamedPipeConnectionPoolSettingsElement.cs
- FormatterConverter.cs
- DataGridViewCellCancelEventArgs.cs
- SmiXetterAccessMap.cs
- AnnotationHelper.cs
- SmtpAuthenticationManager.cs
- TriggerActionCollection.cs
- Point4D.cs
- Int32.cs
- ChildDocumentBlock.cs
- MD5CryptoServiceProvider.cs
- SqlDataSourceFilteringEventArgs.cs
- BrowserDefinitionCollection.cs
- RectIndependentAnimationStorage.cs
- TextServicesManager.cs
- userdatakeys.cs
- HttpGetProtocolReflector.cs
- ClientSettingsProvider.cs
- XmlWrappingReader.cs
- ProvidePropertyAttribute.cs
- UIElementParaClient.cs
- Operand.cs
- XmlCustomFormatter.cs
- CapabilitiesRule.cs
- AsyncContentLoadedEventArgs.cs
- IdentityElement.cs
- TileBrush.cs
- ApplicationManager.cs
- OleDbErrorCollection.cs
- CheckBoxFlatAdapter.cs
- GlobalItem.cs
- ImageMapEventArgs.cs
- MethodRental.cs
- MarkupObject.cs
- DesignerMetadata.cs
- SqlConnectionPoolProviderInfo.cs
- PrincipalPermission.cs
- IssuedTokenClientBehaviorsElement.cs
- DataError.cs
- AuthenticateEventArgs.cs
- Hashtable.cs
- HtmlElementErrorEventArgs.cs
- SHA1Managed.cs
- LongMinMaxAggregationOperator.cs
- MetabaseSettings.cs
- HttpListenerException.cs
- Random.cs
- OracleEncoding.cs
- InfoCardTraceRecord.cs
- HtmlTableCellCollection.cs
- AttributeQuery.cs
- DivideByZeroException.cs
- NativeObjectSecurity.cs
- EntityDesignerUtils.cs
- ProcessHostConfigUtils.cs
- Error.cs
- CodeDefaultValueExpression.cs