コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionViewModel{T}" /> class.
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="platformProvider">The platform provider.</param>
        /// <param name="eventAggregator">The event aggregator.</param>
        /// <param name="buildTracker">The build tracker.</param>
        /// <param name="projectFactory">The project factory.</param>
        /// <param name="removeConnectionFactory">The remove connection factory.</param>
        /// <param name="editConnectionFactory">The edit connection factory.</param>
        /// <param name="settings">The settings.</param>
        public ConnectionViewModel(
            IApp application,
            IPlatformProvider platformProvider,
            IEventAggregator eventAggregator,
            IBuildTracker buildTracker,
            IProjectViewModelFactory projectFactory,
            IRemoveConnectionViewModelFactory removeConnectionFactory,
            IEditConnectionViewModelFactory <T> editConnectionFactory,
            T settings)
            : base(platformProvider)
        {
            Ensure.That(application).IsNotNull();
            Ensure.That(eventAggregator).IsNotNull();
            Ensure.That(buildTracker).IsNotNull();
            Ensure.That(projectFactory).IsNotNull();
            Ensure.That(removeConnectionFactory).IsNotNull();
            Ensure.That(editConnectionFactory).IsNotNull();
            Ensure.That(settings).IsNotNull();

            _application             = application;
            _eventAggregator         = eventAggregator;
            _projectFactory          = projectFactory;
            _removeConnectionFactory = removeConnectionFactory;
            _editConnectionFactory   = editConnectionFactory;
            Settings    = settings;
            _isBusy     = true;
            _isErrored  = false;
            DisplayName = Properties.Resources.Connection_View;
            KeepAlive   = true;

            WeakEventManager <IBuildTracker, BuildTrackerConnectionErrorEventArgs> .AddHandler(buildTracker, nameof(buildTracker.ConnectionError), BuildTrackerConnectionError);

            WeakEventManager <IBuildTracker, BuildTrackerConnectionProgressEventArgs> .AddHandler(buildTracker, nameof(buildTracker.ConnectionProgressChanged), BuildTrackerConnectionProgressChanged);

            _projects = new BindableCollection <IProjectViewModel>();

            _filteredProjects = new CollectionViewSource
            {
                Source = _projects
            };

            _filteredProjects.Filter += (sender, e) =>
            {
                var project = (IProjectViewModel)e.Item;

                e.Accepted = _matches?.Contains(project) ?? true;
            };

            FilteredProjects = _filteredProjects.View;
        }
コード例 #2
0
        public ProjectCollectionViewModel(
            [NotNull] IProjectViewModelFactory projectViewModelFactory,
            [NotNull] IStatusFullModel statusModel,
            [NotNull] IFileSearch fileSearch,
            [NotNull] IConfigurationService configurationService,
            [NotNull] IDelayService delayService)
        {
            Guard.NotNull(statusModel, nameof(statusModel));
            Guard.NotNull(projectViewModelFactory, nameof(projectViewModelFactory));
            Guard.NotNull(fileSearch, nameof(fileSearch));
            Guard.NotNull(configurationService, nameof(configurationService));
            Guard.NotNull(delayService, nameof(delayService));

            this.statusModel             = statusModel;
            this.projectViewModelFactory = projectViewModelFactory;
            this.fileSearch           = fileSearch;
            this.configurationService = configurationService;
            this.delayService         = delayService;

            Projects   = new ObservableCollection <ProjectViewModel>();
            Initialize = new CapturingExceptionAsyncCommand(async _ => await LoadProjectsAsync());
        }