|
|
|
@ -44,16 +44,16 @@ namespace ICSharpCode.Core
@@ -44,16 +44,16 @@ namespace ICSharpCode.Core
|
|
|
|
|
public class NavigationService |
|
|
|
|
{ |
|
|
|
|
#region Private members
|
|
|
|
|
static LinkedList<INavigationPoint> history; |
|
|
|
|
static LinkedListNode<INavigationPoint> currentNode; |
|
|
|
|
static bool loggingSuspended; |
|
|
|
|
static LinkedList<INavigationPoint> history = new LinkedList<INavigationPoint>(); |
|
|
|
|
static LinkedListNode<INavigationPoint> currentNode; // autoinitialized to null (FxCop)
|
|
|
|
|
static bool loggingSuspended; // autoinitialized to false (FxCop)
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
static NavigationService() |
|
|
|
|
{ |
|
|
|
|
history = new LinkedList<INavigationPoint>(); |
|
|
|
|
currentNode = null; |
|
|
|
|
loggingSuspended = false; |
|
|
|
|
// history = new LinkedList<INavigationPoint>();
|
|
|
|
|
// currentNode = null;
|
|
|
|
|
// loggingSuspended = false;
|
|
|
|
|
|
|
|
|
|
WorkbenchSingleton.WorkbenchCreated += WorkbenchCreatedHandler; |
|
|
|
|
FileService.FileRenamed += FileService_FileRenamed; |
|
|
|
@ -87,6 +87,7 @@ namespace ICSharpCode.Core
@@ -87,6 +87,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
|
|
|
|
|
#region Public Methods
|
|
|
|
|
|
|
|
|
|
// TODO: FxCop says "find another way to do this" (ReviewVisibleEventHandlers)
|
|
|
|
|
public static void ContentChanging(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
foreach (INavigationPoint p in history) |
|
|
|
@ -110,12 +111,12 @@ namespace ICSharpCode.Core
@@ -110,12 +111,12 @@ namespace ICSharpCode.Core
|
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public static void Log(INavigationPoint p) |
|
|
|
|
public static void Log(INavigationPoint pointToLog) |
|
|
|
|
{ |
|
|
|
|
if (loggingSuspended) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
LogInternal(p); |
|
|
|
|
LogInternal(pointToLog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// refactoring this out of Log() allows the NavigationService
|
|
|
|
@ -155,10 +156,12 @@ namespace ICSharpCode.Core
@@ -155,10 +156,12 @@ namespace ICSharpCode.Core
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<INavigationPoint> GetListOfPoints() |
|
|
|
|
public static ICollection<INavigationPoint> Points |
|
|
|
|
{ |
|
|
|
|
get { |
|
|
|
|
return new List<INavigationPoint>(history); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void ClearHistory() |
|
|
|
|
{ |
|
|
|
@ -176,21 +179,21 @@ namespace ICSharpCode.Core
@@ -176,21 +179,21 @@ namespace ICSharpCode.Core
|
|
|
|
|
OnHistoryChanged(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void Go(int n) |
|
|
|
|
public static void Go(int delta) |
|
|
|
|
{ |
|
|
|
|
if (0 == n) { |
|
|
|
|
if (0 == delta) { |
|
|
|
|
return; |
|
|
|
|
} else if (0>n) { |
|
|
|
|
} else if (0>delta) { |
|
|
|
|
// move backwards
|
|
|
|
|
while (0>n && currentNode!=history.First) { |
|
|
|
|
while (0>delta && currentNode!=history.First) { |
|
|
|
|
currentNode = currentNode.Previous; |
|
|
|
|
n++; |
|
|
|
|
delta++; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// move forwards
|
|
|
|
|
while (0<n && currentNode!=history.Last) { |
|
|
|
|
while (0<delta && currentNode!=history.Last) { |
|
|
|
|
currentNode = currentNode.Next; |
|
|
|
|
n--; |
|
|
|
|
delta--; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -246,7 +249,7 @@ namespace ICSharpCode.Core
@@ -246,7 +249,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
#region event trapping
|
|
|
|
|
|
|
|
|
|
#region ViewContent events
|
|
|
|
|
public static void WorkbenchCreatedHandler(object sender, EventArgs e) |
|
|
|
|
static void WorkbenchCreatedHandler(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
WorkbenchSingleton.Workbench.ViewOpened += |
|
|
|
|
new ViewContentEventHandler(ViewContentOpened); |
|
|
|
@ -265,7 +268,7 @@ namespace ICSharpCode.Core
@@ -265,7 +268,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
e.Content.WorkbenchWindow.WindowSelected -= WorkBenchWindowSelected; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static IWorkbenchWindow lastSelectedWindow = null; |
|
|
|
|
static IWorkbenchWindow lastSelectedWindow; // = null; (FXCop)
|
|
|
|
|
static void WorkBenchWindowSelected(object sender, EventArgs e) |
|
|
|
|
{ |
|
|
|
|
try { |
|
|
|
@ -273,7 +276,7 @@ namespace ICSharpCode.Core
@@ -273,7 +276,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
if (window == lastSelectedWindow) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
int n = NavigationService.Count; |
|
|
|
|
//int n = NavigationService.Count;
|
|
|
|
|
Log(window); |
|
|
|
|
//LoggingService.DebugFormatted("WorkbenchSelected: logging {0}", window.Title);
|
|
|
|
|
|
|
|
|
@ -285,6 +288,7 @@ namespace ICSharpCode.Core
@@ -285,6 +288,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
LoggingService.ErrorFormatted("{0}:\n{1}",ex.Message, ex.StackTrace); |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
@ -304,7 +308,7 @@ namespace ICSharpCode.Core
@@ -304,7 +308,7 @@ namespace ICSharpCode.Core
|
|
|
|
|
#region Public Events
|
|
|
|
|
public static event System.EventHandler HistoryChanged; |
|
|
|
|
|
|
|
|
|
public static void OnHistoryChanged() |
|
|
|
|
static void OnHistoryChanged() |
|
|
|
|
{ |
|
|
|
|
if (HistoryChanged!=null) { |
|
|
|
|
HistoryChanged(NavigationService.CurrentPosition, EventArgs.Empty); |
|
|
|
|