Beispiel #1
0
        public static bool SaveFloppyIfRequired(TRS80.Computer Computer, byte DriveNum)
        {
            bool?save = false;

            if (Computer.DiskHasChanged(DriveNum))
            {
                save = dialogs.AskYesNoCancel($"Drive {DriveNum} has changed. Save it?");
            }

            if (!save.HasValue)
            {
                return(false);
            }

            if (save.Value)
            {
                var path = Computer.GetFloppyFilePath(DriveNum);
                if (!IsPathWritable(path))
                {
                    var defaultPath = settings.DefaultFloppyDirectory;
                    if (String.IsNullOrWhiteSpace(defaultPath) || !Directory.Exists(defaultPath))
                    {
                        path = DocsPath;
                    }

                    if (IsLibraryFile(path))
                    {
                        path = GetFloppyFilePath("Choose path to save floppy", Path.Combine(defaultPath, Path.GetFileName(path)), true, true, true);
                    }
                    else
                    {
                        path = GetFloppyFilePath("Choose path to save floppy", defaultPath, true, false, true);
                    }

                    if (string.IsNullOrWhiteSpace(path))
                    {
                        return(false);
                    }
                    else
                    {
                        Computer.SetFloppyFilePath(DriveNum, path);
                        SaveDefaultDriveFileName(DriveNum, path);
                    }
                }
                Computer.SaveFloppy(DriveNum);
            }
            return(true);
        }