You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NDSD_Screwdriver
{
public class FormUtils
{
public static Random r = new Random();
/// <summary>
/// 随机颜色测试
/// </summary>
/// <returns></returns>
public static Brush TestRamColor()
{
int i = r.Next(0, 4);
if (i == 1)
{
return Brushes.Green;
}
else if (i == 2)
{
return Brushes.Yellow;
}
else /*if (i == 3)*/
{
return Brushes.Red;
}
//else return Brushes.Transparent;
}
/// <summary>
/// 颜色枚举值转换为颜色
/// </summary>
/// <param name="lightState"></param>
/// <returns></returns>
public static Brush EnumColorToBrush(LightState lightState)
{
switch (lightState)
{
case LightState.Green:
return Brushes.Green;
case LightState.Yellow:
return Brushes.Yellow;
case LightState.Red:
return Brushes.Red;
default: return Brushes.Transparent;
}
}
}
public enum LightState
{
Green = 0,
Yellow,
Red,
}
}