Beispiel #1
0
 public RunDictContent(ITextWithSelection textWithSelection, List <DictionaryProvider> providers, WebBrowserForForm UITarget)
 {
     m_textWithSelection = textWithSelection;
     m_providers         = providers;
     m_UITarget          = UITarget;
 }
Beispiel #2
0
 public RunFavoritDictContent(ITextWithSelection textWithSelection, WebBrowserForForm UITarget)
     : base(textWithSelection, null, UITarget)
 {
 }
Beispiel #3
0
        // ToolStripItemCollection <==> IList
        static public void InitMenuForProviders(IList collection, ITextWithSelection textWithSelection, WebBrowserForForm UITarget)
        {
            AddProvidersByType(collection, DictionaryProviderType.Simple, textWithSelection, UITarget, "dictionaries");

            AddBtFindinFavorits(collection, textWithSelection, UITarget);

            collection.Add(new ToolStripSeparator()); // "-"));
            AddProvidersByType(collection, DictionaryProviderType.MonoEn, textWithSelection, UITarget, "mono english");

            collection.Add(new ToolStripSeparator()); // "-"));
            AddProvidersByType(collection, DictionaryProviderType.Idiom, textWithSelection, UITarget, "idiom");

            collection.Add(new ToolStripSeparator()); // "-"));
            AddProvidersByType(collection, DictionaryProviderType.Definition, textWithSelection, UITarget, "definition");
        }
Beispiel #4
0
        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);
                }
            }
        }
Beispiel #5
0
        private static void AddBtFindinFavorits(IList collection, ITextWithSelection textWithSelection, WebBrowserForForm UITarget)
        {
            collection.Add(new ToolStripSeparator()); // "-"));
            ToolStripButton btFavList = new ToolStripButton();

            btFavList.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
//            btFavList.Text = "Find in FavoritList";
            btFavList.Text        = "in all FAVORIT ...";
            btFavList.Font        = new Font(btFavList.Font, FontStyle.Bold);
            btFavList.ForeColor   = BoldColor;
            btFavList.ToolTipText = "Search in Dictionaries from 'Favorit List'"; //  (Alt-D)";
//            btFavList.Tag = new RunDictContent(textWithSelection, new List<DictionaryProvider>() { new FavoritProvider() }, UITarget);
            btFavList.Tag    = new RunFavoritDictContent(textWithSelection, UITarget);
            btFavList.Click += new EventHandler(Dict_Click);
            collection.Add(btFavList);
        }