mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-06 15:56:13 +02:00
Don't unnecessarily redraw time plugin bitmap every second
This commit is contained in:
@@ -9,15 +9,29 @@ namespace DesktopMagic.BuiltInPlugins;
|
|||||||
|
|
||||||
internal class TimePlugin : Plugin
|
internal class TimePlugin : Plugin
|
||||||
{
|
{
|
||||||
[Setting("display-seconds", "Display Seconds")]
|
[Setting("display-seconds", "Show Seconds")]
|
||||||
private readonly CheckBox displaySecondsCheckBox = new CheckBox(true);
|
private readonly CheckBox displaySecondsCheckBox = new CheckBox(true);
|
||||||
|
|
||||||
|
private string oldTime = string.Empty;
|
||||||
|
private Color oldColor = Color.White;
|
||||||
|
private string oldFont = string.Empty;
|
||||||
|
private bool oldDisplaySecondsCheckBoxValue;
|
||||||
public override int UpdateInterval => 1000;
|
public override int UpdateInterval => 1000;
|
||||||
|
|
||||||
public override Bitmap Main()
|
public override Bitmap? Main()
|
||||||
{
|
{
|
||||||
string time = displaySecondsCheckBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString();
|
string time = displaySecondsCheckBox.Value ? DateTime.Now.ToLongTimeString() : DateTime.Now.ToShortTimeString();
|
||||||
|
|
||||||
|
if (oldTime == time && oldColor == Application.Theme.PrimaryColor && oldFont == Application.Theme.Font && oldDisplaySecondsCheckBoxValue == displaySecondsCheckBox.Value)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldTime = time;
|
||||||
|
oldColor = Application.Theme.PrimaryColor;
|
||||||
|
oldFont = Application.Theme.Font;
|
||||||
|
oldDisplaySecondsCheckBoxValue = displaySecondsCheckBox.Value;
|
||||||
|
|
||||||
Font font = new Font(Application.Theme.Font, 200);
|
Font font = new Font(Application.Theme.Font, 200);
|
||||||
|
|
||||||
Bitmap bmp = new Bitmap(1, 1);
|
Bitmap bmp = new Bitmap(1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user