diff --git a/FourCircleButton.cs b/FourCircleButton.cs
index 63fb98a..e30aacb 100644
--- a/FourCircleButton.cs
+++ b/FourCircleButton.cs
@@ -335,7 +335,6 @@ protected override void OnPaint(PaintEventArgs pevent)
{
cornerRadius = 1;
}
- MinimumSize = new Size(Height - 1, Height - 1);
using (SolidBrush brush = new SolidBrush(Parent.BackColor))
{
pevent.Graphics.FillRectangle(brush, ClientRectangle);
diff --git a/FourPictureBox.cs b/FourPictureBox.cs
index e6482b3..49d9e76 100644
--- a/FourPictureBox.cs
+++ b/FourPictureBox.cs
@@ -10,10 +10,10 @@ public class FourPictureBox : Control
private int _cornerRadius = 5;
private float _rotationAngle = 0;
private Matrix _translationMatrix = new Matrix();
- private bool _displayImage = true;
public FourPictureBox()
{
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true);
+
}
[Category("FourUI")]
@@ -67,7 +67,7 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
- if (_image != null && _displayImage)
+ if (_image != null)
{
int diameter = _cornerRadius * 2;
int offset = 1;
@@ -90,14 +90,14 @@ protected override void OnPaint(PaintEventArgs e)
var scaleX = (float)Width / _image.Width;
var scaleY = (float)Height / _image.Height;
- var matrix = new Matrix();
+ Matrix matrix = new Matrix();
matrix.Multiply(_translationMatrix);
matrix.RotateAt(_rotationAngle, new PointF(Width / 2, Height / 2));
-
matrix.Scale(scaleX, scaleY);
+
brush.Transform = matrix;
brush.WrapMode = WrapMode.Clamp;
@@ -106,20 +106,4 @@ protected override void OnPaint(PaintEventArgs e)
}
}
}
-
- protected override void OnResize(EventArgs e)
- {
- base.OnResize(e);
-
- _displayImage = false;
- Invalidate();
- }
-
- protected override void OnSizeChanged(EventArgs e)
- {
- base.OnSizeChanged(e);
-
- _displayImage = true;
- Invalidate();
- }
}
diff --git a/FourSpinner.cs b/FourSpinner.cs
new file mode 100644
index 0000000..968e32f
--- /dev/null
+++ b/FourSpinner.cs
@@ -0,0 +1,79 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+public class FourSpinner : Control
+{
+ private float rotationAngle = 0;
+ private DateTime lastRenderTime = DateTime.Now;
+ private int sweepAngle = 270;
+ private int borderSize = 1;
+
+ public FourSpinner()
+ {
+ DoubleBuffered = true;
+ ResizeRedraw = true;
+ Application.Idle += Application_Idle;
+
+ ForeColor = Color.FromArgb(33, 133, 255);
+ }
+
+ public int SweepAngle
+ {
+ get => sweepAngle;
+
+ set
+ {
+ if (value > 0 && value <= 360)
+ sweepAngle = value;
+ else
+ throw new ArgumentException("SweepAngle must be between 1 and 360 degrees.");
+ }
+ }
+
+ public int BorderSize
+ {
+ get => borderSize;
+
+ set
+ {
+ if (value > 0)
+ borderSize = value;
+ else
+ throw new ArgumentException("BorderSize must be greater than 0.");
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+
+ int centerX = Width / 2;
+ int centerY = Height / 2;
+
+ e.Graphics.TranslateTransform(centerX-1, centerY-1);
+ e.Graphics.RotateTransform(rotationAngle);
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+
+ int spinnerSize = Math.Min(centerX, centerY);
+ int spinnerThickness = (spinnerSize / 10) * borderSize;
+
+ using (var pen = new Pen(ForeColor, spinnerThickness))
+ {
+ float startAngle = 0;
+ e.Graphics.DrawArc(pen, -spinnerSize / 2, -spinnerSize / 2, spinnerSize, spinnerSize, startAngle, sweepAngle);
+ }
+ }
+
+ private const float RotationSpeed = 180.0f;
+
+ private void Application_Idle(object sender, EventArgs e)
+ {
+ DateTime currentTime = DateTime.Now;
+ double elapsedMilliseconds = (currentTime - lastRenderTime).TotalMilliseconds;
+ float angleChange = (float)(RotationSpeed * elapsedMilliseconds / 900.0);
+ rotationAngle = (rotationAngle + angleChange) % 360;
+ lastRenderTime = currentTime;
+ Invalidate();
+ }
+}
diff --git a/FourStarRating.cs b/FourStarRating.cs
index a9c6618..a9d4718 100644
--- a/FourStarRating.cs
+++ b/FourStarRating.cs
@@ -6,7 +6,10 @@
public class FourStarRating : Control
{
- private float rating = 0.0f; private Color starColor = Color.FromArgb(255, 174, 35);
+ private float rating = 0.0f;
+ private Color starColor = Color.FromArgb(255, 174, 35);
+ private float starBorderSize = 2.0f;
+ private int starCount = 5;
public event EventHandler RatingChanged;
@@ -15,18 +18,52 @@ public float Rating
get { return rating; }
set
{
- if (value < 0.0f)
- rating = 0.0f;
- else if (value > 10.0f)
- rating = 10.0f;
+ if (value <= (starCount * 2))
+ {
+ if (value < 0.0f)
+ rating = 0.0f;
+ else if (value > 10.0f)
+ rating = 10.0f;
+ else
+ rating = value;
+ }
else
- rating = value;
+ throw new ArgumentException("Rating must be equal or less than StarCount*2.");
RatingChanged?.Invoke(this, EventArgs.Empty);
Invalidate();
}
}
+ public int StarCount
+ {
+ get { return starCount; }
+ set
+ {
+ if (value > 2) //who is ever finna do a 2 star rating??
+ starCount = value;
+
+ if (starCount * 2 < rating)
+ {
+ rating = starCount * 2;
+ Rating = starCount * 2;
+ RatingChanged?.Invoke(this, EventArgs.Empty);
+ Refresh();
+ }
+ Invalidate();
+ }
+ }
+
+ public float StarBorderSize
+ {
+ get { return starBorderSize; }
+ set
+ {
+ starBorderSize = Math.Max(1, value);
+ Invalidate();
+ }
+ }
+
public Color StarColor
{
get { return starColor; }
@@ -48,14 +85,10 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
-
-
-
-
Graphics g = e.Graphics;
- g.InterpolationMode = InterpolationMode.NearestNeighbor; g.SmoothingMode = SmoothingMode.AntiAlias;
+ g.InterpolationMode = InterpolationMode.NearestNeighbor;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
- int starCount = 5;
int starWidth = Height - 2;
int spacing = 5;
@@ -76,7 +109,11 @@ protected override void OnPaint(PaintEventArgs e)
g.FillRectangle(new SolidBrush(BackColor), starRect);
}
- g.DrawPath(new Pen(starColor), starPath);
+ // Create a pen with the specified border size
+ using (Pen starBorderPen = new Pen(starColor, StarBorderSize))
+ {
+ g.DrawPath(starBorderPen, starPath);
+ }
}
}
@@ -84,6 +121,7 @@ protected override void OnPaint(PaintEventArgs e)
+
public static GraphicsPath GetRounded5PointStarPath(float centerX, float centerY, float outerRadius, float innerRadius, int numPoints)
{
if (numPoints % 2 == 0 || numPoints < 5)
diff --git a/FourSwitch.cs b/FourSwitch.cs
index 09feaeb..77c3912 100644
--- a/FourSwitch.cs
+++ b/FourSwitch.cs
@@ -20,8 +20,6 @@ public class FourSwitch : Control
private int endX;
private int thumbWidth;
- int refreshRate = -6;
-
private designchoice dchoice = FourSwitch.designchoice.Inward;
public enum designchoice
@@ -130,37 +128,11 @@ public FourSwitch()
- private async void InitializeTimer()
+ private void InitializeTimer()
{
- //BackColor = Parent.BackColor;
- refreshRate = -6; //i cant believe that someone ever got -6 fps
- if (!DesignMode)
- {
- try
- {
- ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
- foreach (ManagementObject mo in searcher.Get())
- {
- refreshRate = Convert.ToInt32(mo["CurrentRefreshRate"]) + 1;
- //MessageBox.Show(refreshRate + " Hz");
- }
- }
- catch
- {
- refreshRate = 60;
- }
- }
- else
- {
- refreshRate = 60;
- }
- while (refreshRate == -6)
- {
- await Task.Delay(100);
- }
smoothMoveTimer = new Timer();
- smoothMoveTimer.Interval = 1000 / refreshRate;
+ smoothMoveTimer.Interval = 4;
smoothMoveTimer.Tick += SmoothMoveTimer_Tick;
}
@@ -219,10 +191,11 @@ protected override void OnPaint(PaintEventArgs e)
}
else if (dchoice == designchoice.Outward)
{
- endX = Width - (Height - 10);
- rectWidth = rectWidth - 1;
+ endX = Width - (Height - 6);
+ rectWidth = rectWidth - 5;
+ rectHeight = rectHeight - 2;
cornerRadius = (rectHeight / 6);
- using (GraphicsPath path = RoundedRectangle(rectX + rectWidth / 10, (rectY + rectHeight / 3) + 1, rectWidth - rectWidth / 10, rectHeight / 3, cornerRadius))
+ using (GraphicsPath path = RoundedRectangle(-1 + rectX + rectWidth / 10, (rectY + rectHeight / 3), rectWidth - rectWidth / 10, 3 + rectHeight / 3, cornerRadius))
{
using (Brush bgBrush = new SolidBrush(trackColor))
@@ -293,14 +266,9 @@ private GraphicsPath RoundedRectangle(int x, int y, int width, int height, int r
private void AnimateThumb()
{
Timer animationTimer = new Timer();
- if (refreshRate > 1)
- {
- animationTimer.Interval = 1000 / refreshRate;
- }
- else
- {
- animationTimer.Interval = 60;
- }
+
+ animationTimer.Interval = 4;
+
diff --git a/FourUI.csproj b/FourUI.csproj
index acf8d69..eb45022 100644
--- a/FourUI.csproj
+++ b/FourUI.csproj
@@ -55,6 +55,12 @@
Component
+
+ Component
+
+
+ Component
+
Component
diff --git a/FourVProgressBar.cs b/FourVProgressBar.cs
new file mode 100644
index 0000000..b40a77d
--- /dev/null
+++ b/FourVProgressBar.cs
@@ -0,0 +1,183 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Threading;
+using System.Windows.Forms;
+
+public class FourVProgressBar : Control
+{
+ private int value = 0;
+ private int minimum = 0;
+ private int maximum = 100;
+
+ Color progressColor = Color.FromArgb(33, 133, 255);
+ Color _bgColor = Color.FromArgb(21, 21, 21);
+
+ [Browsable(true)]
+ [Category("FourUI")]
+ [Description("The progress color.")]
+ public Color ProgressColor
+ {
+ get { return progressColor; }
+ set { progressColor = value; Invalidate(); }
+ }
+
+ [Browsable(true)]
+ [Category("FourUI")]
+ [Description("The background color.")]
+ public Color BackgroundColor
+ {
+ get { return _bgColor; }
+ set { _bgColor = value; Invalidate(); }
+ }
+
+
+ public event EventHandler ValueChanged;
+
+ public FourVProgressBar()
+ {
+ this.Size = new Size(200, 30);
+ this.DoubleBuffered = true;
+ }
+
+ public int Value
+ {
+ get { return value; }
+ set
+ {
+ if (value < minimum)
+ this.value = minimum;
+ else if (value > maximum)
+ this.value = maximum;
+ else
+ {
+ this.value = value;
+ OnValueChanged(EventArgs.Empty);
+ this.Invalidate();
+ }
+ }
+ }
+
+ public int Minimum
+ {
+ get { return minimum; }
+ set
+ {
+ minimum = value;
+ if (value > maximum)
+ maximum = value;
+ if (this.value < minimum)
+ this.value = minimum;
+ this.Invalidate();
+ }
+ }
+
+ public int Maximum
+ {
+ get { return maximum; }
+ set
+ {
+ maximum = value;
+ if (value < minimum)
+ minimum = value;
+ if (this.value > maximum)
+ this.value = maximum;
+ this.Invalidate();
+ }
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+
+ e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
+ using (GraphicsPath trackPathBehindThumb = new GraphicsPath())
+ using (GraphicsPath trackPathAfterThumb = new GraphicsPath())
+ {
+ int trackHeight = 0;
+ if (Height > 5)
+ {
+ trackHeight = Height - 4;
+ }
+ else
+ {
+ trackHeight = Height;
+ }
+ float thumbPosition = (float)((value - minimum) / (double)(maximum - minimum)) * (Width - 20);
+ RectangleF trackRectBehindThumb = new RectangleF(2, (Height - trackHeight) / 2, thumbPosition, trackHeight);
+ RectangleF trackRectAfterThumb = new RectangleF(thumbPosition, (Height - trackHeight) / 2, Width - thumbPosition, trackHeight);
+ float radius = trackHeight / 2;
+
+ Color trackColorBehindThumb = progressColor;
+
+ int offset = 2;
+
+ if (Value == 1)
+ {
+ offset = 7;
+ }
+
+ if (Value == 2)
+ {
+ offset = 3;
+ }
+
+ //blue thingy
+ trackPathBehindThumb.AddArc(trackRectBehindThumb.Left, trackRectBehindThumb.Top, radius * 2, radius * 2, 180, 90);
+ trackPathBehindThumb.AddArc(trackRectBehindThumb.Right + offset + (trackHeight / 2) - radius * 2, trackRectBehindThumb.Top, radius * 2, radius * 2, 270, 90);
+ trackPathBehindThumb.AddArc(trackRectBehindThumb.Right + offset + (trackHeight / 2) - radius * 2, trackRectBehindThumb.Bottom - radius * 2, radius * 2, radius * 2, 0, 90);
+ trackPathBehindThumb.AddArc(trackRectBehindThumb.Left, trackRectBehindThumb.Bottom - radius * 2, radius * 2, radius * 2, 90, 90);
+
+ //gray thingy
+ trackPathAfterThumb.AddArc(trackRectAfterThumb.Left, trackRectAfterThumb.Top, radius * 2, radius * 2, 180, 90);
+ trackPathAfterThumb.AddArc(trackRectAfterThumb.Right - trackHeight, trackRectAfterThumb.Top, radius * 2, radius * 2, 270, 90);
+ trackPathAfterThumb.AddArc(trackRectAfterThumb.Right - trackHeight, trackRectAfterThumb.Bottom - radius * 2, radius * 2, radius * 2, 0, 90);
+ trackPathAfterThumb.AddArc(trackRectAfterThumb.Left, trackRectAfterThumb.Bottom - radius * 2, radius * 2, radius * 2, 90, 90);
+ trackPathAfterThumb.CloseFigure();
+
+ using (GraphicsPath thumbPath = new GraphicsPath())
+ {
+
+
+
+ using (SolidBrush trackBrushBehindThumb = new SolidBrush(trackColorBehindThumb))
+ using (SolidBrush trackBrushAfterThumb = new SolidBrush(_bgColor))
+ using (SolidBrush thumbBrush = new SolidBrush(progressColor))
+ {
+
+ e.Graphics.FillPath(trackBrushAfterThumb, trackPathAfterThumb);
+ if (value != 0)
+ {
+
+
+ e.Graphics.FillPath(trackBrushBehindThumb, trackPathBehindThumb);
+ }
+
+
+ }
+ }
+ }
+ }
+
+
+
+
+
+
+ public void Wait(int time)
+ {
+ Thread thread = new Thread(delegate ()
+ {
+ System.Threading.Thread.Sleep(time);
+ });
+ thread.Start();
+ while (thread.IsAlive)
+ Application.DoEvents();
+ }
+
+ protected virtual void OnValueChanged(EventArgs e)
+ {
+ ValueChanged?.Invoke(this, e);
+ }
+}