Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / FixedHyperLink.cs / 1305600 / FixedHyperLink.cs
//---------------------------------------------------------------------------- //// Copyright (C) 2004 by Microsoft Corporation. All rights reserved. // // // Description: // Implements the help class of FixedHyperLink. // // History: // 02/04/2005 - Ming Liu(MingLiu) - Created. // // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Windows.Threading; using System.Windows.Markup; using System.Windows.Navigation; using System.Windows.Media; ////// The IFixedNavigate interface will be implemented by FixedPage, FixedDocument, /// and FixedDocumentSequence to support fixed hyperlink. /// internal interface IFixedNavigate { ////// Find the element which given ID in this document context. /// /// The ID of UIElement to search for /// The fixedPage that contains returns UIElement ///UIElement FindElementByID(string elementID, out FixedPage rootFixedPage); /// /// Navigate to the element with ID= elementID /// /// void NavigateAsync (string elementID); } internal static class FixedHyperLink { ////// NavigationService property ChangedCallback. /// public static void OnNavigationServiceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FixedDocument fixedContent = d as FixedDocument; if (fixedContent != null) { NavigationService oldService = (NavigationService) e.OldValue; NavigationService newService = (NavigationService) e.NewValue; if (oldService != null) { oldService.FragmentNavigation -= new FragmentNavigationEventHandler(FragmentHandler); } if (newService != null) { newService.FragmentNavigation += new FragmentNavigationEventHandler(FragmentHandler); } } } ////// Called by NavigationService to let document content to handle the fragment first. /// /// /// internal static void FragmentHandler(object sender, FragmentNavigationEventArgs e) { NavigationService ns = sender as NavigationService; if (ns != null) { string fragment = e.Fragment; IFixedNavigate fixedNavigate = ns.Content as IFixedNavigate; if (fixedNavigate != null) { fixedNavigate.NavigateAsync(e.Fragment); e.Handled = true; } } } ////// Fire BringinToView event on the element ID. /// /// The host document of element ID, call any one implents IFixedNavigate /// internal static void NavigateToElement(object ElementHost, string elementID) { FixedPage rootFixedPage = null; FrameworkElement targetElement = null; targetElement = ((IFixedNavigate)ElementHost).FindElementByID(elementID, out rootFixedPage) as FrameworkElement; if (targetElement != null) { if (targetElement is FixedPage) { // // For fixedpage, we only need to scroll to page position. // targetElement.BringIntoView(); } else { //Just passing in raw rect of targetElement. Let DocumentViewer/Grid handle transforms targetElement.BringIntoView(targetElement.VisualContentBounds); } } return; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- //// Copyright (C) 2004 by Microsoft Corporation. All rights reserved. // // // Description: // Implements the help class of FixedHyperLink. // // History: // 02/04/2005 - Ming Liu(MingLiu) - Created. // // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Windows.Threading; using System.Windows.Markup; using System.Windows.Navigation; using System.Windows.Media; ////// The IFixedNavigate interface will be implemented by FixedPage, FixedDocument, /// and FixedDocumentSequence to support fixed hyperlink. /// internal interface IFixedNavigate { ////// Find the element which given ID in this document context. /// /// The ID of UIElement to search for /// The fixedPage that contains returns UIElement ///UIElement FindElementByID(string elementID, out FixedPage rootFixedPage); /// /// Navigate to the element with ID= elementID /// /// void NavigateAsync (string elementID); } internal static class FixedHyperLink { ////// NavigationService property ChangedCallback. /// public static void OnNavigationServiceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FixedDocument fixedContent = d as FixedDocument; if (fixedContent != null) { NavigationService oldService = (NavigationService) e.OldValue; NavigationService newService = (NavigationService) e.NewValue; if (oldService != null) { oldService.FragmentNavigation -= new FragmentNavigationEventHandler(FragmentHandler); } if (newService != null) { newService.FragmentNavigation += new FragmentNavigationEventHandler(FragmentHandler); } } } ////// Called by NavigationService to let document content to handle the fragment first. /// /// /// internal static void FragmentHandler(object sender, FragmentNavigationEventArgs e) { NavigationService ns = sender as NavigationService; if (ns != null) { string fragment = e.Fragment; IFixedNavigate fixedNavigate = ns.Content as IFixedNavigate; if (fixedNavigate != null) { fixedNavigate.NavigateAsync(e.Fragment); e.Handled = true; } } } ////// Fire BringinToView event on the element ID. /// /// The host document of element ID, call any one implents IFixedNavigate /// internal static void NavigateToElement(object ElementHost, string elementID) { FixedPage rootFixedPage = null; FrameworkElement targetElement = null; targetElement = ((IFixedNavigate)ElementHost).FindElementByID(elementID, out rootFixedPage) as FrameworkElement; if (targetElement != null) { if (targetElement is FixedPage) { // // For fixedpage, we only need to scroll to page position. // targetElement.BringIntoView(); } else { //Just passing in raw rect of targetElement. Let DocumentViewer/Grid handle transforms targetElement.BringIntoView(targetElement.VisualContentBounds); } } return; } } } // 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
- TextEffect.cs
- PersonalizationState.cs
- ControlPaint.cs
- FontStretches.cs
- BaseParser.cs
- _OverlappedAsyncResult.cs
- XamlStream.cs
- ByteStreamGeometryContext.cs
- TransformProviderWrapper.cs
- EndpointDispatcher.cs
- Line.cs
- EntityDataSourceView.cs
- SoapProcessingBehavior.cs
- NegationPusher.cs
- SecurityKeyIdentifierClause.cs
- Options.cs
- SerializerDescriptor.cs
- TextElementEnumerator.cs
- DataSourceComponent.cs
- FixedHighlight.cs
- ThreadInterruptedException.cs
- ExpressionNode.cs
- ColorAnimationUsingKeyFrames.cs
- SizeLimitedCache.cs
- CustomTypeDescriptor.cs
- FolderBrowserDialog.cs
- DoubleCollection.cs
- InfoCardConstants.cs
- ToggleButton.cs
- IndicCharClassifier.cs
- WebControl.cs
- FileStream.cs
- PixelShader.cs
- UnsafeNativeMethods.cs
- Exception.cs
- ModelUIElement3D.cs
- DbConnectionPool.cs
- AnimationClockResource.cs
- ValidatedControlConverter.cs
- EventArgs.cs
- SubclassTypeValidatorAttribute.cs
- CodeDOMUtility.cs
- XmlJsonWriter.cs
- GatewayDefinition.cs
- TextTreePropertyUndoUnit.cs
- ClientSession.cs
- DockPanel.cs
- SmtpAuthenticationManager.cs
- ObjectListItem.cs
- XmlObjectSerializerReadContextComplexJson.cs
- ProviderCommandInfoUtils.cs
- DataGridAutoFormatDialog.cs
- SqlDependencyListener.cs
- PrimitiveSchema.cs
- OverflowException.cs
- base64Transforms.cs
- LowerCaseStringConverter.cs
- BinaryKeyIdentifierClause.cs
- BinaryOperationBinder.cs
- OdbcHandle.cs
- SafePointer.cs
- StatusBar.cs
- SaveFileDialog.cs
- GrammarBuilderWildcard.cs
- SelectionEditor.cs
- ContextMenuService.cs
- Int16Animation.cs
- ObjectListItemCollection.cs
- FixUpCollection.cs
- Console.cs
- CriticalExceptions.cs
- LinqDataSourceValidationException.cs
- _LocalDataStoreMgr.cs
- FillBehavior.cs
- MethodSignatureGenerator.cs
- SqlClientWrapperSmiStream.cs
- LogFlushAsyncResult.cs
- TraceHandler.cs
- UserPreferenceChangedEventArgs.cs
- ButtonChrome.cs
- Rotation3DAnimation.cs
- PointF.cs
- QuotedPrintableStream.cs
- EncoderBestFitFallback.cs
- HScrollBar.cs
- ContextActivityUtils.cs
- AnimationClockResource.cs
- GeneralTransform3DTo2D.cs
- MailHeaderInfo.cs
- DetailsViewModeEventArgs.cs
- BamlRecordHelper.cs
- SponsorHelper.cs
- KeyConstraint.cs
- FontFamily.cs
- PageParserFilter.cs
- RunWorkerCompletedEventArgs.cs
- UDPClient.cs
- MDIControlStrip.cs
- TemplateNameScope.cs
- ScrollChangedEventArgs.cs