Restore Explorer file association support
- Issue MatterHackers/MCCentral#5719 Windows Explorer file associations fail to open file
This commit is contained in:
parent
bb1b241861
commit
12d8291a20
2 changed files with 29 additions and 10 deletions
31
Program.cs
31
Program.cs
|
|
@ -55,7 +55,9 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private static RaygunClient _raygunClient;
|
||||
|
||||
private static string mainServiceName = "";
|
||||
private static string mainServiceName = "shell";
|
||||
|
||||
private const string ServiceBaseUri = "net.pipe://localhost/mattercontrol";
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
|
|
@ -105,11 +107,7 @@ namespace MatterHackers.MatterControl
|
|||
return;
|
||||
}
|
||||
|
||||
// #endif
|
||||
var serviceHost = new ServiceHost(
|
||||
typeof(LocalService),
|
||||
new Uri[] { new Uri("net.pipe://localhost/mattercontrol") });
|
||||
|
||||
var serviceHost = new ServiceHost(typeof(LocalService), new[] { new Uri(ServiceBaseUri) });
|
||||
serviceHost.AddServiceEndpoint(typeof(IMainService), new NetNamedPipeBinding(), mainServiceName);
|
||||
serviceHost.Open();
|
||||
|
||||
|
|
@ -118,6 +116,25 @@ namespace MatterHackers.MatterControl
|
|||
string.Join(", ", serviceHost.Description.Endpoints.Select(s => s.ListenUri.AbsoluteUri).ToArray()));
|
||||
}
|
||||
|
||||
// If MatterControl isn't running and valid files were shelled, schedule a StartupAction to open the files after load
|
||||
var shellFiles = args.Where(f => File.Exists(f) && shellFileExtensions.Contains(Path.GetExtension(f).ToLower()));
|
||||
if (shellFiles.Any())
|
||||
{
|
||||
ApplicationController.StartupActions.Add(new ApplicationController.StartupAction()
|
||||
{
|
||||
Title = "Shell Files",
|
||||
Priority = 0,
|
||||
Action = () =>
|
||||
{
|
||||
// Open each shelled file
|
||||
foreach (string file in shellFiles)
|
||||
{
|
||||
ApplicationController.Instance.ShellOpenFile(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Load optional user configuration
|
||||
IConfiguration config = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
|
|
@ -217,7 +234,7 @@ namespace MatterHackers.MatterControl
|
|||
new ServiceEndpoint(
|
||||
ContractDescription.GetContract(typeof(IMainService)),
|
||||
new NetNamedPipeBinding(),
|
||||
new EndpointAddress($"net.pipe://localhost/{mainServiceName}")))
|
||||
new EndpointAddress($"{ServiceBaseUri}/{mainServiceName}")))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue