Advertisement
Guest User

2

a guest
Dec 11th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp8
  12. {
  13. public partial class Form1 : Form
  14. {
  15. Button button1;
  16. Bitmap image1;
  17. PictureBox pictureBox1;
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. // Указываем размеры и заголовок окна
  22. this.Text = "Rotate img";
  23. this.Size = new Size(700, 700);
  24. // Добавляем на форму кнопку
  25. button1 = new Button();
  26. button1.Text = "Rotate img";
  27. button1.Location = new Point(0, 0);
  28. button1.Size = new Size(70, 40);
  29. button1.Click += new System.EventHandler(button1_Click);
  30. this.Controls.Add(button1);
  31. // Добавляем элемент PictureBox на форму
  32. pictureBox1 = new PictureBox();
  33. pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
  34. pictureBox1.BorderStyle = BorderStyle.Fixed3D;
  35. pictureBox1.ClientSize = new Size(700, 700);
  36. // Добавляем изображение в элемент PictureBox
  37. image1 = new Bitmap("C://Users//arian//Desktop//4.jpg");
  38. pictureBox1.Image = (Image)image1;
  39. // Добавляем на форму элемент PictureBox
  40. this.Controls.Add(pictureBox1);
  41. }
  42.  
  43. // Обработчик события, срабатывающий при нажатии кнопки
  44. void button1_Click(object sender, EventArgs e)
  45. {
  46. image1.RotateFlip(RotateFlipType.RotateNoneFlipX);
  47. // Повторно вставляем изображение в элемент PictureBox
  48. pictureBox1.Image = (Image)image1;
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement