コード例 #1
0
 public SingleApplicationInstanceManager(IIpcCommsServer server, IIpcCommsClient client, IAssemblyProvider assemblyProvider, IApplicationWindowState windowState)
 {
     this.server           = server;
     this.client           = client;
     this.assemblyProvider = assemblyProvider;
     this.windowState      = windowState;
 }
コード例 #2
0
 public SingleApplicationInstanceManager(IIpcCommsServer server, IIpcCommsClient client, IAssemblyProvider assemblyProvider, IApplicationWindowState windowState)
 {
     this.server = server;
     this.client = client;
     this.assemblyProvider = assemblyProvider;
     this.windowState = windowState;
 }
コード例 #3
0
ファイル: UpdateManager.cs プロジェクト: Zapados/SyncTrayzor
        public UpdateManager(
            IApplicationState applicationState,
            IApplicationWindowState applicationWindowState,
            IUserActivityMonitor userActivityMonitor,
            IUpdateCheckerFactory updateCheckerFactory,
            IProcessStartProvider processStartProvider,
            IUpdatePromptProvider updatePromptProvider,
            Func <IUpdateVariantHandler> updateVariantHandlerFactory)
        {
            this.applicationState            = applicationState;
            this.applicationWindowState      = applicationWindowState;
            this.userActivityMonitor         = userActivityMonitor;
            this.updateCheckerFactory        = updateCheckerFactory;
            this.processStartProvider        = processStartProvider;
            this.updatePromptProvider        = updatePromptProvider;
            this.updateVariantHandlerFactory = updateVariantHandlerFactory;

            this.promptTimer       = new DispatcherTimer();
            this.promptTimer.Tick += this.PromptTimerElapsed;

            // Strategy time:
            // We'll prompt the user a fixed period after the computer starts up / resumes from sleep
            // We'll also check on a fixed interval since this point
            // We'll also check when the application is restored from tray

            this.applicationState.Startup                   += this.ApplicationStartup;
            this.applicationState.ResumeFromSleep           += this.ResumeFromSleep;
            this.applicationWindowState.RootWindowActivated += this.RootWindowActivated;
        }
コード例 #4
0
        public UpdateManager(
            IApplicationState applicationState,
            IApplicationWindowState applicationWindowState,
            IUserActivityMonitor userActivityMonitor,
            IUpdateCheckerFactory updateCheckerFactory,
            IProcessStartProvider processStartProvider,
            IUpdatePromptProvider updatePromptProvider,
            IAssemblyProvider assemblyProvider,
            Func <IUpdateVariantHandler> updateVariantHandlerFactory)
        {
            this.applicationState            = applicationState;
            this.applicationWindowState      = applicationWindowState;
            this.userActivityMonitor         = userActivityMonitor;
            this.updateCheckerFactory        = updateCheckerFactory;
            this.processStartProvider        = processStartProvider;
            this.updatePromptProvider        = updatePromptProvider;
            this.assemblyProvider            = assemblyProvider;
            this.updateVariantHandlerFactory = updateVariantHandlerFactory;

            this.promptTimer       = new DispatcherTimer();
            this.promptTimer.Tick += this.PromptTimerElapsed;

            // Strategy time:
            // We'll always check when the user starts up or resumes from sleep.
            // We'll check whenever the user opens the app, debounced to a suitable period.
            // We'll check periodically if none of the above have happened, on a longer interval.
            // If 'remind me later' is active, we'll do none of the above for a long interval.

            this.applicationState.ResumeFromSleep           += this.ResumeFromSleep;
            this.applicationWindowState.RootWindowActivated += this.RootWindowActivated;
        }
コード例 #5
0
        public UpdateManager(
            IApplicationState applicationState,
            IApplicationWindowState applicationWindowState,
            IUserActivityMonitor userActivityMonitor,
            IUpdateCheckerFactory updateCheckerFactory,
            IProcessStartProvider processStartProvider,
            IUpdatePromptProvider updatePromptProvider,
            Func<IUpdateVariantHandler> updateVariantHandlerFactory)
        {
            this.applicationState = applicationState;
            this.applicationWindowState = applicationWindowState;
            this.userActivityMonitor = userActivityMonitor;
            this.updateCheckerFactory = updateCheckerFactory;
            this.processStartProvider = processStartProvider;
            this.updatePromptProvider = updatePromptProvider;
            this.updateVariantHandlerFactory = updateVariantHandlerFactory;

            this.promptTimer = new DispatcherTimer();
            this.promptTimer.Tick += this.PromptTimerElapsed;

            // Strategy time:
            // We'll prompt the user a fixed period after the computer starts up / resumes from sleep
            // We'll also check on a fixed interval since this point
            // We'll also check when the application is restored from tray

            this.applicationState.Startup += this.ApplicationStartup;
            this.applicationState.ResumeFromSleep += this.ResumeFromSleep;
            this.applicationWindowState.RootWindowActivated += this.RootWindowActivated;
        }
コード例 #6
0
ファイル: UpdateManager.cs プロジェクト: johnhk/SyncTrayzor
        public UpdateManager(
            IApplicationState applicationState,
            IApplicationWindowState applicationWindowState,
            IUserActivityMonitor userActivityMonitor,
            IUpdateCheckerFactory updateCheckerFactory,
            IProcessStartProvider processStartProvider,
            IUpdatePromptProvider updatePromptProvider,
            IAssemblyProvider assemblyProvider,
            Func<IUpdateVariantHandler> updateVariantHandlerFactory)
        {
            this.applicationState = applicationState;
            this.applicationWindowState = applicationWindowState;
            this.userActivityMonitor = userActivityMonitor;
            this.updateCheckerFactory = updateCheckerFactory;
            this.processStartProvider = processStartProvider;
            this.updatePromptProvider = updatePromptProvider;
            this.assemblyProvider = assemblyProvider;
            this.updateVariantHandlerFactory = updateVariantHandlerFactory;

            this.promptTimer = new DispatcherTimer();
            this.promptTimer.Tick += this.PromptTimerElapsed;

            // Strategy time:
            // We'll prompt the user a fixed period after the computer starts up / resumes from sleep
            // (this is handled by CheckForUpdates being set to true, if appropriate, by another part of the application)
            // We'll also check on a fixed interval since this point
            // If 'remind me later' is active, we'll also check when the application is restored from tray

            this.applicationState.ResumeFromSleep += this.ResumeFromSleep;
            this.applicationWindowState.RootWindowActivated += this.RootWindowActivated;
        }
コード例 #7
0
        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 += (o, e) => this.viewManager.BindViewToModel(this.taskbarIcon, this.viewModel);

            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.DeviceConnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.HideBalloonTip();
                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_DeviceConnected_Title, String.Format(Resources.TrayIcon_Balloon_DeviceConnected_Message, e.Device.Name), BalloonIcon.Info);
                }
            };

            this.syncThingManager.DeviceDisconnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.HideBalloonTip();
                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_DeviceDisconnected_Title, String.Format(Resources.TrayIcon_Balloon_DeviceDisconnected_Message, e.Device.Name), BalloonIcon.Info);
                }
            };
        }
コード例 #8
0
        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 += (o, e) => this.viewManager.BindViewToModel(this.taskbarIcon, this.viewModel);

            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.DeviceConnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.HideBalloonTip();
                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_DeviceConnected_Title, String.Format(Resources.TrayIcon_Balloon_DeviceConnected_Message, e.Device.Name), BalloonIcon.Info);
                }
            };

            this.syncThingManager.DeviceDisconnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.HideBalloonTip();
                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_DeviceDisconnected_Title, String.Format(Resources.TrayIcon_Balloon_DeviceDisconnected_Message, e.Device.Name), BalloonIcon.Info);
                }
            };
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        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;
        }
コード例 #11
0
 public IpcCommsServer(ISyncthingManager syncthingManager, IApplicationState applicationState, IApplicationWindowState windowState)
 {
     this.syncthingManager = syncthingManager;
     this.applicationState = applicationState;
     this.windowState      = windowState;
 }
コード例 #12
0
        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");
            this.viewManager.BindViewToModel(this.taskbarIcon, this.viewModel);

            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.FolderSyncStateChanged += (o, e) =>
            {
                if (this.ShowSynchronizedBalloon &&
                    DateTime.UtcNow - this.syncThingManager.LastConnectivityEventTime > syncedDeadTime &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime &&
                    e.SyncState == FolderSyncState.Idle && e.PrevSyncState == FolderSyncState.Syncing)
                {
                    Application.Current.Dispatcher.CheckAccess(); // Double-check
                    this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_FinishedSyncing_Title"), Localizer.Translate("TrayIcon_Balloon_FinishedSyncing_Message", e.Folder.FolderId), BalloonIcon.Info);
                }
            };

            this.syncThingManager.DeviceConnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_DeviceConnected_Title"), Localizer.Translate("TrayIcon_Balloon_DeviceConnected_Message", e.Device.Name), BalloonIcon.Info);
                }
            };

            this.syncThingManager.DeviceDisconnected += (o, e) =>
            {
                if (this.ShowDeviceConnectivityBalloons &&
                    DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                {
                    this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_DeviceDisconnected_Title"), Localizer.Translate("TrayIcon_Balloon_DeviceDisconnected_Message", e.Device.Name), BalloonIcon.Info);
                }
            };
        }