Esempio n. 1
0
        async void skydriveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ImportFileItem item = this.skydriveList.SelectedItem as ImportFileItem;

            if (item == null)
            {
                return;
            }

            ROMDatabase db = ROMDatabase.Current;


            if (item.Type == SkyDriveItemType.ROM)
            {
                if (item.Stream != null)
                {
                    await SkyDriveImportPage.ImportROM(item, this);
                }
            }

            else if (item.Type == SkyDriveItemType.Savestate || item.Type == SkyDriveItemType.SRAM)
            {
                //check to make sure there is a rom with matching name
                ROMDBEntry entry = null;

                if (item.Type == SkyDriveItemType.Savestate)  //save state
                {
                    entry = db.GetROMFromSavestateName(item.Name);
                }
                else if (item.Type == SkyDriveItemType.SRAM) //sram
                {
                    entry = db.GetROMFromSRAMName(item.Name);
                }

                if (entry == null) //no matching file name
                {
                    MessageBox.Show(AppResources.NoMatchingNameText, AppResources.ErrorCaption, MessageBoxButton.OK);
                    return;
                }

                //check to make sure format is right
                if (item.Type == SkyDriveItemType.Savestate)  //save state
                {
                    string slot       = item.Name.Substring(item.Name.Length - 5, 1);
                    int    parsedSlot = 0;
                    if (!int.TryParse(slot, out parsedSlot))
                    {
                        MessageBox.Show(AppResources.ImportSavestateInvalidFormat, AppResources.ErrorCaption, MessageBoxButton.OK);
                        return;
                    }
                }



                if (item.Stream != null)
                {
                    await SkyDriveImportPage.ImportSave(item, this);
                }
            }
        }
Esempio n. 2
0
        async void skydriveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SDCardListItem item = this.skydriveList.SelectedItem as SDCardListItem;

            if (item == null)
            {
                return;
            }

            ROMDatabase db = ROMDatabase.Current;

            if (item.isFolder)
            {
                this.skydriveList.ItemsSource = null;
                this.currentFolderBox.Text    = item.Name;
                this.OpenFolder(item.ThisFolder);
            }

            else  //file
            {
                if (item.Type == SkyDriveItemType.Zip || item.Type == SkyDriveItemType.Rar || item.Type == SkyDriveItemType.SevenZip)
                {
                    this.skydriveList.ItemsSource = null;
                    this.currentFolderBox.Text    = item.Name;
                    this.downloadsInProgress++;

                    await this.DownloadFile(item);

                    try
                    {
                        List <SDCardListItem> listItems;

                        listItems = this.GetFilesInArchive(item);

                        this.skydriveStack.Add(listItems);
                        this.skydriveList.ItemsSource = listItems;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, AppResources.ErrorCaption, MessageBoxButton.OK);
                    }

                    this.downloadsInProgress--;
                }

                else if (item.Type == SkyDriveItemType.ROM)
                {
                    // Download
                    if (!item.Downloading)
                    {
                        this.downloadsInProgress++;
                        if (item.Stream == null)
                        {
                            await this.DownloadFile(item);
                        }


                        await SkyDriveImportPage.ImportROM(item, this);

                        this.downloadsInProgress--;
                    }
                    else
                    {
                        MessageBox.Show(AppResources.AlreadyDownloadingText, AppResources.ErrorCaption, MessageBoxButton.OK);
                    }
                }

                else if (item.Type == SkyDriveItemType.Savestate || item.Type == SkyDriveItemType.SRAM)
                {
                    //check to make sure there is a rom with matching name
                    ROMDBEntry entry = null;

                    if (item.Type == SkyDriveItemType.Savestate)  //save state
                    {
                        entry = db.GetROMFromSavestateName(item.Name);
                    }
                    else if (item.Type == SkyDriveItemType.SRAM) //sram
                    {
                        entry = db.GetROMFromSRAMName(item.Name);
                    }

                    if (entry == null) //no matching file name
                    {
                        MessageBox.Show(AppResources.NoMatchingNameText, AppResources.ErrorCaption, MessageBoxButton.OK);
                        return;
                    }

                    //check to make sure format is right
                    if (item.Type == SkyDriveItemType.Savestate)  //save state
                    {
                        string slot       = item.Name.Substring(item.Name.Length - 5, 1);
                        int    parsedSlot = 0;
                        if (!int.TryParse(slot, out parsedSlot))
                        {
                            MessageBox.Show(AppResources.ImportSavestateInvalidFormat, AppResources.ErrorCaption, MessageBoxButton.OK);
                            return;
                        }
                    }

                    // Download
                    if (!item.Downloading)
                    {
                        this.downloadsInProgress++;

                        if (item.Stream == null)
                        {
                            await this.DownloadFile(item);
                        }

                        await SkyDriveImportPage.ImportSave(item, this);

                        this.downloadsInProgress--;
                    }
                    else
                    {
                        MessageBox.Show(AppResources.AlreadyDownloadingText, AppResources.ErrorCaption, MessageBoxButton.OK);
                    }
                }
            }
        }