Example #1
0
        protected override void ParseLine(string line)
        {
            var keyword = ParseKeyword(ref line);

            switch (keyword)
            {
            case Keyword.TEXDICTION:
                TXDs.Add(new TxdFile(line.ToLower()));
                break;

            case Keyword.IDE:
                IDEs.Add(new IdeFile(line));
                break;

            case Keyword.MAPZONE:
            case Keyword.IPL:
                IPLs.Add(new IplFile(line, Version));
                break;

            case Keyword.IMG:
                IMGs.Add(new ImgFile(line, Version));
                break;

            default:
                Log.Message("Ignoring line with keyword {0}", keyword);
                break;
            }
        }
Example #2
0
        public async Task DisposeWorkplace(bool immediately = false)
        {
            if (!IsInitialized)
            {
                throw new InvalidOperationException();
            }

            // closing IDEs in reverse order
            while (IDEs.Count > 0)
            {
                await CloseIDE(IDEs.Last(), immediately);
            }

            bool locked;

            foreach (IInputDevice inputDevice in InputDevices)
            {
                if (inputDevice != null && inputDevice.IsInitialized)
                {
                    locked = false;
                    if (inputDevice.IsLockingRequiredForDispose())
                    {
                        IOmonitor.IdleForLock(inputDevice, out locked);
                    }
                    inputDevice.Dispose();
                    if (locked)
                    {
                        IOmonitor.Unlock(inputDevice);
                    }
                }
            }
            foreach (IOutputDevice outputDevice in OutputDevices)
            {
                if (outputDevice != null && outputDevice.IsInitialized)
                {
                    locked = false;
                    if (outputDevice.IsLockingRequiredForDispose())
                    {
                        IOmonitor.IdleForLock(outputDevice, out locked);
                    }
                    outputDevice.Dispose();
                    if (locked)
                    {
                        IOmonitor.Unlock(outputDevice);
                    }
                }
            }
            foreach (IExtraWorkplaceComponent extraComponent in ExtraComponents
                     .Where(e => e is IDisposable))
            {
                (extraComponent as IDisposable)?.Dispose();
            }

            IsInitialized = false;
            OnGotUpdated();
        }
Example #3
0
        public async Task CloseIDE(IIDE ide, bool immediately = false)
        {
            if (ide == null)
            {
                throw new NullReferenceException();
            }

            if (MainForm.SelectedIDE == ide)
            {
                int i = IDEs.IndexOf(ide);
                if (i + 1 < IDEs.Count)
                {
                    MainForm.SelectIDE(IDEs[i + 1]);
                }
                else if (i > 0)
                {
                    MainForm.SelectIDE(IDEs[i - 1]);
                }
                else
                {
                    MainForm.SelectIDE(null);
                }
            }
            IDEs.Remove(ide);

            ide.ShowingMessage    -= MainSymbolService.ShowMessage;
            ide.AskingUser        -= MainSymbolService.AskUser;
            ide.OpeningFileByUser -= MainSymbolService.OpenFileByUser;
            ide.SavingFileByUser  -= MainSymbolService.SaveFileByUser;

            if (!immediately)
            {
                await ide.DisposeAsync(immediately);
            }
            else
            {
                ide.DisposeAsync(immediately);
            }

            OnGotUpdated();
        }
Example #4
0
        public async Task <bool> CloseWorkplaceByUser(bool immediately = false)
        {
            if (!IsInitialized)
            {
                return(true);
            }

            while (IDEs.Count > 0)
            {
                if (!(await CloseIDEbyUser(IDEs.Last(), true)))
                {
                    return(false);
                }
            }

            if (!ConfigFile.IsChangesSaved)
            {
                DialogResult answer =
                    OnAskingUser("Save changes in file "
                                 + ConfigFile.ShortFileName + " before closing the Workplace?", "Unsaved changes in " + Title, MessageBoxButtons.YesNoCancel);
                switch (answer)
                {
                case DialogResult.Yes:
                    if (!SaveWorkplaceByUser())
                    {
                        return(false);
                    }
                    break;

                case DialogResult.Cancel:
                    return(false);
                }
            }

            await DisposeWorkplace(true);

            return(true);
        }
Example #5
0
        public IIDE NewIDE(IVirtualMachine machine, ICodeEditor codeEditor
                           , IInputPort inputPort   = null, int withInputPortIndex  = -1
                           , IOutputPort outputPort = null, int withOutputPortIndex = -1
                           , bool withConsole       = false)
        {
            if (!IsInitialized)
            {
                throw new InvalidOperationException();
            }

            (codeEditor as Form).MdiParent = MainForm as Form;
            IIDE newIde = new IDE(machine, codeEditor);

            newIde.ParentWorkplace    = this;
            newIde.ShowingMessage    += MainSymbolService.ShowMessage;
            newIde.AskingUser        += MainSymbolService.AskUser;
            newIde.OpeningFileByUser += MainSymbolService.OpenFileByUser;
            newIde.SavingFileByUser  += MainSymbolService.SaveFileByUser;

            if (inputPort != null && withInputPortIndex >= -1)
            {
                newIde.MachineInsertInputPort(withInputPortIndex, inputPort);
            }
            if (outputPort != null && withOutputPortIndex >= -1)
            {
                newIde.MachineInsertOutputPort(withOutputPortIndex, outputPort);
            }

            if (withConsole && (inputPort != null || outputPort != null))
            {
                IInputDevice  newConsoleAsInputDevice;
                IOutputDevice newConsoleAsOutputDevice = null;
                if (inputPort != null)
                {
                    InputDeviceTypeInfo consoleDeviceTypeInfo =
                        InputDeviceBuilder.RegisteredTypes.Find(i => i.TypeFullName == typeof(ConsoleDevice).FullName);
                    if (consoleDeviceTypeInfo != null)
                    {
                        NewInputDevice(consoleDeviceTypeInfo, out newConsoleAsInputDevice);
                        newConsoleAsOutputDevice = newConsoleAsInputDevice as IOutputDevice;
                        newIde.MachineSetInputDevice(inputPort, newConsoleAsInputDevice);
                    }
                }
                if (outputPort != null)
                {
                    if (newConsoleAsOutputDevice != null)
                    {
                        newIde.MachineSetOutputDevice(outputPort, newConsoleAsOutputDevice);
                    }
                    else
                    {
                        OutputDeviceTypeInfo consoleDeviceTypeInfo =
                            OutputDeviceBuilder.RegisteredTypes.Find(i => i.TypeFullName == typeof(ConsoleDevice).FullName);
                        if (consoleDeviceTypeInfo != null)
                        {
                            NewOutputDevice(consoleDeviceTypeInfo, out newConsoleAsOutputDevice);
                            newIde.MachineSetOutputDevice(outputPort, newConsoleAsOutputDevice);
                        }
                    }
                }
            }

            newIde.Machine.Id         = MachinesIdCounter++;
            newIde.Machine.CustomName = newIde.Machine.ToString();

            newIde.Id = IdeIdCounter++;
            newIde.ProgramFile.ShortFileName = GetNewProgramFileShortName(newIde);
            newIde.Title = GetNewIDEtitle(newIde);
            newIde.ConfigFile.ShortFileName = newIde.Title;

            IDEs.Add(newIde);
            OnGotUpdated();

            return(newIde);
        }