using AForge;
|
using Newtonsoft.Json;
|
using System.Collections.Concurrent;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.IO;
|
using System.Linq;
|
//using System.Windows.Forms;
|
//using System.Windows.Forms;
|
|
namespace Hydro.CommonBase
|
{
|
|
|
public class EncryState
|
{
|
/// <summary>
|
/// true表示已锁定,false表示已经解锁。
|
/// </summary>
|
public static bool encryLockState = false;
|
|
}
|
public class GlobalPath
|
{
|
private static string path = null;
|
public static string Path
|
{
|
get
|
{
|
if (path == null) path = Directory.GetCurrentDirectory()+"\\";
|
return path;
|
}
|
set
|
{
|
path = value; if (!string.IsNullOrEmpty(path) && path[path.Length - 1] != '\\') path = path + "\\";
|
}
|
}
|
public static string configPath { get { string p = Path + @"\config\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; }}
|
public static string modelPath { get { string p = Path + @"\model\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
|
|
public static string resultPath { get { string p = Path + @"\result\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
|
|
public static string savePath { get { string p = Path + @"\save\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
|
|
public static string bakPath { get { string p = Path + @"\config_bk\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
|
public static string recordPath { get { string p = Path + @"\Record\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
|
}
|
public class GlobalConfig
|
{
|
|
|
public static GlobalConfig Instance { get; set; }
|
|
|
/// <summary>
|
/// 用户名
|
/// </summary>
|
public string ModelFilePath { get; set; } = "";
|
|
/// <summary>
|
/// 密码
|
/// </summary>
|
public string ModelObjectID { get; set; }
|
|
/// <summary>
|
/// 共享剪切板
|
/// </summary>
|
public bool ConnectSession0 { get; set; } = false;
|
|
/// <summary>
|
/// 共享所有磁盘
|
/// </summary>
|
public bool ShareAllDisk { get; set; } = true;
|
|
/// <summary>
|
/// 共享磁盘列表,当 ShareAllDisk = false 时使用
|
/// </summary>
|
public List<string> ShareDiskList { get; set; } = new List<string>();
|
|
|
///// <summary>
|
///// 截图快捷键
|
///// </summary>
|
//public Keys HotKeys { get; set; } = Keys.Control | Keys.Alt | Keys.A;
|
|
///// <summary>
|
///// 截图快捷键
|
///// </summary>
|
//public Keys RealKeys { get; set; }
|
|
///// <summary>
|
///// 截图辅助键
|
///// </summary>
|
//public List<Keys> ModifyKeys { get; set; }
|
|
/// <summary>
|
/// 延时截图时间
|
/// </summary>
|
public int PrintScreenDelayTime { get; set; } = 2;
|
|
|
public bool ISencryption { get; set; } =false;
|
|
/// <summary>
|
/// 显示本机任务栏
|
/// </summary>
|
public bool ShowTaskBar { get; set; } = false;
|
|
///// <summary>
|
///// 连接时自动全屏
|
///// </summary>
|
//public int MaxThread { get; set; } =1;
|
|
public string ExtJson { get; set; } = "";
|
private CalcExt _ext;
|
/// <summary>
|
/// 计算默认配置
|
/// </summary>
|
public CalcExt Ext=> _ext ?? (_ext = JsonConvert.DeserializeObject<CalcExt>(ExtJson) ?? new CalcExt());
|
|
|
|
public Dictionary<string, SaveSettings> saveSettings { get; set; } = new Dictionary<string, SaveSettings>();
|
|
}
|
public class SaveSettings
|
{
|
|
public List<int> Length_Ds=null;
|
public List<DRange> list_Range=null;
|
public ConcurrentDictionary<ulong, double> saveDatas = null;
|
public string savePath=null;
|
|
|
public int COUNT_D { get { return Length_Ds==null ? -1: Length_Ds.Count; } }
|
|
public int SumLength {
|
get
|
{
|
if (Length_Ds == null) return -1;
|
int sumLength = 0;
|
Length_Ds.ForEach(d => sumLength += d);
|
return sumLength;
|
}
|
}
|
|
[Category("2、存储")]
|
[Description("一组自然数值,表示每一位向量的二进制长度,用“,”隔开")]
|
[DisplayName("4、长度组")]
|
public string str_list_Length
|
{
|
get
|
{
|
|
if (Length_Ds == null) return null;
|
return string.Join(",", Length_Ds);
|
}
|
set
|
{
|
try
|
{
|
if (value == null) return;
|
|
Length_Ds = value.Split(',').ToList().Select(n => int.Parse(n)).ToList();
|
}
|
catch
|
{
|
|
}
|
|
}
|
}
|
|
[Category("2、存储")]
|
[Description("一组Range值,表示每一位向量的范围,举例:1,2|2,3|0.3,0.4")]
|
[DisplayName("5、范围组")]
|
public string str_list_Range
|
{
|
get
|
{
|
if (list_Range == null) return null;
|
return string.Join("|", list_Range.Select(n => $"{n.Min},{n.Max}"));
|
}
|
set
|
{
|
try
|
{
|
if (value == null) return;
|
|
list_Range = value.Split('|').ToList().Select(n => new DRange(double.Parse(n.Split(',')[0]), double.Parse(n.Split(',')[1]))).ToList();
|
|
|
}
|
catch
|
{
|
}
|
|
}
|
}
|
}
|
}
|