private void deleteCheckedToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem item in profile_list.CheckedItems) { Utils.NetworkProfile profile = new Utils.NetworkProfile(); profile.Name = item.Text; profile.Description = item.SubItems[1].Text; switch (item.SubItems[2].Text) { case "Public": profile.Category = 0; break; case "Private": profile.Category = 1; break; case "Domain": profile.Category = 2; break; } profile.Managed = item.SubItems[3].Text == "True" ? true : false; profile.SubKey = item.SubItems[4].Text; profile.SignatureSubKey = item.SubItems[5].Text; profile.Delete(); } ListProfiles(); }
public static NetworkProfile[] GetProfiles() { RegistryKey regKey = Utils.LocalMachine.OpenSubKey(Utils.ProfilePath); List <Utils.NetworkProfile> profiles = new List <Utils.NetworkProfile>(); foreach (string subKey in regKey.GetSubKeyNames()) { var rk = Utils.LocalMachine.OpenSubKey(Utils.ProfilePath + "\\" + subKey); var profile = new Utils.NetworkProfile(); profile.SubKey = subKey; profile.Name = rk.GetValue("ProfileName").ToString(); profile.Description = rk.GetValue("Description").ToString(); profile.Category = ( int )rk.GetValue("Category"); profile.Managed = ( int )rk.GetValue("Managed") == 1 ? true : false; rk = LocalMachine.OpenSubKey(Utils.SignaturePath + "\\" + (profile.Managed ? "Managed" : "Unmanaged")); foreach (string sk in rk.GetSubKeyNames()) { rk = LocalMachine.OpenSubKey(Utils.SignaturePath + "\\" + (profile.Managed ? "Managed\\" : "Unmanaged\\") + sk); if (rk.GetValue("ProfileGuid").ToString() == profile.SubKey) { profile.SignatureSubKey = sk; } } profiles.Add(profile); } return(profiles.ToArray()); }
private void btn_save_Click(object sender, EventArgs e) { if (profile_list.SelectedItems.Count > 0) { ListViewItem item = profile_list.SelectedItems[0]; Utils.NetworkProfile profile = new Utils.NetworkProfile(); profile.Name = tb_profilenName.Text; profile.Description = tb_profileDescription.Text; switch (cb_Category.SelectedItem.ToString()) { case "Public": profile.Category = 0; break; case "Private": profile.Category = 1; break; case "Domain": profile.Category = 2; break; } profile.Managed = item.SubItems[3].Text == "True" ? true : false; profile.SubKey = item.SubItems[4].Text; profile.SignatureSubKey = item.SubItems[5].Text; profile.Save(); } ListProfiles(); }