Exemplo n.º 1
0
        public override Uri MapUri(Uri uri)
        {
            this.tempUri = uri.ToString();

            if (tempUri.Contains("/FileTypeAssociation"))
            {
                int    fileIdIndex = tempUri.IndexOf("fileToken=") + 10;
                string fileID      = tempUri.Substring(fileIdIndex);

                string incomingFileName = SharedStorageAccessManager.GetSharedFileName(fileID);
                string incomingFileType = Path.GetExtension(incomingFileName).ToLower();

                if (incomingFileType.Contains("cloudsix")) //this is from cloudsix, need to get the true file name and file type
                {
                    CloudSixFileSelected fileinfo = CloudSixPicker.GetAnswer(fileID);
                    incomingFileName = fileinfo.Filename;
                    incomingFileType = Path.GetExtension(incomingFileName).ToLower();
                }


                if (incomingFileType == ".gb" || incomingFileType == ".gbc" || incomingFileType == ".gba" || incomingFileType == ".sav" ||
                    incomingFileType == ".sgm" || incomingFileType == ".zip" || incomingFileType == ".zib" || incomingFileType == ".rar" ||
                    incomingFileType == ".7z")
                {
                    return(new Uri("/MainPage.xaml?fileToken=" + fileID, UriKind.Relative));
                }
                else
                {
                    return(new Uri("/MainPage.xaml", UriKind.Relative));
                }
            }

            return(uri);
        }
Exemplo n.º 2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            //get the fileID
            try
            {
                String fileID = NavigationContext.QueryString["fileToken"];
                NavigationContext.QueryString.Remove("fileToken");

                //currently only zip file need to use this page, copy the zip file to local storage
                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                string        fileName    = SharedStorageAccessManager.GetSharedFileName(fileID);
                tempZipFile = await SharedStorageAccessManager.CopySharedFileAsync(localFolder, fileName, NameCollisionOption.ReplaceExisting, fileID);

                //set the title
                CloudSixFileSelected fileinfo = CloudSixPicker.GetAnswer(fileID);
                currentFolderBox.Text = fileinfo.Filename;
                string ext = Path.GetExtension(fileinfo.Filename).ToLower();

                //open zip file or rar file
                try
                {
                    SkyDriveItemType type = SkyDriveItemType.File;
                    if (ext == ".zip" || ext == ".zib")
                    {
                        type = SkyDriveItemType.Zip;
                    }
                    else if (ext == ".rar")
                    {
                        type = SkyDriveItemType.Rar;
                    }
                    else if (ext == ".7z")
                    {
                        type = SkyDriveItemType.SevenZip;
                    }

                    skydriveStack = await GetFilesInArchive(type, tempZipFile);

                    this.skydriveList.ItemsSource = skydriveStack;

                    var indicator = SystemTray.GetProgressIndicator(this);
                    indicator.IsIndeterminate = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, AppResources.ErrorCaption, MessageBoxButton.OK);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(AppResources.FileAssociationError, AppResources.ErrorCaption, MessageBoxButton.OK);
            }



            base.OnNavigatedTo(e);
        }