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
|
|
@ -2503,7 +2503,8 @@ namespace MatterHackers.MatterControl
|
|||
SourceItem = history.NewPlatingItem()
|
||||
});
|
||||
|
||||
this.OpenWorkspace(workspace);
|
||||
// Open but no need to save
|
||||
this.OpenWorkspace(workspace, WorkspacesChangedEventArgs.OperationType.Restore);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4068,6 +4069,9 @@ Support and tutorials:
|
|||
{
|
||||
try
|
||||
{
|
||||
// Initial load builds UI elements, then constructs workspace tabs as they're encountered in RestoreUserTabs()
|
||||
await applicationController.RestoreUserTabs();
|
||||
|
||||
// Batch startup actions
|
||||
await applicationController.Tasks.Execute(
|
||||
"Finishing Startup".Localize(),
|
||||
|
|
@ -4099,8 +4103,6 @@ Support and tutorials:
|
|||
await applicationController.Tasks.Execute(task.Title, null, task.Action);
|
||||
}
|
||||
|
||||
// Initial load builds UI elements, then constructs workspace tabs as they're encountered in RestoreUserTabs()
|
||||
await applicationController.RestoreUserTabs();
|
||||
|
||||
if (ApplicationSettings.Instance.get(UserSettingsKey.ShownWelcomeMessage) != "false")
|
||||
{
|
||||
|
|
|
|||
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