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.

101 lines
2.5 KiB
C#

using Chloe;
using DNSD_DB;
using DNSD_DB.Entity;
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;
}
}
/// <summary>
/// 插入无RFID编号日志
/// </summary>
/// <param name="dbContext"></param>
/// <param name="text"></param>
public static void LogInsert(IDbContext dbContext, string text)
{
dbContext.Insert(new RFIDLogsEntity()
{
CreateTime = DateTime.Now,
LogText = text,
});
}
/// <summary>
/// 插入有RFID编号日志
/// </summary>
/// <param name="dbContext"></param>
/// <param name="text"></param>
public static void LogInsert(IDbContext dbContext, string text, string rfid)
{
dbContext.Insert(new RFIDLogsEntity()
{
CreateTime = DateTime.Now,
LogText = text,
RFIDId = rfid
});
}
public static void SignAnalysis(IDbContext dbContext)
{
}
}
public enum LightState
{
Green = 0,
Yellow,
Red,
}
}