Exemple #1
0
        private void moreMenuButton_Click(object sender, EventArgs e)
        {
            this.btFind.Enabled                            =
                this.btEstimate.Enabled                    =
                    this.miCloseText.Enabled               = !string.IsNullOrEmpty(this.FileName);
            this.nextSentenceToolStripMenuItem.Enabled     = this.List.Items.Count > this.List.SelectedIndex + 1;
            this.previousSentenceToolStripMenuItem.Enabled = 0 < this.List.SelectedIndex;

            // TODO: а были ли изменения??
            this.saveToolStripMenuItem.Enabled = !string.IsNullOrEmpty(this.FileName);
            //  this.btEstimate.Enabled = !string.IsNullOrEmpty(this.FullText);

            #region btFindUsages.Enabled
            string _currentWordOrText = TipTextBox.GetCurrentWord(this.TipTextBox);
            //       this.btFind.Enabled = !string.IsNullOrEmpty(this.FullText);
            string _menuText = "Find '{0}'";
            if (this.btFind.Enabled)
            {
                this.btFind.ToolTipText = string.Format(_menuText, _currentWordOrText);
            }
            else
            {
                this.btFind.ToolTipText = string.Format(_menuText, "Selected");
            }
            #endregion
        }
Exemple #2
0
 internal void Hide(TipTextBox tipTextBox)
 {
     this.toolTip.Hide(tipTextBox);
     if (debugInfo)
     {
         Console.WriteLine("Hide");
     }
 }
Exemple #3
0
        public void FindCitationsForWordAndShow()
        {
            string _currentWordOrText = TipTextBox.GetCurrentWord(this.TipTextBox);

            if (string.IsNullOrEmpty(_currentWordOrText))
            {
                return;
            }
            FindForm searcher = new FindForm();

            searcher.InitAndSearch(this.FullText, _currentWordOrText);
            //TODO:             using (new AbandonTopPosition(Utils.VideoForm))
            // а надо ли ?
            searcher.Show();
        }
Exemple #4
0
        private void ShowTipArticle(TipTextBox sender, Point point, string maskedWord, string word, GoogleTipDictionary.TipArticle tipArticle)
        {
            toolTip.ToolTipTitle = tipArticle.Caption; // +" = " + word;
            string body = Utils.ShrinkLines(tipArticle.Body);

            if (!string.IsNullOrEmpty(maskedWord))
            {
                body = body.Replace(word, maskedWord);
            }

            //  Point point = sender.PointToClient(Cursor.Position);
            //  ttForCurrentDisplay.Show(body, sender, point.X, point.Y + 15, 15000);

            if (!sender.IsDisposed && !sender.Disposing)
            {
                //if(sender.InvokeRequired)
                sender.Invoke(new ShowTooTip(toolTip.Show), body, sender, point.X, point.Y + 15, 10000);
                //else toolTip.Show(body, sender, point.X, point.Y + 15, 15000);
            }
        }
Exemple #5
0
        void ShowSynonyms(TipTextBox textBox)
        {
            if (textBox == null)
            {
                MessageBox.Show("Current editor is missing"); return;
            }

            GoogleSynonymsDictionary dict = new GoogleSynonymsDictionary();

            if (string.IsNullOrEmpty(dict.GetContainsSourceLanguage(textBox.LangDir.From)))
            {
                MessageBox.Show(string.Format("Language {0} is missing for dictionary", textBox.LangDir.From)); return;
            }

            int start = textBox.SelectionStart;
            int end   = start;

            string word       = TipTextBox.GetWord(textBox, ref start, ref end);
            string titledWord = word;

            if (word.Contains(SentenceForLesson.CharHided))
            {
                if (textBox.Sentence == null)
                {
                    MessageBox.Show("Current sentence is missing"); return;
                }
                word = TipTextBox.GetClearWord(textBox.Sentence, start, end);
            }

            if (!string.IsNullOrEmpty(word))
            {
                FloatWebBrowserForm browserForm = new FloatWebBrowserForm();
                browserForm.HTMLContent = dict.GetContent(word, textBox.LangDir);
                browserForm.Text        = string.Format("Synonyms for '{0}'", titledWord);
                browserForm.Show(this);
            }
        }
Exemple #6
0
        public void PopupDictionaryArticle(TipTextBox sender, Point point, int charIndexUnderCursor)
        {
            //Console.WriteLine("!");

            //word = GetClearWordValue(word);
            string word = sender.GetStringUnderCursor(charIndexUnderCursor, ref this.currentMaskedWord);

            if (string.IsNullOrEmpty(word))
            {
                return;
            }

            this.currentPoint  = point;
            this.currentSender = sender;
            if (word.Equals(this.currentWord))
            {
                if ((CurrentThread != null && CurrentThread.IsAlive))
                {
                    return;
                }
                else // if(!this.toolTip.Active) // is showed
                {
                    this.TipArticleCallBack = this.TipArticleCallBack;
                    if (debugInfo)
                    {
                        Console.WriteLine("Recall");
                    }
                    return;
                }
            }

            if (this.TipArticleCallBack != null)
            {
                lock (this.TipArticleCallBack)
                {
                    if (CurrentThread != null && CurrentThread.IsAlive)
                    {
                        if (debugInfo)
                        {
                            Console.WriteLine("Abort " + CurrentThread.Name);
                        }
                        CurrentThread.Abort();
                    }
                }
            }
            else // be made only once
            {
                if (CurrentThread != null && CurrentThread.IsAlive)
                {
                    if (debugInfo)
                    {
                        Console.WriteLine("First Abort " + CurrentThread.Name);
                    }
                    CurrentThread.Abort();
                }
            }

            if (debugInfo)
            {
                Console.WriteLine("GetInfo for: " + word);
            }

            this.currentWord = word;
            LangPair lp = sender.LangDir;

            if (lp.From.Equals(lp.To) || sender.IsMonoRegim)
            {
                GoogleMonoDictionary monoDict = new GoogleMonoDictionary();
                // TODO: здесь приходит HTML возможно надо свое окно а не парсинг
                //if ( Array.IndexOf(monoDict.Languages, this.LangDir.From) != -1 )
                //{
                //    string article = monoDict.GetContent(word, this.LangDir);
                //    tipArticle = GoogleTipDictionary.GetTipArticle(word, article);
                //}
                //else
                TipHelper.Instance.TipArticleCallBack = new GoogleTipDictionary.TipArticle(string.Format("Mono dictionary for '{0}' is not supported", lp), " ");
                //tipArticle = new GoogleTipDictionary.TipArticle(string.Format("Change language pair '{0}'", LangDir), " ");
            }
            else
            {
                new Starter(this.currentWord, lp); //, new DelegateSetTipArticle(SetTipArticle));
            }
        }
Exemple #7
0
        public Tutor()
        {
            InitializeComponent();

            this.BackColor            = CF.ExternalBorder;
            this.panel1.BackColor     = Color.White;
            this.tutorList1.List.Font = new Font(this.Font.Name, 12);
            this.tutorList1.List.SelectedIndexChanged += new EventHandler(List_SelectedIndexChanged);
            this.tutorList1.panelTopIndent.Padding     = new Padding(4, 2, 190, 4);
            this.tutorList1.panelTopIndent.Visible     = true;

            this.keyBoards.PressYesLetter += new EventHandler(z1_PressYesLetter);

            txBox = this.textArea.ForeignText;
            this.tutorList1.Initialize(txBox);

            this.txBox.HideSelection       = false;
            this.txBox.IsSystemTextChaghed = false;
            this.txBox.HideSelection       = false;

            this.txBox.SelectionChanged += new System.EventHandler(this.txBox_SelectionChanged);

            this.splitterHorizontal.Paint += new System.Windows.Forms.PaintEventHandler(this.splitterHorizontal_Paint);


            this.KeyDown                 += new System.Windows.Forms.KeyEventHandler(this.KeyProcess);
            this.keyBoards.KeyDown       += new System.Windows.Forms.KeyEventHandler(this.KeyProcess);
            this.textArea.KeyDown        += new System.Windows.Forms.KeyEventHandler(this.KeyProcess);
            this.tutorList1.List.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyProcess);

            this.textArea.translatedText.TabStop = false;

            // init menu bar
            this.menuForSelected.TextsForMenu = this;

            // init top menu
            btPrev.Click += new EventHandler(btPrev_Click);
            btNext.Click += new EventHandler(btNext_Click);
            btExit.Click += new EventHandler(btExit_Click);

            #region replace items from main menu
            List <ToolStripItem> menuItems = new List <ToolStripItem>();
            foreach (ToolStripItem item in this.toolStrip1.Items)
            {
                menuItems.Add(item);
            }
            foreach (ToolStripItem item in menuItems)
            {
                this.tutorList1.toolStrip1.Items.Add(item);
            }
            #endregion

            // this.RestoreState();
            this.FormClosed += new FormClosedEventHandler(Tutor_FormClosed);

            this.menuForSelected.TextsForMenu = this;
            this.menuForSelected.InitDictionaries(this.textArea);

            #region scores
            // scores
            this.tutorList1.List.SelectedIndexChanged += new EventHandler(List_SelectedIndexChangedForScore);
            this.tutorList1.TextReloaded   += new SentenceList.ListContentUpdated(tutorList1_TextReloaded);
            this.tutorList1.ChangingFile   += new EventHandler(tutorList1_ChangingFile);
            this.scoreCurrent.ToolTipPrefix = "Score for current sentence";
            this.scoreProgressForAllSentences.ToolTipPrefix = "Score for the whole lesson ";
            // ResetProgress for all
            this.scoreCurrent.ResetProgress();
            this.scoreProgressForAllSentences.ResetProgress();
            this.scoreCurrent.ResetProgress();
            #endregion

            this.textArea.paForeignText.Height = 62;
            this.tutorList1.TextReloaded      += new SentenceList.ListContentUpdated(LessonReloaded);

            this.btAbout.Click                   += new System.EventHandler(this.miAbout_Click);
            this.btSendFeedback.Click            += new System.EventHandler(this.miSendFeedback_Click);
            this.btExit.Click                    += new System.EventHandler(this.miExit_Click);
            this.menuForSelected.IsWordAavailable = true;
            this.menuForSelected.SwitchOfAddWordsToLesson();

            CurrentLangInfo.ChangedLanguageDirection         += new EventHandler(Common_ChangedLanguageDirection);
            this.menuForSelected.HideTranslationStateChanged += new EventHandler(MenuForSelected_HideTranslationStateChanged);
        }
Exemple #8
0
 public void Initialize(TipTextBox richTextBox)
 {
     this.m_TipTextBox = richTextBox;
 }
Exemple #9
0
        void timer_Tick(object sender, EventArgs e)
        {
            if (this.Sentence == null)
            {
                return;
            }
            if (this.ForeignText.IsDisposed)
            {
                return;
            }
            // здесь вызов только выделенного текста
            // oldSelectedText сбрасывается через секунду
            if (oldSelectedText != this.ForeignText.SelectedText) // проверим с таймером что текст устоялся
            {
                oldSelectedText = this.ForeignText.SelectedText;
            }
            else
            {
                if (this.ActiveControl == ForeignText)
                {
                    if (oldSelectedText != previousTextForTranslate)
                    {
                        string _SelectedText = this.ForeignText.SelectedText;
                        string _maskedText   = "";
                        // Console.WriteLine(_SelectedText + " -- CallTranslate(_SelectedText);");

                        if (_SelectedText.Contains(SentenceForLesson.CharHided))
                        {
                            if (_SelectedText.Length == 1)
                            {
                                return;
                            }
                            _maskedText   = _SelectedText;
                            _SelectedText = TipTextBox.GetClearWord(this.Sentence,
                                                                    this.ForeignText.SelectionStart, this.ForeignText.SelectionStart + this.ForeignText.SelectionLength);
                        }

                        // старое один выделенный символ не переводим
                        if (previousTextForTranslate == _SelectedText) // || _SelectedText.Length == 1 )
                        {
                            return;
                        }

                        if (oldSelectedText.Length > 0 && UtilsForText.IsWord(_SelectedText)) // IsHaveSeveralWords(_SelectedText))
                        {
                            string translation = this.Sentence.GetCashForTranslation(_SelectedText);
                            if (string.IsNullOrEmpty(translation) && !WWW.InternetIsUnavailable.Equals(translation))
                            {
                                CallTranslate(_SelectedText, _maskedText);
                            }
                            else
                            {
                                this.translatedText.AssignText(translation);
                            }
                        }
                        else
                        {
                            this.translatedText.AssignText(this.Sentence.TranslAndComment);
                        }
                        previousTextForTranslate = _SelectedText;
                    }
                }
            }
        }