private void Properties_PropertyClicked(PropertyPage props, ClickType click, int propIdx, int rowIdx, int colIdx)
 {
     if (saveMode)
     {
         var idx = dialog.Properties.GetSelectedIndex(0);
         if (idx >= 0 && idx < userProjects.Count - 1)
         {
             PlatformUtils.MessageBoxAsync("Delete project?", "Delete", MessageBoxButtons.YesNo, (r) =>
             {
                 if (r == DialogResult.Yes)
                 {
                     File.Delete(GetUserProjectFilename(userProjects[idx]));
                     userProjects.RemoveAt(idx);
                     props.UpdateRadioButtonList(0, userProjects.ToArray(), userProjects.Count - 1);
                     props.SetPropertyEnabled(1, true);
                     props.SetPropertyEnabled(2, false);
                     PlatformUtils.ShowToast("Project Deleted!");
                 }
             });
         }
     }
     else
     {
         // HACK : We dont support nested activities right now, so return
         // this special code to signal that we should open from storage.
         storageFilename = "///STORAGE///";
         dialog.CloseWithResult(DialogResult.OK);
     }
 }
Example #2
0
        private void ExportRom()
        {
            var props   = dialog.GetPropertyPage((int)ExportFormat.Rom);
            var songIds = GetSongIds(props.GetPropertyValue <bool[]>(4));

            if (songIds.Length > RomFileBase.MaxSongs)
            {
                PlatformUtils.MessageBoxAsync($"Please select {RomFileBase.MaxSongs} songs or less.", "ROM Export", MessageBoxButtons.OK);
                return;
            }

            if (props.GetPropertyValue <string>(0) == "NES ROM")
            {
                Action <string> ExportRomAction = (filename) =>
                {
                    if (filename != null)
                    {
                        var rom = new RomFile();
                        rom.Save(
                            project, filename, songIds,
                            props.GetPropertyValue <string>(1),
                            props.GetPropertyValue <string>(2),
                            props.GetPropertyValue <string>(3) == "PAL");

                        lastExportFilename = filename;
                    }
                };

                if (PlatformUtils.IsMobile)
                {
                    PlatformUtils.StartMobileSaveFileOperationAsync("*/*", $"{project.Name}.nes", (f) =>
                    {
                        ExportRomAction(f);
                        PlatformUtils.FinishMobileSaveFileOperationAsync(true, () => { PlatformUtils.ShowToast("NES ROM Export Successful!"); });
                    });
                }
                else
                {
                    var filename = lastExportFilename != null ? lastExportFilename : PlatformUtils.ShowSaveFileDialog("Export ROM File", "NES ROM (*.nes)|*.nes", ref Settings.LastExportFolder);
                    ExportRomAction(filename);
                }
            }
            else
            {
                Action <string> ExportFdsAction = (filename) =>
                {
                    if (filename != null)
                    {
                        var fds = new FdsFile();
                        fds.Save(
                            project, filename, songIds,
                            props.GetPropertyValue <string>(1),
                            props.GetPropertyValue <string>(2));

                        lastExportFilename = filename;
                    }
                };

                if (PlatformUtils.IsMobile)
                {
                    PlatformUtils.StartMobileSaveFileOperationAsync("*/*", $"{project.Name}.fds", (f) =>
                    {
                        ExportFdsAction(f);
                        PlatformUtils.FinishMobileSaveFileOperationAsync(true, () => { PlatformUtils.ShowToast("FDS Disk Export Successful!"); });
                    });
                }
                else
                {
                    var filename = lastExportFilename != null ? null : PlatformUtils.ShowSaveFileDialog("Export Famicom Disk", "FDS Disk (*.fds)|*.fds", ref Settings.LastExportFolder);
                    ExportFdsAction(filename);
                }
            }
        }