コード例 #1
0
        private async void OpenFolder_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var folder = ((HyperlinkButton)sender).Tag.ToString();

            try
            {
                await LaunchOperations.LaunchFolderFromPathAsync(folder);
            }
            catch (System.IO.FileNotFoundException)
            {
                await(new MessageDialog("File or folder does not exist.")).ShowAsync();
            }
            catch (UnauthorizedAccessException)
            {
                await(new MessageDialog($"We're sorry, but we can't access this folder.\r\nTry finding it manually on File Explorer in '{folder}'")).ShowAsync();
            }
        }
コード例 #2
0
        private async void OpenSingleFileContainingFolder_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var info = (ViewModels.History.FileInfo)(((Button)sender).Tag);

            try
            {
                await LaunchOperations.LaunchFolderFromPathAndSelectSingleItemAsync(info.Path, info.FileName);
            }
            catch (System.IO.FileNotFoundException)
            {
                await(new MessageDialog("File or folder does not exist.")).ShowAsync();
            }
            catch (UnauthorizedAccessException)
            {
                await(new MessageDialog($"We're sorry, but we can't access this folder.\r\nTry finding it manually on File Explorer in '{info.Path}'")).ShowAsync();
            }
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: meteorsnows/Roamit
        protected override async void OnActivated(IActivatedEventArgs e)
        {
            Debug.WriteLine("Activated.");

            Frame rootFrame = Window.Current.Content as Frame;

            bool isJustLaunched = (rootFrame == null);

            if (e is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = e as ToastNotificationActivatedEventArgs;

                // Parse the query string
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);

                if (!args.Contains("action"))
                {
                    LaunchRootFrameIfNecessary(ref rootFrame, true);
                    return;
                }

                HistoryRow hr;
                switch (args["action"])
                {
                case "cloudClipboard":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ClipboardReceive), "CLOUD_CLIPBOARD");
                    break;

                case "clipboardReceive":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ClipboardReceive), args["guid"]);
                    break;

                case "fileProgress":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    if (rootFrame.Content is MainPage)
                    {
                        break;
                    }
                    rootFrame.Navigate(typeof(MainPage));
                    break;

                case "fileFinished":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    if (rootFrame.Content is MainPage)
                    {
                        break;
                    }
                    rootFrame.Navigate(typeof(MainPage), "history");
                    break;

                case "openFolder":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFolderFromPathAsync((hr.Data as ReceivedFileCollection).StoreRootPath);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "openFolderSingleFile":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFolderFromPathAndSelectSingleItemAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "openSingleFile":
                    hr = await GetHistoryItemGuid(Guid.Parse(args["guid"]));

                    await LaunchOperations.LaunchFileFromPathAsync((hr.Data as ReceivedFileCollection).Files[0].StorePath, (hr.Data as ReceivedFileCollection).Files[0].Name);

                    if (isJustLaunched)
                    {
                        Application.Current.Exit();
                    }
                    break;

                case "saveAsSingleFile":
                case "saveAs":
                    LaunchRootFrameIfNecessary(ref rootFrame, false);
                    rootFrame.Navigate(typeof(ProgressPage));
                    var guid = Guid.Parse(args["guid"]);
                    await ReceivedSaveAsHelper.SaveAs(guid);

                    if ((isJustLaunched) || (DeviceInfo.FormFactorType != DeviceInfo.DeviceFormFactorType.Desktop))
                    {
                        Application.Current.Exit();
                    }
                    else
                    {
                        rootFrame.GoBack();
                    }
                    break;

                default:
                    LaunchRootFrameIfNecessary(ref rootFrame, true);
                    break;
                }
            }
            else if (e.Kind == ActivationKind.Protocol)
            {
                ProtocolActivatedEventArgs pEventArgs = e as ProtocolActivatedEventArgs;

                if ((pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake") || (pEventArgs.Uri.AbsoluteUri.ToLower() == "roamit://wake/"))
                {
                    Debug.WriteLine("Wake request received");
                    Application.Current.Exit();
                }
                else
                {
                    string clipboardData       = ParseFastClipboardUri(pEventArgs.Uri.AbsoluteUri);
                    string remoteLaunchUriData = ParseRemoteLaunchUri(pEventArgs.Uri.AbsoluteUri);
                    string localLaunchUriData  = ParseLocalLaunchUri(pEventArgs.Uri.AbsoluteUri);
                    string commServiceData     = ParseCommunicationServiceData(pEventArgs.Uri.AbsoluteUri);
                    bool   isSettings          = ParseSettings(pEventArgs.Uri.AbsoluteUri);
                    string receiveDialogData   = ParseReceive(pEventArgs.Uri.AbsoluteUri);


                    if (isSettings)
                    {
                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                        }
                        rootFrame.Navigate(typeof(MainPage), "settings");
                    }
                    else if (receiveDialogData.Length > 0)
                    {
                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                        }
                        rootFrame.Navigate(typeof(MainPage), "receiveDialog");

                        if (receiveDialogData.Length > 1)
                        {
                            var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(receiveDialogData.Substring(1).DecodeBase64());
                            await ParseMessage(data);
                        }
                    }
                    else if (commServiceData.Length > 0)
                    {
                        var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(commServiceData.DecodeBase64());
                        await ParseMessage(data);
                    }
                    else if (clipboardData.Length > 0)
                    {
                        string[] parts = clipboardData.Split('?');
                        var      guid  = await TextReceiver.QuickTextReceivedAsync(parts[0].DecodeBase64(), parts[1].DecodeBase64());

                        LaunchRootFrameIfNecessary(ref rootFrame, false);
                        rootFrame.Navigate(typeof(ClipboardReceive), guid.ToString());
                    }
                    else if (remoteLaunchUriData.Length > 0)
                    {
#if !DEBUG
                        App.Tracker.Send(HitBuilder.CreateCustomEvent("ExtensionCalled", "").Build());
#endif

                        string type = ExternalContentHelper.SetUriData(new Uri(remoteLaunchUriData.DecodeBase64()));

                        SendDataTemporaryStorage.IsSharingTarget = true;

                        if (rootFrame == null)
                        {
                            LaunchRootFrameIfNecessary(ref rootFrame, false);
                            rootFrame.Navigate(typeof(MainPage), new ShareTargetDetails
                            {
                                Type = type,
                            });
                        }
                        else
                        {
                            MainPage.Current.BeTheShareTarget(new ShareTargetDetails
                            {
                                Type = type,
                            });
                        }
                    }
                    else if (localLaunchUriData.Length > 0)
                    {
                        try
                        {
                            //TODO: Log it in history
                            await LaunchOperations.LaunchUrl(localLaunchUriData.DecodeBase64());
                        }
                        catch
                        {
                        }

                        if (rootFrame == null)
                        {
                            Application.Current.Exit();
                        }
                    }
                    else
                    {
                        LaunchRootFrameIfNecessary(ref rootFrame, true);
                    }
                }
            }
            else
            {
                LaunchRootFrameIfNecessary(ref rootFrame, true);
            }

            base.OnActivated(e);
        }
コード例 #4
0
        //private async void GetForAndroid_Tapped(object sender, TappedRoutedEventArgs e)
        //{
        //    await LaunchOperations.LaunchUrl(Constants.GooglePlayAppUrl);
        //}

        //private async void GetForWindows_Tapped(object sender, TappedRoutedEventArgs e)
        //{
        //    await LaunchOperations.LaunchUrl(Constants.WindowsStoreAppUrl);
        //}

        private async void GetForWindowsAndAndroid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            await LaunchOperations.LaunchUrl(Constants.RoamitHomepageUrl);
        }
コード例 #5
0
 private async void GetExtension_Tapped(object sender, TappedRoutedEventArgs e)
 {
     await LaunchOperations.LaunchUrl(Constants.BrowserExtensionsUrl);
 }