Beispiel #1
0
        // // Driven by user IDE subs:

        public bool NewIDEbyUser(out IIDE newIde)
        {
            if (VirtualMachineBuilder?.VisibleTypes.Count < 1)
            {
                OnShowingMessage("There're no available Virtual Machine types to add in a new IDE. Check types settings via Component Manager."
                                 , "Workplace Configuration Warning in " + Title, MessageBoxIcon.Exclamation);
                newIde = null;
                return(false);
            }
            if (CodeEditorBuilder?.VisibleTypes.Count < 1)
            {
                OnShowingMessage("There're no available Code Editor types to add in a new IDE. Check types settings via Component Manager."
                                 , "Workplace Configuration Warning in " + Title, MessageBoxIcon.Exclamation);
                newIde = null;
                return(false);
            }
            //

            IVirtualMachine machine             = null;
            ICodeEditor     codeEditor          = null;
            IInputPort      inputPort           = null;
            int             withInputPortIndex  = -1;
            IOutputPort     outputPort          = null;
            int             withOutputPortIndex = -1;
            bool            withConsole         = false;

            newIde = null;

            DialogResult newIDEdialogResult;

            using (var newIDEdialog = new NewIdeDialog(VirtualMachineBuilder.VisibleTypes, CodeEditorBuilder.VisibleTypes
                                                       , InputPortBuilder.VisibleTypes, OutputPortBuilder.VisibleTypes
                                                       , InputDeviceBuilder.VisibleTypes.Any(t => t.TypeName == typeof(ConsoleDevice).Name) ||
                                                       OutputDeviceBuilder.VisibleTypes.Any(t => t.TypeName == typeof(ConsoleDevice).Name)))
            {
                newIDEdialogResult = newIDEdialog.ShowDialog(MainForm as Form);
                if (newIDEdialogResult == DialogResult.OK)
                {
                    machine = VirtualMachineBuilder.GetNew(VirtualMachineBuilder.VisibleTypes[newIDEdialog.ChosenMachineTypeIndex]);
                    machine.CurrentLanguage = newIDEdialog.ChosenLanguage;
                    codeEditor = CodeEditorBuilder.GetNew(CodeEditorBuilder.VisibleTypes[newIDEdialog.ChosenCodeEditorTypeIndex]);
                    inputPort  = newIDEdialog.ChosenInputPortTypeFullName.IsNotNullOrEmpty()
                            ? InputPortBuilder.GetNew(InputPortBuilder.VisibleTypes[newIDEdialog.ChosenInputPortTypeIndex]) : null;
                    withInputPortIndex = newIDEdialog.ChosenInputPortIndex;
                    outputPort         = newIDEdialog.ChosenOutputPortTypeFullName.IsNotNullOrEmpty()
                            ? OutputPortBuilder.GetNew(OutputPortBuilder.VisibleTypes[newIDEdialog.ChosenOutputPortTypeIndex]) : null;
                    withOutputPortIndex = newIDEdialog.ChosenOutputPortIndex;
                    withConsole         = newIDEdialog.ChosenWithConsole;
                }
            }
            if (newIDEdialogResult != DialogResult.OK)
            {
                return(false);
            }

            newIde = NewIDE(machine, codeEditor, inputPort, withInputPortIndex
                            , outputPort, withOutputPortIndex, withConsole);

            return(true);
        }
Beispiel #2
0
 XAMLatorMonitor(IIDE ide)
 {
     this.ide  = ide;
     clients   = new Dictionary <DeviceInfo, HttpClient>();
     discovery = new DiscoveryReceiver();
     discovery.DevicesChanged += HandleDiscoveryDevicesChanged;
     discovery.Start();
     ide.DocumentChanged += HandleDocumentChanged;
 }
Beispiel #3
0
 internal XAMLatorMonitor(IIDE ide, ITcpCommunicatorServer server = null)
 {
     IDE = ide;
     if (server == null)
     {
         server = new TcpCommunicatorServer();
     }
     this.server          = server;
     server.DataReceived += HandleDataReceived;
     ide.DocumentChanged += HandleDocumentChanged;
 }
Beispiel #4
0
 public SaveCurrentSessionCommand(
     PackageAccessor packageAccessor,
     ISessionManager sessionManager,
     IIDE ide,
     ILogger logger)
 {
     _package        = packageAccessor.Package;
     _sessionManager = sessionManager;
     _ide            = ide;
     _logger         = logger;
     _saveLock       = new object();
 }
Beispiel #5
0
 public void RunIDE(IIDE ide)
 {
     (ide as LinuxIDE).ShowMaximized();
     try
     {
         QApplication.Exec();
     }
     catch (Exception e)
     {
         m_Log.Error("An exception occurred while running the Linux platform.", e);
         if (!LinuxPlatform.ShuttingDown)
             throw new ApplicationException("The application is unable to continue due to an inconsistant Qt state.", e);
     }
 }
Beispiel #6
0
 public void RunIDE(IIDE ide)
 {
     (ide as LinuxIDE).ShowMaximized();
     try
     {
         QApplication.Exec();
     }
     catch (Exception e)
     {
         m_Log.Error("An exception occurred while running the Linux platform.", e);
         if (!LinuxPlatform.ShuttingDown)
         {
             throw new ApplicationException("The application is unable to continue due to an inconsistant Qt state.", e);
         }
     }
 }
Beispiel #7
0
        // // Naming service subs:

        public string GetNewProgramFileShortName(IIDE ide)
        {
            if (ide == null)
            {
                throw new NullReferenceException();
            }

            string name;

            name  = "New_";
            name += (ide.Machine.CurrentLanguage.IsNotNullOrEmpty()) ? ide.Machine.CurrentLanguage : ide.Machine.BaseLanguage;
            name += "_program";

            int lastnumber = -1;
            int num        = -1;

            foreach (IIDE ide_ in IDEs)
            {
                if (ide_.ProgramFile.ShortFileName.IndexOf(name) == 0)
                {
                    if ((ide_.ProgramFile.ShortFileName + "|").Substring(name.Length) == "|")
                    {
                        num = 1;
                    }
                    else if (ide_.ProgramFile.ShortFileName.Length - name.Length > 3 &&
                             ide_.ProgramFile.ShortFileName.Substring(name.Length, 2) == " (" &&
                             XString.Right(ide_.ProgramFile.ShortFileName, 1) == ")")
                    {
                        string snum = ide_.ProgramFile.ShortFileName.Substring(name.Length + 2);
                        snum = snum.Substring(0, snum.Length - 1);
                        if (!Int32.TryParse(snum, out num))
                        {
                            num = -1;
                        }
                    }
                }
                if (num > lastnumber)
                {
                    lastnumber = num;
                }
            }
            lastnumber++;
            name += (lastnumber > 1) ? " (" + lastnumber.ToString() + ")" : "";

            return(name);
        }
Beispiel #8
0
        public string GetNewIDEtitle(IIDE ide)
        {
            if (ide == null)
            {
                throw new NullReferenceException();
            }

            string name;

            name  = ((ide.Machine.CustomName.IsNotNullOrEmpty()) ? ide.Machine.CustomName : ide.Machine.DefaultName);
            name += " IDE";

            int lastnumber = -1;
            int num        = -1;

            foreach (IIDE ide_ in IDEs)
            {
                if (ide_.Title.IndexOf(name) == 0)
                {
                    if ((ide_.Title + "|").Substring(name.Length) == "|")
                    {
                        num = 1;
                    }
                    else if (ide_.Title.Length - name.Length > 3 &&
                             ide_.Title.Substring(name.Length, 2) == " (" &&
                             XString.Right(ide_.Title, 1) == ")")
                    {
                        string snum = ide_.Title.Substring(name.Length + 2);
                        snum = snum.Substring(0, snum.Length - 1);
                        if (!Int32.TryParse(snum, out num))
                        {
                            num = -1;
                        }
                    }
                }
                if (num > lastnumber)
                {
                    lastnumber = num;
                }
            }
            lastnumber++;
            name += (lastnumber > 1) ? " (" + lastnumber.ToString() + ")" : "";

            return(name);
        }
Beispiel #9
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();
        }
Beispiel #10
0
 public static XAMLatorMonitor Init(IIDE ide)
 {
     Instance = new XAMLatorMonitor(ide);
     return(Instance);
 }
Beispiel #11
0
 XAMLatorMonitor(IIDE ide)
 {
     IDE    = ide;
     server = new TcpCommunicatorServer(Constants.DEFAULT_PORT);
     ide.DocumentChanged += HandleDocumentChanged;
 }
Beispiel #12
0
 public void MainFormSelectIDE(IIDE ide)
 {
     MainForm.SelectIDE(ide);
 }
 public RestoreSessionCommand(IIDE ide, SessionManagerToolWindowState sessionManagerToolWindowState)
 {
     _ide = ide;
     _sessionManagerToolWindowState = sessionManagerToolWindowState;
 }
Beispiel #14
0
 public void SaveIDE(IIDE ide)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public void RunIDE(IIDE ide)
 {
     Application.Run(ide as WindowsIDE);
 }
Beispiel #16
0
 public StdCodeEditor(IIDE parentIDE)
 {
     InitializeComponent();
     //
     _ParentIDE = parentIDE;
 }
Beispiel #17
0
 public void SaveIDEas(IIDE ide, string fileName)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public void RunIDE(IIDE ide)
 {
     Application.Run(ide as WindowsIDE);
 }
 public CloseSessionDocumentsCommand(IIDE ide, SessionManagerToolWindowState sessionManagerToolWindowState, PackageAccessor packageAccessor)
 {
     _ide = ide;
     _sessionManagerToolWindowState = sessionManagerToolWindowState;
     _package = packageAccessor.Package;
 }
Beispiel #20
0
        public async Task <bool> CloseIDEbyUser(IIDE ide, bool immediately = false) // = null, DialogResult autoSave = DialogResult.None)
        {
            if (ide == null)
            {
                throw new NullReferenceException();
            }

            if (ide.Machine.Status != VirtualMachineRunningStatus.StandBy)
            {
                IStateShottable ssm = ide.Machine as IStateShottable;
                if (ssm != null)
                {
                    DialogResult answer = //(autoSave != DialogResult.None) ? autoSave :
                                          OnAskingUser("Machine "
                                                       + ((ide.Machine.CustomName.IsNotNullOrEmpty()) ? ide.Machine.CustomName : ide.Machine.DefaultName)
                                                       + " is running now. Pause it and save state before closing the IDE?", "Unsaved changes in " + ide.Title, MessageBoxButtons.YesNoCancel);
                    switch (answer)
                    {
                    case DialogResult.Yes:
                        await ssm.PauseAsync();

                        if (!ide.SaveMachineStateByUser())
                        {
                            return(false);
                        }
                        break;

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

            if (!ide.ProgramFile.IsChangesSaved)
            {
                DialogResult answer = //(autoSave != DialogResult.None) ? autoSave :
                                      OnAskingUser("Save changes in file "
                                                   + ide.ProgramFile.ShortFileName + " before closing the IDE?", "Unsaved changes in " + ide.Title, MessageBoxButtons.YesNoCancel);
                switch (answer)
                {
                case DialogResult.Yes:
                    if (!ide.SaveProgramFileByUser())
                    {
                        return(false);
                    }
                    break;

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

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

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

            await CloseIDE(ide, immediately);

            return(true);
        }
Beispiel #21
0
 public bool SaveIDEasByUser(IIDE ide)
 {
     throw new NotImplementedException();
 }
Beispiel #22
0
 public bool OpenIDEbyUser(out IIDE ide)
 {
     throw new NotImplementedException();
 }