public NotifyIconViewModel(
            IWindowManager windowManager,
            ISyncThingManager syncThingManager,
            Func<SettingsViewModel> settingsViewModelFactory,
            IProcessStartProvider processStartProvider,
            FileTransfersTrayViewModel fileTransfersViewModel)
        {
            this.windowManager = windowManager;
            this.syncThingManager = syncThingManager;
            this.settingsViewModelFactory = settingsViewModelFactory;
            this.processStartProvider = processStartProvider;
            this.FileTransfersViewModel = fileTransfersViewModel;

            this.syncThingManager.StateChanged += (o, e) =>
            {
                this.SyncThingState = e.NewState;
                if (e.NewState != SyncThingState.Running)
                    this.SyncThingSyncing = false; // Just make sure we reset this...
            };
            this.SyncThingState = this.syncThingManager.State;

            this.syncThingManager.TotalConnectionStatsChanged += (o, e) =>
            {
                var stats = e.TotalConnectionStats;
                this.SyncThingSyncing = stats.InBytesPerSecond > 0 || stats.OutBytesPerSecond > 0;
            };

            this.syncThingManager.DataLoaded += (o, e) =>
            {
                this.Folders = new BindableCollection<FolderViewModel>(this.syncThingManager.Folders.FetchAll()
                    .Select(x => new FolderViewModel(x, this.processStartProvider))
                    .OrderBy(x => x.FolderId));
            };
        }
예제 #2
0
        public NotifyIconViewModel(
            IWindowManager windowManager,
            ISyncthingManager syncthingManager,
            Func<SettingsViewModel> settingsViewModelFactory,
            IProcessStartProvider processStartProvider,
            IAlertsManager alertsManager,
            FileTransfersTrayViewModel fileTransfersViewModel)
        {
            this.windowManager = windowManager;
            this.syncthingManager = syncthingManager;
            this.settingsViewModelFactory = settingsViewModelFactory;
            this.processStartProvider = processStartProvider;
            this.alertsManager = alertsManager;
            this.FileTransfersViewModel = fileTransfersViewModel;

            this.syncthingManager.StateChanged += this.StateChanged;
            this.SyncthingState = this.syncthingManager.State;

            this.syncthingManager.TotalConnectionStatsChanged += this.TotalConnectionStatsChanged;
            this.syncthingManager.DataLoaded += this.DataLoaded;

            this.alertsManager.AlertsStateChanged += this.AlertsStateChanged;
        }