using ryCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace VSoft.Config
{
///
/// 配置类,保存在运行期间会被改变的配置信息(本系统基于乘黄V2架构)
///
public static class Soft_Config
{
///
/// 是否能关闭窗体。
///
public static bool IsCanCloseForm = true;
///
/// 在点击主窗口关闭按钮时,隐藏窗体(只有开启了托盘图标,本功能才能生效,此时需要通过托盘图标进行关闭)。
///
public static bool HideByCloseBtn = true;
///
/// 显示主窗体的热键
///
public static string ShowMainHotKey = "";
///
/// 是否开启鼠标快捷键
///
public static bool ShowMainMouseKeyOn = true;
///
/// 鼠标快捷键
///
public static int ShowMainMouseKey = 0;
///
/// 单击打开软件
///
public static bool OpenByClick = false;
///
/// 启动软件后隐藏自身
///
public static bool HideAfterRun = true;
public static Form MainForm { get; set; }
///
/// 当前软件加载的热键列表
///
public static List HotKeyList = new List();
///
/// 获取设置
///
public static void LoadSetting()
{
ryCommon.Storage Stor = new Storage();
Stor.LoadFromFile(Soft_Info.UserDataFolder + "\\Setting.xml");
Stor.SelectNodeBySet();
ShowMainHotKey = Stor.GetAttrValue("ShowMainHotKey", "1+88");
OpenByClick = Stor.GetAttrValue("OpenByClick", false);
HideAfterRun = Stor.GetAttrValue("HideAfterRun", true);
ShowMainMouseKeyOn = Stor.GetAttrValue("ShowMainMouseKeyOn", true);
ShowMainMouseKey = Stor.GetAttrValue("ShowMainMouseKey", 0);
//low_count = Stor.GetAttrValue("LowCount", 10);
}
///
/// 设置热键到列表中
///
///
///
///
/// 返回热键在列表中的位置
public static int SetHotKeyList(string id,string name,string hotkey)
{
var index= HotKeyList.FindIndex(a => a.ID == id);
if(index!=-1)
{
HotKeyList[index].Name = name;
HotKeyList[index].HotKey = hotkey;
return index;
}
else
{
HotKeyList.Add(new HotKeyItem() { ID=id, Name=name, HotKey=hotkey });
return HotKeyList.Count - 1;
}
}
///
/// 从列表中删除热键
///
///
/// 返回热键在原来列表中的位置
public static int RemoveHotKeyList(string id)
{
var index = HotKeyList.FindIndex(a => a.ID == id);
if (index != -1)
{
HotKeyList.RemoveAt(index);
}
return index;
}
///
/// 在列表中查找热键是否已存在
///
///
/// 返回热键在原来列表中的位置
public static int IsHotKeyExistInList(string hotkey)
{
var index = HotKeyList.FindIndex(a => a.HotKey == hotkey);
return index;
}
}
public class HotKeyItem
{
///
/// ID
///
public string ID { get; set; } = "";
///
/// 热键名称
///
public string Name { get; set; } = "";
///
/// 热键
///
public string HotKey { get; set; } = "";
}
}