private CodeFileDocumentControl AddNewProgramToTab(DockPanel tabControl, string FileName)
        {
            CodeFileDocumentControl edit = AddNewTab(tabControl);

            edit.FileName = FileName;
            SetTabPageText(edit);
            edit.SetHighlightingStrategyForFile(FileName);
            OpenDocuments.Add(Tools.FileNameToLower(FileName), edit);
            //this.codeCompletionParserController.SetAsChanged(FileName);
            //ivan
            AddBreakPointHandler(edit, FileName);
            var RunService = WorkbenchServiceFactory.RunService;

            if (!RunService.HasRunArgument(FileName.ToLower()))
            {
                RunService.AddRunArgument(FileName.ToLower(), "");
            }
            if (!WorkbenchServiceFactory.DebuggerManager.IsRunning)
            {
                AddEditorHandlers(edit);
            }
            CodeCompletionKeyHandler.Attach(edit.TextEditor);
            edit.TextEditor.ActiveTextAreaControl.TextArea.KeyEventHandler += TextArea_KeyEventHandler;

            //HostCallbackImplementation.Register(this);

            //\ivan
            return(edit);
        }
        public static CodeCompletionKeyHandler Attach(TextEditorControl editor)
        {
            CodeCompletionKeyHandler h = new CodeCompletionKeyHandler(editor);
            ht[editor] = h;
            editor.ActiveTextAreaControl.TextArea.KeyEventHandler += h.TextAreaKeyEventHandler;
            editor.ActiveTextAreaControl.TextArea.Caret.PositionChanged += h.CaretPositionChangedEventHandler;
            //editor.ActiveTextAreaControl.TextArea.KeyDown += new System.Windows.Forms.KeyEventHandler(TextArea_KeyDown);
            //editor.ActiveTextAreaControl.KeyDown += h.TextControlEventHandler;
            // When the editor is disposed, close the code completion window
            editor.Disposed += h.CloseCodeCompletionWindow;

            return h;
        }
Example #3
0
        public static CodeCompletionKeyHandler Attach(TextEditorControl editor)
        {
            CodeCompletionKeyHandler h = new CodeCompletionKeyHandler(editor);

            ht[editor] = h;
            editor.ActiveTextAreaControl.TextArea.KeyEventHandler       += h.TextAreaKeyEventHandler;
            editor.ActiveTextAreaControl.TextArea.Caret.PositionChanged += h.CaretPositionChangedEventHandler;
            //editor.ActiveTextAreaControl.TextArea.KeyDown += new System.Windows.Forms.KeyEventHandler(TextArea_KeyDown);
            //editor.ActiveTextAreaControl.KeyDown += h.TextControlEventHandler;
            // When the editor is disposed, close the code completion window
            editor.Disposed += h.CloseCodeCompletionWindow;
            return(h);
        }
Example #4
0
        public void CloseFile(CodeFileDocumentControl tp, bool ask_for_save = true)
        {
            string FileName = tp.FileName.ToLower();
            string exeName  = tp.EXEFileName;

            if (WorkbenchServiceFactory.RunService.IsRun(exeName))
            {
                WorkbenchServiceFactory.RunService.Stop(exeName);
            }
            if (ask_for_save)
            {
                if (tp.DocumentChanged && !tp.FromMetadata)
                {
                    if (!QuestionAndSaveFile(tp))
                    {
                        SaveCanceled = true;
                        return;
                    }
                }
            }
            if (tp.DocumentSavedToDisk)
            {
                AddLastFile(CurrentSourceFileName);
            }
            if (LastSelectedTab != null && !LastSelectedTab.IsDisposed)
            {
                CurrentCodeFileDocument = LastSelectedTab;
            }
            if (tp == ActiveCodeFileDocument)
            {
                ActiveCodeFileDocument = null;
            }
            OutputTextBoxs.Remove(tp);
            OpenDocuments.Remove(Tools.FileNameToLower(tp.FileName));
            //RunArgumentsTable.Remove(tp);
            tp.Dispose();
            CheckErrorListAndClear(FileName);
            WatcherService.RemoveWatcher(FileName);
            if (OpenDocuments.Count == 1)
            {
                CloseButtonsEnabled = false;
            }
            SaveAllButtonsEnabled = !AllSaved();
            WorkbenchServiceFactory.CodeCompletionParserController.CloseFile(FileName);
            WorkbenchServiceFactory.CodeCompletionParserController.ParseInformationUpdated -= tp.TextEditor.UpdateFolding;
            CodeCompletionKeyHandler.Detach(tp.TextEditor);
            tp.TextEditor.Document.DocumentChanged -= tp.Document_DocumentChanged;
            tp.TextEditor.Document.TextContent      = "";
            tp.TextEditor.Document.DocumentChanged += tp.Document_DocumentChanged;
            GC.Collect();
        }