Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorischyrus <stevens@ischyrus.com>2011-02-04 09:49:19 +0300
committerLluis Sanchez Gual <lluis@novell.com>2011-02-15 01:17:38 +0300
commitf5ddb72cbba8bc4949df57de39c3a45ff7245fb3 (patch)
tree9f9ab35014e7c6cb91af69c09db14a655352345f /main/src/addins/WindowsPlatform
parent7727c4297d6efe43d1ef05ed80158b67e1e5b41f (diff)
This shelveset adds jumplist support for Windows 7.
The setup project will now include registry entries that link specific file extensions. The registry entries are then used by the JumpList addin. The library makes use of the Windows API Code Pack.
Diffstat (limited to 'main/src/addins/WindowsPlatform')
-rw-r--r--main/src/addins/WindowsPlatform/JumpList.cs141
-rw-r--r--main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.dllbin0 -> 542720 bytes
-rw-r--r--main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.pdbbin0 -> 1336832 bytes
-rw-r--r--main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.dllbin0 -> 105984 bytes
-rw-r--r--main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.pdbbin0 -> 243200 bytes
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml4
-rw-r--r--main/src/addins/WindowsPlatform/WindowsPlatform.csproj9
7 files changed, 154 insertions, 0 deletions
diff --git a/main/src/addins/WindowsPlatform/JumpList.cs b/main/src/addins/WindowsPlatform/JumpList.cs
new file mode 100644
index 0000000000..4d68112f42
--- /dev/null
+++ b/main/src/addins/WindowsPlatform/JumpList.cs
@@ -0,0 +1,141 @@
+//
+// JumpList.cs
+//
+// Author:
+// Steven Schermerhorn <stevens+monoaddins@ischyrus.com>
+//
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Timers;
+using Microsoft.Win32;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Ide;
+using MonoDevelop.Ide.Desktop;
+using Taskbar = Microsoft.WindowsAPICodePack.Taskbar;
+
+namespace MonoDevelop.Platform
+{
+ public class JumpList : CommandHandler
+ {
+ private IList<string> supportedExtensions;
+ private RecentFiles recentFiles;
+ private Timer updateTimer;
+
+ protected override void Run ()
+ {
+ bool isWindows7 = Taskbar.TaskbarManager.IsPlatformSupported;
+ if (!isWindows7) {
+ return;
+ }
+
+ bool areFileExtensionsRegistered = this.Initialize ();
+
+ if (!areFileExtensionsRegistered) {
+ return;
+ }
+
+ this.updateTimer = new Timer (1000);
+ this.updateTimer.Elapsed += this.OnUpdateTimerEllapsed;
+ this.updateTimer.AutoReset = false;
+
+ this.recentFiles = DesktopService.RecentFiles;
+ this.recentFiles.Changed += this.OnRecentFilesChanged;
+ this.UpdateJumpList ();
+ }
+
+ private void OnRecentFilesChanged (object sender, EventArgs args)
+ {
+ // This event fires several times for a single change. Rather than performing the update
+ // several times we will restart the timer which has a 1 second delay on it.
+ // While this means the update won't make it to the JumpList immediately it is significantly
+ // better for performance.
+ this.updateTimer.Stop ();
+ this.updateTimer.Start ();
+ }
+
+ private void OnUpdateTimerEllapsed (object sender, EventArgs args)
+ {
+ this.UpdateJumpList ();
+ }
+
+ private void UpdateJumpList ()
+ {
+ Taskbar.JumpList jumplist = Taskbar.JumpList.CreateJumpList ();
+ jumplist.KnownCategoryToDisplay = Taskbar.JumpListKnownCategoryType.Neither;
+
+ Taskbar.JumpListCustomCategory recentProjectsCategory = new Taskbar.JumpListCustomCategory ("Recent Solutions");
+ Taskbar.JumpListCustomCategory recentFilesCategory = new Taskbar.JumpListCustomCategory ("Recent Files");
+
+ jumplist.AddCustomCategories (recentProjectsCategory, recentFilesCategory);
+ jumplist.KnownCategoryOrdinalPosition = 0;
+
+ foreach (RecentFile recentProject in recentFiles.GetProjects ()) {
+ // Windows is picky about files that are added to the jumplist. Only files that MonoDevelop
+ // has been registered as supported in the registry can be added.
+ bool isSupportedFileExtension = this.supportedExtensions.Contains (Path.GetExtension (recentProject.FileName));
+ if (isSupportedFileExtension) {
+ recentProjectsCategory.AddJumpListItems (new Taskbar.JumpListItem (recentProject.FileName));
+ }
+ }
+
+ foreach (RecentFile recentFile in recentFiles.GetFiles ()) {
+ if (this.supportedExtensions.Contains (Path.GetExtension (recentFile.FileName)))
+ recentFilesCategory.AddJumpListItems (new Taskbar.JumpListItem (recentFile.FileName));
+ }
+
+ jumplist.Refresh ();
+ }
+
+ private bool Initialize ()
+ {
+ this.supportedExtensions = new List<string> ();
+
+ // Determine the correct value for /HKCR/MonoDevelop[version]/shell/Open/Command
+ ProcessModule monoDevelopAssembly = Process.GetCurrentProcess ().MainModule;
+ string exePath = monoDevelopAssembly.FileName;
+ string executeString = exePath + " %1";
+ string version = monoDevelopAssembly.FileVersionInfo.ProductVersion;
+ string progId = "MonoDevelop" + version;
+ string appId = progId;
+
+ Taskbar.TaskbarManager.Instance.ApplicationId = progId;
+
+ RegistryKey progIdKey = Registry.ClassesRoot.OpenSubKey (progId + @"\shell\Open\Command", false);
+ if (progIdKey == null) {
+ return false;
+ }
+
+ object path = progIdKey.GetValue (String.Empty);
+ bool isProgIdRegistered = String.Equals (executeString, path as string, StringComparison.OrdinalIgnoreCase);
+ if (!isProgIdRegistered) {
+ return false;
+ }
+
+ string[] subkeyNames = Registry.ClassesRoot.GetSubKeyNames ();
+ foreach (string subkey in subkeyNames) {
+ if (subkey[0] != '.') {
+ continue;
+ }
+
+ RegistryKey openWithKey = Registry.ClassesRoot.OpenSubKey (Path.Combine (subkey, "OpenWithProgIds"));
+ if (openWithKey == null) {
+ continue;
+ }
+
+ string progIdValue = openWithKey.GetValue (progId, null) as string;
+ if (progIdValue == null) {
+ continue;
+ }
+
+ this.supportedExtensions.Add (subkey);
+ }
+
+ bool atLeastOneFileTypeRegistered = this.supportedExtensions.Count > 0;
+ return atLeastOneFileTypeRegistered;
+ }
+ }
+}
+
diff --git a/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.dll b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.dll
new file mode 100644
index 0000000000..4542663e1e
--- /dev/null
+++ b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.dll
Binary files differ
diff --git a/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.pdb b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.pdb
new file mode 100644
index 0000000000..2af8f3989e
--- /dev/null
+++ b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.Shell.pdb
Binary files differ
diff --git a/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.dll b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.dll
new file mode 100644
index 0000000000..ac86949212
--- /dev/null
+++ b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.dll
Binary files differ
diff --git a/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.pdb b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.pdb
new file mode 100644
index 0000000000..aef485379e
--- /dev/null
+++ b/main/src/addins/WindowsPlatform/Microsoft.WindowsAPICodePack.pdb
Binary files differ
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml b/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml
index a2198583dc..e69a25683a 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform.addin.xml
@@ -24,6 +24,10 @@
<Extension path = "/MonoDevelop/Ide/Updater">
<UpdateInfo file="..\bin\updateinfo" />
</Extension>
+
+ <Extension path = "/MonoDevelop/Ide/InitCompleteHandlers">
+ <Class class="MonoDevelop.Platform.JumpList" />
+ </Extension>
<!-- <Extension path = "/MonoDevelop/Components/DialogHandlers">
<Class class = "MonoDevelop.Platform.SelectFileDialogHandler"/>
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform.csproj b/main/src/addins/WindowsPlatform/WindowsPlatform.csproj
index 347b7e954f..d07b6693e3 100644
--- a/main/src/addins/WindowsPlatform/WindowsPlatform.csproj
+++ b/main/src/addins/WindowsPlatform/WindowsPlatform.csproj
@@ -38,6 +38,14 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
+ <Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>Microsoft.WindowsAPICodePack.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
@@ -76,6 +84,7 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="RecentFiles.cs" />
+ <Compile Include="JumpList.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ChangeLog" />