Beispiel #1
0
 public void update()
 {
     textEditorControl.invokeOnThread(
         () =>
     {
         var documentText = textEditorControl.Text;
         O2Thread.mtaThread(() => update(documentText));
     });
 }
Beispiel #2
0
        protected virtual void SetLocation()
        {
            control.invokeOnThread(
                () =>
            {
                try
                {
                    TextArea textArea     = control.ActiveTextAreaControl.TextArea;
                    TextLocation caretPos = textArea.Caret.Position;

                    int xpos        = textArea.TextView.GetDrawingXPos(caretPos.Y, caretPos.X);
                    int rulerHeight = textArea.TextEditorProperties.ShowHorizontalRuler ? textArea.TextView.FontHeight : 0;
                    Point pos       = new Point(textArea.TextView.DrawingPosition.X + xpos,
                                                textArea.TextView.DrawingPosition.Y + (textArea.Document.GetVisibleLine(caretPos.Y)) * textArea.TextView.FontHeight
                                                - textArea.TextView.TextArea.VirtualTop.Y + textArea.TextView.FontHeight + rulerHeight);

                    Point location = control.ActiveTextAreaControl.PointToScreen(pos);

                    // set bounds
                    Rectangle bounds = new Rectangle(location, drawingSize);

                    if (!workingScreen.Contains(bounds))
                    {
                        if (bounds.Right > workingScreen.Right)
                        {
                            bounds.X = workingScreen.Right - bounds.Width;
                        }
                        if (bounds.Left < workingScreen.Left)
                        {
                            bounds.X = workingScreen.Left;
                        }
                        if (bounds.Top < workingScreen.Top)
                        {
                            bounds.Y = workingScreen.Top;
                        }
                        if (bounds.Bottom > workingScreen.Bottom)
                        {
                            bounds.Y = bounds.Y - bounds.Height - control.ActiveTextAreaControl.TextArea.TextView.FontHeight;
                            if (bounds.Bottom > workingScreen.Bottom)
                            {
                                bounds.Y = workingScreen.Bottom - bounds.Height;
                            }
                        }
                    }
                    Bounds = bounds;
                }
                catch (Exception ex)
                {
                    PublicDI.log.ex(ex, "in AbstractCompletionWindow.SetLocation");
                }
            });
        }
        public static TextEditorControl showAstValueInSourceCode(this TextEditorControl textEditorControl, AstValue <object> astValue)
        {
            return((TextEditorControl)textEditorControl.invokeOnThread(() =>
            {
                PublicDI.log.error("{0} {1} - {2}", astValue.Text, astValue.StartLocation, astValue.EndLocation);

                var start = new TextLocation(astValue.StartLocation.X - 1,
                                             astValue.StartLocation.Y - 1);
                var end = new TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1);
                var selection = new DefaultSelection(textEditorControl.Document, start, end);
                textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection);
                setCaretToCurrentSelection(textEditorControl);
                return textEditorControl;
            }));
        }
Beispiel #4
0
 public static TextEditorControl setCaretToCurrentSelection(this TextEditorControl textEditorControl)
 {
     return(textEditorControl.invokeOnThread(
                () => {
         var finalCaretPosition = textEditorControl.ActiveTextAreaControl.TextArea.SelectionManager.SelectionCollection[0].StartPosition;
         var tempCaretPosition = new TextLocation {
             X = finalCaretPosition.X, Y = finalCaretPosition.Y + 10
         };
         textEditorControl.ActiveTextAreaControl.Caret.Position = tempCaretPosition;
         textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret();
         textEditorControl.ActiveTextAreaControl.Caret.Position = finalCaretPosition;
         textEditorControl.ActiveTextAreaControl.TextArea.ScrollToCaret();
         return textEditorControl;
     }));
 }
Beispiel #5
0
        public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
        {
            if (busy)  // DC to prevent multiple calls
            {
                "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info();
                return(null);
            }

            busy = true;

            //return (CodeCompletionWindow)parent.invokeOnThread(
            return((CodeCompletionWindow)control.invokeOnThread(
                       () => {
                return ShowCompletionWindow_Thread(parent, control, fileName, completionDataProvider, firstChar, showDeclarationWindow, fixedListViewWidth);
            }));
        }
 public static TextEditorControl open(this TextEditorControl textEditorControl, string sourceCodeFile)
 {
     return((TextEditorControl)textEditorControl.invokeOnThread(
                () =>
     {
         if (sourceCodeFile.fileExists())
         {
             textEditorControl.LoadFile(sourceCodeFile);
         }
         else
         {
             textEditorControl.SetHighlighting("C#");
             textEditorControl.Document.TextContent = sourceCodeFile;
         }
         return textEditorControl;
     }));
 }
		public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
		{
            if (busy)  // DC to prevent multiple calls
            {
                "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info();
                return null;
            }

            busy = true;
            
            //return (CodeCompletionWindow)parent.invokeOnThread(
            return (CodeCompletionWindow)control.invokeOnThread(
                        ()=>{
                                return ShowCompletionWindow_Thread(parent, control, fileName,completionDataProvider, firstChar, showDeclarationWindow, fixedListViewWidth);
                            });
            
		}
        public O2CodeCompletion(TextEditorControl textEditor, Action <string> status)
        {
            OnlyShowCodeCompleteResultsFromO2Namespace = false; //true;
            UseParseCodeThread       = true;
            extraSourceCodeToProcess = new List <string>();
            mappedCompilationUnits   = new Dictionary <string, ICompilationUnit>();
            gacAssemblies            = GacUtils.assemblyNames(true);
            loadedReferences         = new List <string>();

            textEditor.invokeOnThread(
                () => {
                TextEditor    = textEditor;
                statusMessage = status;
                loadIcons();
                setupEnvironment();
            });
        }