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 { 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); 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); }
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 { 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); 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.UseEffects) { retVal.Effect = template.Effect.Clone(); } return retVal; }
private void AddFigure(FrameworkElement uie, char c) { FigureTemplate template = FigureGenerator.GenerateFigureTemplate(c); foreach (MainWindow window in this.windows) { UserControl f = FigureGenerator.NewUserControlFrom(template); window.AddFigure(f); var queue = figuresUserControlQueue[window.Name]; queue.Add(f); // Letters should already have accurate width and height, but others may them assigned. if (double.IsNaN(f.Width) || double.IsNaN(f.Height)) { f.Width = 300; f.Height = 300; } Canvas.SetLeft(f, Utils.RandomBetweenTwoNumbers(0, Convert.ToInt32(window.ActualWidth - f.Width))); Canvas.SetTop(f, Utils.RandomBetweenTwoNumbers(0, Convert.ToInt32(window.ActualHeight - f.Height))); Storyboard storyboard = Animation.CreateDPAnimation(uie, f, UIElement.OpacityProperty, new Duration(TimeSpan.FromSeconds(Settings.Default.FadeAfter)), 1, 0); if (Settings.Default.FadeAway) { storyboard.Begin(uie); } IHasFace face = f as IHasFace; if (face != null) { face.FaceVisible = Settings.Default.FacesOnShapes ? Visibility.Visible : Visibility.Hidden; } if (queue.Count > Settings.Default.ClearAfter) { window.RemoveFigure(queue[0]); queue.RemoveAt(0); } } // Find the last word typed, if applicable. string lastWord = this.wordFinder.LastWord(figuresUserControlQueue.Values.First()); if (lastWord != null) { foreach (MainWindow window in this.windows) { this.wordFinder.AnimateLettersIntoWord(figuresUserControlQueue[window.Name], lastWord); } SpeakString(lastWord); } else { PlaySound(template); } }
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 void PlaySound(FigureTemplate template) { if (Settings.Default.Sounds == "Laughter") { PlayLaughter(); } if (objSpeech != null && Settings.Default.Sounds == "Speech") { if (template.Letter != null && template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0])) { SpeakString(template.Letter); } else { SpeakString(GetLocalizedString(Utils.ColorToString(template.Color)) + " " + template.Name); } } }
public void PlaySound(FigureTemplate template) { if (Settings.Default.Sounds == "Laughter") { PlayLaughter(); } if (objSpeech != null && Settings.Default.Sounds == "Speech") { if (template.Letter != null && template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0])) { SpeakString(template.Letter); } else { string colorToSpeak = GetLocalizedString(Utils.ColorToString(template.Color)); string colorAndShapeToSpeak = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture.TextInfo.IsRightToLeft ? $"{template.Name} {colorToSpeak}" : $"{colorToSpeak} {template.Name}"; SpeakString(colorAndShapeToSpeak); } } }
private void AddFigure(FrameworkElement uie, string s) { FigureTemplate template = FigureGenerator.GenerateFigureTemplate(s); foreach (MainWindow m in this.windows) { UserControl f = FigureGenerator.NewUserControlFrom(template); m.AddFigure(f); var queue = ellipsesUserControlQueue[m.Name]; queue.Enqueue(f); f.Width = 300; f.Height = 300; Canvas.SetLeft(f, Utils.RandomBetweenTwoNumbers(0, Convert.ToInt32(m.ActualWidth - f.Width))); Canvas.SetTop(f, Utils.RandomBetweenTwoNumbers(0, Convert.ToInt32(m.ActualHeight - f.Height))); Storyboard storyboard = Animation.CreateDPAnimation(uie, f, UIElement.OpacityProperty, new Duration(TimeSpan.FromSeconds(Settings.Default.FadeAfter)), 1, 0); if (Settings.Default.FadeAway) { storyboard.Begin(uie); } IHasFace face = f as IHasFace; if (face != null) { face.FaceVisible = Settings.Default.FacesOnShapes ? Visibility.Visible : Visibility.Hidden; } if (queue.Count > Settings.Default.ClearAfter) { UserControl u = queue.Dequeue() as UserControl; m.RemoveFigure(u); } } PlaySound(template); }
public void PlaySound(FigureTemplate template) { if (Settings.Default.Sounds == "Laughter") { PlayLaughter(); } if (objSpeech != null && Settings.Default.Sounds == "Speech") { if (template.Letter != null && template.Letter.Length == 1 && Char.IsLetterOrDigit(template.Letter[0])) { SpeakString(template.Letter); } else { SpeakString(Utils.ColorToString(template.Color) + " " + template.Name); } } }