/// <summary>
        ///     Convert Xml-based files to binary.
        /// </summary>
        public static void ConvertXmlFiles(PlaylistManager playlistManager, LibraryManager libraryManager)
        {
            var playlistsDirectory = Path.Combine(TabsterEnvironment.GetEnvironmentDirectoryPath(TabsterEnvironmentDirectory.UserData), "Playlists");

            // playlists are no longer stored as files, but are now stored in database
            if (Directory.Exists(playlistsDirectory))
            {
#pragma warning disable 612
                var playlistProcessor = new TabsterFileProcessor <TablaturePlaylistDocument>(TablaturePlaylistDocument.FileVersion);
#pragma warning restore 612

                foreach (var file in Directory.GetFiles(playlistsDirectory, string.Format("*{0}", Constants.TablaturePlaylistFileExtension), SearchOption.AllDirectories))
                {
                    var playlistFile = playlistProcessor.Load(file);

                    if (playlistFile != null)
                    {
                        var playlist = new TablaturePlaylist(playlistFile.Name)
                        {
                            Created = playlistFile.FileAttributes.Created
                        };

                        foreach (var item in playlistFile)
                        {
                            playlist.Add(item);
                        }

                        playlistManager.Update(playlist);

                        try
                        {
                            File.Delete(file);
                        }

                        catch (Exception ex)
                        {
                            Logging.GetLogger().Error(string.Format("Error occured during playlist conversion: {0}", file), ex);
                        }
                    }
                }
            }

            if (Directory.Exists(libraryManager.TablatureDirectory))
            {
                foreach (var file in Directory.GetFiles(libraryManager.TablatureDirectory, string.Format("*{0}", Constants.TablatureFileExtension), SearchOption.AllDirectories))
                {
                    var tablatureFile = TabsterXmlFileConverter.ConvertTablatureDocument(file);

                    if (tablatureFile != null)
                    {
                        tablatureFile.Save(file);
                    }
                }
            }
        }
        private void ProcessFirstArgForFile(string arg)
        {
            if (File.Exists(arg))
            {
                var tablatureFileProcessor = new TabsterFileProcessor<TablatureFile>(Constants.TablatureFileVersion);
                var file = tablatureFileProcessor.Load(arg);

                if (file != null)
                {
                    _queuedTablatureFile = file;
                    _queuedFileInfo = new FileInfo(arg);
                }
            }
        }
        /// <summary>
        ///     Convert Xml-based files to binary.
        /// </summary>
        public static void ConvertXmlFiles(PlaylistManager playlistManager, LibraryManager libraryManager)
        {
            var playlistsDirectory = Path.Combine(TabsterEnvironment.GetEnvironmentDirectoryPath(TabsterEnvironmentDirectory.UserData), "Playlists");

            // playlists are no longer stored as files, but are now stored in database
            if (Directory.Exists(playlistsDirectory))
            {
            #pragma warning disable 612
                var playlistProcessor = new TabsterFileProcessor<TablaturePlaylistDocument>(TablaturePlaylistDocument.FileVersion);
            #pragma warning restore 612

                foreach (var file in Directory.GetFiles(playlistsDirectory, string.Format("*{0}", Constants.TablaturePlaylistFileExtension), SearchOption.AllDirectories))
                {
                    var playlistFile = playlistProcessor.Load(file);

                    if (playlistFile != null)
                    {
                        var playlist = new TablaturePlaylist(playlistFile.Name) {Created = playlistFile.FileAttributes.Created};

                        foreach (var item in playlistFile)
                        {
                            playlist.Add(item);
                        }

                        playlistManager.Update(playlist);

                        try
                        {
                            File.Delete(file);
                        }

                        catch(Exception ex)
                        {
                            Logging.GetLogger().Error(string.Format("Error occured during playlist conversion: {0}", file), ex);
                        }
                    }
                }
            }

            if (Directory.Exists(libraryManager.TablatureDirectory))
            {
                foreach (var file in Directory.GetFiles(libraryManager.TablatureDirectory, string.Format("*{0}", Constants.TablatureFileExtension), SearchOption.AllDirectories))
                {
                    var tablatureFile = TabsterXmlFileConverter.ConvertTablatureDocument(file);

                    if (tablatureFile != null)
                        tablatureFile.Save(file);
                }
            }
        }
        private void ProcessFirstArgForFile(string arg)
        {
            if (File.Exists(arg))
            {
                var tablatureFileProcessor = new TabsterFileProcessor <TablatureFile>(Constants.TablatureFileVersion);
                var file = tablatureFileProcessor.Load(arg);

                if (file != null)
                {
                    _queuedTablatureFile = file;
                    _queuedFileInfo      = new FileInfo(arg);
                }
            }
        }
Exemple #5
0
        public MainForm()
        {
            var tablatureDirectory = TabsterEnvironment.CreateEnvironmentDirectoryPath(TabsterEnvironmentDirectory.UserData, "Library");

            var databasePath = Path.Combine(TabsterEnvironment.GetEnvironmentDirectoryPath(TabsterEnvironmentDirectory.ApplicatonData), "library.db");

            var fileProcessor = new TabsterFileProcessor <TablatureFile>(Constants.TablatureFileVersion);

            Logging.GetLogger().Info(string.Format("Initializing database: {0}", databasePath));
            _databaseHelper = new TabsterDatabaseHelper(databasePath);

            _libraryManager     = new LibraryManager(_databaseHelper, fileProcessor, tablatureDirectory);
            _playlistManager    = new PlaylistManager(_databaseHelper, fileProcessor);
            _recentFilesManager = new RecentFilesManager(_databaseHelper, fileProcessor, Settings.Default.MaxRecentItems);

            InitializeComponent();

            Text = string.Format("{0} v{1}", Application.ProductName,
                                 TabsterEnvironment.GetVersion().ToString(TabsterVersionFormatFlags.BuildString | TabsterVersionFormatFlags.Truncated));
#if PORTABLE
            Text = Text.Replace("Build", "Portable Build");
#endif
            InitAspectGetters();

            UpdateSortColumnMenu(true);

            //tabviewermanager events
            TablatureViewForm.GetInstance(this).TabClosed += TabHandler_OnTabClosed;

            recentlyViewedMenuItem.MaxDisplayItems   = Settings.Default.MaxRecentItems;
            recentlyViewedMenuItem.ClearItemClicked += recentlyViewedMenuItem_OnClearItemClicked;

            previewToolStrip.Renderer = new ToolStripRenderer();

            if (Settings.Default.ClientState == FormWindowState.Maximized)
            {
                WindowState = FormWindowState.Maximized;
            }
            else
            {
                Size = Settings.Default.ClientSize;
            }

            ToggleEmptyLibraryOverlay(listViewLibrary, true);
            ToggleEmptyLibraryOverlay(listViewSearch, true);

            PreviewEditor.Font       = TablatureFontManager.GetFont();
            searchPreviewEditor.Font = TablatureFontManager.GetFont();
        }
 public RecentFilesManager(TabsterDatabaseHelper databaseHelper, TabsterFileProcessor <TablatureFile> fileProcessor, int maxItems)
 {
     _databaseHelper = databaseHelper;
     _fileProcessor  = fileProcessor;
     _maxItems       = maxItems;
 }
 public PlaylistManager(TabsterDatabaseHelper databaseHelper, TabsterFileProcessor<TablatureFile> fileProcessor)
 {
     _databaseHelper = databaseHelper;
     _fileProcessor = fileProcessor;
 }
 public RecentFilesManager(TabsterDatabaseHelper databaseHelper, TabsterFileProcessor<TablatureFile> fileProcessor, int maxItems)
 {
     _databaseHelper = databaseHelper;
     _fileProcessor = fileProcessor;
     _maxItems = maxItems;
 }
 public PlaylistManager(TabsterDatabaseHelper databaseHelper, TabsterFileProcessor <TablatureFile> fileProcessor)
 {
     _databaseHelper = databaseHelper;
     _fileProcessor  = fileProcessor;
 }
Exemple #10
0
 public LibraryManager(TabsterDatabaseHelper databaseHelper, TabsterFileProcessor <TablatureFile> fileProcessor,
                       string tablatureDirectory) : base(tablatureDirectory, fileProcessor)
 {
     _databaseHelper = databaseHelper;
     _fileProcessor  = fileProcessor;
 }