|
22 | 22 | using Windows.UI.Core;
|
23 | 23 | using Windows.UI.Xaml.Controls.Primitives;
|
24 | 24 | using Windows.System;
|
| 25 | +using Files.CommandLine; |
25 | 26 | using Files.View_Models;
|
26 | 27 |
|
27 | 28 | namespace Files
|
@@ -511,31 +512,74 @@ protected override void OnActivated(IActivatedEventArgs args)
|
511 | 512 | Window.Current.Content = rootFrame;
|
512 | 513 | }
|
513 | 514 |
|
514 |
| - if (args.Kind == ActivationKind.Protocol) |
| 515 | + switch (args.Kind) |
515 | 516 | {
|
516 |
| - var eventArgs = args as ProtocolActivatedEventArgs; |
| 517 | + case ActivationKind.Protocol: |
| 518 | + var eventArgs = args as ProtocolActivatedEventArgs; |
517 | 519 |
|
518 |
| - if (eventArgs.Uri.AbsoluteUri == "files-uwp:") |
519 |
| - { |
520 |
| - rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo()); |
521 |
| - } |
522 |
| - else |
523 |
| - { |
524 |
| - var trimmedPath = eventArgs.Uri.OriginalString.Split('=')[1]; |
525 |
| - rootFrame.Navigate(typeof(InstanceTabsView), @trimmedPath, new SuppressNavigationTransitionInfo()); |
526 |
| - } |
527 |
| - // Ensure the current window is active. |
528 |
| - Window.Current.Activate(); |
529 |
| - Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; |
530 |
| - Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; |
531 |
| - Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; |
532 |
| - return; |
| 520 | + if (eventArgs.Uri.AbsoluteUri == "files-uwp:") |
| 521 | + { |
| 522 | + rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo()); |
| 523 | + } |
| 524 | + else |
| 525 | + { |
| 526 | + var trimmedPath = eventArgs.Uri.OriginalString.Split('=')[1]; |
| 527 | + rootFrame.Navigate(typeof(InstanceTabsView), @trimmedPath, new SuppressNavigationTransitionInfo()); |
| 528 | + } |
| 529 | + // Ensure the current window is active. |
| 530 | + Window.Current.Activate(); |
| 531 | + Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; |
| 532 | + Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; |
| 533 | + Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; |
| 534 | + return; |
| 535 | + |
| 536 | + case ActivationKind.CommandLineLaunch: |
| 537 | + var cmdLineArgs = args as CommandLineActivatedEventArgs; |
| 538 | + var operation = cmdLineArgs.Operation; |
| 539 | + var cmdLineString = operation.Arguments; |
| 540 | + var activationPath = operation.CurrentDirectoryPath; |
| 541 | + |
| 542 | + var parsedCommands = CommandLineParser.ParseUntrustedCommands(cmdLineString); |
| 543 | + |
| 544 | + if (parsedCommands != null && parsedCommands.Count > 0) |
| 545 | + { |
| 546 | + foreach (var command in parsedCommands) |
| 547 | + { |
| 548 | + switch (command.Type) |
| 549 | + { |
| 550 | + case ParsedCommandType.OpenDirectory: |
| 551 | + // TODO Open Directory |
| 552 | + |
| 553 | + rootFrame.Navigate(typeof(InstanceTabsView), command.Payload, new SuppressNavigationTransitionInfo()); |
| 554 | + |
| 555 | + // Ensure the current window is active. |
| 556 | + Window.Current.Activate(); |
| 557 | + Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; |
| 558 | + Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; |
| 559 | + Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; |
| 560 | + |
| 561 | + return; |
| 562 | + case ParsedCommandType.Unkwon: |
| 563 | + rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo()); |
| 564 | + // Ensure the current window is active. |
| 565 | + Window.Current.Activate(); |
| 566 | + Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; |
| 567 | + Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; |
| 568 | + Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; |
| 569 | + return; |
| 570 | + } |
| 571 | + } |
| 572 | + } |
| 573 | + break; |
533 | 574 | }
|
534 |
| - |
| 575 | + |
535 | 576 | rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
|
536 | 577 |
|
537 | 578 | // Ensure the current window is active.
|
538 | 579 | Window.Current.Activate();
|
| 580 | + Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; |
| 581 | + Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed; |
| 582 | + Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; |
539 | 583 | }
|
540 | 584 |
|
541 | 585 | private void TryEnablePrelaunch()
|
|
0 commit comments