public void OpenBinder(string fileName) { try { var name = new FileInfo(fileName); _activeBinder = new MagicBinderViewModel(name.Name.Substring(0, name.Name.Length - name.Extension.Length), _notificationCenter); _activeBinder.ReadFile(fileName); _settings.LoadedBinder = name.GetRelativePathFrom(new DirectoryInfo(PathHelper.UserDataFolder)); SaveSettings(); _notificationCenter.FireNotification(LogLevel.Info, string.Format("Opened binder '{0}'.", _activeBinder.Name)); } catch (Exception error) { _activeBinder = null; _notificationCenter.FireNotification(LogLevel.Error, string.Format("Error opening binder '{0}': {1}", _activeBinder.Name, error.Message)); } finally { RaisePropertyChanged(() => CardsInBinder); RaisePropertyChanged(() => IsActiveBinder); RaisePropertyChanged(() => ActiveBinder); } }
public CardLookupSetSourceActiveBinder(MagicBinderViewModel binder) { var allSets = binder.Cards .Select(c => c.SetCode) .Distinct() .Select(s => StaticMagicData.SetDefinitionsBySetCode[s]) .OrderByDescending(s => s.ReleaseDateTime) .ThenBy(s => s.Name) .ToList(); allSets.Insert(0, _allSets); AvailableSearchSets = allSets; SearchSet = _allSets; }
public void CreateAndSetNewBinder(string fileName) { var name = new FileInfo(fileName); _activeBinder = new MagicBinderViewModel(name.Name.Substring(0, name.Name.Length - name.Extension.Length), _notificationCenter); _activeBinder.WriteFile(fileName); _settings.LoadedBinder = name.GetRelativePathFrom(new DirectoryInfo(PathHelper.UserDataFolder)); SaveSettings(); RaisePropertyChanged(() => CardsInBinder); RaisePropertyChanged(() => IsActiveBinder); RaisePropertyChanged(() => ActiveBinder); _notificationCenter.FireNotification(null, string.Format("Created binder '{0}'.", _activeBinder.Name)); }
public void LoadBinder(string fileName) { var fileInfo = new FileInfo(fileName); if (!fileInfo.Exists) { _notificationCenter.FireNotification(null, string.Format("Binder file '{0}' does not exist.", fileInfo.Name)); return; } _activeBinder = new MagicBinderViewModel(_notificationCenter); _activeBinder.ReadFile(fileName); _settings.LoadedBinder = fileInfo.GetRelativePathFrom(new DirectoryInfo(PathHelper.UserDataFolder)); SaveSettings(); RaisePropertyChanged(() => CardsInBinder); RaisePropertyChanged(() => IsActiveBinder); RaisePropertyChanged(() => ActiveBinder); _notificationCenter.FireNotification(null, string.Format("Loaded binder '{0}'.", _activeBinder.Name)); }
public ActiveBinderDataSource(MagicBinderViewModel activeBinder) { _activeBinder = activeBinder; }