public ConflictResolutionViewModel(
            ISyncthingManager syncthingManager,
            IConflictFileManager conflictFileManager,
            IProcessStartProvider processStartProvider,
            IConflictFileWatcher conflictFileWatcher,
            IWindowManager windowManager,
            IConfigurationProvider configurationProvider)
        {
            this.syncthingManager = syncthingManager;
            this.conflictFileManager = conflictFileManager;
            this.processStartProvider = processStartProvider;
            this.conflictFileWatcher = conflictFileWatcher;
            this.configurationProvider = configurationProvider;
            this.windowManager = windowManager;

            this.DeleteToRecycleBin = this.configurationProvider.Load().ConflictResolverDeletesToRecycleBin;
            this.Bind(s => s.DeleteToRecycleBin, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.ConflictResolverDeletesToRecycleBin = e.NewValue));

            this.Conflicts.CollectionChanged += (o, e) =>
            {
                if ((e.Action == NotifyCollectionChangedAction.Add && (e.OldItems?.Count ?? 0) == 0) ||
                    (e.Action == NotifyCollectionChangedAction.Remove && (e.NewItems?.Count ?? 0) == 0) ||
                    (e.Action == NotifyCollectionChangedAction.Reset))
                {
                    this.NotifyOfPropertyChange(nameof(this.Conflicts));
                    this.NotifyOfPropertyChange(nameof(this.IsLoadingAndNoConflictsFound));
                    this.NotifyOfPropertyChange(nameof(this.HasFinishedLoadingAndNoConflictsFound));

                    if (this.SelectedConflict == null && this.Conflicts.Count > 0)
                        this.SelectedConflict = this.Conflicts[0];
                }
            };
        }
        public ConflictResolutionViewModel(
            ISyncthingManager syncthingManager,
            IConflictFileManager conflictFileManager,
            IProcessStartProvider processStartProvider,
            IConflictFileWatcher conflictFileWatcher,
            IWindowManager windowManager,
            IConfigurationProvider configurationProvider)
        {
            this.syncthingManager      = syncthingManager;
            this.conflictFileManager   = conflictFileManager;
            this.processStartProvider  = processStartProvider;
            this.conflictFileWatcher   = conflictFileWatcher;
            this.configurationProvider = configurationProvider;
            this.windowManager         = windowManager;

            this.DeleteToRecycleBin = this.configurationProvider.Load().ConflictResolverDeletesToRecycleBin;
            this.Bind(s => s.DeleteToRecycleBin, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.ConflictResolverDeletesToRecycleBin = e.NewValue));

            this.Conflicts.CollectionChanged += (o, e) =>
            {
                if ((e.Action == NotifyCollectionChangedAction.Add && (e.OldItems?.Count ?? 0) == 0) ||
                    (e.Action == NotifyCollectionChangedAction.Remove && (e.NewItems?.Count ?? 0) == 0) ||
                    (e.Action == NotifyCollectionChangedAction.Reset))
                {
                    this.NotifyOfPropertyChange(nameof(this.Conflicts));
                    this.NotifyOfPropertyChange(nameof(this.IsLoadingAndNoConflictsFound));
                    this.NotifyOfPropertyChange(nameof(this.HasFinishedLoadingAndNoConflictsFound));

                    if (this.SelectedConflict == null && this.Conflicts.Count > 0)
                    {
                        this.SelectedConflict = this.Conflicts[0];
                    }
                }
            };
        }
Exemple #3
0
        public ConflictFileWatcher(
            ISyncthingManager syncthingManager,
            IConflictFileManager conflictFileManager,
            IFileWatcherFactory fileWatcherFactory)
        {
            this.syncthingManager    = syncthingManager;
            this.conflictFileManager = conflictFileManager;
            this.fileWatcherFactory  = fileWatcherFactory;

            this.syncthingManager.StateChanged           += this.SyncthingStateChanged;
            this.syncthingManager.Folders.FoldersChanged += this.FoldersChanged;

            this.backoffTimer = new System.Timers.Timer() // Interval will be set when it's started
            {
                AutoReset = false,
            };
            this.backoffTimer.Elapsed += (o, e) =>
            {
                this.RefreshConflictedFiles();
            };
        }
        public ConflictFileWatcher(
            ISyncthingManager syncthingManager,
            IConflictFileManager conflictFileManager,
            IFileWatcherFactory fileWatcherFactory)
        {
            this.syncthingManager = syncthingManager;
            this.conflictFileManager = conflictFileManager;
            this.fileWatcherFactory = fileWatcherFactory;

            this.syncthingManager.StateChanged += this.SyncthingStateChanged;
            this.syncthingManager.Folders.FoldersChanged += this.FoldersChanged;

            this.backoffTimer = new System.Timers.Timer() // Interval will be set when it's started
            {
                AutoReset = false,
            };
            this.backoffTimer.Elapsed += (o, e) =>
            {
                this.RefreshConflictedFiles();
            };
        }