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; }
public ConfigurationApplicator( IConfigurationProvider configurationProvider, IApplicationPathsProvider pathsProvider, INotifyIconManager notifyIconManager, ISyncthingManager syncthingManager, IAutostartProvider autostartProvider, IWatchedFolderMonitor watchedFolderMonitor, IUpdateManager updateManager, IConflictFileWatcher conflictFileWatcher, IAlertsManager alertsManager, IMeteredNetworkManager meteredNetworkManager) { this.configurationProvider = configurationProvider; this.configurationProvider.ConfigurationChanged += this.ConfigurationChanged; this.pathsProvider = pathsProvider; this.notifyIconManager = notifyIconManager; this.syncthingManager = syncthingManager; this.autostartProvider = autostartProvider; this.watchedFolderMonitor = watchedFolderMonitor; this.updateManager = updateManager; this.conflictFileWatcher = conflictFileWatcher; this.alertsManager = alertsManager; this.meteredNetworkManager = meteredNetworkManager; this.syncthingManager.DataLoaded += this.OnDataLoaded; this.updateManager.VersionIgnored += this.VersionIgnored; }
public AboutViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IConfigurationProvider configurationProvider, IUpdateManager updateManager, Func <ThirdPartyComponentsViewModel> thirdPartyComponentsViewModelFactory, IProcessStartProvider processStartProvider) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.configurationProvider = configurationProvider; this.updateManager = updateManager; this.thirdPartyComponentsViewModelFactory = thirdPartyComponentsViewModelFactory; this.processStartProvider = processStartProvider; this.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(3); this.HomepageUrl = AppSettings.Instance.HomepageUrl; this.syncthingManager.DataLoaded += this.SyncthingDataLoaded; this.LoadSyncthingVersion(); var configuration = this.configurationProvider.Load(); this.HaveDonated = configuration.HaveDonated; this.CheckForNewerVersionAsync(); }
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]; } }; }
public static async Task StartWithErrorDialogAsync(this ISyncthingManager syncthingManager, IWindowManager windowManager) { try { await syncthingManager.StartAsync(); } catch (Win32Exception e) { if (e.ErrorCode != -2147467259) { throw; } // Possibly "This program is blocked by group policy. For more information, contact your system administrator" caused // by e.g. CryptoLocker? windowManager.ShowMessageBox( Localizer.F(Resources.Dialog_SyncthingBlockedByGroupPolicy_Message, e.Message, syncthingManager.ExecutablePath), Resources.Dialog_SyncthingBlockedByGroupPolicy_Title, MessageBoxButton.OK, icon: MessageBoxImage.Error); } catch (SyncthingDidNotStartCorrectlyException e) { windowManager.ShowMessageBox( Localizer.F(Resources.Dialog_SyncthingDidNotStart_Message, e.Message), Resources.Dialog_SyncthingDidNotStart_Title, MessageBoxButton.OK, icon: MessageBoxImage.Error); } }
public ConfigurationApplicator( IConfigurationProvider configurationProvider, IApplicationPathsProvider pathsProvider, INotifyIconManager notifyIconManager, ISyncthingManager syncthingManager, IAutostartProvider autostartProvider, IWatchedFolderMonitor watchedFolderMonitor, IUpdateManager updateManager, IConflictFileWatcher conflictFileWatcher, IAlertsManager alertsManager, IMeteredNetworkManager meteredNetworkManager, IPathTransformer pathTransformer) { this.configurationProvider = configurationProvider; this.configurationProvider.ConfigurationChanged += this.ConfigurationChanged; this.pathsProvider = pathsProvider; this.notifyIconManager = notifyIconManager; this.syncthingManager = syncthingManager; this.autostartProvider = autostartProvider; this.watchedFolderMonitor = watchedFolderMonitor; this.updateManager = updateManager; this.conflictFileWatcher = conflictFileWatcher; this.alertsManager = alertsManager; this.meteredNetworkManager = meteredNetworkManager; this.pathTransformer = pathTransformer; this.syncthingManager.Folders.FoldersChanged += this.FoldersChanged; this.updateManager.VersionIgnored += this.VersionIgnored; }
public WatchedFolderMonitor(ISyncthingManager syncthingManager, IDirectoryWatcherFactory directoryWatcherFactory) { this.syncthingManager = syncthingManager; this.directoryWatcherFactory = directoryWatcherFactory; this.syncthingManager.Folders.FoldersChanged += this.FoldersChanged; this.syncthingManager.Folders.SyncStateChanged += this.FolderSyncStateChanged; this.syncthingManager.StateChanged += this.StateChanged; }
public FileTransfersTrayViewModel(ISyncthingManager syncthingManager, IProcessStartProvider processStartProvider) { this.syncthingManager = syncthingManager; this.processStartProvider = processStartProvider; this.CompletedTransfers = new BindableCollection <FileTransferViewModel>(); this.InProgressTransfers = new BindableCollection <FileTransferViewModel>(); this.CompletedTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasCompletedTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; this.InProgressTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasInProgressTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; }
public BarAlertsViewModel( IAlertsManager alertsManager, ISyncthingManager syncthingManager, Func <ConflictResolutionViewModel> conflictResolutionViewModelFactory, IWindowManager windowManager) { this.alertsManager = alertsManager; this.syncthingManager = syncthingManager; this.conflictResolutionViewModelFactory = conflictResolutionViewModelFactory; this.windowManager = windowManager; }
public AlertsManager(ISyncthingManager syncthingManager, IConflictFileWatcher conflictFileWatcher, IMeteredNetworkManager meteredNetworkManager) { this.syncthingManager = syncthingManager; this.conflictFileWatcher = conflictFileWatcher; this.meteredNetworkManager = meteredNetworkManager; this.eventDispatcher = new SynchronizedEventDispatcher(this); this.syncthingManager.Folders.FolderErrorsChanged += this.FolderErrorsChanged; this.conflictFileWatcher.ConflictedFilesChanged += this.ConflictFilesChanged; this.meteredNetworkManager.PausedDevicesChanged += this.PausedDevicesChanged; }
public NotifyIconManager( IViewManager viewManager, NotifyIconViewModel viewModel, IApplicationState application, IApplicationWindowState applicationWindowState, ISyncthingManager syncthingManager, IConnectedEventDebouncer connectedEventDebouncer) { this.viewManager = viewManager; this.viewModel = viewModel; this.application = application; this.applicationWindowState = applicationWindowState; this.syncthingManager = syncthingManager; this.connectedEventDebouncer = connectedEventDebouncer; this.taskbarIcon = (TaskbarIcon)this.application.FindResource("TaskbarIcon"); this.taskbarIcon.TrayBalloonTipClicked += (o, e) => { this.applicationWindowState.EnsureInForeground(); }; // Need to hold off until after the application is started, otherwise the ViewManager won't be set this.application.Startup += this.ApplicationStartup; this.applicationWindowState.RootWindowActivated += this.RootViewModelActivated; this.applicationWindowState.RootWindowDeactivated += this.RootViewModelDeactivated; this.applicationWindowState.RootWindowClosed += this.RootViewModelClosed; this.viewModel.WindowOpenRequested += (o, e) => { this.applicationWindowState.EnsureInForeground(); }; this.viewModel.WindowCloseRequested += (o, e) => { // Always minimize, regardless of settings this.application.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.applicationWindowState.CloseToTray(); }; this.viewModel.ExitRequested += (o, e) => this.application.Shutdown(); this.syncthingManager.TransferHistory.FolderSynchronizationFinished += this.FolderSynchronizationFinished; this.syncthingManager.Devices.DeviceConnected += this.DeviceConnected; this.syncthingManager.Devices.DeviceDisconnected += this.DeviceDisconnected; this.syncthingManager.DeviceRejected += this.DeviceRejected; this.syncthingManager.FolderRejected += this.FolderRejected; this.connectedEventDebouncer.DeviceConnected += this.DebouncedDeviceConnected; }
public ShellViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IApplicationState application, IConfigurationProvider configurationProvider, ConsoleViewModel console, ViewerViewModel viewer, BarAlertsViewModel barAlerts, Func <SettingsViewModel> settingsViewModelFactory, Func <AboutViewModel> aboutViewModelFactory, Func <ConflictResolutionViewModel> confictResolutionViewModelFactory, IProcessStartProvider processStartProvider, IDonationManager donationManager) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.application = application; this.configurationProvider = configurationProvider; this.Console = console; this.Viewer = viewer; this.BarAlerts = barAlerts; this.settingsViewModelFactory = settingsViewModelFactory; this.aboutViewModelFactory = aboutViewModelFactory; this.confictResolutionViewModelFactory = confictResolutionViewModelFactory; this.processStartProvider = processStartProvider; this.DonationManager = donationManager; var configuration = this.configurationProvider.Load(); this.Console.ConductWith(this); this.Viewer.ConductWith(this); this.BarAlerts.ConductWith(this); this.syncthingManager.StateChanged += (o, e) => this.SyncthingState = e.NewState; this.syncthingManager.ProcessExitedWithError += (o, e) => this.ShowExitedWithError(); this.ConsoleHeight = configuration.SyncthingConsoleHeight; this.Bind(s => s.ConsoleHeight, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.SyncthingConsoleHeight = e.NewValue)); this.ShowConsole = configuration.SyncthingConsoleHeight > 0; this.Bind(s => s.ShowConsole, (o, e) => { this.ConsoleHeight = e.NewValue ? Configuration.DefaultSyncthingConsoleHeight : 0.0; }); this.Placement = configuration.WindowPlacement; this.Bind(s => s.Placement, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.WindowPlacement = e.NewValue)); }
public FileTransfersTrayViewModel(ISyncthingManager syncthingManager, IProcessStartProvider processStartProvider, NetworkGraphViewModel networkGraph) { this.syncthingManager = syncthingManager; this.processStartProvider = processStartProvider; this.syncthingManager.StateChanged += this.SyncthingStateChanged; this.NetworkGraph = networkGraph; this.NetworkGraph.ConductWith(this); this.CompletedTransfers = new BindableCollection <FileTransferViewModel>(); this.InProgressTransfers = new BindableCollection <FileTransferViewModel>(); this.CompletedTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasCompletedTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; this.InProgressTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasInProgressTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; }
public ConsoleViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IConfigurationProvider configurationProvider, Func <SettingsViewModel> settingsViewModelFactory) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.settingsViewModelFactory = settingsViewModelFactory; this.LogMessages = new Queue <string>(); // Display log messages 100ms after the previous message, or every 500ms if they're arriving thick and fast this.logMessagesBuffer = new Buffer <string>(TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(500)); this.logMessagesBuffer.Delivered += this.LogMessageDelivered; this.syncthingManager.MessageLogged += this.SyncthingMessageLogged; }
public ConsoleViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IConfigurationProvider configurationProvider, Func<SettingsViewModel> settingsViewModelFactory) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.settingsViewModelFactory = settingsViewModelFactory; this.LogMessages = new Queue<string>(); // Display log messages 100ms after the previous message, or every 500ms if they're arriving thick and fast this.logMessagesBuffer = new Buffer<string>(TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(500)); this.logMessagesBuffer.Delivered += this.LogMessageDelivered; this.syncthingManager.MessageLogged += this.SyncthingMessageLogged; }
public BarAlertsViewModel( IAlertsManager alertsManager, ISyncthingManager syncthingManager, Func <ConflictResolutionViewModel> conflictResolutionViewModelFactory, Func <IntelXeGraphicsAlertViewModel> intelXeGraphicsAlertViewModelFactory, IWindowManager windowManager, IConfigurationProvider configurationProvider, GraphicsCardDetector graphicsCardDetector) { this.alertsManager = alertsManager; this.syncthingManager = syncthingManager; this.conflictResolutionViewModelFactory = conflictResolutionViewModelFactory; this.intelXeGraphicsAlertViewModelFactory = intelXeGraphicsAlertViewModelFactory; this.windowManager = windowManager; this.configurationProvider = configurationProvider; this.graphicsCardDetector = graphicsCardDetector; }
public ShellViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IApplicationState application, IConfigurationProvider configurationProvider, ConsoleViewModel console, ViewerViewModel viewer, BarAlertsViewModel barAlerts, Func<SettingsViewModel> settingsViewModelFactory, Func<AboutViewModel> aboutViewModelFactory, Func<ConflictResolutionViewModel> confictResolutionViewModelFactory, IProcessStartProvider processStartProvider) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.application = application; this.configurationProvider = configurationProvider; this.Console = console; this.Viewer = viewer; this.BarAlerts = barAlerts; this.settingsViewModelFactory = settingsViewModelFactory; this.aboutViewModelFactory = aboutViewModelFactory; this.confictResolutionViewModelFactory = confictResolutionViewModelFactory; this.processStartProvider = processStartProvider; var configuration = this.configurationProvider.Load(); this.Console.ConductWith(this); this.Viewer.ConductWith(this); this.BarAlerts.ConductWith(this); this.syncthingManager.StateChanged += (o, e) => this.SyncthingState = e.NewState; this.syncthingManager.ProcessExitedWithError += (o, e) => this.ShowExitedWithError(); this.ConsoleHeight = configuration.SyncthingConsoleHeight; this.Bind(s => s.ConsoleHeight, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.SyncthingConsoleHeight = e.NewValue)); this.ShowConsole = configuration.SyncthingConsoleHeight > 0; this.Bind(s => s.ShowConsole, (o, e) => { this.ConsoleHeight = e.NewValue ? Configuration.DefaultSyncthingConsoleHeight : 0.0; }); this.Placement = configuration.WindowPlacement; this.Bind(s => s.Placement, (o, e) => this.configurationProvider.AtomicLoadAndSave(c => c.WindowPlacement = e.NewValue)); }
public NetworkGraphViewModel(ISyncthingManager syncthingManager) { this.syncthingManager = syncthingManager; this.OxyPlotModel.PlotAreaBorderColor = OxyColors.LightGray; this.xAxis = new LinearAxis() { Position = AxisPosition.Bottom, IsZoomEnabled = false, IsPanEnabled = false, IsAxisVisible = false, MajorGridlineColor = OxyColors.Gray, MajorGridlineStyle = LineStyle.Dash, }; this.OxyPlotModel.Axes.Add(this.xAxis); this.yAxis = new LinearAxis() { Position = AxisPosition.Right, IsZoomEnabled = false, IsPanEnabled = false, IsAxisVisible = false, AbsoluteMinimum = -1, // Leave a little bit of room for the line to draw }; this.OxyPlotModel.Axes.Add(this.yAxis); this.inboundSeries = new LineSeries() { Color = OxyColors.Red, }; this.OxyPlotModel.Series.Add(this.inboundSeries); this.outboundSeries = new LineSeries() { Color = OxyColors.Green, }; this.OxyPlotModel.Series.Add(this.outboundSeries); this.ResetToEmptyGraph(); this.Update(this.syncthingManager.TotalConnectionStats); this.syncthingManager.TotalConnectionStatsChanged += this.TotalConnectionStatsChanged; this.syncthingManager.StateChanged += this.SyncthingStateChanged; }
public MeteredNetworkManager(ISyncthingManager syncthingManager, INetworkCostManager costManager) { this.syncthingManager = syncthingManager; this.costManager = costManager; // We won't know whether or not Syncthing supports this until it loads if (this.costManager.IsSupported) { this.syncthingManager.StateChanged += this.SyncthingStateChanged; this.syncthingManager.DataLoaded += this.DataLoaded; this.syncthingManager.Devices.DevicePaused += this.DevicePaused; this.syncthingManager.Devices.DeviceResumed += this.DeviceResumed; this.syncthingManager.Devices.DeviceConnected += this.DeviceConnected; this.syncthingManager.Devices.DeviceDisconnected += this.DeviceDisconnected; this.costManager.NetworkCostsChanged += this.NetworkCostsChanged; this.costManager.NetworksChanged += this.NetworksChanged; } }
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 AboutViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IConfigurationProvider configurationProvider, IUpdateManager updateManager, Func<ThirdPartyComponentsViewModel> thirdPartyComponentsViewModelFactory, IProcessStartProvider processStartProvider) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.updateManager = updateManager; this.thirdPartyComponentsViewModelFactory = thirdPartyComponentsViewModelFactory; this.processStartProvider = processStartProvider; this.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(3); this.HomepageUrl = AppSettings.Instance.HomepageUrl; this.syncthingManager.DataLoaded += this.SyncthingDataLoaded; this.LoadSyncthingVersion(); this.CheckForNewerVersionAsync(); }
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; }
public ViewerViewModel( IWindowManager windowManager, ISyncthingManager syncthingManager, IConfigurationProvider configurationProvider, IProcessStartProvider processStartProvider, IApplicationPathsProvider pathsProvider) { this.windowManager = windowManager; this.syncthingManager = syncthingManager; this.processStartProvider = processStartProvider; this.configurationProvider = configurationProvider; this.pathsProvider = pathsProvider; var configuration = this.configurationProvider.Load(); this.zoomLevel = configuration.SyncthingWebBrowserZoomLevel; this.syncthingManager.StateChanged += this.SyncthingStateChanged; this.callback = new JavascriptCallbackObject(this.OpenFolder, this.BrowseFolderPath); this.SetCulture(configuration); configurationProvider.ConfigurationChanged += this.ConfigurationChanged; }
public NotifyIconManager( IViewManager viewManager, NotifyIconViewModel viewModel, IApplicationState application, IApplicationWindowState applicationWindowState, ISyncthingManager syncthingManager) { this.viewManager = viewManager; this.viewModel = viewModel; this.application = application; this.applicationWindowState = applicationWindowState; this.syncthingManager = syncthingManager; this.taskbarIcon = (TaskbarIcon)this.application.FindResource("TaskbarIcon"); // Need to hold off until after the application is started, otherwise the ViewManager won't be set this.application.Startup += this.ApplicationStartup; this.applicationWindowState.RootWindowActivated += this.RootViewModelActivated; this.applicationWindowState.RootWindowDeactivated += this.RootViewModelDeactivated; this.applicationWindowState.RootWindowClosed += this.RootViewModelClosed; this.viewModel.WindowOpenRequested += (o, e) => { this.applicationWindowState.EnsureInForeground(); }; this.viewModel.WindowCloseRequested += (o, e) => { // Always minimize, regardless of settings this.application.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.applicationWindowState.CloseToTray(); }; this.viewModel.ExitRequested += (o, e) => this.application.Shutdown(); this.syncthingManager.TransferHistory.FolderSynchronizationFinished += this.FolderSynchronizationFinished; this.syncthingManager.Devices.DeviceConnected += this.DeviceConnected; this.syncthingManager.Devices.DeviceDisconnected += this.DeviceDisconnected; }
public SettingsViewModel( IConfigurationProvider configurationProvider, IAutostartProvider autostartProvider, IWindowManager windowManager, IProcessStartProvider processStartProvider, IAssemblyProvider assemblyProvider, IApplicationState applicationState, IApplicationPathsProvider applicationPathsProvider, ISyncthingManager syncthingManager, IMeteredNetworkManager meteredNetworkManager) { this.configurationProvider = configurationProvider; this.autostartProvider = autostartProvider; this.windowManager = windowManager; this.processStartProvider = processStartProvider; this.assemblyProvider = assemblyProvider; this.applicationState = applicationState; this.applicationPathsProvider = applicationPathsProvider; this.syncthingManager = syncthingManager; this.MinimizeToTray = this.CreateBasicSettingItem(x => x.MinimizeToTray); this.NotifyOfNewVersions = this.CreateBasicSettingItem(x => x.NotifyOfNewVersions); this.CloseToTray = this.CreateBasicSettingItem(x => x.CloseToTray); this.ObfuscateDeviceIDs = this.CreateBasicSettingItem(x => x.ObfuscateDeviceIDs); this.UseComputerCulture = this.CreateBasicSettingItem(x => x.UseComputerCulture); this.UseComputerCulture.RequiresSyncTrayzorRestart = true; this.DisableHardwareRendering = this.CreateBasicSettingItem(x => x.DisableHardwareRendering); this.DisableHardwareRendering.RequiresSyncTrayzorRestart = true; this.EnableConflictFileMonitoring = this.CreateBasicSettingItem(x => x.EnableConflictFileMonitoring); this.EnableFailedTransferAlerts = this.CreateBasicSettingItem(x => x.EnableFailedTransferAlerts); this.PauseDevicesOnMeteredNetworks = this.CreateBasicSettingItem(x => x.PauseDevicesOnMeteredNetworks); this.PauseDevicesOnMeteredNetworksSupported = meteredNetworkManager.IsSupportedByWindows; this.ShowTrayIconOnlyOnClose = this.CreateBasicSettingItem(x => x.ShowTrayIconOnlyOnClose); this.ShowSynchronizedBalloonEvenIfNothingDownloaded = this.CreateBasicSettingItem(x => x.ShowSynchronizedBalloonEvenIfNothingDownloaded); this.ShowDeviceConnectivityBalloons = this.CreateBasicSettingItem(x => x.ShowDeviceConnectivityBalloons); this.ShowDeviceOrFolderRejectedBalloons = this.CreateBasicSettingItem(x => x.ShowDeviceOrFolderRejectedBalloons); this.IconAnimationModes = new BindableCollection <LabelledValue <IconAnimationMode> >() { LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_DataTransferring, Services.Config.IconAnimationMode.DataTransferring), LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_Syncing, Services.Config.IconAnimationMode.Syncing), LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_Disabled, Services.Config.IconAnimationMode.Disabled), }; this.IconAnimationMode = this.CreateBasicSettingItem(x => x.IconAnimationMode); this.StartSyncthingAutomatically = this.CreateBasicSettingItem(x => x.StartSyncthingAutomatically); this.SyncthingPriorityLevel = this.CreateBasicSettingItem(x => x.SyncthingPriorityLevel); this.SyncthingPriorityLevel.RequiresSyncthingRestart = true; this.SyncthingAddress = this.CreateBasicSettingItem(x => x.SyncthingAddress, new SyncthingAddressValidator()); this.SyncthingAddress.RequiresSyncthingRestart = true; this.CanReadAutostart = this.autostartProvider.CanRead; this.CanWriteAutostart = this.autostartProvider.CanWrite; if (this.autostartProvider.CanRead) { var currentSetup = this.autostartProvider.GetCurrentSetup(); this.StartOnLogon = currentSetup.AutoStart; this.StartMinimized = currentSetup.StartMinimized; } this.SyncthingCommandLineFlags = this.CreateBasicSettingItem( x => String.Join(" ", x.SyncthingCommandLineFlags), (x, v) => { IEnumerable <KeyValuePair <string, string> > envVars; KeyValueStringParser.TryParse(v, out envVars, mustHaveValue: false); x.SyncthingCommandLineFlags = envVars.Select(item => KeyValueStringParser.FormatItem(item.Key, item.Value)).ToList(); }, new SyncthingCommandLineFlagsValidator()); this.SyncthingCommandLineFlags.RequiresSyncthingRestart = true; this.SyncthingEnvironmentalVariables = this.CreateBasicSettingItem( x => KeyValueStringParser.Format(x.SyncthingEnvironmentalVariables), (x, v) => { IEnumerable <KeyValuePair <string, string> > envVars; KeyValueStringParser.TryParse(v, out envVars); x.SyncthingEnvironmentalVariables = new EnvironmentalVariableCollection(envVars); }, new SyncthingEnvironmentalVariablesValidator()); this.SyncthingEnvironmentalVariables.RequiresSyncthingRestart = true; this.SyncthingCustomHomePath = this.CreateBasicSettingItem(x => x.SyncthingCustomHomePath); this.SyncthingCustomHomePath.RequiresSyncthingRestart = true; this.SyncthingDenyUpgrade = this.CreateBasicSettingItem(x => x.SyncthingDenyUpgrade); this.SyncthingDenyUpgrade.RequiresSyncthingRestart = true; var configuration = this.configurationProvider.Load(); foreach (var settingItem in this.settings) { settingItem.LoadValue(configuration); } foreach (var folderSetting in this.FolderSettings) { folderSetting.Bind(s => s.IsWatched, (o, e) => this.UpdateAreAllFoldersWatched()); folderSetting.Bind(s => s.IsNotified, (o, e) => this.UpdateAreAllFoldersNotified()); } this.PriorityLevels = new BindableCollection <LabelledValue <SyncthingPriorityLevel> >() { LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_AboveNormal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.AboveNormal), LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Normal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.Normal), LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_BelowNormal, SyncTrayzor.Services.Config.SyncthingPriorityLevel.BelowNormal), LabelledValue.Create(Resources.SettingsView_Syncthing_ProcessPriority_Idle, SyncTrayzor.Services.Config.SyncthingPriorityLevel.Idle), }; this.Bind(s => s.AreAllFoldersNotified, (o, e) => { if (this.updatingFolderSettings) { return; } this.updatingFolderSettings = true; foreach (var folderSetting in this.FolderSettings) { folderSetting.IsNotified = e.NewValue.GetValueOrDefault(false); } this.updatingFolderSettings = false; }); this.Bind(s => s.AreAllFoldersWatched, (o, e) => { if (this.updatingFolderSettings) { return; } this.updatingFolderSettings = true; foreach (var folderSetting in this.FolderSettings) { folderSetting.IsWatched = e.NewValue.GetValueOrDefault(false); } this.updatingFolderSettings = false; }); this.UpdateAreAllFoldersWatched(); this.UpdateAreAllFoldersNotified(); }
public ConflictFileManager(IFilesystemProvider filesystemProvider, ISyncthingManager syncthingManager) { this.filesystemProvider = filesystemProvider; this.syncthingManager = syncthingManager; }
public FileTransfersTrayViewModel(ISyncthingManager syncthingManager, IProcessStartProvider processStartProvider) { this.syncthingManager = syncthingManager; this.processStartProvider = processStartProvider; this.CompletedTransfers = new BindableCollection<FileTransferViewModel>(); this.InProgressTransfers = new BindableCollection<FileTransferViewModel>(); this.CompletedTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasCompletedTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; this.InProgressTransfers.CollectionChanged += (o, e) => { this.NotifyOfPropertyChange(() => this.HasInProgressTransfers); this.NotifyOfPropertyChange(() => this.AnyTransfers); }; }
public IpcCommsServer(ISyncthingManager syncthingManager, IApplicationState applicationState, IApplicationWindowState windowState) { this.syncthingManager = syncthingManager; this.applicationState = applicationState; this.windowState = windowState; }
public SettingsViewModel( IConfigurationProvider configurationProvider, IAutostartProvider autostartProvider, IWindowManager windowManager, IProcessStartProvider processStartProvider, IAssemblyProvider assemblyProvider, IApplicationState applicationState, IApplicationPathsProvider applicationPathsProvider, ISyncthingManager syncthingManager, IMeteredNetworkManager meteredNetworkManager) { this.configurationProvider = configurationProvider; this.autostartProvider = autostartProvider; this.windowManager = windowManager; this.processStartProvider = processStartProvider; this.assemblyProvider = assemblyProvider; this.applicationState = applicationState; this.applicationPathsProvider = applicationPathsProvider; this.syncthingManager = syncthingManager; this.MinimizeToTray = this.CreateBasicSettingItem(x => x.MinimizeToTray); this.NotifyOfNewVersions = this.CreateBasicSettingItem(x => x.NotifyOfNewVersions); this.CloseToTray = this.CreateBasicSettingItem(x => x.CloseToTray); this.ObfuscateDeviceIDs = this.CreateBasicSettingItem(x => x.ObfuscateDeviceIDs); this.UseComputerCulture = this.CreateBasicSettingItem(x => x.UseComputerCulture); this.UseComputerCulture.RequiresSyncTrayzorRestart = true; this.DisableHardwareRendering = this.CreateBasicSettingItem(x => x.DisableHardwareRendering); this.DisableHardwareRendering.RequiresSyncTrayzorRestart = true; this.EnableConflictFileMonitoring = this.CreateBasicSettingItem(x => x.EnableConflictFileMonitoring); this.EnableFailedTransferAlerts = this.CreateBasicSettingItem(x => x.EnableFailedTransferAlerts); this.PauseDevicesOnMeteredNetworks = this.CreateBasicSettingItem(x => x.PauseDevicesOnMeteredNetworks); this.PauseDevicesOnMeteredNetworksSupported = meteredNetworkManager.IsSupportedByWindows; this.ShowTrayIconOnlyOnClose = this.CreateBasicSettingItem(x => x.ShowTrayIconOnlyOnClose); this.ShowSynchronizedBalloonEvenIfNothingDownloaded = this.CreateBasicSettingItem(x => x.ShowSynchronizedBalloonEvenIfNothingDownloaded); this.ShowDeviceConnectivityBalloons = this.CreateBasicSettingItem(x => x.ShowDeviceConnectivityBalloons); this.ShowDeviceOrFolderRejectedBalloons = this.CreateBasicSettingItem(x => x.ShowDeviceOrFolderRejectedBalloons); this.IconAnimationModes = new BindableCollection <LabelledValue <IconAnimationMode> >() { LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_DataTransferring, Services.Config.IconAnimationMode.DataTransferring), LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_Syncing, Services.Config.IconAnimationMode.Syncing), LabelledValue.Create(Resources.SettingsView_TrayIconAnimation_Disabled, Services.Config.IconAnimationMode.Disabled), }; this.IconAnimationMode = this.CreateBasicSettingItem(x => x.IconAnimationMode); this.StartSyncthingAutomatically = this.CreateBasicSettingItem(x => x.StartSyncthingAutomatically); this.SyncthingPriorityLevel = this.CreateBasicSettingItem(x => x.SyncthingPriorityLevel); this.SyncthingPriorityLevel.RequiresSyncthingRestart = true; this.SyncthingAddress = this.CreateBasicSettingItem(x => x.SyncthingAddress, new SyncthingAddressValidator()); this.SyncthingAddress.RequiresSyncthingRestart = true; this.CanReadAutostart = this.autostartProvider.CanRead; this.CanWriteAutostart = this.autostartProvider.CanWrite; if (this.autostartProvider.CanRead) { var currentSetup = this.autostartProvider.GetCurrentSetup(); this.StartOnLogon = currentSetup.AutoStart; this.StartMinimized = currentSetup.StartMinimized; } this.SyncthingCommandLineFlags = this.CreateBasicSettingItem( x => String.Join(" ", x.SyncthingCommandLineFlags), (x, v) => { KeyValueStringParser.TryParse(v, out var envVars, mustHaveValue: false); x.SyncthingCommandLineFlags = envVars.Select(item => KeyValueStringParser.FormatItem(item.Key, item.Value)).ToList(); }, new SyncthingCommandLineFlagsValidator());