Ejemplo n.º 1
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog
            {
                Title = Resources.ImportTabDialogTitle,
                Filter = string.Format("{0} (*{1})|*{1}", Resources.TabsterFile, Constants.TablatureFileExtension),
                Multiselect = false
            })
            {
                ofd.SetTabsterFilter(_fileImporters, allSupportedTypesOption: false, alphabeticalOrder: true); //todo implement "all supported types" handling

                if (ofd.ShowDialog() != DialogResult.Cancel)
                {
                    //native file format
                    if (ofd.FilterIndex == 1)
                    {
                        var file = _libraryManager.GetTablatureFileProcessor().Load(ofd.FileName);

                        if (file != null)
                        {
                            _libraryManager.Add(file);
                        }
                    }

                    else // third-party format
                    {
                        var importer = _fileImporters[ofd.FilterIndex - 2]; //FilterIndex is not 0-based and native Tabster format uses first index

                        AttributedTablature importedTab = null;

                        try
                        {
                            importedTab = importer.Import(ofd.FileName);
                        }

                        catch
                        {
                            MessageBox.Show(Resources.ImportErrorDialogCaption, Resources.ImportErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        if (importedTab != null)
                        {
                            using (var nd = new NewTabDialog(importedTab.Artist, importedTab.Title, importedTab.Type))
                            {
                                if (nd.ShowDialog() == DialogResult.OK)
                                {
                                    var tab = nd.Tab;
                                    tab.Contents   = importedTab.Contents;
                                    tab.Source     = new Uri(ofd.FileName);
                                    tab.SourceType = TablatureSourceType.FileImport;
                                    _libraryManager.Add(tab);
                                    UpdateDetails();
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void listDownloads_SelectedIndexChanged(object sender, EventArgs e)
        {
            AttributedTablature tab = null;

            if (listDownloads.SelectedItems.Count > 0)
            {
                tab = _downloadedTabs[listDownloads.SelectedItems[0].Index];
            }

            PopulateTablatureFields(tab);
        }
Ejemplo n.º 3
0
 private void okbtn_Click(object sender, EventArgs e)
 {
     Tab = new AttributedTablature(txtArtist.Text.Trim(), txtTitle.Text.Trim(), typeList.SelectedType);
 }
Ejemplo n.º 4
0
 private void okbtn_Click(object sender, EventArgs e)
 {
     Tab = new AttributedTablature(txtArtist.Text.Trim(), txtTitle.Text.Trim(), typeList.SelectedType);
 }
Ejemplo n.º 5
0
 private void PopulateTablatureFields(AttributedTablature tab)
 {
     txtArtist.Text = tab != null ? tab.Artist : string.Empty;
     txtTitle.Text = tab != null ? tab.Title : string.Empty;
     typeList.SelectedType = tab != null ? tab.Type : null;
 }
Ejemplo n.º 6
0
 private void PopulateTablatureFields(AttributedTablature tab)
 {
     txtArtist.Text        = tab != null ? tab.Artist : string.Empty;
     txtTitle.Text         = tab != null ? tab.Title : string.Empty;
     typeList.SelectedType = tab != null ? tab.Type : null;
 }