/// <summary> /// 指定搜索 /// </summary> /// <param name="c"></param> /// <param name="spaceIndex"></param> /// <param name="defaultKey"></param> private void showSpecifySearch(string c, int spaceIndex, string defaultKey) { //确定使用什么功能的键 string key = c.Substring(0, spaceIndex).ToLower(); if (ControlTypes.f.ToString() == key) { string t = c.Substring(spaceIndex + 1); try { this.Controls.Remove(ctl); } catch (Exception) { } ICreateControl icc = CreateControlWithEnum.getShowControl(Enums.ControlTypes.f); TranslateTypes tt = TranslateTypes.English; if (t.isChinese()) { tt = TranslateTypes.Chinese; } ctl = icc.getResults(t, tt); ctl.Name = "test"; ctl.Width = this.txtContent.Width; ctl.Height = 30; ctl.Left = 0; ctl.Top = this.txtContent.Height; this.Controls.Add(ctl); this.Height = this.txtContent.Height + ctl.Height + WINDOW_BORDER_HEIGHT; } else { string url = key.GetConfigValue(); if (url.IsNotEmpty()) { string fUrl = url.Replace("{q}", c.Substring(spaceIndex + 1).EscapeStr()); SearchContent(fUrl); } else { showDefaultSearch(c, defaultKey); } } }
/// <summary> /// 根据枚举获取相应的创建控件格式(搜索,翻译,计算....) /// </summary> /// <returns></returns> public static ICreateControl getShowControl(ControlTypes ct) { ICreateControl obj = null; switch (ct) { //case ControlTypes.Calc: // //obj = new // break; //case ControlTypes.Search: // break; case ControlTypes.f: obj = new CreateTranslateControl(); break; default: break; } return(obj); }