private void AddNewTabPage(IEnumerable <PListDefinition> definitions) { TabPage tabPage; _NewTabPageCounter++; string header = "new " + _NewTabPageCounter; string tabKey = "_" + header; tabPage = new TabPage(header); PListControl control = new PListControl(tabKey); if (definitions != null) { control.Update(definitions); } control.Dock = DockStyle.Fill; control.Saved += new EventHandler <EventArgs>(control_Saved); control.Duplicate += new EventHandler <DuplicateEventArgs>(control_Duplicate); control.CloseRequest += new EventHandler <EventArgs>(control_CloseRequest); tabPage.Controls.Add(control); _TabPages.Add(tabKey, tabPage); _TabControl.TabPages.Add(tabPage); _TabControl.SelectedTab = tabPage; SaveUserSettings(); }
private void LoadTabPage(FileInfo fileInfo) { if (_TabPages.ContainsKey(fileInfo.FullName)) { BindingList <PListDefinition> list = XmlSerializationHelper <BindingList <PListDefinition> > .ConvertFromFile(fileInfo.FullName); if (list != null) { PListControl control = _TabControl.SelectedTab.Controls[0] as PListControl; if (control != null) { control.Update(list); } } else { MessageBox.Show("Unable to load definition file " + fileInfo.FullName + ".", "Load Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } _TabControl.SelectedTab = _TabPages[fileInfo.FullName]; return; } else { BindingList <PListDefinition> list = XmlSerializationHelper <BindingList <PListDefinition> > .ConvertFromFile(fileInfo.FullName); if (list != null) { TabPage tabPage = new TabPage(fileInfo.Name); PListControl control = new PListControl(list, fileInfo, fileInfo.FullName); control.Dock = DockStyle.Fill; control.Saved += new EventHandler <EventArgs>(control_Saved); control.Duplicate += new EventHandler <DuplicateEventArgs>(control_Duplicate); control.CloseRequest += new EventHandler <EventArgs>(control_CloseRequest); tabPage.Controls.Add(control); _TabPages.Add(fileInfo.FullName, tabPage); _TabControl.TabPages.Add(tabPage); _TabControl.SelectedTab = tabPage; SaveUserSettings(); } else { MessageBox.Show("Unable to load definition file " + fileInfo.FullName + ".", "Load Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }