Ejemplo n.º 1
0
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            var id = navigationContext.Parameters["id"];

            if (!string.IsNullOrEmpty(id))
            {
                var fileset = _filesetService.Filesets.FirstOrDefault(fs => fs.Id.ToString() == id);

                if (fileset != null)
                {
                    Fileset = new FilesetViewModel(fileset);
                    ActivityLog = _activityLogService.GetEvents(fileset.Id);
                }

                _filesetService.Filesets.Select(fs => fs.Category)
                    .Distinct()
                    .Where(c => !string.IsNullOrEmpty(c))
                    .ForEach(_categories.Add);
            }
        }
Ejemplo n.º 2
0
        private void ExecuteRemoveFileset(FilesetViewModel model)
        {
            var fs = _filesetService.Filesets.FirstOrDefault(f => f.Id == model.Id);

            if (fs != null)
            {
                _filesetService
                    .Remove(fs)
                    .ContinueWith(task =>
                    {
                        Trace.WriteLineIf(task.IsFaulted, task.Exception);
                    });
            }
        }
Ejemplo n.º 3
0
        private void ExecuteExportFileset(FilesetViewModel fileset)
        {
            var dialog = new SaveFileDialog();
            dialog.Title = "Select location to export the fileset";
            dialog.FileName = fileset.Id + ".fis";

            if (dialog.ShowDialog() == true)
            {
                var fs = _filesetService.Filesets.FirstOrDefault(fvm => fvm.Id == fileset.Id);

                if (fs != null)
                {
                    _filesetService
                        .Save(fs, () => new FileStream(dialog.FileName, FileMode.Create))
                        .ContinueWith(task =>
                        {
                            Trace.WriteLineIf(task.IsFaulted, task);
                        });
                }
            }
        }
Ejemplo n.º 4
0
 private bool CanExecuteRemoveFileset(FilesetViewModel model)
 {
     return model != null;
 }
Ejemplo n.º 5
0
 private bool CanExecuteExportFileset(FilesetViewModel fileset)
 {
     return fileset != null;
 }
Ejemplo n.º 6
0
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            _navigationService = navigationContext.NavigationService;

            foreach (var fileset in _filesetService.Filesets)
            {
                var viewModel = new FilesetViewModel(fileset);
                viewModel.PropertyChanged += OnFilesetPropertyChanged;
                _filesets.Add(viewModel);
            }

            _filesetAdded = _filesetService
                .FilesetAdded
                .ObserveOnDispatcher()
                .Subscribe(fileset =>
                {
                    var viewModel = new FilesetViewModel(fileset);
                    viewModel.PropertyChanged += OnFilesetPropertyChanged;
                    _filesets.Add(viewModel);
                    Filesets.MoveCurrentTo(viewModel);
                });

            _filesetRemoved = _filesetService
                .FilesetRemoved
                .ObserveOnDispatcher()
                .Subscribe(fileset =>
                {
                    var fs = _filesets.FirstOrDefault(fvm => fvm.Id == fileset.Id);

                    if (fs != null)
                    {
                        fs.PropertyChanged -= OnFilesetPropertyChanged;
                        _filesets.Remove(fs);
                    }

                    if (Filesets.IsEmpty)
                    {
                        _navigationService.Region.RegionManager.Regions[AppRegions.MainRegion]
                            .RequestNavigate(typeof(IWelcomeView).Name);
                    }
                });

            Filesets = CollectionViewSource.GetDefaultView(_filesets);
            Filesets.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
            Filesets.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Ascending));
            Filesets.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            Filesets.CurrentChanged += CurrentFilesetChanged;
            Filesets.MoveCurrentTo(null);
            Filesets.MoveCurrentToFirst();
        }