I guess this might help us someday, if we support other environments...

This commit is contained in:
nattthebear 2017-05-16 20:55:37 -04:00
parent 1821f631fe
commit c2fa9070a3
2 changed files with 31 additions and 18 deletions

View File

@ -122,7 +122,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\References\OpenTK.dll</HintPath> <HintPath>..\References\OpenTK.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationFramework" />
<Reference Include="SlimDX, Version=4.0.10.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86"> <Reference Include="SlimDX, Version=4.0.10.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\References\$(Platform)\SlimDX.dll</HintPath> <HintPath>..\References\$(Platform)\SlimDX.dll</HintPath>

View File

@ -2,8 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows;
using System.Windows.Shell;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
@ -11,13 +9,26 @@ namespace BizHawk.Client.EmuHawk
{ {
public class JumpLists public class JumpLists
{ {
static Application _app; static readonly Assembly PresentationFramework;
static Type Application;
static Type JumpList;
static Type JumpTask;
static object _app;
static JumpLists() static JumpLists()
{ {
_app = new Application(); try
var jmp = new JumpList(); {
jmp.ShowRecentCategory = true; PresentationFramework = Assembly.Load("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
JumpList.SetJumpList(_app, jmp); Application = PresentationFramework.GetType("System.Windows.Application");
JumpList = PresentationFramework.GetType("System.Windows.Shell.JumpList");
JumpTask = PresentationFramework.GetType("System.Windows.Shell.JumpTask");
_app = Activator.CreateInstance(Application);
dynamic jmp = Activator.CreateInstance(JumpList);
jmp.ShowRecentCategory = true;
JumpList.GetMethod("SetJumpList").Invoke(null, new[] { _app, jmp });
}
catch { }
} }
/// <summary> /// <summary>
@ -31,18 +42,21 @@ namespace BizHawk.Client.EmuHawk
// title = fullpath.Split('|')[1]; // title = fullpath.Split('|')[1];
//else //else
// title = Path.GetFileName(fullpath); // title = Path.GetFileName(fullpath);
try
string exepath = Assembly.GetEntryAssembly().Location;
var ji = new JumpTask
{ {
ApplicationPath = exepath, string exepath = Assembly.GetEntryAssembly().Location;
Arguments = '"' + fullpath + '"',
Title = title, dynamic ji = Activator.CreateInstance(JumpTask);
ji.ApplicationPath = exepath;
ji.Arguments = '"' + fullpath + '"';
ji.Title = title;
// for some reason, this doesn't work // for some reason, this doesn't work
WorkingDirectory = Path.GetDirectoryName(exepath) ji.WorkingDirectory = Path.GetDirectoryName(exepath);
};
JumpList.AddToRecentCategory(ji); JumpList.GetMethod("AddToRecentCategory", new[] { JumpTask }).Invoke(null, new[] { ji });
}
catch { }
} }
} }
} }