public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);

            var parameters = ShareTargetPageParameters.Deserialize(e.Parameter);
            var fileTokens = parameters?.FileTokens;

            if (fileTokens == null)
            {
                return;
            }
            ActivationKind = parameters.ActivationKind;
            FileTokens     = fileTokens;
            Directory      = DirectoryService.Instance;
            StartDirectoryListing();
            _isNavigatingBack = false;
        }
Beispiel #2
0
        protected override async Task OnActivateApplicationAsync(IActivatedEventArgs args)
        {
            ActivatedEventArgs = args;
            await base.OnActivateApplicationAsync(args);

            // Remove unnecessary notifications whenever the app is used.
            ToastNotificationManager.History.RemoveGroup(ToastNotificationService.SyncAction);

            // Handle toast activation
            var eventArgs = args as ToastNotificationActivatedEventArgs;

            if (eventArgs != null)
            {
                var toastActivationArgs = eventArgs;
                // Parse the query string
                var query = QueryString.Parse(toastActivationArgs.Argument);
                // See what action is being requested
                switch (query["action"])
                {
                // Nothing to do here
                case ToastNotificationService.SyncAction:
                    NavigationService.Navigate(PageToken.DirectoryList.ToString(), null);
                    break;

                // Open Conflict Page
                case ToastNotificationService.SyncConflictAction:
                    ToastNotificationManager.History.RemoveGroup(ToastNotificationService.SyncConflictAction);
                    NavigationService.Navigate(PageToken.SyncConflict.ToString(), null);
                    break;
                }
            }
            else
            {
                switch (args.Kind)
                {
                case ActivationKind.Protocol:
                    var protocolArgs = args as ProtocolActivatedEventArgs;

                    if (protocolArgs != null && protocolArgs.Uri.AbsolutePath == "/share")
                    {
                        var pageParameters = new ShareTargetPageParameters()
                        {
                            ActivationKind = ActivationKind.ShareTarget,
                            FileTokens     = new List <string>()
                        };

                        if (protocolArgs.Data.ContainsKey("FileTokens"))
                        {
                            var tokens = protocolArgs.Data["FileTokens"] as string[];
                            if (tokens != null)
                            {
                                foreach (var token in tokens)
                                {
                                    pageParameters.FileTokens.Add(token);
                                }
                            }
                        }

                        CheckSettingsAndContinue(PageToken.ShareTarget, pageParameters);
                    }
                    break;

                case ActivationKind.FileSavePicker:
                case ActivationKind.CachedFileUpdater:
                    CheckSettingsAndContinue(PageToken.FileSavePicker, null);
                    break;

                case ActivationKind.File:
                    if (args is FileActivatedEventArgs activatedEventArgs)
                    {
                        var sorageItems    = activatedEventArgs.Files;
                        var pageParameters = new ShareTargetPageParameters()
                        {
                            //ShareOperation = activatedEventArgs.ShareOperation,
                            ActivationKind = ActivationKind.ShareTarget,
                            FileTokens     = new List <string>()
                        };
                        StorageApplicationPermissions.FutureAccessList.Clear();
                        foreach (var storageItem in sorageItems)
                        {
                            var token = StorageApplicationPermissions.FutureAccessList.Add(storageItem);
                            pageParameters.FileTokens.Add(token);
                        }
                        CheckSettingsAndContinue(PageToken.ShareTarget, pageParameters);
                    }
                    break;
                }
            }
        }