private void LoadState(object node)
		{
			UIElement uielement = node as UIElement;
			if (uielement == null)
			{
				return;
			}
			int persistId = uielement.PersistId;
			if (persistId != 0)
			{
				if (this.HasSubStreams(persistId))
				{
					ArrayList subStreams = this.GetSubStreams(persistId);
					this.LoadSubStreams(uielement, subStreams);
				}
				if (this._customJournaledObjects != null && this._customJournaledObjects.Contains(persistId))
				{
					CustomJournalStateInternal state = (CustomJournalStateInternal)this._customJournaledObjects[persistId];
					IJournalState journalState = node as IJournalState;
					if (journalState != null)
					{
						journalState.RestoreJournalState(state);
					}
				}
			}
		}
		// Token: 0x06007B5F RID: 31583 RVA: 0x0022B25C File Offset: 0x0022945C
		internal void PrepareForSerialization()
		{
			if (this._customJournaledObjects != null)
			{
				foreach (object obj in this._customJournaledObjects)
				{
					CustomJournalStateInternal customJournalStateInternal = (CustomJournalStateInternal)((DictionaryEntry)obj).Value;
					customJournalStateInternal.PrepareForSerialization();
				}
			}
		}
Ejemplo n.º 3
0
        internal void PrepareForSerialization()
        {
            if (_customJournaledObjects != null)
            {
                foreach (DictionaryEntry entry in _customJournaledObjects)
                {
                    CustomJournalStateInternal cjs = (CustomJournalStateInternal)entry.Value;
                    cjs.PrepareForSerialization();
                }
            }

            // Everything in _subStreams is already binary-serialized.
        }
Ejemplo n.º 4
0
        private void LoadState(object node)
        {
            UIElement element = node as UIElement;

            if (element == null)
            {
                return;
            }

#pragma warning disable 618
            int persistId = element.PersistId;
#pragma warning restore 618

            // Due to
            if (persistId != 0)
            {
                if (this.HasSubStreams(persistId))
                {
                    // Get the properties to restore
                    ArrayList properties = this.GetSubStreams(persistId);
                    LoadSubStreams(element, properties);
                }

                if (_customJournaledObjects != null && _customJournaledObjects.Contains(persistId))
                {
                    CustomJournalStateInternal state =
                        (CustomJournalStateInternal)_customJournaledObjects[persistId];
                    Debug.Assert(state != null);
                    IJournalState customJournalingObject = node as IJournalState;

                    //
                    // For below two scenarios, JournalData cannot be restored successfully. For now, we just
                    // simply ignore it and don't throw exception.
                    //
                    //  A. After the tree was created from xaml/baml stream,  some elements might be replaced
                    //     programatically with new elements which could be created from other xaml/baml by Parser.
                    //
                    //  B. If the loose xaml file has been changed since the journal data was created
                    //
                    //

                    if (customJournalingObject != null)
                    {
                        customJournalingObject.RestoreJournalState(state);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        void IJournalState.RestoreJournalState(CustomJournalStateInternal cjs)
        {
            FramePersistState state = (FramePersistState)cjs;

            _navigationService.GuidId = state.NavSvcGuid;

            // Because the JournalOwnershipProperty doesn't have the FrameworkPropertyMetadataOptions.Journal
            // flag, the parser will always set the value specified in markup, which may be different from
            // state.JournalOwnership. So, at this point JournalOwnership is not necessarily Automatic
            // (the default).
            JournalOwnership = state.JournalOwnership;
            if(_journalOwnership == JournalOwnership.OwnsJournal)
            {
                Invariant.Assert(state.Journal != null);
                _ownJournalScope.Journal = state.Journal;
            }

            if(state.JournalEntry != null)
            {
                state.JournalEntry.Navigate(this, NavigationMode.Back);
            }
        }
 /// <summary>
 /// <see cref="IJournalState.RestoreJournalState"/>
 /// </summary>
 void IJournalState.RestoreJournalState(CustomJournalStateInternal state)
 {
     JournalState viewerState = state as JournalState;
     if (state != null)
     {
         SetCurrentValueInternal(ZoomProperty, viewerState.Zoom);
         if (viewerState.ContentPosition != -1)
         {
             FlowDocument document = Document as FlowDocument;
             if (document != null)
             {
                 TextContainer textContainer = document.StructuralCache.TextContainer;
                 if (viewerState.ContentPosition <= textContainer.SymbolCount)
                 {
                     TextPointer contentPosition = textContainer.CreatePointerAtOffset(viewerState.ContentPosition, viewerState.ContentPositionDirection);
                     // This need be called because the UI may not be ready when Contentposition is set.
                     Dispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(BringContentPositionIntoView), contentPosition);
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 private bool RestoreRootViewerState(CustomJournalStateInternal rvs)
 {
     Debug.Assert(!(_bp is Visual));
     Visual v = _navigatorHostImpl.FindRootViewer();
     if (v == null)
         return false; // Template may not be applied yet.
     IJournalState ijs = v as IJournalState;
     if (ijs != null)
     {
         ijs.RestoreJournalState(rvs);
     }
     //else: maybe type of viewer changed. Still returning true so that restoring state
     //  is not reattempted in this case.
     return true;
 }
Ejemplo n.º 8
0
 /// <summary> 
 /// <see cref="IJournalState.RestoreJournalState"/> 
 /// </summary>
 void IJournalState.RestoreJournalState(CustomJournalStateInternal state) 
 {
     JournalState viewerState = state as JournalState;
     if (state != null)
     { 
         SetCurrentValueInternal(ZoomProperty, viewerState.Zoom);
         SetCurrentValueInternal(ViewingModeProperty, viewerState.ViewingMode); 
         if (viewerState.ContentPosition != -1) 
         {
             IFlowDocumentViewer viewer = CurrentViewer; 
             FlowDocument document = Document;
             if (viewer != null && document != null)
             {
                 TextContainer textContainer = document.StructuralCache.TextContainer; 
                 if (viewerState.ContentPosition <= textContainer.SymbolCount)
                 { 
                     TextPointer contentPosition = textContainer.CreatePointerAtOffset(viewerState.ContentPosition, viewerState.ContentPositionDirection); 
                     viewer.ContentPosition = contentPosition;
                 } 
             }
         }
     }
 }