private void SetToolTip(AutoCompleteItem autocompleteItem)
 {
     string toolTipTitle = autocompleteItem.ToolTipTitle;
     string toolTipText = autocompleteItem.ToolTipText;
     if (string.IsNullOrEmpty(toolTipTitle))
     {
         toolTip.ToolTipTitle = null;
         toolTip.SetToolTip(this, null);
     }
     else if (string.IsNullOrEmpty(toolTipText))
     {
         toolTip.ToolTipTitle = null;
         toolTip.Show(toolTipTitle, this, base.Width + 3, 0, ToolTipDuration);
     }
     else
     {
         toolTip.ToolTipTitle = toolTipTitle;
         toolTip.Show(toolTipText, this, base.Width + 3, 0, ToolTipDuration);
     }
 }
        private void DoAutocomplete(AutoCompleteItem item, Range fragment)
        {
            if (onlyShowToopTip)//ctrl+space onlyshow command
            {
                onlyShowToopTip = false;
                return;
            }

            string newText = item.GetTextForReplace();
            //replace text of fragment
            var tb = fragment.tb;

            tb.BeginAutoUndo();
            tb.TextSource.Manager.ExecuteCommand(new SelectCommand(tb.TextSource));
            if (tb.Selection.ColumnSelectionMode)
            {
                var start = tb.Selection.Start;
                var end = tb.Selection.End;
                start.iChar = fragment.Start.iChar;
                end.iChar = fragment.End.iChar;
                tb.Selection.Start = start;
                tb.Selection.End = end;
            }
            else
            {
                if (newText.StartsWith("["))//defname auto control
                    tb.Selection.Start = new Place(fragment.Start.iChar - 1, fragment.Start.iLine);
                else if (ScriptCommunityPack.keywordsInformation.FindIndex(p => p.Name == newText && p.Properties.Contains(PropertyTypes.SnippetAuto)) != -1)//snippet auto control
                    tb.Selection.Start = fragment.Start;
                else
                {
                    //tb.Selection.Start = new Place(tb.Selection.Start.iChar - 1, tb.Selection.Start.iLine);//KEYWORD auto CONTROL
                    string[] lineDots = fragment.Text.Split('.');
                    string newcmdRewrite = lineDots[lineDots.Length - 1];
                    if (newText.ToLower().StartsWith(".@"))//.On=@ (DOT bug fixed) || TRÄ°GGER AUTO CONTROL
                    {
                        lineDots = lineDots[0].Split('@');
                        string newtriggerRewrite = lineDots[lineDots.Length - 1]; 
                        newText = newText.Substring(newtriggerRewrite.Length+2);
                    }
                    else
                    {
                        newText = newText.Substring(newcmdRewrite.Length + 1);
                    }
                }
                tb.Selection.End = fragment.End;
            }
            tb.InsertText(newText);
            tb.TextSource.Manager.ExecuteCommand(new SelectCommand(tb.TextSource));
            tb.EndAutoUndo();
            tb.Focus();
        }