private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            currentIndex = startIndex;
            Word word = new Word();
            if (startIndex - 1 > 0)
            {
                word = wordList[startIndex - 1];
                System.Windows.Controls.UserControl wordCardControl = GenerateWordCardControl(word);
                if (wordCardControl != null)
                    StackPanel_Card1.Children.Add(wordCardControl);
            }

            if (startIndex >= 0 && startIndex < wordList.Count)
            {
                word = wordList[startIndex];
                System.Windows.Controls.UserControl wordCardControl = GenerateWordCardControl(word);
                if (wordCardControl != null)
                    StackPanel_Card2.Children.Add(wordCardControl);
            }

            if (startIndex + 1 < wordList.Count)
            {
                word = wordList[startIndex + 1];
                System.Windows.Controls.UserControl wordCardControl = GenerateWordCardControl(word);
                if (wordCardControl != null)
                    StackPanel_Card3.Children.Add(wordCardControl);
            }
            //if (word != null)
            //{
            //    BaseData.word = word.word;
            //}
        }
        public OneSideWordCard(Word word)
            : this()
        {
            TextBlock_Line0.Text = Word.WordTypeToString(word.wordType);
            TextBlock_Line1.Text = word.word;
            nowword = word.word;
            TextBlock_Line2.Text = word.translation;

            UIHelper.AdjustWrappedTextBlockFontSize(TextBlock_Line1, 420, 150);
            UIHelper.ReduceFontSizeByWidth(TextBlock_Line2, 420);
        }
        public LiveTileWordPicture(Word word)
            : this()
        {
            TextBlock_Line0.Text = Word.WordTypeToString(word.wordType);
            TextBlock_Line1.Text = word.word;
            TextBlock_Line2.Text = word.translation;

            UIHelper.AdjustWrappedTextBlockFontSize(TextBlock_Line1, 300, 160);
            UIHelper.ReduceFontSizeByWidth(TextBlock_Line2, 300);
            UIHelper.SetTextBlockVerticalCenterOfCanvas(TextBlock_Line1);
            UIHelper.SetTextBlockVerticalCenterOfCanvas(TextBlock_Line2);
        }
        public DictationPage()
        {
            InitializeComponent();
            //isNewPageInstance = true;
            currentWordIndex = 0;
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            waittimer = new DispatcherTimer();
            waittimer.Interval = TimeSpan.FromSeconds(1);


            wordList = null;
            wordSource = null;
            wordCardType = 0;
            startIndex = 0;
            waittime = 0;
            currentword = new Word();
            currentCount = 0;
        }
        public TwoSideWordCard(Word word, bool isWordInFront)
            : this()
        {
            TextBlock_FrontLine0.Text = Word.WordTypeToString(word.wordType);

            if (isWordInFront)
            {
                TextBlock_FrontLine1.Text = word.word;
                TextBlock_BackLine1.Text = word.translation;
            }
            else
            {
                TextBlock_FrontLine1.Text = word.translation;
                TextBlock_BackLine1.Text = word.word;
            }
            nowword = word.word;

            UIHelper.AdjustWrappedTextBlockFontSize(TextBlock_FrontLine1, 420, 250);
            UIHelper.AdjustWrappedTextBlockFontSize(TextBlock_BackLine1, 420, 250);
        }
        public static System.Windows.Controls.UserControl GenerateTwoSideWordCard(Word word, bool isWordInFront, double scaleX = 1, double scaleY = 1, Brush background = null)
        {
            System.Windows.Controls.UserControl uc;
            if (word is Noun)
            {
                uc = new TwoSideNounCard(word as Noun, isWordInFront);
                (uc as TwoSideNounCard).ScaleX = scaleX;
                (uc as TwoSideNounCard).ScaleY = scaleY;
                if (background != null)
                    (uc as TwoSideNounCard).BackgroundBrush = background;
            }
            else if (word is Verb)
            {
                uc = new TwoSideVerbCard(word as Verb, isWordInFront);
                (uc as TwoSideVerbCard).ScaleX = scaleX;
                (uc as TwoSideVerbCard).ScaleY = scaleY;
                if (background != null)
                    (uc as TwoSideVerbCard).BackgroundBrush = background;
            }
            else if (word is Abbreviation)
            {
                uc = new TwoSideAbbrCard(word as Abbreviation, isWordInFront);
                (uc as TwoSideAbbrCard).ScaleX = scaleX;
                (uc as TwoSideAbbrCard).ScaleY = scaleY;
                if (background != null)
                    (uc as TwoSideAbbrCard).BackgroundBrush = background;
            }
            else
            {
                uc = new TwoSideWordCard(word, isWordInFront);
                (uc as TwoSideWordCard).ScaleX = scaleX;
                (uc as TwoSideWordCard).ScaleY = scaleY;
                if (background != null)
                    (uc as TwoSideWordCard).BackgroundBrush = background;
            }
            uc.Width = 450;
            uc.Height = 300;

            return uc;
        }
        private System.Windows.Controls.UserControl GenerateWordCardControl(Word word)
        {
            System.Windows.Controls.UserControl uc;

            switch (cardType)
            {
                case 1:
                    uc = UserControlHelper.GenerateOneSideWordCard(word, 1, 1, (Brush)Application.Current.Resources["PhoneAccentBrush"]);
                    break;
                case 2:
                    uc = UserControlHelper.GenerateTwoSideWordCard(word, true, 1, 1, (Brush)Application.Current.Resources["PhoneAccentBrush"]);
                    break;
                case 3:
                    uc = UserControlHelper.GenerateTwoSideWordCard(word, false, 1, 1, (Brush)Application.Current.Resources["PhoneAccentBrush"]);
                    break;
                default:
                    uc = null;
                    break;
            }

            return uc;
        }
 private void UpdateUI()
 {
     TextBlock_CurrentWordNumber.Text = (currentWordIndex + 1).ToString();
     currentword = wordList[currentWordIndex];
     TextBlock_Chinese.Text = currentword.wordType.ToString() + "  " + currentword.translation;
     speech();
     confirm.IsEnabled = true;
 }
 public static System.Windows.Controls.UserControl GenerateWordTile(Word word)
 {
     if (word is Noun)
         return new LiveTileNounPicture(word as Noun);
     else if (word is Verb)
         return new LiveTileVerbPicture(word as Verb);
     else if (word is Abbreviation)
         return new LiveTileAbbrPicture(word as Abbreviation);
     else
         return new LiveTileWordPicture(word);
 }