コード例 #1
0
ファイル: QTextBox.cs プロジェクト: usmanatron/quuxplayer
 public void CloseIntellisense()
 {
     if (intellisense != null)
     {
         intellisense.KeyPress   -= intellisense_KeyPress;
         intellisense.MouseClick -= intellisense_MouseClick;
         this.Controls.Remove(intellisense);
         intellisense = null;
         this.Invalidate();
         this.Focus();
     }
 }
コード例 #2
0
ファイル: QTextBox.cs プロジェクト: usmanatron/quuxplayer
        public void ShowIntellisense()
        {
            BeforeShowIntellisenseEventArgs ea = new BeforeShowIntellisenseEventArgs();

            if (BeforeShowIntellisense != null)
            {
                BeforeShowIntellisense(this, ea);
            }

            if (!ea.Cancel && ea.Values != null && ea.Values.Count > 0)
            {
                string s = currentView.Document[CaretLocation.LineNumber].Text;

                if (this.IsCommentedOrQuoted(CaretLocation))
                {
                    intellisenseStart = Math.Max(0, s.LastIndexOf('\"', Math.Min(s.Length - 1, CaretLocation.ColumnNumber) - 1));
                }
                else if (this.CaretIsAfterWhiteSpace)
                {
                    intellisenseStart = Math.Max(0, CaretLocation.ColumnNumber - 1);
                }
                else
                {
                    intellisenseStart = Math.Max(0, s.LastIndexOfAny(anyOfForIntellisenseStart,
                                                                     Math.Min(s.Length - 1, CaretLocation.ColumnNumber)) + 1);
                }

                valueNeedsQuoting = ea.ValueNeedsQuoting;
                quoteException    = ea.QuoteException;

                if (intellisense == null)
                {
                    intellisense             = new frmIntellisense();
                    intellisense.KeyPress   += new KeyPressEventHandler(intellisense_KeyPress);
                    intellisense.MouseClick += new MouseEventHandler(intellisense_MouseClick);
                }
                else
                {
                    intellisense.Visible = false;
                }

                intellisense.Values = ea.Values;

                setIntellisenseLocation();
                if (wordsBeforeCursor.Count > 0)
                {
                    intellisense.Find(wordsBeforeCursor.Last());
                }
                this.Controls.Add(intellisense);
                intellisense.Visible = true;
            }
            this.Focus();
        }