예제 #1
0
 private void animationFadeText(TextBlock text, double from, double to, int duration)
 {
     DoubleAnimation animationFade = new DoubleAnimation();
     animationFade.From = from;
     animationFade.To = to;
     animationFade.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
     text.BeginAnimation(Button.OpacityProperty, animationFade);
 }
예제 #2
0
        private void CreateMessagePanels()
        {
            Messages messages = new Messages(this.session);

            MessageObjects allobjects = messages.GetAllMessage();
            List<Message> msgs  = allobjects.Messages;
            int index = rand.Next(msgs.Count);
            Message msg = msgs[index];

            TextBlock tb = new TextBlock();
            tb.Text = msg.Body.Plain;
            tb.FontSize = 14;

            this.MainCanvas.Children.Add(tb);

            double centerX = this.MainCanvas.ActualWidth / 2.0;
            double centerY = this.MainCanvas.ActualHeight / 2.0;

            double offsetX = 16 - rand.Next(32);
            double offsetY = 16 - rand.Next(32);

            //tb.SetValue(Canvas.LeftProperty, centerX + offsetX);
            //tb.SetValue(Canvas.TopProperty, centerY + offsetY);
            tb.SetValue(Canvas.LeftProperty, centerX );
            tb.SetValue(Canvas.TopProperty, centerY );

            double duration = 6.0 + 10.0 * rand.NextDouble();
            double delay = 16.0 * rand.NextDouble();
            //TranslateTransform offsetTransform = new TranslateTransform();
            //DoubleAnimation offsetXAnimation = new DoubleAnimation(0.0, -256.0, new Duration(TimeSpan.FromSeconds(duration)));
            //offsetXAnimation.RepeatBehavior = RepeatBehavior.Forever;
            //offsetXAnimation.BeginTime = TimeSpan.FromSeconds(delay);
            //offsetTransform.BeginAnimation(TranslateTransform.XProperty, offsetXAnimation);
            //offsetTransform.BeginAnimation(TranslateTransform.YProperty, offsetXAnimation);
            //tb.RenderTransform = offsetTransform;
            DoubleAnimation opacityAnimation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(4.0)));
            opacityAnimation.RepeatBehavior = RepeatBehavior.Forever;
            tb.BeginAnimation(TextBlock.OpacityProperty, opacityAnimation);
        }