Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainWindow : Window
- {
- private static PathGeometry geometryEarth;
- private static PathGeometry geometryMerc;
- private static PathGeometry geometryVener;
- private static PathGeometry geometryMoon;
- private static Path moonpath = new Path();
- Ellipse Sun = new Ellipse();
- Ellipse Merc = new Ellipse();
- Ellipse Venera = new Ellipse();
- Ellipse Earth = new Ellipse();
- Ellipse Moon = new Ellipse();
- Canvas cmoon = new Canvas();
- private static bool flag = false;
- public MainWindow()
- {
- InitializeComponent();
- Sun.Name = "Sun";
- Sun.Fill = Brushes.Yellow;
- Sun.HorizontalAlignment = HorizontalAlignment.Left;
- Sun.VerticalAlignment = VerticalAlignment.Center;
- Sun.Width = 50;
- Sun.Height = 50;
- Sun.Margin = new Thickness(375, 375, 0, 0);
- AnimationStart.Children.Add(Sun);
- Merc.Name = "Mercury";
- Merc.Fill = Brushes.Brown;
- Merc.HorizontalAlignment = HorizontalAlignment.Left;
- Merc.VerticalAlignment = VerticalAlignment.Center;
- Merc.Width = 20;
- Merc.Height = 20;
- Merc.Margin = new Thickness(390, 340, 0, 0);
- AnimationStart.Children.Add(Merc);
- Venera.Name = "Venera";
- Venera.Fill = Brushes.Olive;
- Venera.HorizontalAlignment = HorizontalAlignment.Left;
- Venera.VerticalAlignment = VerticalAlignment.Center;
- Venera.Width = 30;
- Venera.Height = 30;
- Venera.Margin = new Thickness(385, 290, 0, 0);
- AnimationStart.Children.Add(Venera);
- Earth.Name = "Earth";
- Earth.Fill = Brushes.Blue;
- Earth.HorizontalAlignment = HorizontalAlignment.Left;
- Earth.VerticalAlignment = VerticalAlignment.Center;
- Earth.Width = 30;
- Earth.Height = 30;
- Earth.Margin = new Thickness(385, 235, 0, 0);
- cmoon.Children.Add(Earth);
- Moon.Name = "Moon";
- Moon.Fill = Brushes.Gray;
- Moon.HorizontalAlignment = HorizontalAlignment.Left;
- Moon.VerticalAlignment = VerticalAlignment.Center;
- Moon.Width = 10;
- Moon.Height = 10;
- Moon.Margin = new Thickness(395, 205, 0, 0);
- EarthCircle();
- MercCircle();
- VeneraCircle();
- Moon.Name = "Moon";
- Moon.Fill = Brushes.Gray;
- Moon.HorizontalAlignment = HorizontalAlignment.Left;
- Moon.VerticalAlignment = VerticalAlignment.Center;
- Moon.Width = 10;
- Moon.Height = 10;
- Moon.Margin = new Thickness(395, 205, 0, 0);
- cmoon.Children.Add(Moon);
- MoonCircle();
- AnimationStart.Children.Add(cmoon);
- }
- //--Земля--//
- private void EarthCircle()
- {
- Path path = new Path();
- geometryEarth = new PathGeometry();
- PathFigure figure = new PathFigure();
- figure.StartPoint = new Point(150, 0);
- ArcSegment d1 = new ArcSegment();
- d1.Point = new Point(300, 150);
- d1.Size = new Size(150, 150);
- d1.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d1);
- ArcSegment d2 = new ArcSegment();
- d2.Point = new Point(150, 300);
- d2.Size = new Size(150, 150);
- d2.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d2);
- ArcSegment d3 = new ArcSegment();
- d3.Point = new Point(0, 150);
- d3.Size = new Size(150, 150);
- d3.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d3);
- ArcSegment d4 = new ArcSegment();
- d4.Point = new Point(150, 0);
- d4.Size = new Size(150, 150);
- d4.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d4);
- geometryEarth.Figures.Add(figure);
- path.Data = geometryEarth;
- path.Stroke = Brushes.White;
- path.StrokeThickness = 1;
- path.Margin = new Thickness(250, 250, 0, 0);
- AnimationStart.Children.Add(path);
- }
- private void Earthanimate()
- {
- DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
- anim.PathGeometry = geometryEarth;
- anim.Duration = TimeSpan.FromSeconds(7);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.Source = PathAnimationSource.X;
- cmoon.BeginAnimation(Canvas.LeftProperty, anim);
- anim = new DoubleAnimationUsingPath();
- anim.Duration = TimeSpan.FromSeconds(7);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.PathGeometry = geometryEarth;
- anim.Source = PathAnimationSource.Y;
- cmoon.BeginAnimation(Canvas.TopProperty, anim);
- }
- //--Меркурий--//
- private void MercCircle()
- {
- Path path = new Path();
- geometryMerc = new PathGeometry();
- PathFigure figure = new PathFigure();
- figure.StartPoint = new Point(50, 0);
- ArcSegment d1 = new ArcSegment();
- d1.Point = new Point(100, 50);
- d1.Size = new Size(50, 50);
- d1.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d1);
- ArcSegment d2 = new ArcSegment();
- d2.Point = new Point(50, 100);
- d2.Size = new Size(50, 50);
- d2.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d2);
- ArcSegment d3 = new ArcSegment();
- d3.Point = new Point(0, 50);
- d3.Size = new Size(50, 50);
- d3.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d3);
- ArcSegment d4 = new ArcSegment();
- d4.Point = new Point(50, 0);
- d4.Size = new Size(50, 50);
- d4.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d4);
- geometryMerc.Figures.Add(figure);
- path.Data = geometryMerc;
- path.Stroke = Brushes.White;
- path.StrokeThickness = 1;
- path.Margin = new Thickness(350, 350, 0, 0);
- AnimationStart.Children.Add(path);
- }
- private void Mercanimate()
- {
- DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
- anim.PathGeometry = geometryMerc;
- anim.Duration = TimeSpan.FromSeconds(3);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.Source = PathAnimationSource.X;
- Merc.BeginAnimation(Canvas.LeftProperty, anim);
- anim = new DoubleAnimationUsingPath();
- anim.Duration = TimeSpan.FromSeconds(3);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.PathGeometry = geometryMerc;
- anim.Source = PathAnimationSource.Y;
- Merc.BeginAnimation(Canvas.TopProperty, anim);
- }
- //--Венера--//
- private void VeneraCircle()
- {
- Path path = new Path();
- geometryVener = new PathGeometry();
- PathFigure figure = new PathFigure();
- figure.StartPoint = new Point(100, 0);
- ArcSegment d1 = new ArcSegment();
- d1.Point = new Point(0, 100);
- d1.Size = new Size(100, 100);
- //d1.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d1);
- ArcSegment d2 = new ArcSegment();
- d2.Point = new Point(100, 200);
- d2.Size = new Size(100, 100);
- //d2.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d2);
- ArcSegment d3 = new ArcSegment();
- d3.Point = new Point(100, 0);
- d3.Size = new Size(100, 100);
- //d3.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d3);
- ArcSegment d4 = new ArcSegment();
- d4.Point = new Point(100, 0);
- d4.Size = new Size(100, 100);
- //d4.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d4);
- geometryVener.Figures.Add(figure);
- path.Data = geometryVener;
- path.Stroke = Brushes.White;
- path.StrokeThickness = 1;
- path.Margin = new Thickness(300, 300, 0, 0);
- AnimationStart.Children.Add(path);
- }
- private void Veneraanimate()
- {
- DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
- anim.PathGeometry = geometryVener;
- anim.Duration = TimeSpan.FromSeconds(5);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.Source = PathAnimationSource.X;
- Venera.BeginAnimation(Canvas.LeftProperty, anim);
- anim = new DoubleAnimationUsingPath();
- anim.Duration = TimeSpan.FromSeconds(5);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.PathGeometry = geometryVener;
- anim.Source = PathAnimationSource.Y;
- Venera.BeginAnimation(Canvas.TopProperty, anim);
- }
- //--Луна--//
- private void MoonCircle()
- {
- geometryMoon = new PathGeometry();
- PathFigure figure = new PathFigure();
- figure.StartPoint = new Point(40, 0);
- ArcSegment d1 = new ArcSegment();
- d1.Point = new Point(80, 40);
- d1.Size = new Size(40, 40);
- d1.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d1);
- ArcSegment d2 = new ArcSegment();
- d2.Point = new Point(40, 80);
- d2.Size = new Size(40, 40);
- d2.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d2);
- ArcSegment d3 = new ArcSegment();
- d3.Point = new Point(0, 40);
- d3.Size = new Size(40, 40);
- d3.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d3);
- ArcSegment d4 = new ArcSegment();
- d4.Point = new Point(40, 0);
- d4.Size = new Size(40, 40);
- d4.SweepDirection = SweepDirection.Clockwise;
- figure.Segments.Add(d4);
- geometryMoon.Figures.Add(figure);
- moonpath.Data = geometryMoon;
- moonpath.Stroke = Brushes.White;
- moonpath.StrokeThickness = 1;
- moonpath.Margin = new Thickness(360, 210, 0, 0);
- cmoon.Children.Add(moonpath);
- }
- private void Moonanimate()
- {
- DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
- anim.PathGeometry = geometryMoon;
- anim.Duration = TimeSpan.FromSeconds(2.5);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.Source = PathAnimationSource.X;
- Moon.BeginAnimation(Canvas.LeftProperty, anim);
- anim = new DoubleAnimationUsingPath();
- anim.Duration = TimeSpan.FromSeconds(2.5);
- anim.RepeatBehavior = RepeatBehavior.Forever;
- anim.PathGeometry = geometryMoon;
- anim.Source = PathAnimationSource.Y;
- Moon.BeginAnimation(Canvas.TopProperty, anim);
- }
- private void AnimationStart_OnMouseUp(object sender, MouseButtonEventArgs e)
- {
- Earthanimate();
- Earth.Margin = new Thickness(238, 238, 0, 0);
- Mercanimate();
- Merc.Margin = new Thickness(340, 340, 0, 0);
- Veneraanimate();
- Venera.Margin = new Thickness(285, 285, 0, 0);
- Moon.Margin = new Thickness(205, 207, 0, 0);
- moonpath.Margin = new Thickness(212, 212, 0, 0);
- Moonanimate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement