public void ShowGeneralOptionsNoThrow()
        {
            try
            {
                var generalOptions = _generalOptionsDataAccess.LoadOptions();
                using (var optionsForm = new GeneralOptionsForm())
                {
                    optionsForm.Options = generalOptions;
                    if (optionsForm.Display())
                    {
                        var newOptions = optionsForm.Options;

                        ConfigureServicePointManager(newOptions);
                        ConfigureLogLevel(newOptions.EnableDebugLog);

                        _updateChecker.IsEnabled        = newOptions.ShouldCheckForNewerVersions;
                        _reportGarbageCollection.MaxAge = TimeSpan.FromDays(newOptions.MaxReportAgeInDays);

                        _generalOptionsDataAccess.SaveOptions(newOptions);
                        UpdateGeneralOptionDependencies(newOptions);
                        _scheduler.SetOptions(_optionsDataAccess.LoadOptions(), newOptions.CheckIfOnline);
                    }
                }
            }
            catch (Exception x)
            {
                ExceptionHandler.Instance.HandleException(x, s_logger);
            }
        }
        public void ShowGeneralOptions()
        {
            var generalOptions = _generalOptionsDataAccess.LoadOptions();

            using (var optionsForm = new GeneralOptionsForm())
            {
                optionsForm.Options = generalOptions;
                if (optionsForm.Display())
                {
                    var newOptions = optionsForm.Options;

                    ConfigureServicePointManager(newOptions);
                    ConfigureLogLevel(newOptions.EnableDebugLog);

                    _updateChecker.IsEnabled        = newOptions.ShouldCheckForNewerVersions;
                    _reportGarbageCollection.MaxAge = TimeSpan.FromDays(newOptions.MaxReportAgeInDays);

                    _generalOptionsDataAccess.SaveOptions(newOptions);
                    UpdateGeneralOptionDependencies(newOptions);
                    _scheduler.SetOptions(_optionsDataAccess.LoadOptions(), newOptions.CheckIfOnline);

                    if (newOptions.EnableTrayIcon != generalOptions.EnableTrayIcon)
                    {
                        _trayNotifier.Dispose();
                        _trayNotifier = newOptions.EnableTrayIcon ? new TrayNotifier(this) : NullTrayNotifer.Instance;
                    }
                }
            }
        }
예제 #3
0
 public async Task ShowGeneralOptionsAsync()
 {
     await EditGeneralOptionsAsync(
         o =>
     {
         using (var optionsForm = new GeneralOptionsForm())
         {
             optionsForm.Options = o;
             if (optionsForm.Display())
             {
                 return(Tuple.Create(true, optionsForm.Options));
             }
             else
             {
                 return(Tuple.Create(false, (GeneralOptions)null));
             }
         }
     });
 }
        public async Task ShowGeneralOptions()
        {
            var generalOptions = _generalOptionsDataAccess.LoadOptions();

            using (var optionsForm = new GeneralOptionsForm())
            {
                optionsForm.Options = generalOptions;
                if (optionsForm.Display())
                {
                    var newOptions = optionsForm.Options;

                    ConfigureServicePointManager(newOptions);
                    ConfigureLogLevel(newOptions.EnableDebugLog);

                    _updateChecker.IsEnabled        = newOptions.ShouldCheckForNewerVersions;
                    _reportGarbageCollection.MaxAge = TimeSpan.FromDays(newOptions.MaxReportAgeInDays);

                    _generalOptionsDataAccess.SaveOptions(newOptions);
                    UpdateGeneralOptionDependencies(newOptions);
                    await _scheduler.SetOptions(_optionsDataAccess.LoadOptions(), newOptions);

                    if (newOptions.EnableTrayIcon != generalOptions.EnableTrayIcon)
                    {
                        _trayNotifier.Dispose();
                        _trayNotifier = newOptions.EnableTrayIcon ? new TrayNotifier(this) : NullTrayNotifer.Instance;
                    }

                    if (_syncObject != null && newOptions.TriggerSyncAfterSendReceive != generalOptions.TriggerSyncAfterSendReceive)
                    {
                        if (newOptions.TriggerSyncAfterSendReceive)
                        {
                            _syncObject.SyncEnd += _sync_SyncEnd;
                        }
                        else
                        {
                            _syncObject.SyncEnd -= _sync_SyncEnd;
                        }
                    }
                }
            }
        }