Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 private void UpdateInstanceControls(TabInstance instance)
 {
     savebtn.Enabled = instance.Editor.Modified;
     instance.Page.ImageIndex = instance.Editor.Modified ? 1 : 0;
 }
Example #4
0
 private void SelectTabInstance(TabInstance instance)
 {
     tabControl1.SelectedTab = instance.Page;
     instance.Editor.Focus(false);
 }
Example #5
0
        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;
        }
Example #6
0
        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;
        }
Example #7
0
 private void SelectTabInstance(TabInstance instance)
 {
     tabControl1.SelectedTab = instance.Page;
     instance.Editor.Focus(false);
 }
Example #8
0
 private void UpdateInstanceControls(TabInstance instance)
 {
     savebtn.Enabled          = instance.Editor.Modified;
     instance.Page.ImageIndex = instance.Editor.Modified ? 1 : 0;
 }