private void StoreKeywords(string cmd, InterpreterItem item)
        {
            string str = cmd.ToLower();

            //if (str != item.AutoComplete.ToLower())
            //{
            if (item.Type == InterpreterItem.OwnerType.Indexer)
            {
                //if (str != item.Desciption.ToLower())
                SettingsManager.Instance.AddLearned(str, item.Type, item.Desciption, item.CommandTokens);
            }
            else if (item.Type == InterpreterItem.OwnerType.Menu)
            {
                //SettingsManager.Instance.AddLearned(str, ProtectCommand(item.Name));
                //SettingsManager.Instance.AddLearned(item.Text, Command.ProtectCommand(item.CommandName)); // StringUtility.ArrayToStr(item.CommandTokens), item.CommandName
                SettingsManager.Instance.AddLearned(StringUtility.ArrayToStr(item.CommandTokens, false), item.Type, item.Name, item.CommandTokens);
            }
            else if (item.Type == InterpreterItem.OwnerType.Plugin)
            {
                //InterpreterPlugin p = _plugins.Find(delegate(InterpreterPlugin plugin) { return plugin.Name == item.OwnerId; });
                //Command command = p.GetCommand(item);
                //if (command == null)
                //    SettingsManager.Instance.AddLearned(str, str);
                //else if (command.FitsPriority(Command.PriorityType.Medium))
                //    SettingsManager.Instance.AddLearned(item.Text, command.ProtectedName);//SettingsManager.Instance.AddLearned(StringUtility.ArrayToStr(item.CommandTokens), command.ProtectedName);
                //else if (command.FitsPriority(Command.PriorityType.Low))
                //    SettingsManager.Instance.AddLearned(item.Text, command.ProtectedName);
                //else if (command.FitsPriority(Command.PriorityType.Medium))
                //    SettingsManager.Instance.AddLearned(BuildCommandParameters(item.Text, item.CommandTokens), command.ProtectedName);
                SettingsManager.Instance.AddLearned(StringUtility.ArrayToStr(item.CommandTokens, false), item.Type, item.Name, item.CommandTokens);
            }
            //else
            //{
            //    //if (str != item.AutoComplete.ToLower())
            //    SettingsManager.Instance.AddLearned(str, item.AutoComplete);
            //}
            //}
        }
        private string ReplaceSpecialKeywords(string text, string[] tokens)
        {
            string ret                = text;
            string this_keyword       = @"!this";
            string clipboard_keyword  = @"!clipboard";
            string process_keyword    = @"!topapp";
            string desktop_keyword    = @"!desktop";
            string explorer_keyword   = @"!here";
            string item_keyword       = @"!selected";
            string url_keyword        = @"!url";
            bool   look_for_this      = true;
            bool   look_for_clipboard = true;
            bool   look_for_process   = true;
            bool   look_for_desktop   = true;
            bool   look_for_explorer  = true;
            bool   look_for_item      = true;
            bool   look_for_url       = true;

            if (tokens != null)
            {
                if (Array.IndexOf <string>(tokens, this_keyword) != -1)
                {
                    look_for_this = false;
                }
                if (Array.IndexOf <string>(tokens, clipboard_keyword) != -1)
                {
                    look_for_clipboard = false;
                }
                if (Array.IndexOf <string>(tokens, process_keyword) != -1)
                {
                    look_for_process = false;
                }
                if (Array.IndexOf <string>(tokens, desktop_keyword) != -1)
                {
                    look_for_desktop = false;
                }
                if (Array.IndexOf <string>(tokens, explorer_keyword) != -1)
                {
                    look_for_explorer = false;
                }
                if (Array.IndexOf <string>(tokens, item_keyword) != -1)
                {
                    look_for_item = false;
                }
                if (Array.IndexOf <string>(tokens, url_keyword) != -1)
                {
                    look_for_url = false;
                }
            }
            if (!look_for_this && !look_for_clipboard && !look_for_process &&
                !look_for_desktop && !look_for_explorer && !look_for_item &&
                !look_for_url)
            {
                return(text);
            }
            if (look_for_this)
            {
                if (text.Contains(this_keyword))
                {
                    ContextLib.DataContainers.Multimedia.MultiLevelData data = UserContext.Instance.GetSelectedContent();
                    if (data.Text != null)
                    {
                        ret = ret.Replace(this_keyword, data.Text);
                    }
                    data.Dispose();
                }
            }
            if (look_for_clipboard)
            {
                if (text.Contains(clipboard_keyword))
                {
                    ContextLib.DataContainers.Multimedia.MultiLevelData data = UserContext.Instance.GetClipboardContent();
                    if (data.Text != null)
                    {
                        ret = ret.Replace(clipboard_keyword, data.Text);
                    }
                    data.Dispose();
                }
            }
            if (look_for_process)
            {
                if (text.Contains(process_keyword))
                {
                    ContextLib.DataContainers.GUI.Window window = UserContext.Instance.GetTopWindow();
                    if (window != null)
                    {
                        ret = ret.Replace(process_keyword, window.ProcessName);
                    }
                }
            }
            if (look_for_desktop)
            {
                if (text.Contains(desktop_keyword))
                {
                    ret = ret.Replace(desktop_keyword, CommonInfo.UserDesktop);
                }
            }
            if (look_for_explorer)
            {
                if (text.Contains(explorer_keyword))
                {
                    ret = ret.Replace(explorer_keyword, UserContext.Instance.GetExplorerPath(false));
                }
            }
            if (look_for_item)
            {
                if (text.Contains(item_keyword))
                {
                    ret = ret.Replace(item_keyword, StringUtility.ArrayToStr(UserContext.Instance.GetExplorerSelectedItems(false)));
                }
            }
            if (look_for_url)
            {
                if (text.Contains(url_keyword))
                {
                    ret = ret.Replace(url_keyword, UserContext.Instance.GetBrowserUrl());
                }
            }
            //string[] args = StringUtility.GenerateKeywords(text, false);
            //for (int i = 0; i < args.Length; i++)
            //{
            //    string arg = args[i].Trim(new char[] { '\"', '\'', ',', ';' });
            //    if (arg == this_keyword)
            //    {
            //        if (look_for_this)
            //        {
            //            ContextLib.DataContainers.Multimedia.MultiLevelData data = UserContext.Instance.GetSelectedContent();
            //            if (data.Text != null)
            //                args[i] = data.Text;
            //            else
            //                args[i] = string.Empty;
            //            data.Dispose();
            //        }
            //    }
            //    else if (arg == clipboard_keyword)
            //    {
            //        if (look_for_clipboard)
            //        {
            //            ContextLib.DataContainers.Multimedia.MultiLevelData data = UserContext.Instance.GetClipboardContent();
            //            if (data.Text != null)
            //                args[i] = data.Text;
            //            else
            //                args[i] = string.Empty;
            //            data.Dispose();
            //        }
            //    }
            //    else if (arg == process_keyword)
            //    {
            //        if (look_for_process)
            //        {
            //            ContextLib.DataContainers.GUI.Window window = UserContext.Instance.GetTopWindow();
            //            if (window != null)
            //                args[i] = window.ProcessName;
            //        }
            //    }
            //    else if (arg == desktop_keyword)
            //    {
            //        if (look_for_desktop)
            //        {
            //            return CommonInfo.UserDesktop;
            //        }
            //    }
            //    else if (arg == explorer_keyword)
            //    {
            //        if (look_for_explorer)
            //        {
            //            args[i] = UserContext.Instance.GetExplorerPath(false);
            //        }
            //    }
            //    else if (arg == item_keyword)
            //    {
            //        if (look_for_item)
            //        {
            //            string items = StringUtility.ArrayToStr(UserContext.Instance.GetExplorerSelectedFiles(false));
            //            args[i] = items;
            //        }
            //    }
            //}
            //foreach (string arg in args)
            //    ret += arg + " ";
            //return ret.TrimEnd();
            return(ret);
        }