Browse Source

Store RecentOpen lists in array (instead of joining strings)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5860 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 15 years ago
parent
commit
da7842263e
  1. 1
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs
  2. 28
      src/Main/Base/Project/Src/Services/File/RecentOpen.cs

1
src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs

@ -56,6 +56,7 @@ namespace ICSharpCode.StartPage
{ {
List<RecentOpenItem> items = new List<RecentOpenItem>(); List<RecentOpenItem> items = new List<RecentOpenItem>();
foreach (string path in (string[])state) { foreach (string path in (string[])state) {
Core.LoggingService.Debug("RecentProjectsControl: Looking up path '" + path + "'");
FileInfo file = new FileInfo(path); FileInfo file = new FileInfo(path);
if (file.Exists) { if (file.Exists) {
items.Add( items.Add(

28
src/Main/Base/Project/Src/Services/File/RecentOpen.cs

@ -51,19 +51,21 @@ namespace ICSharpCode.SharpDevelop
{ {
// don't check whether files exist because that might be slow (e.g. if file is on network // don't check whether files exist because that might be slow (e.g. if file is on network
// drive that's unavailable) // drive that's unavailable)
if (p.Contains("Files")) {
lastfile.AddRange(p["Files"].Split(',')); // if one of these entries is a string, then it's from a previous SharpDevelop version - don't try loading it
if (p.Contains("Files") && !(p.Get("Files") is string)) {
lastfile.AddRange(p.Get("Files", new string[0]));
} }
if (p.Contains("Projects")) { if (p.Contains("Projects") && !(p.Get("Files") is string)) {
lastproject.AddRange(p["Projects"].Split(',')); lastproject.AddRange(p.Get("Projects", new string[0]));
} }
} }
public void AddLastFile(string name) public void AddLastFile(string name)
{ {
for (int i = 0; i < lastfile.Count; ++i) { for (int i = 0; i < lastfile.Count; ++i) {
if (lastfile[i].ToString().Equals(name, StringComparison.OrdinalIgnoreCase)) { if (lastfile[i].Equals(name, StringComparison.OrdinalIgnoreCase)) {
lastfile.RemoveAt(i); lastfile.RemoveAt(i);
} }
} }
@ -72,11 +74,7 @@ namespace ICSharpCode.SharpDevelop
lastfile.RemoveAt(lastfile.Count - 1); lastfile.RemoveAt(lastfile.Count - 1);
} }
if (lastfile.Count > 0) { lastfile.Insert(0, name);
lastfile.Insert(0, name);
} else {
lastfile.Add(name);
}
} }
public void ClearRecentFiles() public void ClearRecentFiles()
@ -101,11 +99,7 @@ namespace ICSharpCode.SharpDevelop
lastproject.RemoveAt(lastproject.Count - 1); lastproject.RemoveAt(lastproject.Count - 1);
} }
if (lastproject.Count > 0) { lastproject.Insert(0, name);
lastproject.Insert(0, name);
} else {
lastproject.Add(name);
}
JumpList.AddToRecentCategory(name); JumpList.AddToRecentCategory(name);
} }
@ -117,8 +111,8 @@ namespace ICSharpCode.SharpDevelop
public Properties ToProperties() public Properties ToProperties()
{ {
Properties p = new Properties(); Properties p = new Properties();
p["Files"] = String.Join(",", lastfile.ToArray()); p.Set("Files", lastfile.ToArray());
p["Projects"] = String.Join(",", lastproject.ToArray()); p.Set("Projects", lastproject.ToArray());
return p; return p;
} }

Loading…
Cancel
Save