Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / MS / Internal / Annotations / Anchoring / AttachedAnnotation.cs / 1 / AttachedAnnotation.cs
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description:
// AttachedAnnotation represents an annotation which has been loaded for a
// specific logical tree and has a runtime anchor in that tree. The same
// annotation may be loaded in a different logical tree and get a different
// anchor - thereby creating a different AttachedAnnotation.
//
// Spec: http://team/sites/ag/Specifications/Annotation%20Service%20Spec.doc
//
// History:
// 08/18/2003: rruiz: Added enum and class as per spec.
// 11/18/2003: magedz: implements IAttachedAnnotations interface as per service spec.
//
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Annotations;
using System.Windows.Annotations.Storage;
using System.Windows.Media;
using System.Xml;
using System.Collections.Generic;
using MS.Utility;
namespace MS.Internal.Annotations.Anchoring
{
///
/// AttachedAnnotation represents an annotation which has been loaded for a
/// specific logical tree and has an anchor in that tree. The same annotation
/// may be loaded in a different logical tree and get a different anchor -
/// thereby creating a different AttachedAnnotation.
///
internal class AttachedAnnotation : IAttachedAnnotation
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Create an instance of AttachedAnnotation.
///
/// the LocatorManager providing processors for this anchored annotation
/// the annotation itself
/// the annotation's anchor represented by the attached anchor
/// the attached anchor itself
/// the level of the attached anchor
internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, Object attachedAnchor, AttachmentLevel attachmentLevel)
: this(manager, annotation, anchor, attachedAnchor, attachmentLevel, null)
{
}
///
/// Create an instance of AttachedAnnotation with a specified parent. Takes an optional
/// parent for the attached annotation. This is useful when the parent is known before
/// hand and not available through the normal means (such as in printing).
///
/// the LocatorManager providing processors for this anchored annotation
/// the annotation itself
/// the annotation's anchor represented by the attached anchor
/// the attached anchor itself
/// the level of the attached anchor
/// parent of the selection
internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, Object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
{
Debug.Assert(manager != null, "LocatorManager can not be null");
Debug.Assert(annotation != null, "Annotation can not be null");
Debug.Assert(anchor != null, "Anchor can not be null");
Debug.Assert(attachedAnchor != null, "AttachedAnchor can not be null");
_annotation = annotation;
_anchor = anchor;
_locatorManager = manager;
Update(attachedAnchor, attachmentLevel, parent);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Returns true if the attachedanchor of this IAttachedAnnotation is
/// equal to the attached anchor passed to the function
///
///
/// true if the anchors are equal
public bool IsAnchorEqual(Object o)
{
//return _selectionProcessor.AnchorEquals(_attachedAnchor, o);
return false;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Operators
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// The Annotation that is being attached to the element tree
///
///
public Annotation Annotation { get { return _annotation; } }
///
/// The specific anchor that has been resolved into the element tree
///
///
public AnnotationResource Anchor { get { return _anchor; } }
///
/// The part of the Avalon element tree that this attached annotation is anchored to
///
///
public Object AttachedAnchor { get { return _attachedAnchor; } }
///
/// This is simply a public accessor for FullyAttachedAnchor. We didn't want to use the
/// FullyAttachedAnchor name in the public API but couldn't get rid of this internal
/// property because there are a few known users of it (through reflection).
///
public Object ResolvedAnchor { get { return FullyAttachedAnchor; } }
///
/// For virtualized content, this property returns the full anchor for the annotation.
/// It may not be all visible or loaded into the tree, but the full anchor is useful
/// for some operations that operate on content that may be virtualized. This property
/// could be:
/// - equal to AttachedAnchor, if the attachment level is Full
/// - different from AttachedAnchor, if the attachment level was not full but the
/// anchor could be resolved using virtual data
/// - null, if the attachment level was not ful but the anchor could not be resolved
/// using virtual data
///
public Object FullyAttachedAnchor
{
get
{
if (_attachmentLevel == AttachmentLevel.Full)
return _attachedAnchor;
else
return _fullyAttachedAnchor;
}
}
///
/// The level of attachment of the annotation to its attached anchor
///
///
public AttachmentLevel AttachmentLevel { get { return _attachmentLevel; } }
///
/// The Avalon logical Parent node of the attached anchor
///
///
public DependencyObject Parent
{
get
{
return _parent;
}
}
///
/// The Avalon coordinate of the attached anchor measured relative
/// from its parent coordinate
///
///
public Point AnchorPoint
{
get
{
Point pt = _selectionProcessor.GetAnchorPoint(_attachedAnchor);
if (!Double.IsInfinity(pt.X) && !Double.IsInfinity(pt.Y))
{
_cachedPoint = pt;
}
return _cachedPoint;
}
}
///
/// The AnnotationStore
///
///
public AnnotationStore Store
{
get { return GetStore(); }
}
#endregion Public Properties
//-----------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
///
/// Update the attached anchor and level for this attached annotation. Internal method called by
/// the annotation service when a change to an anchor is processed. Optional parent will be used
/// if present. Otherwise we get the parent from the selection processor.
///
/// the new attached anchor
/// the new attachment level
/// optional, the parent of the attached annotation
internal void Update(object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
{
Debug.Assert(attachedAnchor != null, "AttachedAnchor can not be null");
Debug.Assert(attachmentLevel > AttachmentLevel.Unresolved && attachmentLevel <= AttachmentLevel.Incomplete,
"Undefined attachment level");
_attachedAnchor = attachedAnchor;
_attachmentLevel = attachmentLevel;
_selectionProcessor = _locatorManager.GetSelectionProcessor(attachedAnchor.GetType());
// Use optional parent if available
if (parent != null)
{
_parent = parent;
}
else
{
_parent = _selectionProcessor.GetParent(_attachedAnchor);
}
Debug.Assert(_selectionProcessor != null, SR.Get(SRID.NoProcessorForSelectionType, attachedAnchor.GetType()));
}
///
/// Sets the fully attached anchor for this attached annotation. Should be used if
/// the attachment level is not Full and the anchor could be fully resolved using virual content.
///
internal void SetFullyAttachedAnchor(object fullyAttachedAnchor)
{
Debug.Assert(_attachmentLevel != AttachmentLevel.Full, "Should only set fully resolved anchor if attachment level is not full.");
_fullyAttachedAnchor = fullyAttachedAnchor;
}
#endregion Internal Methods
//-----------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Functions
private AnnotationStore GetStore()
{
// indirect via the parent element & DP
if (this.Parent != null)
{
AnnotationService service = AnnotationService.GetService(this.Parent);
if (service != null)
return service.Store;
}
return null;
}
#endregion Private Methods
//------------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
// The Annotation that is being attached to the element tree
private Annotation _annotation;
// The specific anchor that has been resolved into the element tree
private AnnotationResource _anchor;
// The part of the Avalon element tree that this attached annotation is anchored to
private Object _attachedAnchor;
// The fully resolved anchor, if different from _attachedAnchor
private Object _fullyAttachedAnchor;
// The level of attachment of the annotation to its attached anchor
private AttachmentLevel _attachmentLevel;
// Parent object of the attached anchor. This shouldn't change without
// the anchor actually changing.
private DependencyObject _parent;
// // The selectionprocessor capable of handling this _attachedanchor
private SelectionProcessor _selectionProcessor;
// the locatormanager that created this attached annotation
private LocatorManager _locatorManager;
// cached anchor point - used if the selection processor returns Infinity
private Point _cachedPoint;
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description:
// AttachedAnnotation represents an annotation which has been loaded for a
// specific logical tree and has a runtime anchor in that tree. The same
// annotation may be loaded in a different logical tree and get a different
// anchor - thereby creating a different AttachedAnnotation.
//
// Spec: http://team/sites/ag/Specifications/Annotation%20Service%20Spec.doc
//
// History:
// 08/18/2003: rruiz: Added enum and class as per spec.
// 11/18/2003: magedz: implements IAttachedAnnotations interface as per service spec.
//
//-----------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Annotations;
using System.Windows.Annotations.Storage;
using System.Windows.Media;
using System.Xml;
using System.Collections.Generic;
using MS.Utility;
namespace MS.Internal.Annotations.Anchoring
{
///
/// AttachedAnnotation represents an annotation which has been loaded for a
/// specific logical tree and has an anchor in that tree. The same annotation
/// may be loaded in a different logical tree and get a different anchor -
/// thereby creating a different AttachedAnnotation.
///
internal class AttachedAnnotation : IAttachedAnnotation
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Create an instance of AttachedAnnotation.
///
/// the LocatorManager providing processors for this anchored annotation
/// the annotation itself
/// the annotation's anchor represented by the attached anchor
/// the attached anchor itself
/// the level of the attached anchor
internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, Object attachedAnchor, AttachmentLevel attachmentLevel)
: this(manager, annotation, anchor, attachedAnchor, attachmentLevel, null)
{
}
///
/// Create an instance of AttachedAnnotation with a specified parent. Takes an optional
/// parent for the attached annotation. This is useful when the parent is known before
/// hand and not available through the normal means (such as in printing).
///
/// the LocatorManager providing processors for this anchored annotation
/// the annotation itself
/// the annotation's anchor represented by the attached anchor
/// the attached anchor itself
/// the level of the attached anchor
/// parent of the selection
internal AttachedAnnotation(LocatorManager manager, Annotation annotation, AnnotationResource anchor, Object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
{
Debug.Assert(manager != null, "LocatorManager can not be null");
Debug.Assert(annotation != null, "Annotation can not be null");
Debug.Assert(anchor != null, "Anchor can not be null");
Debug.Assert(attachedAnchor != null, "AttachedAnchor can not be null");
_annotation = annotation;
_anchor = anchor;
_locatorManager = manager;
Update(attachedAnchor, attachmentLevel, parent);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
#region Public Methods
///
/// Returns true if the attachedanchor of this IAttachedAnnotation is
/// equal to the attached anchor passed to the function
///
///
/// true if the anchors are equal
public bool IsAnchorEqual(Object o)
{
//return _selectionProcessor.AnchorEquals(_attachedAnchor, o);
return false;
}
#endregion Public Methods
//------------------------------------------------------
//
// Public Operators
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Events
//
//------------------------------------------------------
//-----------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// The Annotation that is being attached to the element tree
///
///
public Annotation Annotation { get { return _annotation; } }
///
/// The specific anchor that has been resolved into the element tree
///
///
public AnnotationResource Anchor { get { return _anchor; } }
///
/// The part of the Avalon element tree that this attached annotation is anchored to
///
///
public Object AttachedAnchor { get { return _attachedAnchor; } }
///
/// This is simply a public accessor for FullyAttachedAnchor. We didn't want to use the
/// FullyAttachedAnchor name in the public API but couldn't get rid of this internal
/// property because there are a few known users of it (through reflection).
///
public Object ResolvedAnchor { get { return FullyAttachedAnchor; } }
///
/// For virtualized content, this property returns the full anchor for the annotation.
/// It may not be all visible or loaded into the tree, but the full anchor is useful
/// for some operations that operate on content that may be virtualized. This property
/// could be:
/// - equal to AttachedAnchor, if the attachment level is Full
/// - different from AttachedAnchor, if the attachment level was not full but the
/// anchor could be resolved using virtual data
/// - null, if the attachment level was not ful but the anchor could not be resolved
/// using virtual data
///
public Object FullyAttachedAnchor
{
get
{
if (_attachmentLevel == AttachmentLevel.Full)
return _attachedAnchor;
else
return _fullyAttachedAnchor;
}
}
///
/// The level of attachment of the annotation to its attached anchor
///
///
public AttachmentLevel AttachmentLevel { get { return _attachmentLevel; } }
///
/// The Avalon logical Parent node of the attached anchor
///
///
public DependencyObject Parent
{
get
{
return _parent;
}
}
///
/// The Avalon coordinate of the attached anchor measured relative
/// from its parent coordinate
///
///
public Point AnchorPoint
{
get
{
Point pt = _selectionProcessor.GetAnchorPoint(_attachedAnchor);
if (!Double.IsInfinity(pt.X) && !Double.IsInfinity(pt.Y))
{
_cachedPoint = pt;
}
return _cachedPoint;
}
}
///
/// The AnnotationStore
///
///
public AnnotationStore Store
{
get { return GetStore(); }
}
#endregion Public Properties
//-----------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
///
/// Update the attached anchor and level for this attached annotation. Internal method called by
/// the annotation service when a change to an anchor is processed. Optional parent will be used
/// if present. Otherwise we get the parent from the selection processor.
///
/// the new attached anchor
/// the new attachment level
/// optional, the parent of the attached annotation
internal void Update(object attachedAnchor, AttachmentLevel attachmentLevel, DependencyObject parent)
{
Debug.Assert(attachedAnchor != null, "AttachedAnchor can not be null");
Debug.Assert(attachmentLevel > AttachmentLevel.Unresolved && attachmentLevel <= AttachmentLevel.Incomplete,
"Undefined attachment level");
_attachedAnchor = attachedAnchor;
_attachmentLevel = attachmentLevel;
_selectionProcessor = _locatorManager.GetSelectionProcessor(attachedAnchor.GetType());
// Use optional parent if available
if (parent != null)
{
_parent = parent;
}
else
{
_parent = _selectionProcessor.GetParent(_attachedAnchor);
}
Debug.Assert(_selectionProcessor != null, SR.Get(SRID.NoProcessorForSelectionType, attachedAnchor.GetType()));
}
///
/// Sets the fully attached anchor for this attached annotation. Should be used if
/// the attachment level is not Full and the anchor could be fully resolved using virual content.
///
internal void SetFullyAttachedAnchor(object fullyAttachedAnchor)
{
Debug.Assert(_attachmentLevel != AttachmentLevel.Full, "Should only set fully resolved anchor if attachment level is not full.");
_fullyAttachedAnchor = fullyAttachedAnchor;
}
#endregion Internal Methods
//-----------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Functions
private AnnotationStore GetStore()
{
// indirect via the parent element & DP
if (this.Parent != null)
{
AnnotationService service = AnnotationService.GetService(this.Parent);
if (service != null)
return service.Store;
}
return null;
}
#endregion Private Methods
//------------------------------------------------------
//
// Private Fields
//
//-----------------------------------------------------
#region Private Fields
// The Annotation that is being attached to the element tree
private Annotation _annotation;
// The specific anchor that has been resolved into the element tree
private AnnotationResource _anchor;
// The part of the Avalon element tree that this attached annotation is anchored to
private Object _attachedAnchor;
// The fully resolved anchor, if different from _attachedAnchor
private Object _fullyAttachedAnchor;
// The level of attachment of the annotation to its attached anchor
private AttachmentLevel _attachmentLevel;
// Parent object of the attached anchor. This shouldn't change without
// the anchor actually changing.
private DependencyObject _parent;
// // The selectionprocessor capable of handling this _attachedanchor
private SelectionProcessor _selectionProcessor;
// the locatormanager that created this attached annotation
private LocatorManager _locatorManager;
// cached anchor point - used if the selection processor returns Infinity
private Point _cachedPoint;
#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
- GradientSpreadMethodValidation.cs
- MdiWindowListItemConverter.cs
- PeerNearMe.cs
- CaseInsensitiveComparer.cs
- RuleSet.cs
- AttributeCollection.cs
- TextSpan.cs
- StyleSelector.cs
- CompositeFontParser.cs
- DnsPermission.cs
- ValidationResult.cs
- OleDbInfoMessageEvent.cs
- _emptywebproxy.cs
- DeploymentSection.cs
- ToolBarPanel.cs
- GeometryHitTestParameters.cs
- LocalizedNameDescriptionPair.cs
- UntypedNullExpression.cs
- DrawingContext.cs
- ListItemCollection.cs
- TransactionsSectionGroup.cs
- VerificationAttribute.cs
- ModuleConfigurationInfo.cs
- EncodingFallbackAwareXmlTextWriter.cs
- Types.cs
- BindingMemberInfo.cs
- Int16AnimationBase.cs
- SpotLight.cs
- EntityDataSourceStatementEditor.cs
- Predicate.cs
- EdgeProfileValidation.cs
- OracleCommand.cs
- ChangeDirector.cs
- RC2.cs
- MultitargetUtil.cs
- RSAOAEPKeyExchangeFormatter.cs
- EventRoute.cs
- LookupBindingPropertiesAttribute.cs
- DataGridCommandEventArgs.cs
- WsatServiceAddress.cs
- ReaderWriterLockWrapper.cs
- XmlWrappingReader.cs
- DataContext.cs
- Visitor.cs
- LocalizableAttribute.cs
- ExtendedTransformFactory.cs
- EnumValAlphaComparer.cs
- StateDesigner.cs
- Compiler.cs
- SqlCacheDependencyDatabaseCollection.cs
- Clipboard.cs
- DataGridViewCellConverter.cs
- KeyEvent.cs
- TypeBuilder.cs
- QilNode.cs
- CustomGrammar.cs
- CustomErrorsSection.cs
- HtmlWindow.cs
- GridItemPattern.cs
- Help.cs
- DbConnectionClosed.cs
- WebPartHeaderCloseVerb.cs
- COM2ExtendedTypeConverter.cs
- XLinq.cs
- _ListenerResponseStream.cs
- ImplicitInputBrush.cs
- TailCallAnalyzer.cs
- PlainXmlWriter.cs
- VBCodeProvider.cs
- XmlTextAttribute.cs
- LogExtentCollection.cs
- TargetInvocationException.cs
- CurrentChangingEventArgs.cs
- DataObject.cs
- GridSplitterAutomationPeer.cs
- GridPattern.cs
- TypeProvider.cs
- GradientStopCollection.cs
- DataGridViewTopRowAccessibleObject.cs
- ToolStripItemBehavior.cs
- VerticalAlignConverter.cs
- HScrollBar.cs
- CompositionAdorner.cs
- EnumBuilder.cs
- MenuItemBindingCollection.cs
- CodeAttributeArgument.cs
- RelationshipDetailsRow.cs
- PropertySourceInfo.cs
- KerberosSecurityTokenParameters.cs
- BezierSegment.cs
- DBParameter.cs
- ZoneButton.cs
- HelpOperationInvoker.cs
- XmlSchemaInfo.cs
- PersistChildrenAttribute.cs
- SafeProcessHandle.cs
- XmlAttributeOverrides.cs
- WebPartAddingEventArgs.cs
- TextTrailingCharacterEllipsis.cs
- TemplateModeChangedEventArgs.cs