Пример #1
0
        public NotifyIconViewModel(
            IWindowManager windowManager,
            IFocusWindowProvider focusWindowProvider,
            ISyncthingManager syncthingManager,
            Func <SettingsViewModel> settingsViewModelFactory,
            IProcessStartProvider processStartProvider,
            IAlertsManager alertsManager,
            FileTransfersTrayViewModel fileTransfersViewModel,
            IConfigurationProvider configurationProvider)
        {
            this.windowManager            = windowManager;
            this.focusWindowProvider      = focusWindowProvider;
            this.syncthingManager         = syncthingManager;
            this.settingsViewModelFactory = settingsViewModelFactory;
            this.processStartProvider     = processStartProvider;
            this.alertsManager            = alertsManager;
            this.FileTransfersViewModel   = fileTransfersViewModel;
            this.configurationProvider    = configurationProvider;

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

            this.syncthingManager.TotalConnectionStatsChanged += this.TotalConnectionStatsChanged;
            this.syncthingManager.Folders.FoldersChanged      += this.FoldersChanged;
            this.syncthingManager.Folders.SyncStateChanged    += this.FolderSyncStateChanged;


            this.alertsManager.AlertsStateChanged += this.AlertsStateChanged;

            this.configurationProvider.ConfigurationChanged += this.ConfigurationChanged;
            this.iconAnimationmode = this.configurationProvider.Load().IconAnimationMode;
        }
Пример #2
0
        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));
            };
        }