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 / FixedHyperLink.cs / 1 / 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 
        ///  
        /// 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 
        ///  
        /// 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
- GZipDecoder.cs
- ExtensibleClassFactory.cs
- SystemException.cs
- OleDbRowUpdatedEvent.cs
- ZipIOExtraFieldElement.cs
- JsonEncodingStreamWrapper.cs
- ScriptControlDescriptor.cs
- ScrollContentPresenter.cs
- DataGrid.cs
- OpenTypeLayout.cs
- CodePrimitiveExpression.cs
- DBAsyncResult.cs
- NotSupportedException.cs
- FixedSOMTable.cs
- AudioException.cs
- figurelength.cs
- EntityStoreSchemaGenerator.cs
- XPathDocumentIterator.cs
- PaginationProgressEventArgs.cs
- Exception.cs
- DecoderReplacementFallback.cs
- Quad.cs
- DataGridViewTextBoxCell.cs
- EntityReference.cs
- SettingsPropertyCollection.cs
- RightNameExpirationInfoPair.cs
- TypeToStringValueConverter.cs
- MultipleViewPatternIdentifiers.cs
- ToolStripMenuItem.cs
- SmtpNtlmAuthenticationModule.cs
- NativeActivityAbortContext.cs
- HttpException.cs
- FileCodeGroup.cs
- Subset.cs
- NamedPipeTransportSecurity.cs
- PrtCap_Builder.cs
- EmbeddedObject.cs
- PolyBezierSegmentFigureLogic.cs
- CellIdBoolean.cs
- ImageInfo.cs
- MailMessageEventArgs.cs
- TransactionScopeDesigner.cs
- MissingSatelliteAssemblyException.cs
- Transaction.cs
- StaticResourceExtension.cs
- Logging.cs
- ProfileGroupSettingsCollection.cs
- TrackingMemoryStream.cs
- SiteMapNodeItem.cs
- MeasurementDCInfo.cs
- DeadLetterQueue.cs
- Parsers.cs
- WorkflowOwnershipException.cs
- UriTemplateTrieLocation.cs
- TrackingServices.cs
- DataTemplateKey.cs
- DataPagerFieldCollection.cs
- TemplatePartAttribute.cs
- MarkupCompiler.cs
- ParseHttpDate.cs
- SystemMulticastIPAddressInformation.cs
- Misc.cs
- ByteConverter.cs
- HttpCachePolicyElement.cs
- SQLByte.cs
- ListItemCollection.cs
- VersionedStreamOwner.cs
- AsyncParams.cs
- DockProviderWrapper.cs
- ManagementObject.cs
- TailPinnedEventArgs.cs
- XmlSchemaImport.cs
- IgnoreDeviceFilterElement.cs
- CodeExpressionCollection.cs
- Globals.cs
- TitleStyle.cs
- NavigateUrlConverter.cs
- TimeSpan.cs
- SingleStorage.cs
- ThemeConfigurationDialog.cs
- GlyphCache.cs
- SRef.cs
- GridViewUpdatedEventArgs.cs
- MsmqBindingMonitor.cs
- WindowsImpersonationContext.cs
- SerializationEventsCache.cs
- DataGridViewRowCollection.cs
- MultitargetingHelpers.cs
- TraceHandlerErrorFormatter.cs
- UIElement3DAutomationPeer.cs
- XmlSerializationReader.cs
- Transform3D.cs
- BaseResourcesBuildProvider.cs
- CodeEventReferenceExpression.cs
- ToolStripMenuItem.cs
- InputLanguageEventArgs.cs
- ConnectionConsumerAttribute.cs
- Lasso.cs
- PerfCounterSection.cs
- FieldBuilder.cs