Chocolade19721309

Untitled

May 13th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 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.Drawing.Drawing2D;
  7. using System.Drawing.Imaging;
  8. using System.Linq;
  9. using System.Runtime.CompilerServices;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13.  
  14. namespace Screen_Recorder
  15. {
  16. public partial class Form1 : Form
  17. {
  18. private Button startButton;
  19. private Label countdownLabel;
  20. private NotifyIcon trayIcon;
  21. private Timer countdownTimer;
  22. private int countdownValue = 3;
  23. private ScreenRecorder screenRecorder;
  24. private bool hasMinimized = false;
  25. private int recordingIndex = 1;
  26. private TextBox outputFolderTextBox;
  27. private Button chooseFolderButton;
  28. private TextBox filenameTextBox;
  29. private Button chooseFilenameButton;
  30. private Label statusLabel;
  31.  
  32. private float _rotationAngle;
  33. private Timer _rotationTimer;
  34. private Image _gearImage;
  35. private Rectangle _gearArea;
  36. private int _rotationSpeed = 10; // Rotation speed factor
  37.  
  38. public Form1()
  39. {
  40. InitializeComponent();
  41.  
  42. // Load and set up the gear image and area
  43. _gearImage = Properties.Resources.icons8_gear_50; // Replace with your actual image loading code
  44. _gearArea = new Rectangle(100, 20, _gearImage.Width, _gearImage.Height);
  45.  
  46. _rotationTimer = new Timer();
  47. _rotationTimer.Interval = 50; // Consistent refresh rate
  48. _rotationTimer.Tick += RotationTimer_Tick;
  49.  
  50. this.MouseMove += CustomSlider_MouseMove;
  51. this.MouseLeave += CustomSlider_MouseLeave;
  52.  
  53.  
  54. //customSlider1.StartsFromZero = true;
  55. //customSlider1.UseIntegerValues = true;
  56. //label1.Text = customSlider1.Value.ToString();
  57. /*customSlider1.UseIntegerValues = true;
  58. customSlider1.ShowTickLabels = true;
  59. customSlider1.LabelGap = 10;
  60. label1.Text = customSlider1.Value.ToString();*/
  61.  
  62. //Image img = ResizeImage(Properties.Resources.pngimg_com___buttons_PNG152, 50, 50);
  63. //customButton1.Image = img;
  64. //customButton1.Size = img.Size;
  65. //
  66. // Add event handler if necessary
  67. //recordButton.Click += RecordButton_Click;
  68.  
  69. //Inits();
  70. ////Init();
  71. //screenRecorder = new ScreenRecorder();
  72.  
  73. }
  74.  
  75. public int RotationSpeed
  76. {
  77. get => _rotationSpeed;
  78. set => _rotationSpeed = Math.Max(1, Math.Min(value, 360)); // Constrain the speed for practicality
  79. }
  80.  
  81. private void RotationTimer_Tick(object sender, EventArgs e)
  82. {
  83. _rotationAngle += _rotationSpeed;
  84. if (_rotationAngle >= 360) _rotationAngle -= 360;
  85. Invalidate(); // Force redraw
  86. }
  87.  
  88. protected override void OnPaint(PaintEventArgs e)
  89. {
  90. base.OnPaint(e);
  91. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  92.  
  93. // Correctly identify the center of the image
  94. PointF center = new PointF(_gearArea.X + _gearImage.Width / 2f, _gearArea.Y + _gearImage.Height / 2f);
  95.  
  96. // Set up the transformation for rotation
  97. e.Graphics.TranslateTransform(center.X, center.Y);
  98. e.Graphics.RotateTransform(_rotationAngle);
  99. e.Graphics.TranslateTransform(-center.X, -center.Y);
  100.  
  101. // Draw the image using the transformation
  102. e.Graphics.DrawImage(_gearImage, _gearArea.X, _gearArea.Y);
  103.  
  104. // Reset the transformation matrix after drawing
  105. e.Graphics.ResetTransform();
  106. }
Advertisement
Add Comment
Please, Sign In to add comment