Ejemplo n.º 1
0
        public static System.Windows.Controls.UserControl GenerateOneSideWordCard(Word word, double scaleX = 1, double scaleY = 1, Brush background = null)
        {
            System.Windows.Controls.UserControl uc;
            if (word is Noun)
            {
                uc = new OneSideNounCard(word as Noun);
                (uc as OneSideNounCard).ScaleX = scaleX;
                (uc as OneSideNounCard).ScaleY = scaleY;
                if (background != null)
                    (uc as OneSideNounCard).BackgroundBrush = background;
            }
            else if (word is Verb)
            {
                uc = new OneSideVerbCard(word as Verb);
                (uc as OneSideVerbCard).ScaleX = scaleX;
                (uc as OneSideVerbCard).ScaleY = scaleY;
                if (background != null)
                    (uc as OneSideVerbCard).BackgroundBrush = background;
            }
            else if (word is Abbreviation)
            {
                uc = new OneSideAbbrCard(word as Abbreviation);
                (uc as OneSideAbbrCard).ScaleX = scaleX;
                (uc as OneSideAbbrCard).ScaleY = scaleY;
                if (background != null) 
                    (uc as OneSideAbbrCard).BackgroundBrush = background;
            }
            else
            {
                uc = new OneSideWordCard(word);
                (uc as OneSideWordCard).ScaleX = scaleX;
                (uc as OneSideWordCard).ScaleY = scaleY;
                if (background != null) 
                    (uc as OneSideWordCard).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);
            }
        }