示例#1
0
        private void SynchronizeTimer_Tick(object sender, EventArgs e)
        {
            if (_settingProvider.GetSetting <bool>("AvoidMeteredConnection") && SystemInfoHelper.IsMeteredConnection())
            {
                return;
            }

            SynchronizeAsync();
        }
示例#2
0
 /// <inheritdoc/>
 public void Reset()
 {
     Pause();
     _ignoredApplications = _settingProvider.GetSetting <List <IgnoredApplication> >("IgnoredApplications");
     if (!CoreHelper.IsUnitTesting())
     {
         Resume();
     }
 }
示例#3
0
        /// <inheritdoc/>
        public async void Initialize(IServiceSettingProvider settingProvider)
        {
            _settingProvider = settingProvider;

            var synchronizeInterval   = _settingProvider.GetSetting <int>("SynchronizationInterval");
            var providers             = _settingProvider.GetSetting <List <ICloudStorageProvider> >("CloudStorageProviders");
            var isConnectedToInternet = SystemInfoHelper.CheckForInternetConnection();
            var cloudStorageProviders = new List <CloudStorageProvider>();

            _synchronizeTimer          = new DispatcherTimer();
            _synchronizeTimer.Interval = TimeSpan.FromMinutes(synchronizeInterval);
            _synchronizeTimer.Tick    += SynchronizeTimer_Tick;

            _cloudStorageProviders = new List <ICloudStorageProvider>();

            foreach (var provider in providers)
            {
                if (_cloudStorageProviders.Any(p => string.Compare(p.CloudServiceName, provider.CloudServiceName, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    Logger.Instance.Fatal(new Exception($"The cloud storage provider '{provider.CloudServiceName}' already exists."));
                }

                if (isConnectedToInternet)
                {
                    await provider.TryAuthenticateAsync();
                }

                _cloudStorageProviders.Add(provider);
                cloudStorageProviders.Add(new CloudStorageProvider(provider.CloudServiceName, provider.CloudServiceIcon));
            }

            CloudStorageProviders = cloudStorageProviders.OrderBy(s => s.Name).ToList();

            if (isConnectedToInternet && CurrentCloudStorageProvider != null)
            {
                await CurrentCloudStorageProvider.TryAuthenticateAsync();
            }

            _synchronizeTimer.Start();
            Logger.Instance.Information($"{GetType().Name} initialized.");
        }
示例#4
0
        /// <inheritdoc/>
        public void Initialize(IServiceSettingProvider settingProvider)
        {
            _settingProvider     = settingProvider;
            _ignoredApplications = _settingProvider.GetSetting <List <IgnoredApplication> >("IgnoredApplications");
            if (CoreHelper.IsUnitTesting())
            {
                _clipboardHook = new ClipboardHook(new Window());
            }
            else
            {
                _clipboardHook = new ClipboardHook(Application.Current.MainWindow);
            }

            _clipboardHook.ClipboardChanged += ClipboardHook_ClipboardChanged;
            Resume();
            Logger.Instance.Information($"{GetType().Name} initialized.");
        }