Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.10 KB | None | 0 0
  1. public partial class MainWindow : Window
  2. {
  3. private static PathGeometry geometryEarth;
  4. private static PathGeometry geometryMerc;
  5. private static PathGeometry geometryVener;
  6. private static PathGeometry geometryMoon;
  7.  
  8. private static Path moonpath = new Path();
  9.  
  10. Ellipse Sun = new Ellipse();
  11. Ellipse Merc = new Ellipse();
  12. Ellipse Venera = new Ellipse();
  13. Ellipse Earth = new Ellipse();
  14. Ellipse Moon = new Ellipse();
  15.  
  16. Canvas cmoon = new Canvas();
  17. private static bool flag = false;
  18.  
  19. public MainWindow()
  20. {
  21. InitializeComponent();
  22.  
  23. Sun.Name = "Sun";
  24. Sun.Fill = Brushes.Yellow;
  25. Sun.HorizontalAlignment = HorizontalAlignment.Left;
  26. Sun.VerticalAlignment = VerticalAlignment.Center;
  27. Sun.Width = 50;
  28. Sun.Height = 50;
  29. Sun.Margin = new Thickness(375, 375, 0, 0);
  30. AnimationStart.Children.Add(Sun);
  31.  
  32. Merc.Name = "Mercury";
  33. Merc.Fill = Brushes.Brown;
  34. Merc.HorizontalAlignment = HorizontalAlignment.Left;
  35. Merc.VerticalAlignment = VerticalAlignment.Center;
  36. Merc.Width = 20;
  37. Merc.Height = 20;
  38. Merc.Margin = new Thickness(390, 340, 0, 0);
  39. AnimationStart.Children.Add(Merc);
  40.  
  41. Venera.Name = "Venera";
  42. Venera.Fill = Brushes.Olive;
  43. Venera.HorizontalAlignment = HorizontalAlignment.Left;
  44. Venera.VerticalAlignment = VerticalAlignment.Center;
  45. Venera.Width = 30;
  46. Venera.Height = 30;
  47. Venera.Margin = new Thickness(385, 290, 0, 0);
  48. AnimationStart.Children.Add(Venera);
  49.  
  50. Earth.Name = "Earth";
  51. Earth.Fill = Brushes.Blue;
  52. Earth.HorizontalAlignment = HorizontalAlignment.Left;
  53. Earth.VerticalAlignment = VerticalAlignment.Center;
  54. Earth.Width = 30;
  55. Earth.Height = 30;
  56. Earth.Margin = new Thickness(385, 235, 0, 0);
  57. cmoon.Children.Add(Earth);
  58.  
  59.  
  60. Moon.Name = "Moon";
  61. Moon.Fill = Brushes.Gray;
  62. Moon.HorizontalAlignment = HorizontalAlignment.Left;
  63. Moon.VerticalAlignment = VerticalAlignment.Center;
  64. Moon.Width = 10;
  65. Moon.Height = 10;
  66. Moon.Margin = new Thickness(395, 205, 0, 0);
  67.  
  68. EarthCircle();
  69. MercCircle();
  70. VeneraCircle();
  71.  
  72.  
  73. Moon.Name = "Moon";
  74. Moon.Fill = Brushes.Gray;
  75. Moon.HorizontalAlignment = HorizontalAlignment.Left;
  76. Moon.VerticalAlignment = VerticalAlignment.Center;
  77. Moon.Width = 10;
  78. Moon.Height = 10;
  79. Moon.Margin = new Thickness(395, 205, 0, 0);
  80. cmoon.Children.Add(Moon);
  81.  
  82. MoonCircle();
  83. AnimationStart.Children.Add(cmoon);
  84. }
  85. //--Земля--//
  86. private void EarthCircle()
  87. {
  88. Path path = new Path();
  89. geometryEarth = new PathGeometry();
  90. PathFigure figure = new PathFigure();
  91. figure.StartPoint = new Point(150, 0);
  92. ArcSegment d1 = new ArcSegment();
  93. d1.Point = new Point(300, 150);
  94. d1.Size = new Size(150, 150);
  95. d1.SweepDirection = SweepDirection.Clockwise;
  96. figure.Segments.Add(d1);
  97. ArcSegment d2 = new ArcSegment();
  98. d2.Point = new Point(150, 300);
  99. d2.Size = new Size(150, 150);
  100. d2.SweepDirection = SweepDirection.Clockwise;
  101. figure.Segments.Add(d2);
  102. ArcSegment d3 = new ArcSegment();
  103. d3.Point = new Point(0, 150);
  104. d3.Size = new Size(150, 150);
  105. d3.SweepDirection = SweepDirection.Clockwise;
  106. figure.Segments.Add(d3);
  107. ArcSegment d4 = new ArcSegment();
  108. d4.Point = new Point(150, 0);
  109. d4.Size = new Size(150, 150);
  110. d4.SweepDirection = SweepDirection.Clockwise;
  111. figure.Segments.Add(d4);
  112. geometryEarth.Figures.Add(figure);
  113. path.Data = geometryEarth;
  114. path.Stroke = Brushes.White;
  115. path.StrokeThickness = 1;
  116. path.Margin = new Thickness(250, 250, 0, 0);
  117. AnimationStart.Children.Add(path);
  118. }
  119. private void Earthanimate()
  120. {
  121. DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
  122. anim.PathGeometry = geometryEarth;
  123. anim.Duration = TimeSpan.FromSeconds(7);
  124. anim.RepeatBehavior = RepeatBehavior.Forever;
  125. anim.Source = PathAnimationSource.X;
  126. cmoon.BeginAnimation(Canvas.LeftProperty, anim);
  127. anim = new DoubleAnimationUsingPath();
  128. anim.Duration = TimeSpan.FromSeconds(7);
  129. anim.RepeatBehavior = RepeatBehavior.Forever;
  130. anim.PathGeometry = geometryEarth;
  131. anim.Source = PathAnimationSource.Y;
  132. cmoon.BeginAnimation(Canvas.TopProperty, anim);
  133. }
  134.  
  135. //--Меркурий--//
  136. private void MercCircle()
  137. {
  138. Path path = new Path();
  139. geometryMerc = new PathGeometry();
  140. PathFigure figure = new PathFigure();
  141. figure.StartPoint = new Point(50, 0);
  142. ArcSegment d1 = new ArcSegment();
  143. d1.Point = new Point(100, 50);
  144. d1.Size = new Size(50, 50);
  145. d1.SweepDirection = SweepDirection.Clockwise;
  146. figure.Segments.Add(d1);
  147. ArcSegment d2 = new ArcSegment();
  148. d2.Point = new Point(50, 100);
  149. d2.Size = new Size(50, 50);
  150. d2.SweepDirection = SweepDirection.Clockwise;
  151. figure.Segments.Add(d2);
  152. ArcSegment d3 = new ArcSegment();
  153. d3.Point = new Point(0, 50);
  154. d3.Size = new Size(50, 50);
  155. d3.SweepDirection = SweepDirection.Clockwise;
  156. figure.Segments.Add(d3);
  157. ArcSegment d4 = new ArcSegment();
  158. d4.Point = new Point(50, 0);
  159. d4.Size = new Size(50, 50);
  160. d4.SweepDirection = SweepDirection.Clockwise;
  161. figure.Segments.Add(d4);
  162. geometryMerc.Figures.Add(figure);
  163. path.Data = geometryMerc;
  164. path.Stroke = Brushes.White;
  165. path.StrokeThickness = 1;
  166. path.Margin = new Thickness(350, 350, 0, 0);
  167. AnimationStart.Children.Add(path);
  168. }
  169. private void Mercanimate()
  170. {
  171. DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
  172. anim.PathGeometry = geometryMerc;
  173. anim.Duration = TimeSpan.FromSeconds(3);
  174. anim.RepeatBehavior = RepeatBehavior.Forever;
  175. anim.Source = PathAnimationSource.X;
  176. Merc.BeginAnimation(Canvas.LeftProperty, anim);
  177. anim = new DoubleAnimationUsingPath();
  178. anim.Duration = TimeSpan.FromSeconds(3);
  179. anim.RepeatBehavior = RepeatBehavior.Forever;
  180. anim.PathGeometry = geometryMerc;
  181. anim.Source = PathAnimationSource.Y;
  182. Merc.BeginAnimation(Canvas.TopProperty, anim);
  183. }
  184.  
  185. //--Венера--//
  186. private void VeneraCircle()
  187. {
  188. Path path = new Path();
  189. geometryVener = new PathGeometry();
  190. PathFigure figure = new PathFigure();
  191. figure.StartPoint = new Point(100, 0);
  192. ArcSegment d1 = new ArcSegment();
  193. d1.Point = new Point(0, 100);
  194. d1.Size = new Size(100, 100);
  195. //d1.SweepDirection = SweepDirection.Clockwise;
  196. figure.Segments.Add(d1);
  197. ArcSegment d2 = new ArcSegment();
  198. d2.Point = new Point(100, 200);
  199. d2.Size = new Size(100, 100);
  200. //d2.SweepDirection = SweepDirection.Clockwise;
  201. figure.Segments.Add(d2);
  202. ArcSegment d3 = new ArcSegment();
  203. d3.Point = new Point(100, 0);
  204. d3.Size = new Size(100, 100);
  205. //d3.SweepDirection = SweepDirection.Clockwise;
  206. figure.Segments.Add(d3);
  207. ArcSegment d4 = new ArcSegment();
  208. d4.Point = new Point(100, 0);
  209. d4.Size = new Size(100, 100);
  210. //d4.SweepDirection = SweepDirection.Clockwise;
  211. figure.Segments.Add(d4);
  212. geometryVener.Figures.Add(figure);
  213. path.Data = geometryVener;
  214. path.Stroke = Brushes.White;
  215. path.StrokeThickness = 1;
  216. path.Margin = new Thickness(300, 300, 0, 0);
  217. AnimationStart.Children.Add(path);
  218. }
  219. private void Veneraanimate()
  220. {
  221. DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
  222. anim.PathGeometry = geometryVener;
  223. anim.Duration = TimeSpan.FromSeconds(5);
  224. anim.RepeatBehavior = RepeatBehavior.Forever;
  225. anim.Source = PathAnimationSource.X;
  226. Venera.BeginAnimation(Canvas.LeftProperty, anim);
  227. anim = new DoubleAnimationUsingPath();
  228. anim.Duration = TimeSpan.FromSeconds(5);
  229. anim.RepeatBehavior = RepeatBehavior.Forever;
  230. anim.PathGeometry = geometryVener;
  231. anim.Source = PathAnimationSource.Y;
  232. Venera.BeginAnimation(Canvas.TopProperty, anim);
  233. }
  234.  
  235. //--Луна--//
  236. private void MoonCircle()
  237. {
  238. geometryMoon = new PathGeometry();
  239. PathFigure figure = new PathFigure();
  240. figure.StartPoint = new Point(40, 0);
  241. ArcSegment d1 = new ArcSegment();
  242. d1.Point = new Point(80, 40);
  243. d1.Size = new Size(40, 40);
  244. d1.SweepDirection = SweepDirection.Clockwise;
  245. figure.Segments.Add(d1);
  246. ArcSegment d2 = new ArcSegment();
  247. d2.Point = new Point(40, 80);
  248. d2.Size = new Size(40, 40);
  249. d2.SweepDirection = SweepDirection.Clockwise;
  250. figure.Segments.Add(d2);
  251. ArcSegment d3 = new ArcSegment();
  252. d3.Point = new Point(0, 40);
  253. d3.Size = new Size(40, 40);
  254. d3.SweepDirection = SweepDirection.Clockwise;
  255. figure.Segments.Add(d3);
  256. ArcSegment d4 = new ArcSegment();
  257. d4.Point = new Point(40, 0);
  258. d4.Size = new Size(40, 40);
  259. d4.SweepDirection = SweepDirection.Clockwise;
  260. figure.Segments.Add(d4);
  261. geometryMoon.Figures.Add(figure);
  262. moonpath.Data = geometryMoon;
  263. moonpath.Stroke = Brushes.White;
  264. moonpath.StrokeThickness = 1;
  265. moonpath.Margin = new Thickness(360, 210, 0, 0);
  266. cmoon.Children.Add(moonpath);
  267. }
  268. private void Moonanimate()
  269. {
  270. DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath();
  271. anim.PathGeometry = geometryMoon;
  272. anim.Duration = TimeSpan.FromSeconds(2.5);
  273. anim.RepeatBehavior = RepeatBehavior.Forever;
  274. anim.Source = PathAnimationSource.X;
  275. Moon.BeginAnimation(Canvas.LeftProperty, anim);
  276. anim = new DoubleAnimationUsingPath();
  277. anim.Duration = TimeSpan.FromSeconds(2.5);
  278. anim.RepeatBehavior = RepeatBehavior.Forever;
  279. anim.PathGeometry = geometryMoon;
  280. anim.Source = PathAnimationSource.Y;
  281. Moon.BeginAnimation(Canvas.TopProperty, anim);
  282. }
  283.  
  284. private void AnimationStart_OnMouseUp(object sender, MouseButtonEventArgs e)
  285. {
  286. Earthanimate();
  287. Earth.Margin = new Thickness(238, 238, 0, 0);
  288. Mercanimate();
  289. Merc.Margin = new Thickness(340, 340, 0, 0);
  290. Veneraanimate();
  291. Venera.Margin = new Thickness(285, 285, 0, 0);
  292.  
  293. Moon.Margin = new Thickness(205, 207, 0, 0);
  294. moonpath.Margin = new Thickness(212, 212, 0, 0);
  295. Moonanimate();
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement