public static UserControl NewUserControlFrom(FigureTemplate template, VocabularyImage img) { UserControl retVal = null; // create a CoolImage based on a provided image in the ImageDictionary retVal = new CoolImage(template.Fill.Clone(), template.Letter, template.Color); return(retVal); }
public static UserControl NewUserControlFrom(FigureTemplate template) { UserControl retVal = null; if (template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0])) { retVal = new CoolLetter(template.Fill.Clone(), template.Letter[0]); } else if (Char.IsLetterOrDigit(template.Letter[0])) { // create a CoolImage based on a provided image in the ImageDictionary retVal = new CoolImage(template.Fill.Clone(), template.Letter, template.Color); } else { retVal = template.GeneratorFunc(template.Fill.Clone()); } var randomTransition1 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce); var ani1 = Tweener.Tween.CreateAnimation(randomTransition1, 0, 1, new TimeSpan(0, 0, 0, 1), 30); var randomTransition2 = (Tweener.TransitionType)Utils.RandomBetweenTwoNumbers(1, (int)Tweener.TransitionType.EaseOutInBounce); var ani2 = Tweener.Tween.CreateAnimation(randomTransition2, 360, 0, new TimeSpan(0, 0, 0, 1), 30); if (retVal != null) { retVal.RenderTransformOrigin = new Point(0.5, 0.5); var group = new TransformGroup(); group.Children.Add(new ScaleTransform()); group.Children.Add(new RotateTransform()); retVal.RenderTransform = group; group.Children[0].BeginAnimation(ScaleTransform.ScaleXProperty, ani1); group.Children[0].BeginAnimation(ScaleTransform.ScaleYProperty, ani1); group.Children[1].BeginAnimation(RotateTransform.AngleProperty, ani2); if (Settings.Default.BitmapEffects) { retVal.Effect = template.Effect.Clone(); } } return(retVal); }