public void LogNavigationPoint(NavigationPoint point, bool transient = false) { if (point == null) { throw new ArgumentNullException(nameof(point)); } var item = new NavigationHistoryItem(point); //if the current node's transient but has been around for a while, consider making it permanent if (Current == null || (currentIsTransient && DateTime.Now.Subtract(Current.Created).TotalMilliseconds > TRANSIENT_TIMEOUT)) { currentIsTransient = false; } //if the current point's transient, always replace it if (currentIsTransient) { //collapse down possible extra point in history var backOne = history[-1]; if (backOne != null && point.ShouldReplace(backOne.NavigationPoint)) { // The new node is the same as the last permanent, so we can discard it history.RemoveCurrent(); currentIsTransient = false; item.Dispose(); } else { currentIsTransient = transient; history.ReplaceCurrent(item); } } //if the new point wants to replace the old one, let it else if (Current != null && !transient && point.ShouldReplace(Current.NavigationPoint)) { history.ReplaceCurrent(item); //but in this case, the point should not be transient -- unless the old point was, //but that's handled earlier currentIsTransient = false; } //final choice: append the the node //BUT only if the existing current node would not want to replace the new node else if (Current == null || !Current.NavigationPoint.ShouldReplace(point)) { history.AddPoint(item); currentIsTransient = transient; } else { item.Dispose(); } OnHistoryChanged(); }
public static void LogActiveDocument (bool transient) { if (switching) return; NavigationPoint point = GetNavPointForActiveDoc (); if (point == null) return; NavigationHistoryItem item = new NavigationHistoryItem (point); //if the current node's transient but has been around for a while, consider making it permanent if (Current == null || (currentIsTransient && DateTime.Now.Subtract (Current.Created).TotalMilliseconds > TRANSIENT_TIMEOUT)) { currentIsTransient = false; } //if the current point's transient, always replace it if (currentIsTransient) { //collapse down possible extra point in history NavigationHistoryItem backOne = history[-1]; if (backOne != null && point.ShouldReplace (backOne.NavigationPoint)) { // The new node is the same as the last permanent, so we can discard it history.RemoveCurrent (); currentIsTransient = false; item.Dispose (); } else { currentIsTransient = transient; history.ReplaceCurrent (item); } } //if the new point wants to replace the old one, let it else if (Current != null && !transient && point.ShouldReplace (Current.NavigationPoint)) { history.ReplaceCurrent (item); //but in this case, the point should not be transient -- unless the old point was, //but that's handled earlier currentIsTransient = false; } //final choice: append the the node //BUT only if the existing current node would not want to replace the new node else if (Current == null || !Current.NavigationPoint.ShouldReplace (point)) { history.AddPoint (item); currentIsTransient = transient; } else point.Dispose (); OnHistoryChanged (); }
static NavigationHistoryService() { IdeApp.Workspace.LastWorkspaceItemClosed += delegate { history.Clear(); OnHistoryChanged(); }; IdeApp.Workbench.DocumentClosed += delegate(object sender, DocumentEventArgs e) { ClosedDocumentNavigationPoint point = new ClosedDocumentNavigationPoint( e.Document.FileName, IdeApp.Workbench.Documents.IndexOf(IdeApp.Workbench.ActiveDocument) ); NavigationHistoryItem item = new NavigationHistoryItem(point); closedHistory.AddPoint(item); OnClosedHistoryChanged(); }; //keep nav points up to date TextEditorService.LineCountChanged += LineCountChanged; TextEditorService.LineCountChangesCommitted += CommitCountChanges; TextEditorService.LineCountChangesReset += ResetCountChanges; IdeApp.Workspace.FileRenamedInProject += FileRenamed; IdeApp.Workbench.ActiveDocumentChanged += ActiveDocChanged; }
static NavigationHistoryService () { IdeApp.Workspace.LastWorkspaceItemClosed += delegate { history.Clear (); OnHistoryChanged (); }; IdeApp.Workbench.DocumentClosed += delegate(object sender, DocumentEventArgs e) { ClosedDocumentNavigationPoint point = new ClosedDocumentNavigationPoint ( e.Document.FileName, IdeApp.Workbench.Documents.IndexOf (IdeApp.Workbench.ActiveDocument) ); NavigationHistoryItem item = new NavigationHistoryItem (point); closedHistory.AddPoint (item); OnClosedHistoryChanged (); }; //keep nav points up to date TextEditorService.LineCountChanged += LineCountChanged; TextEditorService.LineCountChangesCommitted += CommitCountChanges; TextEditorService.LineCountChangesReset += ResetCountChanges; IdeApp.Workspace.FileRenamedInProject += FileRenamed; IdeApp.Workbench.ActiveDocumentChanged += ActiveDocChanged; }
public static bool IsCurrent(NavigationHistoryItem point) { return(history.IsCurrent(point)); }
public static void MoveTo(NavigationHistoryItem item) { history.MoveTo(item); SwitchToCurrent(); OnHistoryChanged(); }
public static bool IsCurrent (NavigationHistoryItem point) { return history.IsCurrent (point); }
public static void MoveTo (NavigationHistoryItem item) { history.MoveTo (item); SwitchToCurrent (); OnHistoryChanged (); }