Advertisement
programusy

Untitled

Mar 16th, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. using System.Windows.Media;
  4. using System.Windows.Shapes;
  5.  
  6. namespace SmileyFace
  7. {
  8. public partial class MainWindow : Window
  9. {
  10. public MainWindow()
  11. {
  12. InitializeComponent();
  13.  
  14. Ellipse face = new Ellipse
  15. {
  16. Width = 100,
  17. Height = 100,
  18. Stroke = Brushes.Black,
  19. Fill = Brushes.Yellow,
  20. StrokeThickness = 2
  21. };
  22. Canvas.SetLeft(face, 100);
  23. Canvas.SetTop(face, 100);
  24. canvas.Children.Add(face);
  25.  
  26. Ellipse leftEye = new Ellipse
  27. {
  28. Width = 20,
  29. Height = 20,
  30. Stroke = Brushes.Black,
  31. Fill = Brushes.Black
  32. };
  33. Canvas.SetLeft(leftEye, 120);
  34. Canvas.SetTop(leftEye, 120);
  35. canvas.Children.Add(leftEye);
  36.  
  37. Ellipse rightEye = new Ellipse
  38. {
  39. Width = 20,
  40. Height = 20,
  41. Stroke = Brushes.Black,
  42. Fill = Brushes.Black
  43. };
  44. Canvas.SetLeft(rightEye, 160);
  45. Canvas.SetTop(rightEye, 120);
  46. canvas.Children.Add(rightEye);
  47.  
  48. Path smile = new Path
  49. {
  50. Stroke = Brushes.Black,
  51. StrokeThickness = 2,
  52. Data = new PathGeometry(new PathFigure[]
  53. {
  54. new PathFigure(new Point(120, 160), new PathSegment[]
  55. {
  56. new ArcSegment(new Point(180, 160), new Size(40, 20), 0, false, SweepDirection.Clockwise, true)
  57. }, false)
  58. })
  59. };
  60. canvas.Children.Add(smile);
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement