Ejemplo n.º 1
0
 /// <summary>
 /// Generates a Hyperlink event to indicate a link has been detected
 /// </summary>
 /// <param name="sender">Event source object</param>
 /// <param name="args">Event arguments</param>
 private void RaiseHyperlink(object sender, AutoCompleteEventArgs args)
 {
     if (Hyperlink != null)
     {
         Hyperlink(sender, args);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates a PatternMatch event to indicate a patternhas been matched
 /// </summary>
 /// <param name="sender">Event source object</param>
 /// <param name="args">Event arguments</param>
 private void RaisePatternMatch(object sender, AutoCompleteEventArgs args)
 {
     if (PatternMatch != null)
     {
         PatternMatch(sender, args);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the provided character to the autocomplete string
        /// </summary>
        /// <param name="s">Character to add</param>
        public void AddCharacter(string s, int index)
        {
            AutoCompleteEventArgs args;
            string temp;
            string pat;

            if (s == "\r")
            {
                Reset();
                return;
            }
            else if (Index == -1)
            {
                Index = index;
            }

            temp = Text + s;
            foreach (string p in Patterns)
            {
                pat = p.Trim('*');

                if ((p.StartsWith("*") && temp.EndsWith(pat)) || temp == pat)
                {
                    Text   = temp.Substring(temp.Length - pat.Length);
                    Index += temp.Length - pat.Length;

                    args      = new AutoCompleteEventArgs();
                    args.Text = Text;

                    RaisePatternMatch(this, args);
                    Reset();
                    return;
                }
            }

            if (s == " ")
            {
                Reset();
                return;
            }

            Text = temp;

            switch (Text.ToLower())
            {
            case "http://":
            case "www.":
                HyperlinkIndex = Index;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks if the current input looks like a hyperlink and applies the necessary formatting
        /// </summary>
        private void CheckForHyperlink()
        {
            AutoCompleteEventArgs args = new AutoCompleteEventArgs();

            args.Text = Text;

            if (HyperlinkIndex >= 0)
            {
                RaiseHyperlink(this, args);
            }

            HyperlinkIndex = -1;
        }