using AForge;
using Newtonsoft.Json;
using System;
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
{
///
/// true表示已锁定,false表示已经解锁。
///
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 static string ChartFilePath { get { string p = Path + @"Chart\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
public static string BranchPath { get { string p = Path + @"Branch\"; if (!Directory.Exists(p)) Directory.CreateDirectory(p); return p; } }
}
[Serializable]
public class GlobalConfig
{
public static GlobalConfig Instance { get; set; }
///
/// 用户名
///
public string ModelFilePath { get; set; } = "";
///
/// 密码
///
public string ModelObjectID { get; set; }
///
/// 共享剪切板
///
public bool ConnectSession0 { get; set; } = false;
///
/// 共享所有磁盘
///
public bool ShareAllDisk { get; set; } = true;
///
/// 共享磁盘列表,当 ShareAllDisk = false 时使用
///
public List ShareDiskList { get; set; } = new List();
/////
///// 截图快捷键
/////
//public Keys HotKeys { get; set; } = Keys.Control | Keys.Alt | Keys.A;
/////
///// 截图快捷键
/////
//public Keys RealKeys { get; set; }
/////
///// 截图辅助键
/////
//public List ModifyKeys { get; set; }
///
/// 延时截图时间
///
public int PrintScreenDelayTime { get; set; } = 2;
public bool ISencryption { get; set; } =false;
///
/// 显示本机任务栏
///
public bool ShowTaskBar { get; set; } = false;
/////
///// 连接时自动全屏
/////
//public int MaxThread { get; set; } =1;
public string ExtJson { get; set; } = "";
private CalcExt _ext;
///
/// 计算默认配置
///
public CalcExt Ext=> _ext ?? (_ext = JsonConvert.DeserializeObject(ExtJson) ?? new CalcExt());
public Dictionary saveSettings { get; set; } = new Dictionary();
}
[Serializable]
public class SaveSettings
{
public List Length_Ds=null;
public List list_Range=null;
public ConcurrentDictionary 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
{
}
}
}
}
}