예제 #1
0
        public async Task <IActionResult> AddWatcher([FromBody] AddWatcher request)
        {
            // Reponse
            var response = await _watcherService.AddWatcher(request);

            // Return
            return(CreatedAtRoute("Watchers_GetWatcher", new { response.WatcherId }, response));
        }
예제 #2
0
        public bool OpenFile(string FileName, string PreferedFileName, bool not_open_designer = false)
        {
            CodeFileDocumentControl tp = FindTab(FileName);
            bool IsNewFile             = FileName == null;

            if (tp == null)
            {
                if (!IsNewFile && !File.Exists(FileName))
                {
                    MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!FILE_NOT_FOUND{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                visualStates.FileOpened = true;//?????
                if (!IsNewFile)
                {
                    openFileDialog1.InitialDirectory = Path.GetDirectoryName(FileName);
                }
                if (!IsBlankNewProgram(CurrentCodeFileDocument))
                {
                    if (IsNewFile)
                    {
                        if (PreferedFileName == null)
                        {
                            FileName = InstNameNewProgramm(MainDockPanel);
                        }
                        else
                        {
                            FileName = PreferedFileName;
                        }
                    }
                    tp = AddNewProgramToTab(MainDockPanel, FileName);
                }
                else
                if (!IsNewFile)
                {
                    CheckErrorListAndClear(CurrentCodeFileDocument.FileName);
                    WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(CurrentCodeFileDocument.FileName);
                    OpenDocuments.Remove(Tools.FileNameToLower(CurrentCodeFileDocument.FileName));
                    CurrentCodeFileDocument.FileName = FileName;
                    SetTabPageText(CurrentCodeFileDocument);
                    if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower()))
                    {
                        WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), "");
                    }
                    tp = CurrentCodeFileDocument;
                }
                if (!IsNewFile)
                {
                    AddLastFile(FileName);
                    WatcherService.AddWatcher(FileName);
                    int ticks = Environment.TickCount;
                    tp.LoadFromFile(FileName);
                    //MessageBox.Show((Environment.TickCount-ticks).ToString());

                    tp.DocumentSavedToDisk = true;
                    //ivan added
                    ShowAddedBreakpoints(tp);
                    //ShowAddedBreakpoints(tabControl1.TabPages[TabIndex]);
                }
                //CloseButtonsEnabled = OpenDocuments.Count > 1;
                ChangedSelectedTab();
                if (FileName != null) // SS 09.08.08
                {
                    WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(FileName);
                }
            }
            if (tp != null)
            {
                if (MainDockPanel.ActiveDocument != tp)
                {
                    CurrentCodeFileDocument = tp;
                }
            }
            if (FileName != null)
            {
                string filename = Tools.FileNameToLower(FileName);
                if (OpenDocuments.ContainsKey(filename))
                {
                    OpenDocuments[filename] = tp;
                }
                else
                {
                    OpenDocuments.Add(filename, tp);
                }
                CloseButtonsEnabled = OpenDocuments.Count > 1;//Ivan 09.08.08 err 195
            }
            visualStates.FileOpened = false;

            //ssyy
            if (!IsNewFile)
            {
                if (Path.GetExtension(FileName) == ".pas")
                {
                    string XMLFile = Path.ChangeExtension(FileName, string_consts.xml_form_extention);
                    if (File.Exists(XMLFile))
                    {
                        if (not_open_designer)
                        {
                            if (VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.DesignerAndCodeTabs != null)
                            {
                                //VisualPascalABC.Form1.Form1_object.CahngedSelectedTab();
                                VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.DesignerAndCodeTabs.SelectedTab =
                                    VisualPascalABC.VisualPABCSingleton.MainForm._currentCodeFileDocument.TextPage;
                            }
                        }
                        else
                        {
                            _currentCodeFileDocument.AddDesigner(XMLFile);
                        }
                    }
                }
            }

            return(true);
        }
예제 #3
0
        public CodeFileDocumentControl OpenFileForDebug(string FileName)
        {
            CodeFileDocumentControl tp = FindTab(FileName);
            bool IsNewFile             = FileName == null;

            if (tp == null)
            {
                visualStates.FileOpened = true;//?????
                if (!IsNewFile && !File.Exists(FileName))
                {
                    //MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!FILE_NOT_FOUND{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    bool exists = false;
                    foreach (string s in search_debug_paths)
                    {
                        FileName = String.Concat(s, Path.DirectorySeparatorChar, Path.GetFileName(FileName));
                        if (File.Exists(FileName))
                        {
                            tp = FindTab(FileName);
                            if (tp != null)
                            {
                                CurrentCodeFileDocument = tp;
                                //(CurrentTabPage.ag as CodeFileDocumentControl).DocumentSavedToDisk = !IsNewFile;
                                visualStates.FileOpened = false;
                                AddDebugPage(CurrentCodeFileDocument);
                                return(CurrentCodeFileDocument);
                            }
                            else
                            {
                                exists = true;
                                break;
                            }
                        }
                    }
                    if (!exists)
                    {
                        visualStates.FileOpened = false;
                        return(null);
                    }
                }
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(FileName);
                if (!IsBlankNewProgram(CurrentCodeFileDocument))
                {
                    if (IsNewFile)
                    {
                        FileName = InstNameNewProgramm(MainDockPanel);
                    }
                    tp = AddNewProgramToTab(MainDockPanel, FileName);
                }
                else
                if (!IsNewFile)
                {
                    //CheckErrorListAndClear((tabControl1.TabPages[TabIndex].ag as CodeFileDocumentControl).FileName);
                    CurrentCodeFileDocument.FileName = FileName;
                    if (!ProjectFactory.Instance.ProjectLoaded)
                    {
                        SetTabPageText(CurrentCodeFileDocument);
                    }
                    tp = CurrentCodeFileDocument;
                }
                if (!IsNewFile)
                {
                    AddLastFile(FileName);
                    WatcherService.AddWatcher(FileName);
                    tp.LoadFromFile(FileName);
                    tp.DocumentSavedToDisk = true;
                    //ivan added
                    ShowAddedBreakpoints(tp);
                    //ShowAddedBreakpoints(tabControl1.TabPages[TabIndex]);
                }
                CloseButtonsEnabled = OpenDocuments.Count > 1;
            }
            if (tp != null)
            {
                CurrentCodeFileDocument = tp;
                if (tp.DesignerAndCodeTabs != null)
                {
                    tp.DesignerAndCodeTabs.SelectedTab = tp.TextPage;
                }
                //(CurrentTabPage.ag as CodeFileDocumentControl).DocumentSavedToDisk = !IsNewFile;
            }
            visualStates.FileOpened = false;
            AddDebugPage(CurrentCodeFileDocument);
            //CahngedSelectedTab();
            return(CurrentCodeFileDocument);
        }