Exemplo n.º 1
0
        public ManageSavestatePage()
        {
            InitializeComponent();

            //create ad control
            if (PhoneDirect3DXamlAppComponent.EmulatorSettings.Current.ShouldShowAds)
            {
                AdControl adControl = new AdControl();
                ((Grid)(LayoutRoot.Children[0])).Children.Add(adControl);
                adControl.SetValue(Grid.RowProperty, 2);
            }


            db = ROMDatabase.Current;

            object tmp;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);
            this.romEntry = tmp as ROMDBEntry;
            PhoneApplicationService.Current.State.Remove("parameter");

            titleLabel.Text = this.romEntry.DisplayName;

            CreateAppBar();

            var savestates = db.GetSavestatesForROM(this.romEntry);

            this.stateList.ItemsSource = savestates;
        }
Exemplo n.º 2
0
        public ManageSavestatePage()
        {
            InitializeComponent();

#if GBC
            SystemTray.GetProgressIndicator(this).Text = AppResources.ApplicationTitle2;
#endif
            //create ad control
            if (App.HasAds)
            {
                AdControl adControl = new AdControl();
                ((Grid)(LayoutRoot.Children[0])).Children.Add(adControl);
                adControl.SetValue(Grid.RowProperty, 2);
            }


            db = ROMDatabase.Current;

            object tmp;
            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);
            this.romEntry = tmp as ROMDBEntry;
            PhoneApplicationService.Current.State.Remove("parameter");

            titleLabel.Text = this.romEntry.DisplayName;

            CreateAppBar();

            var savestates = db.GetSavestatesForROM(this.romEntry);

            this.stateList.ItemsSource = savestates;
        }
Exemplo n.º 3
0
        private void DeleteSaveMenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            ListBoxItem contextMenuListItem = this.romList.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem;
            ROMDBEntry  re = contextMenuListItem.DataContext as ROMDBEntry;

            FileHandler.DeleteSRAMFile(re);
        }
Exemplo n.º 4
0
        private async Task Init()
        {
            object tmp;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);

            if (tmp == null)
            {
                //go back because there is no information about the rom entry
                if (this.NavigationService.CanGoBack)
                {
                    this.NavigationService.GoBack();
                }
                return;
            }

            this.romEntry = tmp as ROMDBEntry;
            this.game     = romEntry.DisplayName;
            PhoneApplicationService.Current.State.Remove("parameter");
            this.gameNameLabel.Text   = game;
            this.txtSearchString.Text = romEntry.DisplayName;

            try
            {
                this.cheatCodes = await FileHandler.LoadCheatCodes(this.romEntry);
            }
            catch (Exception) { }

            this.RefreshCheatList();
        }
Exemplo n.º 5
0
        public static void UpdateROMTile(string romFileName)
        {
            var tiles = ShellTile.ActiveTiles;

            romFileName = romFileName.ToLower();
            foreach (var tile in tiles)
            {
                int index = tile.NavigationUri.OriginalString.LastIndexOf('=');
                if (index < 0)
                {
                    continue;
                }
                String romName = tile.NavigationUri.OriginalString.Substring(index + 1);
                if (romName.ToLower().Equals(romFileName))
                {
                    ROMDatabase db    = ROMDatabase.Current;
                    ROMDBEntry  entry = db.GetROM(romFileName);
                    if (entry == null)
                    {
                        break;
                    }

                    FlipTileData data = CreateFlipTileData(entry);
                    tile.Update(data);

                    break;
                }
            }
        }
Exemplo n.º 6
0
        private static void createSavestate(int slot, string romFileName)
        {
            ROMDatabase db           = ROMDatabase.Current;
            string      saveFileName = romFileName.Substring(0, romFileName.Length - 3);

            if (slot < 10)
            {
                saveFileName += "00" + slot;
            }
            else
            {
                saveFileName += "0" + slot;
            }
            SavestateEntry entry;

            if ((entry = db.GetSavestate(romFileName, slot)) == null)
            {
                ROMDBEntry rom = db.GetROM(romFileName);
                entry = new SavestateEntry()
                {
                    ROM         = rom,
                    FileName    = saveFileName,
                    ROMFileName = romFileName,
                    Savetime    = DateTime.Now,
                    Slot        = slot
                };
                db.Add(entry);
            }
            else
            {
                entry.Savetime = DateTime.Now;
            }
            db.CommitChanges();
        }
Exemplo n.º 7
0
        public static async Task FindExistingSavestatesForNewROM(ROMDBEntry entry)
        {
            ROMDatabase   db          = ROMDatabase.Current;
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder   = await localFolder.GetFolderAsync(ROM_DIRECTORY);

            StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);

            IReadOnlyList <StorageFile> saves = await saveFolder.GetFilesAsync();

            // Savestates zuordnen
            foreach (var save in saves)
            {
                if (save.Name.Substring(0, save.Name.Length - 2).Equals(entry.DisplayName + ".0"))
                {
                    // Savestate gehoert zu ROM
                    String         number  = save.Name.Substring(save.Name.Length - 2);
                    int            slot    = int.Parse(number);
                    SavestateEntry ssEntry = new SavestateEntry()
                    {
                        ROM      = entry,
                        Savetime = save.DateCreated.DateTime,
                        Slot     = slot,
                        FileName = save.Name
                    };
                    db.Add(ssEntry);
                }
            }
        }
Exemplo n.º 8
0
        private static void createSavestate(int slot, string romFileName)
        {
            ROMDatabase db = ROMDatabase.Current;



            int index = romFileName.LastIndexOf('.');
            int diff  = romFileName.Length - index;

            string saveFileName = romFileName.Substring(0, romFileName.Length - diff);

            saveFileName += slot;
            saveFileName += ".sgm";

            SavestateEntry entry;

            if ((entry = db.GetSavestate(romFileName, slot)) == null)
            {
                ROMDBEntry rom = db.GetROM(romFileName);
                entry = new SavestateEntry()
                {
                    ROM         = rom,
                    FileName    = saveFileName,
                    ROMFileName = romFileName,
                    Savetime    = DateTime.Now,
                    Slot        = slot
                };
                db.Add(entry);
            }
            else
            {
                entry.Savetime = DateTime.Now;
            }
            db.CommitChanges();
        }
Exemplo n.º 9
0
        private static FlipTileData CreateFlipTileData(ROMDBEntry re)
        {
            FlipTileData data = new FlipTileData();

            data.Title = re.DisplayName;
            if (re.SnapshotURI.Equals(FileHandler.DEFAULT_SNAPSHOT) || re.SnapshotURI.Equals(FileHandler.DEFAULT_SNAPSHOT_ALT))
            {
#if !GBC
                data.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative);
                data.BackgroundImage      = new Uri("Assets/Tiles/FlipCycleTileMedium.png", UriKind.Relative);
                data.WideBackgroundImage  = new Uri("Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative);
#else
                data.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmallGBC.png", UriKind.Relative);
                data.BackgroundImage      = new Uri("Assets/Tiles/FlipCycleTileMediumGBC.png", UriKind.Relative);
                data.WideBackgroundImage  = new Uri("Assets/Tiles/FlipCycleTileLargeGBC.png", UriKind.Relative);
#endif
            }
            else
            {
                data.SmallBackgroundImage = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
                data.BackgroundImage      = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
                data.WideBackgroundImage  = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
            }
            return(data);
        }
Exemplo n.º 10
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);
                }
            }
        }
Exemplo n.º 11
0
        internal static async Task <List <CheatData> > LoadCheatCodes(ROMDBEntry re)
        {
            List <CheatData> cheats      = new List <CheatData>();
            String           romFileName = re.FileName;
            int index = romFileName.LastIndexOf('.');
            int diff  = romFileName.Length - index;

            string cheatFileName = romFileName.Substring(0, romFileName.Length - diff);

            cheatFileName += ".cht";

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder   = await localFolder.GetFolderAsync(ROM_DIRECTORY);

            StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);

            StorageFile file = null;

            try
            {
                file = await saveFolder.GetFileAsync(cheatFileName);
            }
            catch (System.IO.FileNotFoundException)
            {
                return(cheats);
            }
            string codes = null;

            using (var stream = await file.OpenReadAsync())
            {
                using (var readStream = stream.GetInputStreamAt(0L))
                {
                    using (DataReader reader = new DataReader(readStream))
                    {
                        await reader.LoadAsync((uint)stream.Size);

                        codes = reader.ReadString((uint)stream.Size);
                    }
                }
            }
            if (!String.IsNullOrWhiteSpace(codes))
            {
                string[] lines = codes.Split('\n');
                for (int i = 0; i < lines.Length; i += 3)
                {
                    if (lines.Length - i < 3)
                    {
                        continue;
                    }
                    CheatData data = new CheatData();
                    data.Description = lines[i];
                    data.CheatCode   = lines[i + 1];
                    data.Enabled     = lines[i + 2].Equals("1");

                    cheats.Add(data);
                }
            }

            return(cheats);
        }
Exemplo n.º 12
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            await this.initTask;

            try
            {
                String romFileName = NavigationContext.QueryString[FileHandler.ROM_URI_STRING];
                NavigationContext.QueryString.Remove(FileHandler.ROM_URI_STRING);

                ROMDBEntry entry = this.db.GetROM(romFileName);
                await this.StartROM(entry);
            }
            catch (KeyNotFoundException)
            { }
            catch (Exception)
            {
                MessageBox.Show(AppResources.TileOpenError, AppResources.ErrorCaption, MessageBoxButton.OK);
            }

            try
            {
                String importRomID = NavigationContext.QueryString["fileToken"];
                NavigationContext.QueryString.Remove("fileToken");

                ROMDBEntry entry = await FileHandler.ImportRomBySharedID(importRomID);

                await this.StartROM(entry);
            }
            catch (KeyNotFoundException)
            { }
            catch (Exception)
            {
                MessageBox.Show(AppResources.FileAssociationError, AppResources.ErrorCaption, MessageBoxButton.OK);
            }
        }
Exemplo n.º 13
0
        private void SaveStateMenuItem_Click(object sender, RoutedEventArgs e)
        {
            ListBoxItem contextMenuListItem = this.romList.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem;
            ROMDBEntry  re = contextMenuListItem.DataContext as ROMDBEntry;

            PhoneApplicationService.Current.State["parameter"] = re;
            this.NavigationService.Navigate(new Uri("/ManageSavestatePage.xaml", UriKind.Relative));
        }
Exemplo n.º 14
0
        private void StackPanel_Hold(object sender, System.Windows.Input.GestureEventArgs e)
        {
            ROMDBEntry entry = (sender as StackPanel).DataContext as ROMDBEntry;

            PhoneApplicationService.Current.State["parameter"] = entry;

            this.NavigationService.Navigate(new Uri("/ContextPage.xaml", UriKind.Relative));
        }
Exemplo n.º 15
0
        public ContextPage()
        {
            InitializeComponent();

            this.entry = PhoneApplicationService.Current.State["parameter"] as ROMDBEntry;
            PhoneApplicationService.Current.State.Remove("parameter");

            this.titleBox.Text = this.entry.DisplayName;
        }
Exemplo n.º 16
0
        public static async Task SaveCheatCodes(ROMDBEntry re, List <CheatData> cheatCodes)
        {
            try
            {
                String romFileName = re.FileName;
                int    index       = romFileName.LastIndexOf('.');
                int    diff        = romFileName.Length - index;

                string cheatFileName = romFileName.Substring(0, romFileName.Length - diff);
                cheatFileName += ".cht";

                StorageFolder localFolder = ApplicationData.Current.LocalFolder;
                StorageFolder romFolder   = await localFolder.GetFolderAsync(ROM_DIRECTORY);

                StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);


                StorageFile file = await saveFolder.CreateFileAsync("cheattmp.cht", CreationCollisionOption.ReplaceExisting);

                using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    using (IOutputStream outStream = stream.GetOutputStreamAt(0L))
                    {
                        using (DataWriter writer = new DataWriter(outStream))
                        {
                            writer.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
                            writer.ByteOrder       = Windows.Storage.Streams.ByteOrder.LittleEndian;

                            for (int i = 0; i < cheatCodes.Count; i++)
                            {
                                if (i > 0)
                                {
                                    writer.WriteString("\n");
                                }
                                writer.WriteString(cheatCodes[i].Description);
                                writer.WriteString("\n");
                                writer.WriteString(cheatCodes[i].CheatCode);
                                writer.WriteString("\n");
                                writer.WriteString(cheatCodes[i].Enabled ? "1" : "0");
                            }
                            await writer.StoreAsync();

                            await writer.FlushAsync();

                            writer.DetachStream();
                        }
                    }
                }

                //rename the temp file to the offical file
                await file.RenameAsync(cheatFileName, NameCollisionOption.ReplaceExisting);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Save cheat code error: " + ex.Message);
            }
        }
Exemplo n.º 17
0
        private async Task StartROM(ROMDBEntry entry)
        {
            LoadROMParameter param = await FileHandler.GetROMFileToPlayAsync(entry.FileName);

            entry.LastPlayed = DateTime.Now;
            this.db.CommitChanges();

            PhoneApplicationService.Current.State["parameter"] = param;
            this.NavigationService.Navigate(new Uri("/EmulatorPage.xaml", UriKind.Relative));
        }
Exemplo n.º 18
0
        private static void captureSnapshot(ushort[] pixeldata, int pitch, string filename)
        {
            WriteableBitmap bitmap = new WriteableBitmap(pitch / 2, (int)pixeldata.Length / (pitch / 2));
            int             x      = 0;
            int             y      = 0;

            for (int i = 0; i < bitmap.PixelWidth * bitmap.PixelHeight; i++)
            {
                ushort pixel = pixeldata[i];
                byte   r     = (byte)((pixel & 0xf800) >> 11);
                byte   g     = (byte)((pixel & 0x07e0) >> 5);
                byte   b     = (byte)(pixel & 0x001f);
                r = (byte)((255 * r) / 31);
                g = (byte)((255 * g) / 63);
                b = (byte)((255 * b) / 31);
                bitmap.SetPixel(x, y, r, g, b);
                x++;
                if (x >= bitmap.PixelWidth)
                {
                    y++;
                    x = 0;
                }
            }
            String snapshotName = filename.Substring(0, filename.Length - 3) + "jpg";

            //StorageFolder folder = await ApplicationData.Current.LocalFolder.GetFolderAsync(ROM_DIRECTORY);
            ////StorageFolder saveFolder = await folder.GetFolderAsync(SAVE_DIRECTORY);
            //StorageFolder shared = await folder.GetFolderAsync("Shared");
            //StorageFolder shellContent = await shared.GetFolderAsync("ShellContent");
            //StorageFile file = await shellContent.CreateFileAsync(snapshotName, CreationCollisionOption.ReplaceExisting);

            try
            {
                IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream("/Shared/ShellContent/" + snapshotName, System.IO.FileMode.Create, iso))
                {
                    bitmap.SaveJpeg(fs, bitmap.PixelWidth, bitmap.PixelHeight, 0, 90);
                    //await fs.FlushAsync();
                    fs.Flush(true);
                }
                ROMDatabase db    = ROMDatabase.Current;
                ROMDBEntry  entry = db.GetROM(filename);
                entry.SnapshotURI = "Shared/ShellContent/" + snapshotName;
                db.CommitChanges();

                UpdateLiveTile();

                CreateOrUpdateSecondaryTile(false);

                UpdateROMTile(filename);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 19
0
        private static void captureSnapshot(byte[] pixeldata, int pitch, string filename)
        {
            int    pixelWidth  = pitch / 4;
            int    pixelHeight = (int)pixeldata.Length / pitch;
            Bitmap bitmap      = new Bitmap(pixelWidth, pixelHeight, 24);
            int    x           = 0;
            int    y           = 0;

            for (int i = 0; i < pitch * pixelHeight; i += 4)
            {
                byte  r = pixeldata[i];
                byte  g = pixeldata[i + 1];
                byte  b = pixeldata[i + 2];
                Color c = Color.FromArgb(0xff, r, g, b);
                bitmap.SetColor(x, y, c);
                x++;
                if (x >= pixelWidth)
                {
                    y++;
                    x = 0;
                }
            }

            int index = filename.LastIndexOf('.');
            int diff  = filename.Length - 1 - index;

            String snapshotName = filename.Substring(0, filename.Length - diff) + "bmp";

            try
            {
                IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication();
                using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream("/Shared/ShellContent/" + snapshotName, System.IO.FileMode.Create, iso))
                {
                    bitmap.Save(fs);

                    fs.Flush(true);
                }
                ROMDatabase db    = ROMDatabase.Current;
                ROMDBEntry  entry = db.GetROM(filename);
                entry.SnapshotURI = "Shared/ShellContent/" + snapshotName;
                db.CommitChanges();

                UpdateLiveTile();

                CreateOrUpdateSecondaryTile(false);

                UpdateROMTile(filename);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 20
0
        private async void StartROMFromList(ListBox list)
        {
            if (list.SelectedItem == null)
            {
                return;
            }

            ROMDBEntry entry = (ROMDBEntry)list.SelectedItem;

            list.SelectedItem = null;

            await StartROM(entry);
        }
Exemplo n.º 21
0
        public static async Task DeleteROMAsync(ROMDBEntry rom)
        {
            ROMDatabase   db       = ROMDatabase.Current;
            String        fileName = rom.FileName;
            StorageFolder folder   = await ApplicationData.Current.LocalFolder.GetFolderAsync(ROM_DIRECTORY);

            StorageFile file = await folder.GetFileAsync(fileName);

            DeleteROMTile(file.Name);
            await file.DeleteAsync(StorageDeleteOption.PermanentDelete);

            db.RemoveROM(file.Name);
            db.CommitChanges();
        }
Exemplo n.º 22
0
        private static void PinToStart(object sender, ListBox list)
        {
            ListBoxItem contextMenuListItem = list.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem;
            ROMDBEntry  re = contextMenuListItem.DataContext as ROMDBEntry;

            try
            {
                FileHandler.CreateROMTile(re);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(AppResources.MaximumTilesPinned);
            }
        }
Exemplo n.º 23
0
        private async Task DeleteListEntry(object sender, ListBox list)
        {
            ListBoxItem contextMenuListItem = list.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem;
            ROMDBEntry  re = contextMenuListItem.DataContext as ROMDBEntry;

            try
            {
                await FileHandler.DeleteROMAsync(re);

                this.RefreshROMList();
            }
            catch (System.IO.FileNotFoundException ex)
            { }
        }
Exemplo n.º 24
0
        public static ROMDBEntry InsertNewDBEntry(string fileName)
        {
            ROMDatabase db          = ROMDatabase.Current;
            string      displayName = fileName.Substring(0, fileName.Length - 4);
            ROMDBEntry  entry       = new ROMDBEntry()
            {
                DisplayName = displayName,
                FileName    = fileName,
                LastPlayed  = DEFAULT_DATETIME,
                SnapshotURI = DEFAULT_SNAPSHOT
            };

            db.Add(entry);
            return(entry);
        }
Exemplo n.º 25
0
        public static async Task FillDatabaseAsync()
        {
            ROMDatabase   db          = ROMDatabase.Current;
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder   = await localFolder.GetFolderAsync(ROM_DIRECTORY);

            IReadOnlyList <StorageFile> roms = await romFolder.GetFilesAsync();

            foreach (var file in roms)
            {
                ROMDBEntry entry = FileHandler.InsertNewDBEntry(file.Name);
                await FileHandler.FindExistingSavestatesForNewROM(entry);
            }
            db.CommitChanges();
        }
Exemplo n.º 26
0
        internal static async Task DeleteSRAMFile(ROMDBEntry re)
        {
            string sramName = re.FileName.Substring(0, re.FileName.LastIndexOf('.')) + ".sav";

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder   = await localFolder.GetFolderAsync(ROM_DIRECTORY);

            StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);

            try
            {
                IStorageFile file = await saveFolder.GetFileAsync(sramName);

                await file.DeleteAsync();
            }
            catch (Exception) { }
        }
Exemplo n.º 27
0
        public static ROMDBEntry InsertNewDBEntry(string fileName)
        {
            int index = fileName.LastIndexOf('.');
            int diff  = fileName.Length - index;

            string     displayName = fileName.Substring(0, fileName.Length - diff);
            ROMDBEntry entry       = new ROMDBEntry()
            {
                DisplayName = displayName,
                FileName    = fileName,
                LastPlayed  = DEFAULT_DATETIME,
                SnapshotURI = DEFAULT_SNAPSHOT
            };

            ROMDatabase.Current.Add(entry);
            return(entry);
        }
Exemplo n.º 28
0
        //public static async Task RenameROMFile(string oldname, string newname)
        //{
        //    ROMDatabase db = ROMDatabase.Current;


        //    StorageFolder localFolder = ApplicationData.Current.LocalFolder;
        //    StorageFolder romFolder = await localFolder.GetFolderAsync(ROM_DIRECTORY);

        //    StorageFile oldfile = await romFolder.GetFileAsync(oldname);
        //    StorageFile newfile = await romFolder.CreateFileAsync(newname, CreationCollisionOption.ReplaceExisting);

        //    using (var outputStream = await newfile.OpenStreamForWriteAsync())
        //    {
        //        using (var inputStream = await oldfile.OpenStreamForReadAsync())
        //        {
        //            await inputStream.CopyToAsync(outputStream);
        //        }
        //    }


        //}



        internal static async Task <ROMDBEntry> ImportRomBySharedID(string fileID, string desiredName, DependencyObject page)
        {
            //note: desiredName can be different from the file name obtained from fileID
            ROMDatabase db = ROMDatabase.Current;


            //set status bar
            var indicator = SystemTray.GetProgressIndicator(page);

            indicator.IsIndeterminate = true;
            indicator.Text            = String.Format(AppResources.ImportingProgressText, desiredName);



            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder   = await localFolder.CreateFolderAsync(ROM_DIRECTORY, CreationCollisionOption.OpenIfExists);

            IStorageFile file = await SharedStorageAccessManager.CopySharedFileAsync(romFolder, desiredName, NameCollisionOption.ReplaceExisting, fileID);


            ROMDBEntry entry = db.GetROM(file.Name);

            if (entry == null)
            {
                entry = FileHandler.InsertNewDBEntry(file.Name);
                await FileHandler.FindExistingSavestatesForNewROM(entry);

                db.CommitChanges();
            }

            //update voice command list
            await MainPage.UpdateGameListForVoiceCommand();

#if GBC
            indicator.Text = AppResources.ApplicationTitle2;
#else
            indicator.Text = AppResources.ApplicationTitle;
#endif
            indicator.IsIndeterminate = false;

            MessageBox.Show(String.Format(AppResources.ImportCompleteText, entry.DisplayName));


            return(entry);
        }
Exemplo n.º 29
0
        private async void Init()
        {
            object tmp;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);
            this.romEntry = tmp as ROMDBEntry;
            this.game     = romEntry.DisplayName;
            PhoneApplicationService.Current.State.Remove("parameter");
            this.gameNameLabel.Text = game;

            try
            {
                this.cheatCodes = await FileHandler.LoadCheatCodes(this.romEntry);
            }
            catch (Exception) { }

            this.RefreshCheatList();
        }
Exemplo n.º 30
0
        private async void linkStartButton_Click(object sender, RoutedEventArgs e)
        {
            ROMDBEntry       firstEntry = (ROMDBEntry)firstGamePicker.SelectedItem;
            LoadROMParameter param      = await FileHandler.GetROMFileToPlayAsync(firstEntry.FileName);

            firstEntry.LastPlayed = DateTime.Now;
            ROMDatabase.Current.CommitChanges();



            ROMDBEntry       secondEntry = (ROMDBEntry)firstGamePicker.SelectedItem;
            LoadROMParameter param2      = await FileHandler.GetROMFileToPlayAsync(secondEntry.FileName);

            PhoneApplicationService.Current.State["parameter"]  = param;
            PhoneApplicationService.Current.State["parameter2"] = param2;

            this.NavigationService.Navigate(new Uri("/LinkedEmulatorPage.xaml", UriKind.Relative));
        }