ShowToolTip() публичный Метод

public ShowToolTip ( string text ) : void
text string
Результат void
Пример #1
0
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (e.ToolTipShown)
            {
                return;
            }

            Point      mousepos = e.MousePosition;
            FoldMarker marker   = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y);

            if (marker != null && marker.IsFolded)
            {
                StringBuilder sb = new StringBuilder(marker.InnerText);

                // max 10 lines
                int endLines = 0;

                for (int i = 0; i < sb.Length; ++i)
                {
                    if (sb[i] == '\n')
                    {
                        ++endLines;

                        if (endLines >= 10)
                        {
                            sb.Remove(i + 1, sb.Length - i - 1);
                            sb.Append(Environment.NewLine);
                            sb.Append("...");
                            break;
                        }
                    }
                }

                sb.Replace("\t", "    ");
                e.ShowToolTip(sb.ToString());
                return;
            }

            List <TextMarker> markers = textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition);

            foreach (TextMarker tm in markers)
            {
                if (tm.ToolTip != null)
                {
                    e.ShowToolTip(tm.ToolTip.Replace("\t", "    "));
                    return;
                }
            }
        }
Пример #2
0
        void OnToolTipRequest(object sender, TextEditor.ToolTipRequestEventArgs e)
        {
            if (e.InDocument && !e.ToolTipShown)
            {
                IExpressionFinder expressionFinder;
                if (MainForm.IsVisualBasic)
                {
                    expressionFinder = new VBExpressionFinder();
                }
                else
                {
                    expressionFinder = new CSharpExpressionFinder(mainForm.parseInformation);
                }
                ExpressionResult expression = expressionFinder.FindFullExpression(
                    editor.Text,
                    editor.Document.PositionToOffset(e.LogicalPosition));
                if (expression.Region.IsEmpty)
                {
                    expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
                }

                TextEditor.TextArea textArea = editor.ActiveTextAreaControl.TextArea;
                NRefactoryResolver  resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
                ResolveResult       rr       = resolver.Resolve(expression,
                                                                mainForm.parseInformation,
                                                                textArea.MotherTextEditorControl.Text);
                string toolTipText = GetText(rr);
                if (toolTipText != null)
                {
                    e.ShowToolTip(toolTipText);
                }
            }
        }
Пример #3
0
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (e.InDocument && !e.ToolTipShown)
            {
                IExpressionFinder expressionFinder;
                if (MainForm.IsVisualBasic)
                {
                    expressionFinder = new VBExpressionFinder();
                }
                else
                {
                    expressionFinder = new CSharpExpressionFinder(mainForm.parseInformation);
                }
                ExpressionResult expression = expressionFinder.FindFullExpression(
                    editor.Text,
                    editor.Document.PositionToOffset(e.LogicalPosition));
                if (expression.Region.IsEmpty)
                {
                    expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
                }

                TextArea textArea = editor.ActiveTextAreaControl.TextArea;
                NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
                ResolveResult rr = resolver.Resolve(expression,
                                                    mainForm.parseInformation,
                                                    textArea.MotherTextEditorControl.Text);
                string toolTipText = GetText(rr);
                if (toolTipText != null)
                {
                    e.ShowToolTip(toolTipText);
                }
            }
        }
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (e.ToolTipShown)
            {
                return;
            }
            Point      mousePosition          = e.MousePosition;
            TextView   textView               = this.textArea.TextView;
            int        x                      = mousePosition.X - this.textArea.TextView.DrawingPosition.X;
            int        y                      = mousePosition.Y;
            Rectangle  drawingPosition        = this.textArea.TextView.DrawingPosition;
            FoldMarker foldMarkerFromPosition = textView.GetFoldMarkerFromPosition(x, y - drawingPosition.Y);

            if (foldMarkerFromPosition == null || !foldMarkerFromPosition.IsFolded)
            {
                foreach (TextMarker marker in this.textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition))
                {
                    if (marker.ToolTip == null)
                    {
                        continue;
                    }
                    e.ShowToolTip(marker.ToolTip.Replace("\t", "    "));
                    return;
                }
                return;
            }
            StringBuilder stringBuilder = new StringBuilder(foldMarkerFromPosition.InnerText);
            int           num           = 0;

            for (int i = 0; i < stringBuilder.Length; i++)
            {
                if (stringBuilder[i] == '\n')
                {
                    num++;
                    if (num >= 10)
                    {
                        stringBuilder.Remove(i + 1, stringBuilder.Length - i - 1);
                        stringBuilder.Append(Environment.NewLine);
                        stringBuilder.Append("...");
                        break;
                    }
                }
            }
            stringBuilder.Replace("\t", "    ");
            e.ShowToolTip(stringBuilder.ToString());
        }
Пример #5
0
		void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
		{
			if (e.ToolTipShown)
				return;
			Point mousepos = e.MousePosition;
			FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X,
			                                                                mousepos.Y - textArea.TextView.DrawingPosition.Y);
			if (marker != null && marker.IsFolded) {
				StringBuilder sb = new StringBuilder(marker.InnerText);
				
				// max 10 lines
				int endLines = 0;
				for (int i = 0; i < sb.Length; ++i) {
					if (sb[i] == '\n') {
						++endLines;
						if (endLines >= 10) {
							sb.Remove(i + 1, sb.Length - i - 1);
							sb.Append(Environment.NewLine);
							sb.Append("...");
							break;
							
						}
					}
				}
				sb.Replace("\t", "    ");
				e.ShowToolTip(sb.ToString());
				return;
			}
			
			List<TextMarker> markers = textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition);
			foreach (TextMarker tm in markers) {
				if (tm.ToolTip != null) {
					e.ShowToolTip(tm.ToolTip.Replace("\t", "    "));
					return;
				}
			}
		}
Пример #6
0
        private void OnToolTipRequest(object sender, TextEditor.ToolTipRequestEventArgs e)
        {
            if (!e.InDocument || e.ToolTipShown)
            {
                return;
            }

            IExpressionFinder expressionFinder;

            if (IntellisenseForm.SupportedLanguage == SupportedLanguage.VisualBasic)
            {
                expressionFinder = new VBExpressionFinder();
            }
            else
            {
                expressionFinder = new CSharpExpressionFinder(_iForm.ParseInformation);
            }

            var expression = expressionFinder.FindFullExpression(
                _editor.Text,
                _editor.Document.PositionToOffset(e.LogicalPosition));

            if (expression.Region.IsEmpty)
            {
                expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
            }

            var textArea = _editor.ActiveTextAreaControl.TextArea;
            var resolver = new NRefactoryResolver(_iForm.ProjectContent.Language);
            var rr       = resolver.Resolve(expression,
                                            _iForm.ParseInformation,
                                            textArea.MotherTextEditorControl.Text);

            var toolTipText = GetText(rr);

            if (toolTipText != null)
            {
                e.ShowToolTip(toolTipText);
            }
        }
Пример #7
0
        protected override void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (!e.InDocument || e.LogicalPosition.IsEmpty)
                return;
         
            var text = (TextArea) sender;
            if (text.Document == null) return;

            var lineSegment = text.Document.GetLineSegment(e.LogicalPosition.Line);
            var lineText = text.Document.GetText(lineSegment);

            string word = GetWordAtColumn(lineText, e.LogicalPosition.Column);

            if (word == null)
                return;

            // register-variable?
            if (_formatter != null)
            {
                string varName = _formatter.GetVariableByRegisterName(word);
                if (varName != null)
                {
                    e.ShowToolTip(varName);
                    return;
                }
            }

            // opcode-mnemonic?
            var opcode = Opcodes.Lookup(word);
            if (opcode != null)
            {
                string toolTip = string.Format("{0}\n\n{1}\n\n{2}", opcode.Syntax, opcode.Arguments, opcode.Description);
                e.ShowToolTip(toolTip);
                return;
            }
        }
        // was part of Tool Tip Provider        
        void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            O2Thread.mtaThread(
            () =>
            {
                try
                {
                    if (e.InDocument && !e.ToolTipShown)
                    {
                        var logicalPosition = e.LogicalPosition;

                        // parseSourceCode(CodeCompleteTargetText);
                        ResolveResult rr = resolveLocation(logicalPosition);
                        string toolTipText = GetText(rr);
                        if (toolTipText != null)
                        {
                            e.ShowToolTip(toolTipText);
                            //}
                            //if (toolTipText.valid())
                            "ToolTipText: {0}".format(toolTipText).info();
                        }

                    }
                }
                catch (Exception ex)
                {
                    ex.log("in OnToolTipRequest");
                }
            });            
        }
Пример #9
0
		/// <summary>
		/// This function shows variable values as tooltips
		/// </summary>
		static void TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e)
		{
			DebuggerGridControl toolTipControl = null;
			try {
				TextArea textArea = (TextArea)sender;
				if (e.ToolTipShown) return;
				if (oldToolTipControl != null && !oldToolTipControl.AllowClose) return;
				if (!CodeCompletionOptions.EnableCodeCompletion) return;
				if (!CodeCompletionOptions.TooltipsEnabled) return;
				
				if (CodeCompletionOptions.TooltipsOnlyWhenDebugging) {
					if (currentDebugger == null) return;
					if (!currentDebugger.IsDebugging) return;
				}
				
				if (e.InDocument) {
					// Query all registered tooltip providers using the AddInTree.
					// The first one that does not return null will be used.
					ToolTipInfo ti = null;
					foreach (ITextAreaToolTipProvider toolTipProvider in AddInTree.BuildItems<ITextAreaToolTipProvider>(ToolTipProviderAddInTreePath, null, false)) {
						if ((ti = toolTipProvider.GetToolTipInfo(textArea, e)) != null) {
							break;
						}
					}
					
					if (ti != null) {
						toolTipControl = ti.ToolTipControl as DebuggerGridControl;
						if (ti.ToolTipText != null) {
							e.ShowToolTip(ti.ToolTipText);
						}
					}
					CloseOldToolTip();
					if (toolTipControl != null) {
						toolTipControl.ShowForm(textArea, e.LogicalPosition);
					}
					oldToolTipControl = toolTipControl;
					
				}
			} catch (Exception ex) {
				ICSharpCode.Core.MessageService.ShowError(ex, "Error while requesting tooltip for location " + e.LogicalPosition);
			} finally {
				if (toolTipControl == null && CanCloseOldToolTip)
					CloseOldToolTip();
			}
		}
Пример #10
0
        public void TextAreaToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            DebuggerGridControl toolTipControl = null;
            TextMarker marker = null;
            //RemoveMarker((sender as TextArea).Document);
            if (debuggedProcess == null) return;
            if (debuggedProcess.SelectedFunction == null || !debuggedProcess.IsPaused) return;
            try
            {
                TextArea textArea = (TextArea)sender;
                
                if (textArea != curTextArea) return;
                if (e.ToolTipShown) return;
                if (oldToolTipControl != null && !oldToolTipControl.AllowClose) return;
                if (!IsRunning) return;

                if (e.InDocument)
                {
                    ToolTipInfo ti = null;
                    int num_line = 0;
                    int start_off = 0;
                    int end_off = 0;
                    string var = GetVariable(e,textArea,out num_line, out start_off, out end_off);
                    if (var == null || var == "") return;
                    //if (debuggedProcess.SelectedFunction.LocalVariables.Count > 0)
                    {
                        //NamedValue nv = FindVarByName(var, num_line);
                        ListItem nv = FindVarByName(var, num_line);
                        if (nv != null)
                        {
                        	System.Threading.Thread.Sleep(50);
                        	DebuggerGridControl dgc = new DebuggerGridControl(new DynamicTreeDebuggerRow(nv));
                        	dgc.doc = textArea.Document;
                        	ti = new ToolTipInfo(dgc);
                        	ICSharpCode.TextEditor.TextLocation logicPos = e.LogicalPosition;
            				LineSegment seg = textArea.Document.GetLineSegment(logicPos.Y);
            				marker = new TextMarker(start_off, end_off-start_off+1, TextMarkerType.Cant, Color.Black, Color.White);
                        	textArea.Document.MarkerStrategy.AddMarker(marker);
                        	textArea.Document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine,seg.LineNumber));
                        	textArea.Document.CommitUpdate();
                        }
                    }
                    if (ti != null)
                    {
                        toolTipControl = ti.ToolTipControl as DebuggerGridControl;
                        if (ti.ToolTipText != null)
                        {
                            e.ShowToolTip(ti.ToolTipText);
                        }
                    }
                    CloseOldToolTip();
                    if (toolTipControl != null)
                    {
                        toolTipControl.ShowForm(textArea, e.LogicalPosition);
                    }
                    oldToolTipControl = toolTipControl;
                    RemoveMarker(textArea.Document);
                    oldMarker = marker;

                }
            }
            catch (System.Exception ex)
            {
                //frm.WriteToOutputBox(ex.Message);// ICSharpCode.Core.MessageService.ShowError(ex);
            }
            finally
            {
                if (toolTipControl == null && CanCloseOldToolTip)
                {
                    CloseOldToolTip();
                    RemoveMarker((sender as TextArea).Document);
                }
            }
        }
Пример #11
0
 void TextArea_ToolTipRequest(object sender, ToolTipRequestEventArgs e)
 {
     if (currentTab == null
         || currentTab.parseInfo == null
         || sender != currentTab.textEditor.ActiveTextAreaControl.TextArea
         || !e.InDocument) {
         return;
     }
     HighlightColor hc = currentTab.textEditor.Document.GetLineSegment(e.LogicalPosition.Line).GetColorForPosition(e.LogicalPosition.Column);
     if (hc == null || hc.Color == System.Drawing.Color.Green || hc.Color == System.Drawing.Color.Brown || hc.Color == System.Drawing.Color.DarkGreen)
         return;
     string word = TextUtilities.GetWordAt(currentTab.textEditor.Document, currentTab.textEditor.Document.PositionToOffset(e.LogicalPosition));
     if (currentTab.msgFileTab != null) {
         int msg;
         if (int.TryParse(word, out msg) && currentTab.messages.ContainsKey(msg)) {
             e.ShowToolTip(currentTab.messages[msg]);
             return;
         }
     }
     string lookup = currentTab.parseInfo.LookupToken(word, currentTab.filepath, e.LogicalPosition.Line + 1);
     if (lookup != null) {
         e.ShowToolTip(lookup);
         return;
     }
 }