public void openEditEntry(JournalEntry editEntry) { //open window var window = new ConnectWindow { Owner = this }; window.LoadEntry(editEntry); window.ShowDialog(); }
/// <summary> /// Navigates the Journal instance forward to the next /// JournalEntry item in the history stack. /// </summary> /// <remarks> /// If CanGoForward is false, this method will throw an InvalidOperationException. /// </remarks> internal void GoForward() { if (this.CanGoForward == false) { throw new InvalidOperationException( string.Format(CultureInfo.InvariantCulture, Resource.CannotGoForward, "CanGoForward")); } lock (this._syncLock) { this._backStack.Push(this._currentEntry); this._currentEntry = this._forwardStack.Pop(); } this.UpdateObservables(this._currentEntry, NavigationMode.Forward); this.UpdateNavigationState(this.CurrentEntry); }
public void reWriteEntry(JournalEntry newVersion) { int newVerstionID = newVersion.Id; //declare varible for oldversion JournalEntry OldVersion = null; //Locate old Version foreach (var entry in currentJournal.Entries) { if(entry.Id == newVerstionID) { OldVersion = newVersion; break; } //Resave New Version if(OldVersion != null) { //Remove Old Version currentJournal.Entries.RemoveAt(newVerstionID); currentJournal.Entries.Add(OldVersion); //Find location of newly modified entry int modifiedEntry = currentJournal.Entries.Count; //Move modified entry to previous location currentJournal.Entries.Move(modifiedEntry, newVerstionID); } } //Refresh Grid dataGrid_JournalEntries.ItemsSource = null; dataGrid_JournalEntries.ItemsSource = currentJournal.Entries; }
private void CompleteNavigation(DependencyObject content) { Uri uri = null; string pageTitle = null; Page existingContentPage = this._host.Content as Page; Page newContentPage = content as Page; pageTitle = JournalEntry.GetName(content ?? this._host.Content as DependencyObject); NavigationOperation navOp = this._currentNavigation; this._currentNavigation = null; if (navOp != null) { // Set uri uri = navOp.UriBeforeMapping; this.UpdateNavigationCacheModeAlwaysPages(); // Used to suppress navigation notifications. navOp.SuppressNotifications = true; this.CurrentSource = navOp.UriForJournal; this._source = navOp.UriBeforeMapping; this._currentSourceAfterMapping = navOp.Uri; this.Host.UpdateSourceFromNavigationService(navOp.UriForJournal); this.Host.CurrentSource = this.CurrentSource; // Check if this is a 'New' operation if (navOp.Mode == NavigationMode.New && navOp.Uri != null && navOp.SuppressJournalAdd == false) { try { this._journalIsAddingHistoryPoint = true; JournalEntry je = new JournalEntry(pageTitle ?? uri.OriginalString, navOp.UriForJournal); this.Journal.AddHistoryPoint(je); } finally { this._journalIsAddingHistoryPoint = false; } } this.Host.CanGoBack = this.CanGoBack; this.Host.CanGoForward = this.CanGoForward; navOp.SuppressNotifications = false; } if (this.Journal.UseNavigationState && HtmlPage.IsEnabled) { HtmlPage.Document.SetProperty("title", pageTitle ?? uri.OriginalString); } if (content == null) { // We're navigating to a fragment in the current page, so for WPF compatibility, fire FragmentNavigation THEN Navigated this.RaiseFragmentNavigation(UriParsingHelper.InternalUriGetFragment(navOp.Uri)); this.RaiseNavigated(content, uri, existingContentPage, newContentPage); } else { // We're navigating to a fragment in the new content, so let the host load content, then for WPF compatibility, // fire Navigated THEN FragmentNavigation this.Host.Content = content; this.RaiseNavigated(content, uri, existingContentPage, newContentPage); string fragment = UriParsingHelper.InternalUriGetFragment(navOp.Uri); if (!String.IsNullOrEmpty(fragment)) { this.RaiseFragmentNavigation(fragment); } } }
internal bool NavigateToEntry(JournalEntry entry) { if (entry == null) { Debug.Fail("Tried to navigate to a null JournalEntry."); return false; } if (!Journal.IsNavigable(entry)) { Debug.Fail("Tried to navigate to a non-navigable journal entry."); return false; } NavigationService navigationService = _rootNavSvc.FindTarget(entry.NavigationServiceId); Debug.Assert(navigationService != null, "NavigationService cannot be null for journal navigations"); NavigationMode mode = Journal.GetNavigationMode(entry); bool navigated = false; try { navigated = entry.Navigate(navigationService.INavigatorHost, mode); } finally { if (!navigated) { AbortJournalNavigation(); } } return navigated; }
internal NavigateInfo(Uri source, NavigationMode navigationMode, JournalEntry journalEntry) { _source = source; _navigationMode = navigationMode; _journalEntry = journalEntry; }
// Token: 0x060028DA RID: 10458 RVA: 0x000BD669 File Offset: 0x000BB869 internal void CommitJournalNavigation(JournalEntry navigated) { this.NavigateTo(navigated); }
private void ContentLoader_BeginLoad_Callback(IAsyncResult result) { DependencyObject content = null; Uri uriBeingLoaded = null; try { NavigationOperation asyncNavigationOperationCompleted = result.AsyncState as NavigationOperation; NavigationOperation navOp = this._currentNavigation; if (navOp == null || navOp.Uri != asyncNavigationOperationCompleted.Uri) { // We already fired NavigationStopped in NavigateCore(), so just return without doing anything return; } uriBeingLoaded = navOp.UriBeforeMapping; LoadResult loadResult = this._contentLoader.EndLoad(result); if (loadResult == null) { throw new InvalidOperationException(String.Format(Resource.NavigationService_InvalidLoadResult, "LoadResult", this._contentLoader.GetType())); } else if (loadResult.RedirectUri != null) { // If we get a Redirect, navigate again without storing any context this.NavigateCore(loadResult.RedirectUri, NavigationMode.New, false /*suppressJournalAdd*/, true /*isRedirect*/); } else { content = loadResult.LoadedContent as DependencyObject; // If the content is anything but a UserControl, we should throw. // We support UserControls as they are a typical thing created in designers such as Blend, // but for a full experience one would use Page to get to things like NavigationContext, // NavigationService, Title, etc. if (!(content is UserControl)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Resource.NavigationService_ContentIsNotAUserControl, content == null ? "null" : content.GetType().ToString(), "System.Windows.Controls.UserControl")); } // Content loader was successful, so complete navigation // Create a new navigation context JournalEntry.SetNavigationContext(content, new NavigationContext(UriParsingHelper.InternalUriParseQueryStringToDictionary(asyncNavigationOperationCompleted.Uri, true /* decodeResults */))); content.SetValue(NavigationServiceProperty, this); // Complete navigation operation this.CompleteNavigation(content); } } catch (Exception ex) { if (this.RaiseNavigationFailed(uriBeingLoaded, ex)) { throw; } } }
/// <summary> /// Ensures current data about the current page is stored in the journal. /// This either updates an existing entry or adds a new one. /// </summary> /// <param name="journalEntry"></param> internal void UpdateCurrentEntry(JournalEntry journalEntry) { if (journalEntry == null) { throw new ArgumentNullException("journalEntry"); } Debug.Assert(journalEntry.ContentId != 0); Debug.Assert(!(journalEntry.IsAlive() && journalEntry.JEGroupState.JournalDataStreams != null), "Keep-alive content state should not be serialized."); if (_currentEntryIndex > -1 && _currentEntryIndex < TotalCount) { // update existing entry using the old entry's index. // Note: the new entry can be for a different NavigationService. JournalEntry oldEntry = _journalEntryList[_currentEntryIndex]; journalEntry.Id = oldEntry.Id; _journalEntryList[_currentEntryIndex] = journalEntry; } else { // add new entry to the front journalEntry.Id = ++_journalEntryId; _journalEntryList.Add(journalEntry); } _version++; // If the next navigation is not #fragment or CustomContentState, this entry should be // remembered as the "exit" entry for the group, so when navigating back to the same // page, it will be shown. (It is not necessarily the last one in the group.) // Journal filtering will hide all other entries while at another page (different // NavigationService.Content object). journalEntry.JEGroupState.GroupExitEntry = journalEntry; }
/// <summary> /// Updates NavigationState to reflect the Journal state, if the Journal is using NavigationState. /// </summary> /// <param name="journalEntry">JournalEntry used to update the browser location.</param> private void UpdateNavigationState(JournalEntry journalEntry) { if (this.UseNavigationState) { if (this._suppressNavigationEvent == false) { string state = journalEntry.Source == null ? string.Empty : UriParsingHelper.InternalUriToExternalValue(journalEntry.Source); Application.Current.Host.NavigationState = state; if (HtmlPage.IsEnabled) { HtmlPage.Document.SetProperty("title", journalEntry.Name); } } } }
private static int JournalEntryCompare(JournalEntry a, JournalEntry b) { return b.Date.CompareTo(a.Date); }
// Token: 0x060029FF RID: 10751 RVA: 0x000C1A81 File Offset: 0x000BFC81 internal PageFunctionReturnInfo(PageFunctionBase finishingChildPageFunction, Uri source, NavigationMode navigationMode, JournalEntry journalEntry, object returnEventArgs) : base(source, navigationMode, journalEntry) { this._returnEventArgs = returnEventArgs; this._finishingChildPageFunction = finishingChildPageFunction; }
//Methods private void button_Click(object sender, RoutedEventArgs e) { //Varibles string title = textBox_Title.Text; string entry = textBox_Entry.Text; DateTime currentDate = DateTime.Now; JournalEntry newEntry = new JournalEntry(); newEntry.Id = currentJournal.Entries.Count + 1; newEntry.Title = title; newEntry.Entry = entry; newEntry.EntryDate = currentDate; currentJournal.Entries.Add(newEntry); textBox_Title.Text = String.Empty; textBox_Entry.Text = String.Empty; }
/// <summary> /// Updates NavigationState to reflect the Journal state, if the Journal is using NavigationState. /// </summary> /// <param name="journalEntry">JournalEntry used to update the browser location.</param> private void UpdateNavigationState(JournalEntry journalEntry) { if (this.UseNavigationState) { if (this._suppressNavigationEvent == false) { string state = journalEntry.Source == null ? string.Empty : UriParsingHelper.InternalUriToExternalValue(journalEntry.Source); // Title updates only occur when DOM access is enabled, so check this first. if (HtmlPage.IsEnabled) { // In older versions of IE (6, 7, and 8 in 7 compat mode) we use an // iframe to cause journal updates. But this requires that the title // be set before the navigation for the dropdowns for back/forward // to show the correct titles at the correct places in these lists. // // In newer versions of IE, and in all other supported browsers, the // title should be set after the navigation for correct behavior. if (UsingIFrame()) { HtmlPage.Document.SetProperty("title", journalEntry.Name); Application.Current.Host.NavigationState = state; } else { Application.Current.Host.NavigationState = state; HtmlPage.Document.SetProperty("title", journalEntry.Name); } } else { // We don't have DOM access, so just update NavigationState // without a title update Application.Current.Host.NavigationState = state; } } } }
internal void CommitJournalNavigation(JournalEntry navigated) { NavigateTo(navigated); }
/// <summary> /// Updates observable properties of the journal. /// </summary> /// <param name="currentEntry">The current journal entry.</param> /// <param name="mode">The mode of navigation that triggered the update.</param> private void UpdateObservables(JournalEntry currentEntry, NavigationMode mode) { this.OnNavigated(currentEntry.Name, currentEntry.Source, mode); }
/// <summary> /// For jump navigation this determines if it is a backwards or forwards navigation /// </summary> internal NavigationMode GetNavigationMode(JournalEntry entry) { int index = _journalEntryList.IndexOf(entry); if (index <= _currentEntryIndex) { // If index = _currentEntryIndex it means the application is being navigated back to // in the browser. The browser has just loaded the journal and is restoring the // current page. This would also work if we chose "forward" but it must be one of the // two so that NavigationService will complete the navigation with CommitJournalNavigation() return NavigationMode.Back; } else { return NavigationMode.Forward; } }
private void CompleteNavigation(DependencyObject content) { Uri uri = null; string pageTitle = null; Page existingContentPage = this._host.Content as Page; Page newContentPage = content as Page; pageTitle = JournalEntry.GetName(content ?? this._host.Content as DependencyObject); NavigationOperation navOp = this._currentNavigation; this._currentNavigation = null; if (navOp != null) { // Set uri uri = navOp.UriBeforeMapping; // Used to suppress navigation notifications. navOp.SuppressNotifications = true; if (this.CurrentSource == navOp.UriForJournal) { // Do not record the navigation in the journal when moving to the same URI whether this // is a redirection or not. navOp.SuppressJournalAdd = true; } this.CurrentSource = navOp.UriForJournal; this._source = navOp.UriBeforeMapping; this._currentSourceAfterMapping = navOp.Uri; this.Host.UpdateSourceFromNavigationService(navOp.UriForJournal); this.Host.CurrentSource = this.CurrentSource; // Check if this is a 'New' operation if (navOp.Mode == NavigationMode.New && navOp.Uri != null && navOp.SuppressJournalAdd == false) { try { this._journalIsAddingHistoryPoint = true; JournalEntry je = new JournalEntry(pageTitle ?? uri.OriginalString, navOp.UriForJournal); this.Journal.AddHistoryPoint(je); } finally { this._journalIsAddingHistoryPoint = false; } } this.Host.CanGoBack = this.CanGoBack; this.Host.CanGoForward = this.CanGoForward; navOp.SuppressNotifications = false; } if (this.Journal.UseNavigationState && HtmlPage.IsEnabled) { HtmlPage.Document.SetProperty("title", pageTitle ?? (uri == null ? string.Empty : uri.OriginalString)); } if (content == null) { // We're navigating to a fragment in the current page, so for WPF compatibility, fire FragmentNavigation THEN Navigated if (navOp != null) { this.RaiseFragmentNavigation(UriParsingHelper.InternalUriGetFragment(navOp.Uri)); this.RaiseNavigated(content, uri, existingContentPage, newContentPage); } } else { // We're navigating to a fragment in the new content, so let the host load content, then for WPF compatibility, // fire Navigated THEN FragmentNavigation this.Host.Content = content; this.RaiseNavigated(content, uri, existingContentPage, newContentPage); string fragment = navOp == null ? null : UriParsingHelper.InternalUriGetFragment(navOp.Uri); if (!String.IsNullOrEmpty(fragment)) { this.RaiseFragmentNavigation(fragment); } } }
internal void NavigateTo(JournalEntry target) { Debug.Assert(IsNavigable(target), "target must be navigable"); Debug.Assert(ValidateIndexes()); int index = _journalEntryList.IndexOf(target); // When navigating back to a page which contains a previously navigated frame a // saved journal entry is replayed to restore the frame�s location, in many cases // this entry is not in the journal. if (index > -1) { _currentEntryIndex = index; _uncommittedCurrentIndex = _currentEntryIndex; UpdateView(); } }
private JournalEntry UpdateJournal( NavigationMode navigationMode, JournalReason journalReason, JournalEntry destinationJournalEntry) { Debug.Assert(navigationMode == NavigationMode.New || navigationMode == NavigationMode.Back || navigationMode == NavigationMode.Forward, "The journal should not be updated on Refresh."); // The point of this assert is that there should be no destinationJournalEntry for // navigationMode=New, but it is always required for Back/Fwd. Debug.Assert(destinationJournalEntry == null ^ (navigationMode == NavigationMode.Back || navigationMode == NavigationMode.Forward)); JournalEntry journalEntry = null; if (!_doNotJournalCurrentContent) { journalEntry = MakeJournalEntry(journalReason); } if (journalEntry == null) { _doNotJournalCurrentContent = false; // This case will be true when we have navigated to null and then gone back. We cannot add null to the journal // but we still need to commit the back navigation to the journal so the journal state stays sane. if ((navigationMode == NavigationMode.Back || navigationMode == NavigationMode.Forward) && JournalScope != null) { JournalScope.Journal.CommitJournalNavigation(destinationJournalEntry); } // There's no need to do anything here for a New navigation. return null; } // EnsureJournal() should be called no earlier than here. Only the second navigation in a // NavigationService really requires a journal. // In particular, a child Frame should not be forced to create its own journal when it // is being re-navigated by DataStreams.Load(), because it doesn't yet have access to the // parent JournalNavigationScope. JournalNavigationScope journalScope = EnsureJournal(); if (journalScope == null) { return null; } PageFunctionBase pfBase = _bp as PageFunctionBase; if (pfBase != null) { // PageFunctions that don't show UI don't get navigated to in the journal // We still need to add it to the journal since we need to resume this when its child finishes // This codepath is not executed if this pagefunction finished without launching a child. // That case is handled in HandleFinish if (navigationMode == NavigationMode.New && pfBase.Content == null) { journalEntry.EntryType = JournalEntryType.UiLess; } } journalScope.Journal.UpdateCurrentEntry(journalEntry); if (journalEntry.IsNavigable()) { CallUpdateTravelLog(navigationMode == NavigationMode.New); } if (navigationMode == NavigationMode.New) { journalScope.Journal.RecordNewNavigation(); } else // Back or Forward { journalScope.Journal.CommitJournalNavigation(destinationJournalEntry); } _customContentStateToSave = null; // not needed anymore return journalEntry; }
internal bool IsNavigable(JournalEntry entry) { if (entry == null) return false; // Fallback to entry.IsNavigable if the Filter hasn't been specified return (Filter != null) ? Filter(entry) : entry.IsNavigable(); }
internal PageFunctionReturnInfo(PageFunctionBase finishingChildPageFunction, Uri source, NavigationMode navigationMode, JournalEntry journalEntry, object returnEventArgs) : base(source, navigationMode, journalEntry) { _returnEventArgs = returnEventArgs; _finishingChildPageFunction = finishingChildPageFunction; }
/// <summary> /// This is the filter callback for Journal. To keep a single code path and to avoid /// inconsistent results, use Journal.IsNavigable() instead of this method. /// </summary> private bool IsEntryNavigable(JournalEntry entry) { if (entry == null || !entry.IsNavigable()) return false; // If the entry is associated with a child frame, the frame has to be currently available. // For a given journal entry group, only the "exit" entry is made visible. Effectively, // this collapses all fragment-navigation and CustomContentState-navigation entries for // a page (other than the current one) to a single entry. That's what IE does. NavigationService ns = _rootNavSvc.FindTarget(entry.NavigationServiceId); return ns != null && (ns.ContentId == entry.ContentId || entry.JEGroupState.GroupExitEntry == entry); }
/// <summary> /// Adds a new JournalEntry to the history stack. /// </summary> /// <param name="journalEntry">A new JournalEntry to add to the history stack.</param> /// <remarks> /// Any JournalEntry items existing on the ForwardStack will be removed. /// </remarks> internal void AddHistoryPoint(JournalEntry journalEntry) { Guard.ArgumentNotNull(journalEntry, "journalEntry"); lock (this._syncLock) { this._forwardStack.Clear(); if (this._currentEntry != null) { this._backStack.Push(this._currentEntry); } this._currentEntry = journalEntry; } this.UpdateObservables(journalEntry, NavigationMode.New); this.UpdateNavigationState(this.CurrentEntry); }
internal override void PrepareForSerialization() { if (JournalEntry != null) { if (JournalEntry.IsAlive()) // not serializable { JournalEntry = null; // Only the NavigationService GUID will be restored. // See related case and explanation in Frame.GetJournalState(). } else { Debug.Assert(JournalEntry.GetType().IsSerializable); } } if (Journal != null) { Journal.PruneKeepAliveEntries(); } }
// Token: 0x060029FA RID: 10746 RVA: 0x000C1A2A File Offset: 0x000BFC2A internal NavigateInfo(Uri source, NavigationMode navigationMode, JournalEntry journalEntry) { this._source = source; this._navigationMode = navigationMode; this._journalEntry = journalEntry; }