Browse Source

StartPage: Move check if solution files still exist onto a background thread (solutions might be stored on slow network drive)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5815 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
3516730165
  1. 1
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml
  2. 32
      src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs

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

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
SelectionMode="Single"
core:SortableGridViewColumn.SortMode="Automatic"
Margin="0,0,0,20"
Visibility="Collapsed"
MouseDoubleClick="lastProjectsDoubleClick"
KeyDown="lastProjectsKeyDown">
<ListView.Resources>

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

@ -7,14 +7,18 @@ @@ -7,14 +7,18 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.StartPage
@ -39,29 +43,45 @@ namespace ICSharpCode.StartPage @@ -39,29 +43,45 @@ namespace ICSharpCode.StartPage
set { SetValue(HeaderProperty, value); }
}
void BuildRecentProjectList()
{
// When building the project list we access the .sln files (to see if they still exist).
// Because those might be stored on a slow network drive, we do this on a background thread so that
// SharpDevelop startup doesn't have to wait.
ThreadPool.QueueUserWorkItem(AsyncBuildRecentProjectList, FileService.RecentOpen.RecentProject.ToArray());
}
void AsyncBuildRecentProjectList(object state)
{
List<RecentOpenItem> items = new List<RecentOpenItem>();
foreach (string path in FileService.RecentOpen.RecentProject) {
foreach (string path in (string[])state) {
FileInfo file = new FileInfo(path);
if (file.Exists) {
items.Add(
new RecentOpenItem {
Name = System.IO.Path.GetFileNameWithoutExtension(path),
Name = Path.GetFileNameWithoutExtension(path),
LastModification = file.LastWriteTime.ToShortDateString(),
Path = path
});
}
}
lastProjectsListView.ItemsSource = items;
lastProjectsListView.Visibility = items.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
if (items.Count > 0) {
WorkbenchSingleton.SafeThreadAsyncCall(new Action(
delegate {
lastProjectsListView.ItemsSource = items;
lastProjectsListView.Visibility = Visibility.Visible;
}));
}
}
class RecentOpenItem
class RecentOpenItem : INotifyPropertyChanged
{
public string Name { get; set; }
public string LastModification { get; set; }
public string Path { get; set; }
event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { } remove { } }
}
void lastProjectsDoubleClick(object sender, RoutedEventArgs e)

Loading…
Cancel
Save