public void addUIState(IEnumerable <MediaItem> items) { if (items.Count() == 0) { return; } UIMediaCollection.EnterWriteLock(); if (DebugOutput) { Logger.Log.Info("begin add event: " + items.ElementAt(0).Location); } try { UIMediaCollection.AddRange(items); } finally { if (DebugOutput) { Logger.Log.Info("end add event: " + items.ElementAt(0).Location); } UIMediaCollection.ExitWriteLock(); fireEvents(MediaStateChangedAction.Add, items); } }
public void renameUIState(IEnumerable <MediaItem> oldItems, IEnumerable <String> newLocations) { if (oldItems.Count() == 0 || newLocations.Count() == 0) { return; } bool success = false; UIMediaCollection.EnterReadLock(); if (DebugOutput) { Logger.Log.Info("begin rename event " + oldItems.ElementAt(0).Location + " " + newLocations.ElementAt(0)); } try { success = UIMediaCollection.RenameRange(oldItems, newLocations); } finally { if (DebugOutput) { Logger.Log.Info("end rename event " + oldItems.ElementAt(0).Location + " " + newLocations.ElementAt(0)); } UIMediaCollection.ExitReadLock(); // redraw the UI since sorting order might have changed fireEvents(MediaStateChangedAction.Modified, null); } }
public void removeUIState(IEnumerable <MediaItem> removeItems) { if (removeItems.Count() == 0) { return; } List <MediaItem> removed = new List <MediaItem>(); UIMediaCollection.EnterWriteLock(); if (DebugOutput) { Logger.Log.Info("begin remove event: " + removeItems.ElementAt(0).Location); } try { removed = UIMediaCollection.RemoveRange(removeItems); } finally { if (DebugOutput) { Logger.Log.Info("end remove event: " + removeItems.ElementAt(0).Location); } UIMediaCollection.ExitWriteLock(); fireEvents(MediaStateChangedAction.Remove, removed); } }
public void clearUIState(String stateInfo, DateTime stateDateTime, MediaStateType stateType) { UIMediaCollection.EnterWriteLock(); try { UIMediaCollection.Clear(); MediaStateInfo = stateInfo; MediaStateDateTime = stateDateTime; MediaStateType = stateType; } finally { UIMediaCollection.ExitWriteLock(); fireEvents(MediaStateChangedAction.Clear, null); } }
public override void changedUIState(IEnumerable <MediaItem> changedItems) { foreach (MediaFileItem item in changedItems) { FileInfo info = new FileInfo(item.Location); info.Refresh(); if (info.Exists) { UIMediaCollection.EnterWriteLock(); try { UIMediaCollection.Reload(item); } finally { UIMediaCollection.ExitWriteLock(); } } } }