Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Framework / MS / Internal / documents / Application / DocumentApplicationJournalEntry.cs / 1 / DocumentApplicationJournalEntry.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: Attached to custom journal entries created for changes in the DocumentApplication's
// UI state.
//
// History:
// 06/24/2005 - JeremyNS created
//
//---------------------------------------------------------------------------
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Controls;
namespace MS.Internal.Documents.Application
{
///
/// DocumentApplicationJournalEntry is not a real journal entry, just the CustomContentState
/// attached to one. It wraps a DocumentApplicationState object, which is the actual view state.
/// The split is needed because PresentationUI cannot access internal Framework classes and methods.
///
[Serializable]
internal sealed class DocumentApplicationJournalEntry : System.Windows.Navigation.CustomContentState
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Constructs a DocumentApplicationJournalEntry
///
/// State of the DocumentApplication to journal
/// Name of the journal entry to display in the UI.
/// If this is null it will default to the URI source.
public DocumentApplicationJournalEntry(object state, string name)
{
Invariant.Assert(state is DocumentApplicationState,
"state should be of type DocumentApplicationState");
// Store parameters locally.
_state = state;
_displayName = name;
}
public DocumentApplicationJournalEntry(object state):
this(state, null)
{
}
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Used to reset the UI to state of this entry
///
/// NavigationService currently running
/// Navigation direction
///
/// Critical: set_StoredDocumentApplicationState is defined in a non-APTCA assembly.
/// TreatAsSafe: call to set_StoredDocumentApplicationState does not entail any risk.
///
[SecurityCritical, SecurityTreatAsSafe]
public override void Replay(NavigationService navigationService, NavigationMode mode)
{
ContentControl navigator = (ContentControl)navigationService.INavigatorHost;
// Find a reference to the DocumentViewer hosted in the NavigationWindow
// On initial history navigation in the browser, the window's layout may not have been
// done yet. ApplyTemplate() causes the viewer to be created.
navigator.ApplyTemplate();
DocumentApplicationDocumentViewer docViewer = navigator.Template.FindName(
"PUIDocumentApplicationDocumentViewer", navigator)
as DocumentApplicationDocumentViewer;
Debug.Assert(docViewer != null, "PUIDocumentApplicationDocumentViewer not found.");
if (docViewer != null)
{
// Set the new state on the DocumentViewer
if (_state is DocumentApplicationState)
{
docViewer.StoredDocumentApplicationState = (DocumentApplicationState)_state;
}
// Check that a Document exists.
if (navigationService.Content != null)
{
IDocumentPaginatorSource document = navigationService.Content as IDocumentPaginatorSource;
// If the document has already been paginated (could happen in the
// case of a fragment navigation), then set the DocumentViewer to the
// new state that was set.
if ((document != null) && (document.DocumentPaginator.IsPageCountValid))
{
docViewer.SetUIToStoredState();
}
}
}
}
public override string JournalEntryName
{
get { return _displayName; }
}
//------------------------------------------------------
//
// Private Fields.
//
//------------------------------------------------------
// The DocumentApplicationState has been weakly-typed to avoid PresentationFramework
// having a type dependency on PresentationUI. The perf impact of the weak
// typed variables in this case was determined to be much less than forcing the load
// of a new assembly when Assembly.GetTypes was called on PresentationFramework.
private object _state; // DocumentApplicationState
private string _displayName;
}
}
// 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: Attached to custom journal entries created for changes in the DocumentApplication's
// UI state.
//
// History:
// 06/24/2005 - JeremyNS created
//
//---------------------------------------------------------------------------
using System;
using System.Runtime.Serialization;
using System.Security;
using System.Security.Permissions;
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Controls;
namespace MS.Internal.Documents.Application
{
///
/// DocumentApplicationJournalEntry is not a real journal entry, just the CustomContentState
/// attached to one. It wraps a DocumentApplicationState object, which is the actual view state.
/// The split is needed because PresentationUI cannot access internal Framework classes and methods.
///
[Serializable]
internal sealed class DocumentApplicationJournalEntry : System.Windows.Navigation.CustomContentState
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
///
/// Constructs a DocumentApplicationJournalEntry
///
/// State of the DocumentApplication to journal
/// Name of the journal entry to display in the UI.
/// If this is null it will default to the URI source.
public DocumentApplicationJournalEntry(object state, string name)
{
Invariant.Assert(state is DocumentApplicationState,
"state should be of type DocumentApplicationState");
// Store parameters locally.
_state = state;
_displayName = name;
}
public DocumentApplicationJournalEntry(object state):
this(state, null)
{
}
//------------------------------------------------------
//
// Public Methods
//
//-----------------------------------------------------
///
/// Used to reset the UI to state of this entry
///
/// NavigationService currently running
/// Navigation direction
///
/// Critical: set_StoredDocumentApplicationState is defined in a non-APTCA assembly.
/// TreatAsSafe: call to set_StoredDocumentApplicationState does not entail any risk.
///
[SecurityCritical, SecurityTreatAsSafe]
public override void Replay(NavigationService navigationService, NavigationMode mode)
{
ContentControl navigator = (ContentControl)navigationService.INavigatorHost;
// Find a reference to the DocumentViewer hosted in the NavigationWindow
// On initial history navigation in the browser, the window's layout may not have been
// done yet. ApplyTemplate() causes the viewer to be created.
navigator.ApplyTemplate();
DocumentApplicationDocumentViewer docViewer = navigator.Template.FindName(
"PUIDocumentApplicationDocumentViewer", navigator)
as DocumentApplicationDocumentViewer;
Debug.Assert(docViewer != null, "PUIDocumentApplicationDocumentViewer not found.");
if (docViewer != null)
{
// Set the new state on the DocumentViewer
if (_state is DocumentApplicationState)
{
docViewer.StoredDocumentApplicationState = (DocumentApplicationState)_state;
}
// Check that a Document exists.
if (navigationService.Content != null)
{
IDocumentPaginatorSource document = navigationService.Content as IDocumentPaginatorSource;
// If the document has already been paginated (could happen in the
// case of a fragment navigation), then set the DocumentViewer to the
// new state that was set.
if ((document != null) && (document.DocumentPaginator.IsPageCountValid))
{
docViewer.SetUIToStoredState();
}
}
}
}
public override string JournalEntryName
{
get { return _displayName; }
}
//------------------------------------------------------
//
// Private Fields.
//
//------------------------------------------------------
// The DocumentApplicationState has been weakly-typed to avoid PresentationFramework
// having a type dependency on PresentationUI. The perf impact of the weak
// typed variables in this case was determined to be much less than forcing the load
// of a new assembly when Assembly.GetTypes was called on PresentationFramework.
private object _state; // DocumentApplicationState
private string _displayName;
}
}
// 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
- Container.cs
- TextParentUndoUnit.cs
- MetadataItem.cs
- EventLogEntry.cs
- InputLangChangeEvent.cs
- MetaChildrenColumn.cs
- ModuleBuilderData.cs
- GroupItem.cs
- Type.cs
- ThemeDirectoryCompiler.cs
- DoubleAnimationUsingPath.cs
- TraceUtility.cs
- NamespaceInfo.cs
- AsymmetricKeyExchangeDeformatter.cs
- MapPathBasedVirtualPathProvider.cs
- ScrollContentPresenter.cs
- DetailsViewDesigner.cs
- ExtensionDataReader.cs
- SymmetricAlgorithm.cs
- TextTreeRootTextBlock.cs
- EncodingNLS.cs
- ChtmlFormAdapter.cs
- RangeExpression.cs
- SourceLineInfo.cs
- WindowsListViewItemStartMenu.cs
- DbConnectionInternal.cs
- ProviderBase.cs
- DataGridViewComboBoxColumn.cs
- ThreadExceptionEvent.cs
- Gdiplus.cs
- WebServicesSection.cs
- AdPostCacheSubstitution.cs
- WinInet.cs
- DataListItem.cs
- SettingsContext.cs
- SingleBodyParameterMessageFormatter.cs
- StringFunctions.cs
- SiblingIterators.cs
- FontStretch.cs
- DataGridViewColumnHeaderCell.cs
- SchemaImporterExtension.cs
- SingleAnimationUsingKeyFrames.cs
- HttpGetProtocolReflector.cs
- NamespaceDecl.cs
- ListDependantCardsRequest.cs
- InvalidateEvent.cs
- WebPartCloseVerb.cs
- ErrorWebPart.cs
- xdrvalidator.cs
- Operator.cs
- ProtocolsConfigurationEntry.cs
- Canonicalizers.cs
- SoapAttributeOverrides.cs
- ProxyGenerationError.cs
- DocumentViewerBaseAutomationPeer.cs
- SqlDesignerDataSourceView.cs
- Int16KeyFrameCollection.cs
- NetworkInterface.cs
- RoleManagerEventArgs.cs
- DataControlHelper.cs
- FileChangesMonitor.cs
- DataGridViewColumnCollection.cs
- BaseCodeDomTreeGenerator.cs
- DataControlHelper.cs
- DbConnectionInternal.cs
- TextEmbeddedObject.cs
- InkCanvasAutomationPeer.cs
- SoapParser.cs
- EdmMember.cs
- RuntimeConfigLKG.cs
- AssemblyName.cs
- EdgeProfileValidation.cs
- Stack.cs
- MULTI_QI.cs
- UnmanagedHandle.cs
- PageEventArgs.cs
- StylusPointProperties.cs
- FtpCachePolicyElement.cs
- ValidatingReaderNodeData.cs
- OracleString.cs
- SqlTransaction.cs
- ApplicationInfo.cs
- TraceContextRecord.cs
- UserControlCodeDomTreeGenerator.cs
- NullableIntMinMaxAggregationOperator.cs
- SmtpFailedRecipientException.cs
- MergeEnumerator.cs
- ToolStripRenderEventArgs.cs
- TemplateKey.cs
- AnnotationAdorner.cs
- DependencyObject.cs
- DaylightTime.cs
- Pair.cs
- StrongNameUtility.cs
- ResourceWriter.cs
- XmlWriterDelegator.cs
- Int16.cs
- ConfigXmlElement.cs
- UnsafeNativeMethodsPenimc.cs
- SafeRightsManagementEnvironmentHandle.cs