-
Notifications
You must be signed in to change notification settings - Fork 0
/
Puvox__customs.cs
86 lines (71 loc) · 2.38 KB
/
Puvox__customs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using System.Xml.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Net;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
using Microsoft.Win32;
using System.Collections.Specialized;
using System.Threading.Tasks;
using System.Security.Cryptography;
//using System.ComponentModel.DataAnnotations;
//using System.Web.Script.Serialization;
//using System.Windows.Controls;
//using System.Windows.Media;
//using System.Windows.Media.Imaging;
namespace PuvoxLibrary
{
public partial class Methods
{
public static Color color_from_hex(string hex_str) {
try
{
return (Color)System.Drawing.ColorTranslator.FromHtml(hex_str);
}
catch (Exception e)
{
m(e.Message);
return Color.Transparent;
}
}
public static bool blinkActive = false;
public static async void Blink_start(System.Windows.Forms.Control ctrl, Color c1, Color c2, short CycleTime_ms, bool BkClr)
{
try
{
blinkActive = true;
var sw = new Stopwatch(); sw.Start();
short halfCycle = (short)Math.Round(CycleTime_ms * 0.5);
while (blinkActive)
{
await Task.Delay(1);
var n = sw.ElapsedMilliseconds % CycleTime_ms;
var per = (double)Math.Abs(n - halfCycle) / halfCycle;
var red = (short)Math.Round((c2.R - c1.R) * per) + c1.R;
var grn = (short)Math.Round((c2.G - c1.G) * per) + c1.G;
var blw = (short)Math.Round((c2.B - c1.B) * per) + c1.B;
var clr = Color.FromArgb(red, grn, blw);
if (BkClr) ctrl.BackColor = clr; else ctrl.ForeColor = clr;
}
ctrl.BackColor = Color.Transparent;
}
catch (Exception e)
{
m(e.Message);
return;
}
}
public static void Blink_stop(System.Windows.Forms.Control ctrl)
{
blinkActive = false;
}
}
}