mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.4 KiB
64 lines
1.4 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using ICSharpCode.TreeView; |
|
|
|
namespace ICSharpCode.ILSpy |
|
{ |
|
/// <summary> |
|
/// Stores the navigation history. |
|
/// </summary> |
|
sealed class NavigationHistory |
|
{ |
|
List<SharpTreeNode> back = new List<SharpTreeNode>(); |
|
List<SharpTreeNode> forward = new List<SharpTreeNode>(); |
|
|
|
public bool CanNavigateBack { |
|
get { return back.Count > 0; } |
|
} |
|
|
|
public bool CanNavigateForward { |
|
get { return forward.Count > 0; } |
|
} |
|
|
|
public SharpTreeNode GoBack(SharpTreeNode oldNode) |
|
{ |
|
if (oldNode != null) |
|
forward.Add(oldNode); |
|
|
|
SharpTreeNode node = back[back.Count - 1]; |
|
back.RemoveAt(back.Count - 1); |
|
return node; |
|
} |
|
|
|
public SharpTreeNode GoForward(SharpTreeNode oldNode) |
|
{ |
|
if (oldNode != null) |
|
back.Add(oldNode); |
|
|
|
SharpTreeNode node = forward[forward.Count - 1]; |
|
forward.RemoveAt(forward.Count - 1); |
|
return node; |
|
} |
|
|
|
public void RemoveAll(Predicate<SharpTreeNode> predicate) |
|
{ |
|
back.RemoveAll(predicate); |
|
forward.RemoveAll(predicate); |
|
} |
|
|
|
public void Clear() |
|
{ |
|
back.Clear(); |
|
forward.Clear(); |
|
} |
|
|
|
public void Record(SharpTreeNode node) |
|
{ |
|
forward.Clear(); |
|
back.Add(node); |
|
} |
|
} |
|
}
|
|
|