private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) { return; } SaveInfo(); T_Plan tmp = null; foreach (var p in D3Config.alplan) { if (p.Path == this.comboBox1.SelectedValue.ToString()) { tmp = p; break; } } D3Config.PLAN = tmp; if (D3Config.PLAN.Keys != null) { D3Config.KEYS = D3Config.PLAN.Keys.ToJson().FromJson <T_Key>(); } BindData(); SaveInfo(); }
public static T_Plan ReadDefaultSetting(string _DefaultPath) { var objplan = new T_Plan(); var str = ""; try { str = System.IO.File.ReadAllText(_DefaultPath, Encoding.GetEncoding("gb2312")); objplan = str.FromJson <T_Plan>(); return(objplan); } catch { return(null); } }
public static void LoadPlanList() { var defaultfile = System.IO.File.ReadAllText(DefaultPath, Encoding.GetEncoding("gb2312")); alplan.Clear(); PLAN = null; var strs = System.IO.Directory.GetFiles(PlanPath); foreach (var str in strs) { try { var tp = ReadDefaultSetting(str); alplan.Add(tp); if (str == defaultfile) { PLAN = tp; } } catch { } } if (PLAN == null && alplan.Count > 0) { PLAN = alplan[0]; } if (PLAN == null) { PLAN = new T_Plan() { Name = "默认", Path = PlanPath + "\\默认.txt", t1 = new T_Time() { fmode = EnumD3.做操作 }, t2 = new T_Time() { fmode = EnumD3.做操作 } }; alplan.Add(PLAN); } }