private void LoadConfigVars() { string[] sections = UserDetails.getAllSections("GUI"); if (sections == null) { return; } System.Collections.Specialized.NameValueCollection configItems = null; foreach (string section in sections) { if (string.IsNullOrEmpty(section)) { continue; } configItems = UserDetails.getSection("GUI", section); if (configItems == null || configItems.Count == 0) { continue; } SectionParam para = new SectionParam(section); //enumerate the keys string value; foreach (string key in configItems) { value = configItems[key]; if (string.IsNullOrEmpty(value)) { continue; } if (key.ToLower() == TextPassword.ToLower()) { try { // decrypt password string sDecryptedPw = Utilities.DecryptString(value, TextPassPhase); para.AddParam <string>(key, sDecryptedPw); } catch (Exception ex) { string msg = String.Format("Failed to decrypt password. Exception={0}", ex.Message); MessageBox.Show(msg); } } else { para.AddParam <string>(key, value); } } sectionParam.Add(para); } }
private void AddSection(ref ScrollPanel bsp, SectionParam para, List <ConfigParam2> lstVars) { if (bsp == null || para == null || lstVars == null) { return; } GroupListView2 glv2 = new GroupListView2(); ConfigListView clv = glv2.EmbeddLV; clv.Scrollable = false; // Add columns ColumnHeader columnHeader1 = new ColumnHeader(); columnHeader1.Width = FirstColumnWidth; columnHeader1.TextAlign = HorizontalAlignment.Left; columnHeader1.Text = "Name"; ColumnHeader columnHeader2 = new ColumnHeader(); columnHeader2.Width = SecondColumnWidth; columnHeader2.TextAlign = HorizontalAlignment.Left; columnHeader2.Text = "Description"; clv.Name = para.SectionName; clv.Columns.AddRange(new ColumnHeader[] { columnHeader1, columnHeader2 }); glv2.LabelText = para.SectionName; Node node = para.getNode(); string configDesc, configValue; int nColumn1Width; while (node != null) { configDesc = ((TypeList <string>)node).getDesc(); configValue = ((TypeList <string>)node).getData(); AddItem(ref clv, lstVars, para.SectionName, configDesc, configValue); nColumn1Width = DetermineWidth(configDesc); FirstColumnWidth = nColumn1Width > FirstColumnWidth ? nColumn1Width : FirstColumnWidth; node = node.getNext(); } // Add custom draw clv.OwnerDraw = true; clv.DrawItem += new DrawListViewItemEventHandler(clv_DrawItem); if (clv.RowHeight > LVSmallChange) { LVSmallChange = clv.RowHeight; } if (glv2.Height > LVLargeChange) { LVLargeChange = glv2.Height; } glv2.SetPreferedHeight(); bsp.Controls.Add(glv2); }