示例#1
0
        private void checkedChange(object sender, ItemCheckEventArgs e)
        {
            var clb = (CheckedListBox)sender;

            clb.ItemCheck -= checkedChange;
            clb.SetItemCheckState(e.Index, e.NewValue);
            clb.ItemCheck += checkedChange;
            string name = clb.Name.Replace("Exp_", null);
            var    dic  = typeof(Configuration).GetField(name).GetValue("Items");

            ((ExtensionVariable)dic).Items[clb.Items[e.Index].ToString()] = (e.NewValue == CheckState.Checked);
            JsonSettings.Save(dic, $"ext\\{name}");
        }
示例#2
0
 static void init(out ExtensionVariable dic, string name)
 {
     if (File.Exists($"{JsonSettings.FolderPath}{name}.json"))
     {
         dic = JsonSettings.Get <ExtensionVariable>(name);
     }
     else
     {
         dic = new ExtensionVariable {
             Items = new Dictionary <string, bool>()
         };                                                                     // DefaultDict()
         JsonSettings.Save(dic, name);
     }
 }
示例#3
0
        public Discipline Load(string filename)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine($@"Filename not found '{filename}'");
                return(this);
            }

            try
            {
                var tmp = JsonSettings.Get <Discipline>(filename);
                return(tmp);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(this);
        }