/// <summary> /// Open form for saving open files as a group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveOpenFilesAsGroupToolStripMenuItem_Click(object sender, EventArgs e) { if (tabControl1.TabPages.Count > 0) { var groupForm = new CreateGroupForm { StartPosition = FormStartPosition.CenterParent }; var result = groupForm.ShowDialog(); if (result != DialogResult.OK) { return; } var tabFiles = ( from TabPage tabPage in tabControl1.TabPages select new TabFile { TabName = tabPage.Text, File = tabPage.ToolTipText, Name = tabPage.Name }) .ToList(); var group = new FileGroup { GroupName = groupForm.name, Tabfiles = tabFiles }; _groups.FileGroups.Add(@group); FileGroupHandler.Save(_groups); } else { MessageBox.Show("No open files to group."); } }
/// <summary> /// Open form to load files from group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void loadGroupToolStripMenuItem_Click(object sender, EventArgs e) { var lgf = new LoadGroupForm(_groups); var result = lgf.ShowDialog(); if (result != DialogResult.OK) { return; } var selectedGroups = lgf.SelectedGroups; if (tabControl1.TabCount > 0) { var closeDialog = MessageBox.Show("Close current open files?", "Close files ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (closeDialog == DialogResult.Yes) { closeAlToolStripMenuItem_Click(null, null); } } var groups = FileGroupHandler.Load(); foreach (var fileGroup in groups.FileGroups.Where(fileGroup => selectedGroups.Contains(fileGroup.GroupName)) ) { LoadTabFiles(fileGroup.Tabfiles); } }
private void LoadGroups() { _groups = FileGroupHandler.Load(); }