public void FromXML(XElement xmlElement) { LibraryPath = XMLHelper.GetSingleValue(xmlElement, "Path"); Name = XMLHelper.GetSingleValue(xmlElement, "Name"); string scannerIdentifier = XMLHelper.GetSingleValue(xmlElement, "LibraryScanner"); if (string.IsNullOrEmpty(scannerIdentifier)) { Scanner = LibraryScannerFactory.GetDefault(); } else { Scanner = LibraryScannerFactory.GetScanner(scannerIdentifier); } }
private void LibraryXmlFileChanged(object sender, EventArgs e) { // stop any existing scanner if (iScanner != null) { iScanner.Stop(); } // change the root data to show updating iRoot.Data = new ContainerDataMessage("Updating...", iSupport, XmlInserted, iInstallPath); // rescan the new xml file iScanner = new LibraryScanner(); iScanner.Start(iUserOptions.LibraryXmlFile, this.LibraryScannerFinished, this.LibraryScannerError); // kill off the old file watcher if (iFileWatcher != null) { iFileWatcher.EnableRaisingEvents = false; iFileWatcher.Dispose(); iFileWatcher = null; } // create a new file watcher try { string path = Path.GetDirectoryName(iUserOptions.LibraryXmlFile); string file = Path.GetFileName(iUserOptions.LibraryXmlFile); iFileWatcher = new FileSystemWatcher(); iFileWatcher.NotifyFilter = NotifyFilters.LastWrite; iFileWatcher.Path = path; iFileWatcher.Filter = file; iFileWatcher.IncludeSubdirectories = false; iFileWatcher.Changed += LibraryXmlFileUpdated; iFileWatcher.EnableRaisingEvents = true; } catch (Exception) { if (iFileWatcher != null) { iFileWatcher.Dispose(); iFileWatcher = null; } } }
/// <summary> /// Adds a library with the given parameters to the collection and saves it to the metadata folder. /// </summary> /// <param name="name">Name of the library</param> /// <param name="destination">path to the library folder</param> /// <param name="scanner">the scanner object used to scan the library folder</param> public Library AddLibrary(string name, string destination, LibraryScanner scanner) { Library library = new Library(GetNewID(), Path.Combine(MetadataPath, Guid.NewGuid().ToString())) { Name = name, LibraryPath = destination, Scanner = scanner }; Libraries.Add(library.ID, library); XMLHelper.SaveToXML(library, Path.Combine(library.MetadataFolder, ConfigurationManager.AppSettings.Get("library_metadata_filename") + "." + ConfigurationManager.AppSettings.Get("metadata_extensions"))); library.ScanLibrary(); return(library); }
void OnMainWindowShown(object sender, EventArgs e) { if (DesignMode) { return; } var app = AppSettings.Instance; InitializeLog(); SearchEngine.Initialize(app.Providers.Keys.Where(k => app.Providers[k].Enabled)); string[] stopList = File.ReadAllLines(AppSettings.StopListPath) .Select(s => s.Trim()) .Where(s => !string.IsNullOrWhiteSpace(s)) .ToArray(); Library.Initialize(AppSettings.GetFolderPath(), stopList); InitializeSettings(); Playlist.Initialize(); DownloadQueue.Initialize(); PostProcessingQueue.Initialize(); uiDownloadQueue.Initialize(DownloadQueue.Instance); uiPostProcessingQueue.Initialize(PostProcessingQueue.Instance); Action <QueueItem> enqueue = r => uiPostProcessingQueue.Enqueue(r.NewId()); DownloadQueue.Instance.Completed += (s, evt) => BeginInvoke(new Action(() => enqueue(evt.Data))); if (app.UpdateLibraryAfterDownload) { PostProcessingQueue.Instance.Completed += (s, evt) => LibraryScanner.UpdateLibrary(); } uiCurrentResult.SetResult(UiSettings.Instance.CurrentTrack); StartSearch(); DownloadQueue.Start(); PostProcessingQueue.Start(); InitializePlaylist(); InitializeSuggestions(); SuggestionScanner.Suggested += OnScannerSuggestions; SuggestionScanner.Start(app.DelaySuggestionsScan, app.ScanSuggestionsInterval); LibraryScanner.Start(UserSettings.Instance.LibraryFolder, app.TagSeparator, app.DelayLibraryScan, app.ScanLibraryInterval); ShowScrollBar(uiResults.Handle, SbVert, true); ShowScrollBar(uiPlaylist.Handle, SbVert, true); initializing = false; }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var errorListScanner = new ErrorListScanner(_dte); var archiveResolution = new LibraryArchiveResolution(); var statusBar = ServiceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; var allResolutions = new List<Resolution>(); var allUnresolved = new List<string>(); foreach (var project in errorListScanner.Projects) { var archives = archiveResolution.GetLibraryArchives(project, statusBar); var unresolvedSymbols = errorListScanner.GetUnresolvedSymbols(project); var libraryScanner = new LibraryScanner(unresolvedSymbols, archives); libraryScanner.Scan(statusBar); allResolutions.AddRange(libraryScanner.GetResolutions(project)); allUnresolved.AddRange(libraryScanner.GetUnresolvedSymbols()); } AutoLibWindow window = package.FindToolWindow(typeof (AutoLibWindow), 0, true) as AutoLibWindow; if (window?.Frame == null) throw new NotSupportedException("Cannot create tool window"); window.WindowControl.SetItemSource(allResolutions.Select(DisplayItem.Create).ToList()); window.WindowControl.SetUnresolved(allUnresolved); IVsWindowFrame windowFrame = (IVsWindowFrame) window.Frame; window.WindowControl.SetFrame(windowFrame); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); }
void OnSearchUpdateLibraryClicked(object sender, LinkLabelLinkClickedEventArgs e) { LibraryScanner.UpdateLibrary(); }