Skip to content

Commit

Permalink
Cleanup and removed duplicated Recent/Recent Files in jump list
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Ginnivan committed May 22, 2012
1 parent cab60e2 commit abc2018
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/MarkPad/App.xaml
Expand Up @@ -3,6 +3,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<JumpList.JumpList> <JumpList.JumpList>
<JumpList ShowRecentCategory="True" /> <JumpList ShowRecentCategory="False" />
</JumpList.JumpList> </JumpList.JumpList>
</Application> </Application>
28 changes: 14 additions & 14 deletions src/MarkPad/Shell/JumpListIntegration.cs
Expand Up @@ -36,7 +36,7 @@ public void Handle(FileOpenEvent message)


public void OpenFileAsync(string openedFile) public void OpenFileAsync(string openedFile)
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return; return;


var currentFiles = jumpList.JumpItems.OfType<JumpTask>().Select(t => t.Arguments).ToList(); var currentFiles = jumpList.JumpItems.OfType<JumpTask>().Select(t => t.Arguments).ToList();
Expand All @@ -45,10 +45,10 @@ public void OpenFileAsync(string openedFile)
{ {
// find file in list // find file in list
var settings = settingsService.GetSettings<MarkPadSettings>(); var settings = settingsService.GetSettings<MarkPadSettings>();
var files = settings.RecentFiles; var index = settings.RecentFiles.IndexOf(openedFile);
var index = files.IndexOf(openedFile); if (index >= 0)
if (index >= 0) files.RemoveAt(index); settings.RecentFiles.RemoveAt(index);
files.Insert(0, openedFile); settings.RecentFiles.Insert(0, openedFile);
settingsService.SaveSettings(settings); settingsService.SaveSettings(settings);


// Sometimes the settings and the jumplist can get out of sequence. // Sometimes the settings and the jumplist can get out of sequence.
Expand All @@ -61,10 +61,10 @@ public void OpenFileAsync(string openedFile)
{ {
// update settings // update settings
var settings = settingsService.GetSettings<MarkPadSettings>(); var settings = settingsService.GetSettings<MarkPadSettings>();
var files = settings.RecentFiles ?? new List<string>();


files.Insert(0, openedFile); settings.RecentFiles.Insert(0, openedFile);
if (files.Count > 5) files.RemoveAt(5); if (settings.RecentFiles.Count > 5)
settings.RecentFiles.RemoveAt(5);
settingsService.SaveSettings(settings); settingsService.SaveSettings(settings);


InsertFileFirst(openedFile); InsertFileFirst(openedFile);
Expand All @@ -73,7 +73,7 @@ public void OpenFileAsync(string openedFile)


private void InsertFileFirst(string openedFile) private void InsertFileFirst(string openedFile)
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return; return;


if (jumpList != null) if (jumpList != null)
Expand All @@ -86,7 +86,7 @@ private void InsertFileFirst(string openedFile)


public void Handle(AppReadyEvent message) public void Handle(AppReadyEvent message)
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return; return;


jumpList = GetJumpList(); jumpList = GetJumpList();
Expand All @@ -103,7 +103,7 @@ public void Dispose()


private void PopulateJumpList(IEnumerable<string> recentFiles) private void PopulateJumpList(IEnumerable<string> recentFiles)
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return; return;


if (recentFiles == null) return; if (recentFiles == null) return;
Expand All @@ -120,7 +120,7 @@ private void PopulateJumpList(IEnumerable<string> recentFiles)


private static JumpItem CreateJumpListItem(string file) private static JumpItem CreateJumpListItem(string file)
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return null; return null;


var path = Assembly.GetEntryAssembly().CodeBase; var path = Assembly.GetEntryAssembly().CodeBase;
Expand All @@ -134,7 +134,7 @@ private static JumpItem CreateJumpListItem(string file)
}; };
} }


private static bool IsWin7() private static bool IsWin7OrAbove()
{ {
// check for Windows7 // check for Windows7
var os = Environment.OSVersion.Version; var os = Environment.OSVersion.Version;
Expand All @@ -146,7 +146,7 @@ private static bool IsWin7()


private static JumpList GetJumpList() private static JumpList GetJumpList()
{ {
if (!IsWin7()) if (!IsWin7OrAbove())
return null; return null;


var list = JumpList.GetJumpList(Application.Current); var list = JumpList.GetJumpList(Application.Current);
Expand Down
Binary file modified tools/NotifyPropertyWeaverMsBuildTask.dll
Binary file not shown.

0 comments on commit abc2018

Please sign in to comment.