Пример #1
0
        public void insertSentence(string nativeSentence)
        {
            if (presentWords.ContainsKey(nativeSentence))
            {
                rmSentence(nativeSentence);
            }
            allClosedSentences.Add(nativeSentence);
            string translatedSentence = sentenceDictionary.translateToEnglish(nativeSentence);

            serverCommunication.sendAddClosedSentence(nativeSentence);
            SentenceView sentview = new SentenceView(nativeSentence, translatedSentence, mainPage, true);

            presentWords[nativeSentence]  = sentview;
            sentview.restoreButton.Click += (o, e) =>
            {
                rmSentence(nativeSentence);
                mainPage.RightSidebar.readSentencesTab.insertSentence(nativeSentence);
            };
            sentview.removeButton.Click += (o, e) =>
            {
                rmSentence(nativeSentence);
            };
            this.SentenceListViewer.Children.Insert(1, sentview);
            colorBackgrounds();
        }
Пример #2
0
        public void rmSentence(string nativeSentence)
        {
            if (!presentWords.ContainsKey(nativeSentence))
            {
                return;
            }
            SentenceView sentview = presentWords[nativeSentence];

            this.SentenceListViewer.Children.Remove(sentview);
            serverCommunication.sendRmSentence(nativeSentence);
            colorBackgrounds();
        }
Пример #3
0
        void findClosedSentencesAsynch(string searchText)
        {
            //SentenceListViewer.Dispatcher.BeginInvoke(() =>
            //{
            for (int i = 1; i < SentenceListViewer.Children.Count; ++i)
            {
                SentenceListViewer.Children.RemoveAt(i);
            }
            //});

            if (searchText == "")
            {
                foreach (string sentence in allClosedSentences)
                {
                    string       translatedSentence = sentenceDictionary.translateToEnglish(sentence);
                    SentenceView sv = new SentenceView(sentence, translatedSentence, mainPage, true);
                    //SentenceListViewer.Dispatcher.BeginInvoke(() =>
                    //{
                    SentenceListViewer.Children.Insert(1, sv);
                    //});
                }
            }
            else
            {
                foreach (string sentence in allClosedSentences)
                {
                    string translatedSentence = sentenceDictionary.translateToEnglish(sentence);
                    bool   matchingPinyin     = false;
                    foreach (string word in sentenceDictionary.getWords(sentence))
                    {
                        if (wordDictionary.getReading(word).Contains(searchText) || wordDictionary.translateToEnglish(word).Contains(searchText))
                        {
                            matchingPinyin = true;
                            break;
                        }
                    }
                    if (matchingPinyin || sentence.Contains(searchText) || translatedSentence.Contains(searchText))
                    {
                        SentenceView sv = new SentenceView(sentence, translatedSentence, mainPage, true);
                        //SentenceListViewer.Dispatcher.BeginInvoke(() =>
                        //{
                        SentenceListViewer.Children.Insert(1, sv);
                        //});
                    }
                }
            }
            colorBackgrounds();
        }
        public void insertSentence(string nativeSentence)
        {
            string translatedSentence = sentenceDictionary.translateToEnglish(nativeSentence);

            serverCommunication.sendAddContribSentence(nativeSentence, translatedSentence);
            SentenceView sentview = new SentenceView(nativeSentence, translatedSentence, mainPage);

            sentview.removeButton.Click += (o, e) =>
            {
                this.ContributedSentenceListViewer.Children.Remove(sentview);
                colorBackgrounds();
                serverCommunication.sendRmContribSentence(nativeSentence);
            };
            this.ContributedSentenceListViewer.Children.Insert(1, sentview);
            colorBackgrounds();
        }
Пример #5
0
        private void colorBackgrounds()
        {
            int i = 0;

            foreach (var x in SentenceListViewer.Children.Skip(2))
            {
                SentenceView sentview = x as SentenceView;
                if (i % 2 == 1)
                {
                    sentview.rootStackPanel.Background = new SolidColorBrush(Color.FromArgb(255, 224, 251, 255));
                }
                else
                {
                    sentview.rootStackPanel.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
                }
                i += 1;
            }
        }
Пример #6
0
        public void insertSentence(string nativeSentence)
        {
            if (presentWords.ContainsKey(nativeSentence))
            {
                rmSentence(nativeSentence);
            }
            string       tranlatedSentence = sentenceDictionary.translateToEnglish(nativeSentence);
            SentenceView sentview          = new SentenceView(nativeSentence, tranlatedSentence, mainPage);

            presentWords[nativeSentence]  = sentview;
            sentview.removeButton.Content = "Close";
            sentview.removeButton.Click  += (o, e) =>
            {
                rmSentence(nativeSentence);
                mainPage.RightSidebar.closedSentencesTab.insertSentence(nativeSentence);
            };
            SentenceListViewer.Children.Insert(2, sentview);
            colorBackgrounds();
        }