private void onOpenClick(object sender, EventArgs e) { var result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) { this._reset(); _selectedJsonFile = openFileDialog.FileName; this.lblSelectedBiosJson.Text = _selectedJsonFile; try { var json = File.ReadAllText(_selectedJsonFile); var javaScriptSer = new JavaScriptSerializer(); this._biosConfigEdit = javaScriptSer.Deserialize <BIOSConfigEdit>(json); var dic = _biosConfigEdit.BIOConfigDictionary; foreach (KeyValuePair <string, dynamic> item in javaScriptSer.Deserialize <dynamic>(json)) { foreach (KeyValuePair <string, dynamic> n in item.Value) { var biosItemList = new List <BIOSItem>(); foreach (var b in n.Value) { var attrList = new List <string>(); foreach (KeyValuePair <string, dynamic> x in b) { attrList.Add((string)x.Value); } var biosItem = new BIOSItem() { to = attrList[0], navigation = attrList[1], recuring = attrList[2], invoke = attrList[3] }; biosItemList.Add(biosItem); } if (biosItemList.Count > 0 && !_biosConfigEdit.BIOConfigDictionary.ContainsKey(item.Key)) { var biosConfig = new BIOSConfig() { navs = biosItemList.ToArray() }; dic.Add(item.Key, biosConfig); } } } } catch (Exception ex) { _frmConfigEditor.ShowMessage(ex.Message, true); } } this._updateView(); }
public BiosItemControl(string key, BIOSConfig biosConfig) { InitializeComponent(); _biosConfig = biosConfig; this.labelBiosItem.Text = key; var navCount = biosConfig.navs.Count(); for (int i = navCount - 1; i >= 0; i--) { BIOSItem item = biosConfig.navs[i]; var navControl = new NavigationControl(item, this) { Idx = i }; this.scrollableControl.Controls.Add(navControl); navControl.Dock = DockStyle.Top; } }