private void importToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog a = new OpenFileDialog(); a.Filter = "Exported Hosts Profiles (*.xml)|*.*"; a.FilterIndex = 1; a.RestoreDirectory = true; if (a.ShowDialog() == DialogResult.OK) { profiles = HostsProfile.readFromXML(a.FileName); currentHosts = HostsProfile.getCurrentProfile(profiles); selectedProfile = currentHosts; customizeHosts(selectedProfile); updateListBox(); } }
public FormMain() { InitializeComponent(); m_HostsProvider = new HostProvider(); quickSwitchToolStripMenuItem.DropDownItemClicked += new ToolStripItemClickedEventHandler(quickSwitchToolStripMenuItem_DropDownItemClicked); Text = string.Format("Hosts Switcher - v.{0}", typeof(FormMain).Assembly.GetName().Version); listLocked = true; if (File.Exists(appSettingsFilePath)) { profiles = HostsProfile.readFromXML(appSettingsFilePath); currentHosts = HostsProfile.getCurrentProfile(profiles); } else { List <HostsProfile> profiles = new List <HostsProfile>(); currentHosts = new HostsProfile(); profiles.Add(currentHosts); HostsProfile.writeToSettingsXML(profiles); } initializeListView(); selectedProfile = currentHosts; customizeHosts(selectedProfile); updateListBox(); listView1.ItemChecked += new ItemCheckedEventHandler(listView_CheckedChanged); listView1.CheckBoxes = true; listView1.SubItemClicked += new ListViewEx.SubItemEventHandler(listView1_SubItemClicked); listView1.SubItemEndEditing += new ListViewEx.SubItemEndEditingEventHandler(listView1_SubItemEndEditing); listView1.DoubleClickActivation = false; }