Exemple #1
0
        public LocalMachine AddMachine(string filepath, IFileSystem fileSystem, bool open)
        {
            if (String.IsNullOrEmpty(filepath))
            {
                return(null);
            }

            lock (_machines)
            {
                if (GetPersistedMachine(filepath) == null)
                {
                    LocalMachine machine;
                    if (open)
                    {
                        machine = LocalMachine.OpenFromFile(fileSystem, filepath);
                    }
                    else
                    {
                        machine = LocalMachine.GetClosedMachine(fileSystem, filepath);
                    }

                    AddMachine(machine);

                    return(machine);
                }
            }

            return(null);
        }
Exemple #2
0
        private void NewMachine()
        {
            LocalMachine machine = LocalMachine.New("Untitled", null);

            _model.AddMachine(machine);

            ActiveMachine = machine;
            machine.Start();
        }
Exemple #3
0
        static public LocalMachine OpenFromFile(IFileSystem fileSystem, string filepath)
        {
            LocalMachine machine = new LocalMachine(null, new History());

            machine.PersistantFilepath = filepath;

            machine.OpenFromFile(fileSystem);

            return(machine);
        }
Exemple #4
0
        static private LocalMachine New(string name, History history, string persistentFilepath)
        {
            LocalMachine machine = new LocalMachine(name, history);
            Core         core    = Core.Create(Core.LatestVersion, Core.Type.CPC6128);

            machine.SetCore(core);

            machine.PersistantFilepath = persistentFilepath;

            return(machine);
        }
Exemple #5
0
        static public LocalMachine GetClosedMachine(IFileSystem fileSystem, string filepath)
        {
            MachineFileInfo info = null;

            using (ITextFile textFile = fileSystem.OpenTextFile(filepath))
            {
                info = MachineFile.Read(textFile);
            }

            LocalMachine machine = New(info.Name, info.History, filepath);

            if (machine.History != null)
            {
                HistoryEvent historyEvent = machine.History.CurrentEvent.MostRecent <BookmarkHistoryEvent>();;

                machine.Display.GetFromBookmark((historyEvent as BookmarkHistoryEvent)?.Bookmark);
                machine.Display.EnableGreyscale(true);
            }

            return(machine);
        }