예제 #1
0
        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 void Pivot_Main_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Pivot_Main.SelectedIndex == 0)
            {
                StackPanel_ExampleCard.Children.Clear();

                Noun noun = new Noun("Lektion", "课,单元", WordGender.Feminine, "-en", "");
                System.Windows.Controls.UserControl uc;
                switch (ListPicker_CardType.SelectedIndex)
                {
                    case 0:
                        uc = new OneSideNounCard(noun);
                        TextBlock_ReversiblePrompt.Opacity = 0;
                        break;
                    case 1:
                        uc = new TwoSideNounCard(noun, true);
                        TextBlock_ReversiblePrompt.Opacity = 100;
                        break;
                    case 2:
                        uc = new TwoSideNounCard(noun, false);
                        TextBlock_ReversiblePrompt.Opacity = 100;
                        break;
                    default:
                        uc = null;
                        break;
                }
                StackPanel_ExampleCard.Children.Add(uc);
            }
        }