public override List <DictionaryProvider> GetProviders() { List <DictionaryProvider> m_providers = new List <DictionaryProvider>(); foreach (Type type in GlobalOptions.WorkedDictionaries) { DictionaryProvider provider = (DictionaryProvider)Activator.CreateInstance(type); //TODO: здесь бы вставить и проверку поддержки языка if (!provider.OnlyAsUrlProvider) { m_providers.Add(provider); } } return(m_providers); }
private void RegisterEvent() { if (string.IsNullOrEmpty(this.Word)) { return; } DictionaryProvider provider = null; if (this.LastUsedDict != null) { RunDictContent dictContent = this.LastUsedDict.Tag as RunDictContent; if (dictContent != null && dictContent.Providers.Count > 0) { provider = dictContent.Providers[0]; } } HistoryItem hi = new HistoryItem(this.Word, provider); //, this.webBrowser1.TempContent); #region clear old content if (this.comboBox.Items.Contains(hi.Word)) { this.comboBox.Items.Remove(hi.Word); } else { foreach (object ob in this.comboBox.Items) { if (ob is HistoryItem && hi.Equals((HistoryItem)ob)) { this.comboBox.Items.Remove(hi); } } } #endregion this.comboBox.Items.Insert(0, hi); try { this.comboBox.SelectedValueChanged -= new System.EventHandler(this.comboBox_SelectedValueChanged); this.comboBox.SelectedIndex = 0; } finally { this.comboBox.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged); } UpdateFormCaption(); CheckButtonsPrevNext(); }
public AsyncProvider(string text, LangPair langPair, DictionaryProvider provider, WaitingUIObjectWithFinish waitingUiObject, Dictionary <string, string> containerCollection, string keyForResult) { m_text = text; m_langPair = langPair; m_provider = provider; m_waitingUiObject = waitingUiObject; m_containerCollection = containerCollection; m_keyForResult = keyForResult; this.m_thread = new Thread(new ThreadStart(Translate)); this.m_thread.Name = string.Format("Getting from: '{0}' data: '{1}'", provider.Title, text); if (provider.IsDoFullLoading) { this.m_thread.SetApartmentState(ApartmentState.STA); } this.m_thread.Start(); }
// public HistoryItem(string word, DictionaryProvider dictionaryProvider, string content) public HistoryItem(string word, DictionaryProvider dictionaryProvider) { m_Word = word; m_DictionaryProvider = dictionaryProvider; // m_Content = content; }
static void AddProvidersByType(IList collection, DictionaryProviderType type, ITextWithSelection textWithSelection, WebBrowserForForm UITarget, string title) { // string titleStart = "In all "; string titleStart = "in all "; string titleEnd = " ... "; List <DictionaryProvider> allProviders = new List <DictionaryProvider>(); title = titleStart + title.ToUpper() + titleEnd; ToolStripItem miAllProviders = new ToolStripButton(title, null, Dict_Click); miAllProviders.Font = new Font(miAllProviders.Font, FontStyle.Bold); // | FontStyle.Underline); miAllProviders.ForeColor = BoldColor; // Color.Gray; collection.Add(miAllProviders); miAllProviders.ToolTipText = "Search in all Dictionaries for this group"; miAllProviders.Tag = new RunDictContent(textWithSelection, allProviders, UITarget); foreach (Type tp in GlobalOptions.AllDictionaries) { DictionaryProvider dp = (DictionaryProvider)Activator.CreateInstance(tp); if ((dp.DictType & type) == type) // dp.Type.HasFlag( because WordNet simple dictionary and idiom dictionary { ToolStripItem miDict = null; if (UITarget != null) // or != null { miDict = new ToolStripButton(" - " + dp.Title, null, Dict_Click); } else { miDict = new ToolStripMenuItem(" - " + dp.Title, null, Dict_Click); if (UITarget != null) { ((ToolStripMenuItem)miDict).CheckOnClick = true; } } //miDict.Font = new Font(miDict.Font.FontFamily, miDict.Font.Size - 1); // miAllProviders.ToolTipText = "Click here for search in " + dp.Title; string toolTipText = ""; foreach (string langPair in dp.Languages) { if (!string.IsNullOrEmpty(toolTipText)) { toolTipText += ", "; } else if (DictionaryProvider.AllLanguages.Equals(langPair)) { toolTipText = "All languages"; break; } toolTipText += langPair; } miDict.ToolTipText = toolTipText; // dp.CorrectionURL; miDict.Tag = new RunDictContent(textWithSelection, new List <DictionaryProvider>() { dp }, UITarget); miDict.TextAlign = ContentAlignment.MiddleLeft; #region add google image if (dp.GetType().Name.ToLower().Contains("google")) { // miDict.TextAlign = ContentAlignment.MiddleRight; miDict.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; miDict.ImageScaling = ToolStripItemImageScaling.None; miDict.ImageTransparentColor = Color.White; miDict.Image = f.db.Properties.Resources.google; miDict.TextImageRelation = TextImageRelation.ImageBeforeText; //miDict.TextImageRelation = TextImageRelation.TextBeforeImage; // miDict.TextImageRelation = TextImageRelation.TextBeforeImage; //miDict.Image = f.db.Properties.Resources.redAsterisk8_; miDict.ToolTipText = "Google - " + miDict.ToolTipText; } #endregion collection.Add(miDict); allProviders.Add(dp); } } }