private TabInstance CreateTabInstance(ITablatureFile file, FileInfo fileInfo) { var editor = new BasicTablatureTextEditor { Dock = DockStyle.Fill, ReadOnly = false }; var instance = new TabInstance(file, fileInfo, editor); _tabInstances.Add(instance); tabControl1.TabPages.Add(instance.Page); editor.ContentsModified += editor_ContentsModified; editor.TablatureLoaded += editor_TablatureLoaded; editor.LoadTablature(file); if (TabOpened != null) { TabOpened(this, file); } return(instance); }
private bool CloseInstance(TabInstance instance, bool closeIfLast) { var saveBeforeClosing = true; if (instance.Modified) { var result = MessageBox.Show(string.Format(Resources.SaveChangesDialogCaption + Environment.NewLine + instance.File.ToFriendlyString(), Resources.SaveChangesDialogTitle), Resources.Save, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return(false); } if (result == DialogResult.No) { saveBeforeClosing = false; } } if (saveBeforeClosing) { instance.File.Save(instance.FileInfo.FullName); } tabControl1.TabPages.Remove(instance.Page); _tabInstances.Remove(instance); if (TabClosed != null) { TabClosed(this, instance.File); } if (closeIfLast && tabControl1.TabPages.Count == 0) { Close(); } return(true); }
private void UpdateInstanceControls(TabInstance instance) { savebtn.Enabled = instance.Editor.Modified; instance.Page.ImageIndex = instance.Editor.Modified ? 1 : 0; }
private void SelectTabInstance(TabInstance instance) { tabControl1.SelectedTab = instance.Page; instance.Editor.Focus(false); }
private TabInstance CreateTabInstance(ITablatureFile file, FileInfo fileInfo) { var editor = new BasicTablatureTextEditor {Dock = DockStyle.Fill, ReadOnly = false}; var instance = new TabInstance(file, fileInfo, editor); _tabInstances.Add(instance); tabControl1.TabPages.Add(instance.Page); editor.ContentsModified += editor_ContentsModified; editor.TablatureLoaded += editor_TablatureLoaded; editor.LoadTablature(file); if (TabOpened != null) TabOpened(this, file); return instance; }
private bool CloseInstance(TabInstance instance, bool closeIfLast) { var saveBeforeClosing = true; if (instance.Modified) { var result = MessageBox.Show(string.Format(Resources.SaveChangesDialogCaption + Environment.NewLine + instance.File.ToFriendlyString(), Resources.SaveChangesDialogTitle), Resources.Save, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) return false; if (result == DialogResult.No) saveBeforeClosing = false; } if (saveBeforeClosing) { instance.File.Save(instance.FileInfo.FullName); } tabControl1.TabPages.Remove(instance.Page); _tabInstances.Remove(instance); if (TabClosed != null) TabClosed(this, instance.File); if (closeIfLast && tabControl1.TabPages.Count == 0) { Close(); } return true; }