Exemplo n.º 1
0
        public static bool SaveTapeIfRequired(Computer Computer)
        {
            bool?save = false;

            if (Computer.TapeChanged)
            {
                save = dialogs.AskYesNoCancel("The tape has been written to. Save it?");
            }

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

            if (save.Value)
            {
                var path = Computer.TapeFilePath;
                if (String.IsNullOrWhiteSpace(path) || IsFileNameToken(path) || !Directory.Exists(Path.GetDirectoryName(path)))
                {
                    if (!Directory.Exists(Path.GetDirectoryName(path)))
                    {
                        path = Path.Combine(AppDataPath, "Tapes\\");
                    }

                    path = dialogs.GetTapeFilePath(path, true);
                    if (string.IsNullOrWhiteSpace(path))
                    {
                        return(false);
                    }
                    else
                    {
                        Computer.TapeFilePath = path;
                        settings.LastTapeFile = path;
                    }
                }
                Computer.TapeSave();
            }
            return(true);
        }