Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Screen_Recorder
- {
- public partial class Form1 : Form
- {
- private Button startButton;
- private Label countdownLabel;
- private NotifyIcon trayIcon;
- private Timer countdownTimer;
- private int countdownValue = 3;
- private ScreenRecorder screenRecorder;
- private bool hasMinimized = false;
- private int recordingIndex = 1;
- private TextBox outputFolderTextBox;
- private Button chooseFolderButton;
- private TextBox filenameTextBox;
- private Button chooseFilenameButton;
- private Label statusLabel;
- private float _rotationAngle;
- private Timer _rotationTimer;
- private Image _gearImage;
- private Rectangle _gearArea;
- private int _rotationSpeed = 10; // Rotation speed factor
- public Form1()
- {
- InitializeComponent();
- // Load and set up the gear image and area
- _gearImage = Properties.Resources.icons8_gear_50; // Replace with your actual image loading code
- _gearArea = new Rectangle(100, 20, _gearImage.Width, _gearImage.Height);
- _rotationTimer = new Timer();
- _rotationTimer.Interval = 50; // Consistent refresh rate
- _rotationTimer.Tick += RotationTimer_Tick;
- this.MouseMove += CustomSlider_MouseMove;
- this.MouseLeave += CustomSlider_MouseLeave;
- //customSlider1.StartsFromZero = true;
- //customSlider1.UseIntegerValues = true;
- //label1.Text = customSlider1.Value.ToString();
- /*customSlider1.UseIntegerValues = true;
- customSlider1.ShowTickLabels = true;
- customSlider1.LabelGap = 10;
- label1.Text = customSlider1.Value.ToString();*/
- //Image img = ResizeImage(Properties.Resources.pngimg_com___buttons_PNG152, 50, 50);
- //customButton1.Image = img;
- //customButton1.Size = img.Size;
- //
- // Add event handler if necessary
- //recordButton.Click += RecordButton_Click;
- //Inits();
- ////Init();
- //screenRecorder = new ScreenRecorder();
- }
- public int RotationSpeed
- {
- get => _rotationSpeed;
- set => _rotationSpeed = Math.Max(1, Math.Min(value, 360)); // Constrain the speed for practicality
- }
- private void RotationTimer_Tick(object sender, EventArgs e)
- {
- _rotationAngle += _rotationSpeed;
- if (_rotationAngle >= 360) _rotationAngle -= 360;
- Invalidate(); // Force redraw
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- base.OnPaint(e);
- e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
- // Correctly identify the center of the image
- PointF center = new PointF(_gearArea.X + _gearImage.Width / 2f, _gearArea.Y + _gearImage.Height / 2f);
- // Set up the transformation for rotation
- e.Graphics.TranslateTransform(center.X, center.Y);
- e.Graphics.RotateTransform(_rotationAngle);
- e.Graphics.TranslateTransform(-center.X, -center.Y);
- // Draw the image using the transformation
- e.Graphics.DrawImage(_gearImage, _gearArea.X, _gearArea.Y);
- // Reset the transformation matrix after drawing
- e.Graphics.ResetTransform();
- }
Advertisement
Add Comment
Please, Sign In to add comment