Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Windows.Media.Animation;
- namespace WpfApplication41
- {
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- static double x, y;
- static Random R = new Random();
- class body
- {
- public body(Canvas canvas)
- {
- Ellipse el = new Ellipse();
- Ellipse leg1, leg2;
- leg1 = new Ellipse();
- leg2 = new Ellipse();
- leg1.Width = 9;
- leg1.Height = 100;
- leg2.Width = 9;
- leg2.Height = 100;
- el.Width = 60;
- el.Height = 140;
- el.Fill = Brushes.Green;
- leg1.Fill = Brushes.Green;
- leg2.Fill = Brushes.Green;
- x = R.Next(0, 600);
- y = R.Next(0, 600);
- RotateTransform a = new RotateTransform(0);
- el.RenderTransform = a;
- Canvas.SetLeft(el, x);
- Canvas.SetTop(el, y);
- canvas.Children.Add(el);
- Canvas.SetLeft(leg1, x - 40);
- Canvas.SetTop(leg1, y - 35);
- canvas.Children.Add(leg1);
- Canvas.SetLeft(leg2, x - 20);
- Canvas.SetTop(leg2, y - 35);
- canvas.Children.Add(leg2);
- Storyboard st = new Storyboard();
- st.Duration = new Duration(TimeSpan.FromSeconds(1.0));
- DoubleAnimation buttonAnimation = new DoubleAnimation()
- {
- From = 173, To = 203,
- Duration = st.Duration
- };
- // buttonAnimation.Duration = TimeSpan.FromSeconds(1);
- buttonAnimation.AutoReverse = true;
- buttonAnimation.RepeatBehavior = RepeatBehavior.Forever;
- PowerEase b = new PowerEase();
- b.Power = 2;
- b.EasingMode = EasingMode.EaseInOut;
- buttonAnimation.EasingFunction = b;
- el.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, buttonAnimation);
- // el.BeginAnimation(Canvas.TopProperty, buttonAnimation);
- }
- }
- class head
- {
- public head(Canvas canvas)
- {
- Ellipse h = new Ellipse();
- Ellipse eye1, eye2;
- eye1 = new Ellipse();
- eye2 = new Ellipse();
- eye1.Width = 8;
- eye1.Height = 8;
- eye2.Width = 8;
- eye2.Height = 8;
- h.Width = 50;
- h.Height = 50;
- h.Fill = Brushes.Green;
- eye1.Fill = Brushes.Black;
- eye2.Fill = Brushes.Black;
- RotateTransform a = new RotateTransform(0);
- h.RenderTransform = a;
- RotateTransform e1 = new RotateTransform(0);
- eye1.RenderTransform = e1;
- RotateTransform e2 = new RotateTransform(0);
- eye2.RenderTransform = e2;
- Canvas.SetLeft(h, x - 3);
- Canvas.SetTop(h, y - 125);
- canvas.Children.Add(h);
- Canvas.SetLeft(eye1, x - 18);
- Canvas.SetTop(eye1, y - 155);
- canvas.Children.Add(eye1);
- /* Canvas.SetLeft(h, x - 3);
- Canvas.SetTop(h, y - 125);
- canvas.Children.Add(h);*/
- Storyboard st = new Storyboard();
- st.Duration = new Duration(TimeSpan.FromSeconds(1.0));
- Storyboard ey1 = new Storyboard();
- ey1.Duration = new Duration(TimeSpan.FromSeconds(0.2));
- DoubleAnimation buttonAnimation = new DoubleAnimation()
- {
- From = 164,
- To = 266,
- Duration = st.Duration
- };
- DoubleAnimation eye = new DoubleAnimation()
- {
- From = 296,
- To = 276,
- Duration = ey1.Duration
- };
- eye.AutoReverse = true;
- eye.RepeatBehavior = RepeatBehavior.Forever;
- PowerEase k = new PowerEase();
- k.Power = 2;
- k.EasingMode = EasingMode.EaseInOut;
- eye.EasingFunction = k;
- eye1.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, eye);
- //eye1.RenderTransform.BeginAnimation(RotateTransform.CenterYProperty, eye);
- // eye1.RenderTransform.BeginAnimation(RotateTransform.CenterXProperty, eye);
- // buttonAnimation.Duration = TimeSpan.FromSeconds(1);
- buttonAnimation.AutoReverse = true;
- buttonAnimation.RepeatBehavior = RepeatBehavior.Forever;
- PowerEase b = new PowerEase();
- b.Power = 2;
- b.EasingMode = EasingMode.EaseInOut;
- buttonAnimation.EasingFunction = b;
- h.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, buttonAnimation);
- //eye1.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, buttonAnimation);
- }
- }
- class arms
- {
- public arms(Canvas canvas)
- {
- Ellipse el = new Ellipse();
- el.Width = 85;
- el.Height = 9;
- Ellipse el1 = new Ellipse();
- el1.Width = 85;
- el1.Height = 9;
- el.Fill = Brushes.Green;
- el1.Fill = Brushes.Green;
- RotateTransform a = new RotateTransform(170);
- el.RenderTransform = a;
- RotateTransform g = new RotateTransform(70);
- el1.RenderTransform = g;
- Canvas.SetLeft(el, x - 24);
- Canvas.SetTop(el, y - 140);
- canvas.Children.Add(el);
- Canvas.SetLeft(el1, x - 96);
- Canvas.SetTop(el1, y - 90);
- canvas.Children.Add(el1);
- Storyboard st = new Storyboard();
- st.Duration = new Duration(TimeSpan.FromSeconds(1.0));
- DoubleAnimation buttonAnimation = new DoubleAnimation()
- {
- From = 358,
- To = 353,
- Duration = st.Duration
- };
- /*DoubleAnimation buttonAnimation2 = new DoubleAnimation()
- {
- From = 308,
- To = 330,
- Duration = st.Duration
- };*/
- /* DoubleAnimation buttonAnimation2 = new DoubleAnimation()
- {
- From = 173,
- To = 203,
- Duration = st.Duration
- };*/
- // buttonAnimation.Duration = TimeSpan.FromSeconds(1);
- buttonAnimation.AutoReverse = true;
- buttonAnimation.RepeatBehavior = RepeatBehavior.Forever;
- PowerEase b = new PowerEase();
- b.Power = 2;
- b.EasingMode = EasingMode.EaseInOut;
- buttonAnimation.EasingFunction = b;
- el.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, buttonAnimation);
- el.RenderTransform.BeginAnimation(RotateTransform.CenterXProperty, buttonAnimation);
- DoubleAnimation buttonAnimation2 = new DoubleAnimation()
- {
- From = 358,
- To = 343,
- Duration = st.Duration
- };
- buttonAnimation2.AutoReverse = true;
- buttonAnimation2.RepeatBehavior = RepeatBehavior.Forever;
- PowerEase k = new PowerEase();
- k.Power = 2;
- k.EasingMode = EasingMode.EaseInOut;
- buttonAnimation2.EasingFunction = k;
- el1.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, buttonAnimation2);
- //el.RenderTransform.BeginAnimation(RotateTransform.CenterYProperty, buttonAnimation);
- }
- }
- private void button_Click(object sender, RoutedEventArgs e)
- {
- body b = new body(canvas);
- arms a = new arms(canvas);
- head h = new head(canvas);
- }
- }
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement