public OptionsModel(
            ISettingsFaultFinder faultFinder,
            IOptionTasks optionTasks,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            Contracts.Options data,
            GeneralOptions generalOptions,
            IProfileType profileType,
            bool isGoogle,
            OptionModelSessionData sessionData)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            _mappingConfigurationModelFactory = new MappingConfigurationModelFactory(sessionData);
            _faultFinder = faultFinder ?? throw new ArgumentNullException(nameof(faultFinder));
            _optionTasks = optionTasks ?? throw new ArgumentNullException(nameof(optionTasks));
            _outlookAccountPasswordProvider = outlookAccountPasswordProvider ?? throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            _generalOptions = generalOptions ?? throw new ArgumentNullException(nameof(generalOptions));
            ProfileType     = profileType ?? throw new ArgumentNullException(nameof(profileType));
            _sessionData    = sessionData ?? throw new ArgumentNullException(nameof(sessionData));

            Id = data.Id;

            _isGoogle = isGoogle;

            InitializeData(data);
        }
Exemplo n.º 2
0
        public GoogleServerSettingsViewModel(OptionsModel model, IOptionTasks optionTasks, IViewOptions viewOptions)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _model                  = model;
            _optionTasks            = optionTasks;
            ViewOptions             = viewOptions;
            _doAutoDiscoveryCommand = new DelegateCommandWithoutCanExecuteDelegation(_ => DoAutoDiscovery());
            _testConnectionCommand  = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                TestConnectionAsync(CalenderUrl);
            });


            RegisterPropertyChangePropagation(_model, nameof(_model.CalenderUrl), nameof(CalenderUrl));
            RegisterPropertyChangePropagation(_model, nameof(_model.EmailAddress), nameof(EmailAddress));
            RegisterPropertyChangePropagation(_model, nameof(_model.UseGoogleNativeApi), nameof(UseGoogleNativeApi));
            RegisterPropertyChangePropagation(_model, nameof(_model.UseGoogleNativeApiAvailable), nameof(UseGoogleNativeApiAvailable));
        }
Exemplo n.º 3
0
        public GenericOptionsViewModel(
            IOptionsViewModelParent parent,
            GeneralOptions generalOptions,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            Func <ISettingsFaultFinder, ICurrentOptions, IServerSettingsViewModel> serverSettingsViewModelFactory,
            Func <ICurrentOptions, IMappingConfigurationViewModelFactory> mappingConfigurationViewModelFactoryFactory,
            IOptionTasks optionTasks)
            : base(parent)
        {
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (mappingConfigurationViewModelFactoryFactory == null)
            {
                throw new ArgumentNullException(nameof(mappingConfigurationViewModelFactoryFactory));
            }

            _syncSettingsViewModel    = new SyncSettingsViewModel();
            _networkSettingsViewModel = new NetworkSettingsViewModel();

            var faultFinder = generalOptions.FixInvalidSettings ? new SettingsFaultFinder(this) : NullSettingsFaultFinder.Instance;

            _serverSettingsViewModel                 = serverSettingsViewModelFactory(faultFinder, this);
            _generalOptions                          = generalOptions;
            _outlookAccountPasswordProvider          = outlookAccountPasswordProvider;
            _mappingConfigurationViewModelFactory    = mappingConfigurationViewModelFactoryFactory(this);
            _outlookFolderViewModel                  = new OutlookFolderViewModel(faultFinder, optionTasks);
            _outlookFolderViewModel.PropertyChanged += OutlookFolderViewModel_PropertyChanged;
            _timeRangeViewModel                      = new TimeRangeViewModel();
        }
    public GenericOptionsViewModel (
      IOptionsViewModelParent parent,
      GeneralOptions generalOptions,
      IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
      Func<ISettingsFaultFinder, ICurrentOptions, IServerSettingsViewModel> serverSettingsViewModelFactory,
      Func<ICurrentOptions, IMappingConfigurationViewModelFactory> mappingConfigurationViewModelFactoryFactory,
      IOptionTasks optionTasks)
        : base (parent)
    {
      if (generalOptions == null)
        throw new ArgumentNullException (nameof (generalOptions));
      if (outlookAccountPasswordProvider == null)
        throw new ArgumentNullException (nameof (outlookAccountPasswordProvider));
      if (mappingConfigurationViewModelFactoryFactory == null)
        throw new ArgumentNullException (nameof (mappingConfigurationViewModelFactoryFactory));

      _syncSettingsViewModel = new SyncSettingsViewModel();
      _networkSettingsViewModel = new NetworkSettingsViewModel();

      var faultFinder = generalOptions.FixInvalidSettings ? new SettingsFaultFinder (this) : NullSettingsFaultFinder.Instance;
      _serverSettingsViewModel = serverSettingsViewModelFactory (faultFinder, this);
      _generalOptions = generalOptions;
      _outlookAccountPasswordProvider = outlookAccountPasswordProvider;
      _mappingConfigurationViewModelFactory = mappingConfigurationViewModelFactoryFactory(this);
      _outlookFolderViewModel = new OutlookFolderViewModel (faultFinder, optionTasks);
      _outlookFolderViewModel.PropertyChanged += OutlookFolderViewModel_PropertyChanged;
      _timeRangeViewModel = new TimeRangeViewModel();
    }
Exemplo n.º 5
0
        public static IProfileTypeRegistry Create(
            IOptionsViewModelParent optionsViewModelParent,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            IReadOnlyList <string> availableCategories,
            IOptionTasks optionTasks,
            ISettingsFaultFinder settingsFaultFinder,
            GeneralOptions generalOptions,
            IViewOptions viewOptions)
        {
            if (optionsViewModelParent == null)
            {
                throw new ArgumentNullException(nameof(optionsViewModelParent));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (availableCategories == null)
            {
                throw new ArgumentNullException(nameof(availableCategories));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (settingsFaultFinder == null)
            {
                throw new ArgumentNullException(nameof(settingsFaultFinder));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }


            var generic = new GenericProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions);
            var google  = new GoogleProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions);
            var all     = new List <IProfileType> {
                generic, google
            };

            all.Add(new FruuxProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new PosteoProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new YandexProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new GmxCalendarProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new SarenetProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new LandmarksProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new SogoProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new CozyProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new NextcloudProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new MailboxOrgProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new EasyProjectProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));
            all.Add(new WebDeProfile(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions));

            return(new ProfileTypeRegistry(all, generic, google));
        }
        public OptionsModel(
            IOptionTasks optionTasks,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            Contracts.Options data,
            GeneralOptions generalOptions,
            IProfileModelFactory profileModelFactory,
            bool isGoogle,
            OptionModelSessionData sessionData,
            IServerSettingsDetector serverSettingsDetector)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (serverSettingsDetector == null)
            {
                throw new ArgumentNullException(nameof(serverSettingsDetector));
            }

            _mappingConfigurationModelFactory = new MappingConfigurationModelFactory(sessionData);
            _optionTasks = optionTasks ?? throw new ArgumentNullException(nameof(optionTasks));
            _outlookAccountPasswordProvider = outlookAccountPasswordProvider ?? throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            _generalOptions = generalOptions ?? throw new ArgumentNullException(nameof(generalOptions));
            ModelFactory    = profileModelFactory ?? throw new ArgumentNullException(nameof(profileModelFactory));
            _sessionData    = sessionData ?? throw new ArgumentNullException(nameof(sessionData));

            Id = data.Id;

            _isGoogle = isGoogle;
            _serverSettingsDetector = serverSettingsDetector;

            InitializeData(data);
        }
        public EasyProjectMultipleOptionsTemplateViewModel(
            IOptionsViewModelParent parent,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel prototypeModel,
            IViewOptions viewOptions)
        {
            _parent = parent;
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (prototypeModel == null)
            {
                throw new ArgumentNullException(nameof(prototypeModel));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _prototypeModel = prototypeModel;
            ViewOptions     = viewOptions;


            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _mergeResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                MergeResourcesAsync();
            });

            SelectFolderCommand = new DelegateCommand(_ => SelectFolder());

            _networkSettingsViewModel = new NetworkSettingsViewModel(_prototypeModel);
            Items = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _optionTasks             = optionTasks;

            var folder = _optionTasks.GetDefaultCalendarFolderOrNull();

            if (folder != null)
            {
                _selectedFolder    = folder;
                SelectedFolderName = folder.Name;
            }

            RegisterPropertyChangePropagation(_prototypeModel, nameof(_prototypeModel.Name), nameof(Name));
        }
    public ProfileExportProcessor (NameSpace session, IOptionTasks optionTasks)
    {
      if (session == null) throw new ArgumentNullException(nameof(session));
      if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks));

      _session = session;
      _optionTasks = optionTasks;
    }
 public static SelectResourceForm CreateForFolderAssignment(
   IOptionTasks optionTasks,
   ResourceType initialResourceTabToDisplay,
   IReadOnlyList<CalendarDataViewModel> calendars = null,
   IReadOnlyList<AddressBookDataViewModel> addressBooks = null,
   IReadOnlyList<TaskListDataViewModel> taskLists = null)
 {
   return new SelectResourceForm(initialResourceTabToDisplay, optionTasks, calendars, addressBooks, taskLists);
 }
Exemplo n.º 10
0
 public static SelectResourceForm CreateForFolderAssignment(
     IOptionTasks optionTasks,
     ResourceType initialResourceTabToDisplay,
     IReadOnlyList <CalendarDataViewModel> calendars       = null,
     IReadOnlyList <AddressBookDataViewModel> addressBooks = null,
     IReadOnlyList <TaskListDataViewModel> taskLists       = null)
 {
     return(new SelectResourceForm(initialResourceTabToDisplay, optionTasks, calendars, addressBooks, taskLists));
 }
Exemplo n.º 11
0
        public OptionsCollectionViewModel(
            bool expandAllSyncProfiles,
            Func <Guid, string> profileDataDirectoryFactory,
            IUiService uiService,
            IOptionTasks optionTasks,
            IProfileTypeRegistry profileTypeRegistry,
            Func <IOptionsViewModelParent, IProfileType, IProfileModelFactory> profileModelFactoryFactory,
            IViewOptions viewOptions)
        {
            _optionTasks = optionTasks;
            ViewOptions  = viewOptions;
            _profileDataDirectoryFactory = profileDataDirectoryFactory;
            _uiService = uiService;
            if (profileDataDirectoryFactory == null)
            {
                throw new ArgumentNullException(nameof(profileDataDirectoryFactory));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _expandAllSyncProfiles = expandAllSyncProfiles;

            _profileTypeRegistry         = profileTypeRegistry;
            _profileModelFactoriesByType = profileTypeRegistry.AllTypes.ToDictionary(t => t, t => profileModelFactoryFactory(this, t));

            RegisterPropertyChangeHandler(viewOptions, nameof(viewOptions.IsAdvancedViewEnabled), () =>
            {
                if (!viewOptions.IsAdvancedViewEnabled)
                {
                    OnAdvancedViewDisabled();
                }
            });

            AddCommand                      = new DelegateCommand(_ => Add());
            AddMultipleCommand              = new DelegateCommand(_ => AddMultiple());
            CloseCommand                    = new DelegateCommand(shouldSaveNewOptions => Close((bool)shouldSaveNewOptions));
            DeleteSelectedCommand           = new DelegateCommandHandlingRequerySuggested(_ => DeleteSelected(), _ => CanDeleteSelected);
            ClearCacheOfSelectedCommand     = new DelegateCommandHandlingRequerySuggested(_ => ClearCacheOfSelected(), _ => CanClearCacheOfSelected);
            CopySelectedCommand             = new DelegateCommandHandlingRequerySuggested(_ => CopySelected(), _ => CanCopySelected);
            MoveSelectedUpCommand           = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedUp(), _ => CanMoveSelectedUp);
            MoveSelectedDownCommand         = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedDown(), _ => CanMoveSelectedDown);
            OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested(_ => OpenProfileDataDirectory(), _ => CanOpenProfileDataDirectory);
            ExpandAllCommand                = new DelegateCommandHandlingRequerySuggested(_ => ExpandAll(), _ => _options.Count > 0);
            CollapseAllCommand              = new DelegateCommandHandlingRequerySuggested(_ => CollapseAll(), _ => _options.Count > 0);
            ExportAllCommand                = new DelegateCommandHandlingRequerySuggested(_ => ExportAll(), _ => _options.Count > 0);
            ImportCommand                   = new DelegateCommandHandlingRequerySuggested(_ => Import(), _ => true);
        }
        public MultipleOptionsTemplateViewModel(
            IOptionsViewModelParent parent,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel prototypeModel,
            IViewOptions viewOptions)

        {
            _parent = parent;
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (prototypeModel == null)
            {
                throw new ArgumentNullException(nameof(prototypeModel));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            ViewOptions = viewOptions;

            _prototypeModel = prototypeModel;

            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                GetAccountSettings();
            });

            _networkSettingsViewModel = new NetworkSettingsViewModel(_prototypeModel);

            Items = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _optionTasks             = optionTasks;

            RegisterPropertyChangePropagation(_prototypeModel, nameof(_prototypeModel.Name), nameof(Name));
        }
Exemplo n.º 13
0
        private static void SetupFolderSelectionColumns(DataGridView dataGridView, IOptionTasks optionTasks, params OlItemType[] allowedFolderType)
        {
            var folderColumn = new DataGridViewTextBoxColumn();

            folderColumn.HeaderText   = "Selected Outlook Folder";
            folderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView.Columns.Add(folderColumn);

            var selectFolderColumn = new DataGridViewButtonColumn();

            selectFolderColumn.UseColumnTextForButtonValue = true;
            selectFolderColumn.Text         = "...";
            selectFolderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns.Add(selectFolderColumn);

            var removeFolderColumn = new DataGridViewButtonColumn();

            removeFolderColumn.UseColumnTextForButtonValue = true;
            removeFolderColumn.Text         = "x";
            removeFolderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dataGridView.Columns.Add(removeFolderColumn);

            dataGridView.CellContentClick += (sender, e) =>
            {
                var column     = dataGridView.Columns[e.ColumnIndex];
                var row        = dataGridView.Rows[e.RowIndex];
                var viewModel  = (ResourceDataViewModelBase)row.DataBoundItem;
                var folderCell = row.Cells[folderColumn.Index];

                if (column == selectFolderColumn)
                {
                    var folder = optionTasks.PickFolderOrNull();
                    if (folder != null)
                    {
                        if (Array.IndexOf(allowedFolderType, folder.DefaultItemType) == -1)
                        {
                            MessageBox.Show($"Folder has to have item type '{String.Join (", ", allowedFolderType)}'.", "Select folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        folderCell.Value         = folder.Name;
                        viewModel.SelectedFolder = new FolderDescriptor(folder.EntryId, folder.StoreId);
                    }
                }
                else if (column == removeFolderColumn)
                {
                    viewModel.SelectedFolder = null;
                    folderCell.Value         = null;
                }
            };
        }
        protected ProfileModelFactoryBase(IProfileType profileType, IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, ISettingsFaultFinder settingsFaultFinder, GeneralOptions generalOptions, IViewOptions viewOptions, OptionModelSessionData sessionData)
        {
            if (profileType == null)
            {
                throw new ArgumentNullException(nameof(profileType));
            }
            if (optionsViewModelParent == null)
            {
                throw new ArgumentNullException(nameof(optionsViewModelParent));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (availableCategories == null)
            {
                throw new ArgumentNullException(nameof(availableCategories));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (settingsFaultFinder == null)
            {
                throw new ArgumentNullException(nameof(settingsFaultFinder));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }
            if (sessionData == null)
            {
                throw new ArgumentNullException(nameof(sessionData));
            }

            ProfileType                    = profileType;
            OptionsViewModelParent         = optionsViewModelParent;
            OutlookAccountPasswordProvider = outlookAccountPasswordProvider;
            AvailableCategories            = availableCategories;
            OptionTasks                    = optionTasks;
            SettingsFaultFinder            = settingsFaultFinder;
            GeneralOptions                 = generalOptions;
            ViewOptions                    = viewOptions;
            SessionData                    = sessionData;
            ServerSettingsDetector         = new Lazy <IServerSettingsDetector>(CreateServerSettingsDetector);
        }
Exemplo n.º 15
0
        public ProfileExportProcessor(NameSpace session, IOptionTasks optionTasks)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }

            _session     = session;
            _optionTasks = optionTasks;
        }
        public OutlookFolderViewModel(ISettingsFaultFinder faultFinder, IOptionTasks optionTasks)
        {
            if (faultFinder == null)
            {
                throw new ArgumentNullException(nameof(faultFinder));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }

            _faultFinder        = faultFinder;
            _optionTasks        = optionTasks;
            SelectFolderCommand = new DelegateCommand(_ => SelectFolder());
        }
        public void SetUp()
        {
            _uiServiceStub = MockRepository.GenerateStub <IUiService>();


            // see http://stackoverflow.com/questions/3444581/mocking-com-interfaces-using-rhino-mocks
            // Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add (typeof (TypeIdentifierAttribute));

            _optionTasksStub = MockRepository.GenerateStub <IOptionTasks>();
            _viewModel       = new OptionsCollectionViewModel(
                new Contracts.GeneralOptions(),
                MockRepository.GenerateStub <IOutlookAccountPasswordProvider>(),
                new string[0],
                id => @"A:\bla",
                _uiServiceStub,
                _optionTasksStub);
        }
Exemplo n.º 18
0
        public OptionsModel(
            ISettingsFaultFinder faultFinder,
            IOptionTasks optionTasks,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            Contracts.Options data,
            GeneralOptions generalOptions,
            IProfileType profileType,
            bool isGoogle)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (faultFinder == null)
            {
                throw new ArgumentNullException(nameof(faultFinder));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (profileType == null)
            {
                throw new ArgumentNullException(nameof(profileType));
            }

            _faultFinder = faultFinder;
            _optionTasks = optionTasks;
            _outlookAccountPasswordProvider = outlookAccountPasswordProvider;
            _generalOptions = generalOptions;
            ProfileType     = profileType;

            Id = data.Id;

            _isGoogle = isGoogle;

            InitializeData(data);
        }
    public void SetUp()
    {
      _uiServiceStub = MockRepository.GenerateStub<IUiService>();


      // see http://stackoverflow.com/questions/3444581/mocking-com-interfaces-using-rhino-mocks
      // Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add (typeof (TypeIdentifierAttribute));

      _optionTasksStub = MockRepository.GenerateStub<IOptionTasks>();
      _viewModel = new OptionsCollectionViewModel(
        new Contracts.GeneralOptions(),
        MockRepository.GenerateStub<IOutlookAccountPasswordProvider>(),
        new string[0],
        id => @"A:\bla",
        _uiServiceStub, 
        _optionTasksStub);
    }
Exemplo n.º 20
0
        public OptionsCollectionViewModel(
            GeneralOptions generalOptions,
            IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
            IReadOnlyList <string> availableEventCategories,
            Func <Guid, string> profileDataDirectoryFactory,
            IUiService uiService,
            IOptionTasks optionTasks)
        {
            _optionTasks = optionTasks;
            _profileDataDirectoryFactory = profileDataDirectoryFactory;
            _uiService = uiService;
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (profileDataDirectoryFactory == null)
            {
                throw new ArgumentNullException(nameof(profileDataDirectoryFactory));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }

            _generalOptions = generalOptions;


            _optionsViewModelFactory = new OptionsViewModelFactory(
                this,
                outlookAccountPasswordProvider,
                availableEventCategories,
                optionTasks);
            AddCommand                      = new DelegateCommand(_ => Add());
            AddMultipleCommand              = new DelegateCommand(_ => AddMultiple());
            CloseCommand                    = new DelegateCommand(shouldSaveNewOptions => Close((bool)shouldSaveNewOptions));
            DeleteSelectedCommand           = new DelegateCommandHandlingRequerySuggested(_ => DeleteSelected(), _ => CanDeleteSelected);
            CopySelectedCommand             = new DelegateCommandHandlingRequerySuggested(_ => CopySelected(), _ => CanCopySelected);
            MoveSelectedUpCommand           = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedUp(), _ => CanMoveSelectedUp);
            MoveSelectedDownCommand         = new DelegateCommandHandlingRequerySuggested(_ => MoveSelectedDown(), _ => CanMoveSelectedDown);
            OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested(_ => OpenProfileDataDirectory(), _ => CanOpenProfileDataDirectory);
            ExpandAllCommand                = new DelegateCommandHandlingRequerySuggested(_ => ExpandAll(), _ => _options.Count > 0);
            CollapseAllCommand              = new DelegateCommandHandlingRequerySuggested(_ => CollapseAll(), _ => _options.Count > 0);
            ExportAllCommand                = new DelegateCommandHandlingRequerySuggested(_ => ExportAll(), _ => _options.Count > 0);
            ImportCommand                   = new DelegateCommandHandlingRequerySuggested(_ => Import(), _ => true);
        }
Exemplo n.º 21
0
        public GenericOptionsViewModel(
            IOptionsViewModelParent parent,
            IOptionsSection serverSettingsViewModel,
            IOptionTasks optionTasks,
            OptionsModel model,
            IReadOnlyList <string> availableCategories,
            IViewOptions viewOptions)
            : base(viewOptions, model)
        {
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (serverSettingsViewModel == null)
            {
                throw new ArgumentNullException(nameof(serverSettingsViewModel));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (availableCategories == null)
            {
                throw new ArgumentNullException(nameof(availableCategories));
            }


            Model = model;
            _availableCategories = availableCategories;

            _syncSettingsViewModel    = new SyncSettingsViewModel(model, viewOptions);
            _networkSettingsViewModel = new NetworkSettingsViewModel(model);

            _serverSettingsViewModel = serverSettingsViewModel;
            _outlookFolderViewModel  = new OutlookFolderViewModel(model, optionTasks, viewOptions);
            _timeRangeViewModel      = new TimeRangeViewModel(model, viewOptions);

            RegisterPropertyChangeHandler(model, nameof(model.MappingConfigurationModelOrNull), UpdateMappingConfigurationViewModel);

            RegisterPropertyChangePropagation(model, nameof(model.SelectedFolderOrNull), nameof(OutlookFolderType));
        }
Exemplo n.º 22
0
    public OptionsViewModelFactory (
      IOptionsViewModelParent optionsViewModelParent, 
      IOutlookAccountPasswordProvider outlookAccountPasswordProvider,
      IReadOnlyList<string> availableCategories, 
      IOptionTasks optionTasks)
    {
      if (optionsViewModelParent == null)
        throw new ArgumentNullException (nameof (optionsViewModelParent));
      if (outlookAccountPasswordProvider == null)
        throw new ArgumentNullException (nameof (outlookAccountPasswordProvider));
      if (availableCategories == null)
        throw new ArgumentNullException (nameof (availableCategories));
      if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks));

      _optionsViewModelParent = optionsViewModelParent;
      _outlookAccountPasswordProvider = outlookAccountPasswordProvider;
      _availableCategories = availableCategories;
      _optionTasks = optionTasks;
    }
        public MultipleOptionsTemplateViewModel(
            IOptionsViewModelParent parent,
            GeneralOptions generalOptions,
            IServerSettingsTemplateViewModel serverSettingsViewModel,
            ProfileType profileType,
            IOptionTasks optionTasks)

        {
            _parent = parent;
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }

            _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                DiscoverResourcesAsync();
            });

            _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                GetAccountSettings();
            });

            _networkSettingsViewModel = new NetworkSettingsViewModel();

            Items = new[] { _networkSettingsViewModel };

            _serverSettingsViewModel = serverSettingsViewModel;
            _profileType             = profileType;
            _optionTasks             = optionTasks;
            _generalOptions          = generalOptions;
        }
Exemplo n.º 24
0
        public void SetUp()
        {
            _uiServiceStub = MockRepository.GenerateStub <IUiService>();

            // see http://stackoverflow.com/questions/3444581/mocking-com-interfaces-using-rhino-mocks
            // Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add (typeof (TypeIdentifierAttribute));

            _optionTasksStub = MockRepository.GenerateStub <IOptionTasks>();

            _testProfileRegistry = new TestProfileRegistry(_optionTasksStub);

            _viewModel = new OptionsCollectionViewModel(
                false,
                id => @"A:\bla",
                _uiServiceStub,
                _optionTasksStub,
                p => _testProfileRegistry,
                new ViewOptions(false));
        }
Exemplo n.º 25
0
        public ServerSettingsViewModel(OptionsModel model, IOptionTasks optionTasks, IViewOptions viewOptions)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _model = model;

            _optionTasks = optionTasks;
            ViewOptions  = viewOptions;

            _testConnectionCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                TestConnectionAsync();
            });
            _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                _model.AutoFillAccountSettings();
            });
            _createDavResourceCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
            {
                ComponentContainer.EnsureSynchronizationContext();
                CreateDavResource();
            });

            RegisterPropertyChangePropagation(_model, nameof(_model.CalenderUrl), nameof(CalenderUrl));
            RegisterPropertyChangePropagation(_model, nameof(_model.UserName), nameof(UserName));
            RegisterPropertyChangePropagation(_model, nameof(_model.Password), nameof(Password));
            RegisterPropertyChangePropagation(_model, nameof(_model.EmailAddress), nameof(EmailAddress));
            RegisterPropertyChangePropagation(_model, nameof(_model.UseAccountPassword), nameof(UseAccountPassword));
            RegisterPropertyChangePropagation(_model, nameof(_model.UseWebDavCollectionSync), nameof(UseWebDavCollectionSync));
        }
Exemplo n.º 26
0
        protected ProfileBase(IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, ISettingsFaultFinder settingsFaultFinder, GeneralOptions generalOptions, IViewOptions viewOptions)
        {
            if (optionsViewModelParent == null)
            {
                throw new ArgumentNullException(nameof(optionsViewModelParent));
            }
            if (outlookAccountPasswordProvider == null)
            {
                throw new ArgumentNullException(nameof(outlookAccountPasswordProvider));
            }
            if (availableCategories == null)
            {
                throw new ArgumentNullException(nameof(availableCategories));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (settingsFaultFinder == null)
            {
                throw new ArgumentNullException(nameof(settingsFaultFinder));
            }
            if (generalOptions == null)
            {
                throw new ArgumentNullException(nameof(generalOptions));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            OptionsViewModelParent         = optionsViewModelParent;
            OutlookAccountPasswordProvider = outlookAccountPasswordProvider;
            AvailableCategories            = availableCategories;
            OptionTasks         = optionTasks;
            SettingsFaultFinder = settingsFaultFinder;
            GeneralOptions      = generalOptions;
            ViewOptions         = viewOptions;
        }
    public OptionsCollectionViewModel (
      GeneralOptions generalOptions,
      IOutlookAccountPasswordProvider outlookAccountPasswordProvider, 
      IReadOnlyList<string> availableEventCategories, 
      Func<Guid, string> profileDataDirectoryFactory,
      IUiService uiService,
      IOptionTasks optionTasks)
    {
      _optionTasks = optionTasks;
      _profileDataDirectoryFactory = profileDataDirectoryFactory;
      _uiService = uiService;
      if (generalOptions == null)
        throw new ArgumentNullException (nameof (generalOptions));
      if (profileDataDirectoryFactory == null)
        throw new ArgumentNullException (nameof (profileDataDirectoryFactory));
      if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks));

      _generalOptions = generalOptions;


      _optionsViewModelFactory = new OptionsViewModelFactory (
        this,
        outlookAccountPasswordProvider,
        availableEventCategories,
        optionTasks);
      AddCommand = new DelegateCommand (_ => Add());
      AddMultipleCommand = new DelegateCommand (_ => AddMultiple());
      CloseCommand = new DelegateCommand (shouldSaveNewOptions => Close((bool)shouldSaveNewOptions));
      DeleteSelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => DeleteSelected (), _ => CanDeleteSelected);
      CopySelectedCommand = new DelegateCommandHandlingRequerySuggested (_ => CopySelected (), _ => CanCopySelected);
      MoveSelectedUpCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedUp (), _ => CanMoveSelectedUp);
      MoveSelectedDownCommand = new DelegateCommandHandlingRequerySuggested (_ => MoveSelectedDown (), _ => CanMoveSelectedDown);
      OpenProfileDataDirectoryCommand = new DelegateCommandHandlingRequerySuggested (_ => OpenProfileDataDirectory (), _ => CanOpenProfileDataDirectory);
      ExpandAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExpandAll (), _ => _options.Count > 0);
      CollapseAllCommand = new DelegateCommandHandlingRequerySuggested (_ => CollapseAll (), _ => _options.Count > 0);
      ExportAllCommand = new DelegateCommandHandlingRequerySuggested (_ => ExportAll (), _ => _options.Count > 0);
      ImportCommand = new DelegateCommandHandlingRequerySuggested (_ => Import (), _ => true);
    }
Exemplo n.º 28
0
        private SelectResourceForm(
            ResourceType initialResourceTabToDisplay,
            IOptionTasks optionTasks,
            IReadOnlyList <CalendarDataViewModel> calendars       = null,
            IReadOnlyList <AddressBookDataViewModel> addressBooks = null,
            IReadOnlyList <TaskListDataViewModel> taskLists       = null)
            : this(initialResourceTabToDisplay, calendars, addressBooks, taskLists)
        {
            if (calendars != null)
            {
                SetupFolderSelectionColumns(_calendarDataGridView, optionTasks, OlItemType.olAppointmentItem);
            }

            if (addressBooks != null)
            {
                SetupFolderSelectionColumns(_addressBookDataGridView, optionTasks, OlItemType.olContactItem);
            }

            if (taskLists != null)
            {
                SetupFolderSelectionColumns(_tasksDataGridView, optionTasks, OlItemType.olTaskItem);
            }
        }
    public MultipleOptionsTemplateViewModel (
        IOptionsViewModelParent parent,
        GeneralOptions generalOptions,
        IServerSettingsTemplateViewModel serverSettingsViewModel,
        ProfileType profileType,
        IOptionTasks optionTasks)

    {
      _parent = parent;
      if (parent == null)
        throw new ArgumentNullException (nameof (parent));
      if (generalOptions == null)
        throw new ArgumentNullException (nameof (generalOptions));
      if (optionTasks == null) throw new ArgumentNullException(nameof(optionTasks));

      _discoverResourcesCommand = new DelegateCommandWithoutCanExecuteDelegation (_ =>
      {
        ComponentContainer.EnsureSynchronizationContext();
        DiscoverResourcesAsync();
      });

      _getAccountSettingsCommand = new DelegateCommandWithoutCanExecuteDelegation(_ =>
      {
        ComponentContainer.EnsureSynchronizationContext();
        GetAccountSettings();
      });

      _networkSettingsViewModel = new NetworkSettingsViewModel();

      Items = new[] { _networkSettingsViewModel };

      _serverSettingsViewModel = serverSettingsViewModel;
      _profileType = profileType;
      _optionTasks = optionTasks;
      _generalOptions = generalOptions;
    }
Exemplo n.º 30
0
        public OutlookFolderViewModel(OptionsModel model, IOptionTasks optionTasks, IViewOptions viewOptions)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (optionTasks == null)
            {
                throw new ArgumentNullException(nameof(optionTasks));
            }
            if (viewOptions == null)
            {
                throw new ArgumentNullException(nameof(viewOptions));
            }

            _model       = model;
            _optionTasks = optionTasks;
            ViewOptions  = viewOptions;
            ModelOptions = model.ModelFactory.ModelOptions;

            RegisterPropertyChangePropagation(_model, nameof(_model.EnableChangeTriggeredSynchronization), nameof(EnableChangeTriggeredSynchronization));
            RegisterPropertyChangePropagation(_model, nameof(_model.SelectedFolderOrNull), nameof(SelectedFolderName));
            SelectFolderCommand = new DelegateCommand(_ => SelectFolder());
        }
Exemplo n.º 31
0
 public ProfileModelFactory(IProfileType profileType, IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, GeneralOptions generalOptions, IViewOptions viewOptions, OptionModelSessionData sessionData)
     : base(profileType, optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, generalOptions, viewOptions, sessionData)
 {
 }
    private SelectResourceForm (
        ResourceType initialResourceTabToDisplay,
        IOptionTasks optionTasks,
        IReadOnlyList<CalendarDataViewModel> calendars = null,
        IReadOnlyList<AddressBookDataViewModel> addressBooks = null,
        IReadOnlyList<TaskListDataViewModel> taskLists = null)
        : this (initialResourceTabToDisplay, calendars, addressBooks, taskLists)
    {
      if (calendars != null)
        SetupFolderSelectionColumns (_calendarDataGridView, optionTasks, OlItemType.olAppointmentItem);

      if (addressBooks != null)
        SetupFolderSelectionColumns (_addressBookDataGridView, optionTasks, OlItemType.olContactItem);

      if (taskLists != null)
        SetupFolderSelectionColumns (_tasksDataGridView, optionTasks, OlItemType.olTaskItem);
    }
Exemplo n.º 33
0
 public override IProfileModelFactory CreateModelFactory(IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, GeneralOptions generalOptions, IViewOptions viewOptions, OptionModelSessionData sessionData)
 {
     return(new ProfileModelFactory(this, optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, generalOptions, viewOptions, sessionData));
 }
    private static void SetupFolderSelectionColumns (DataGridView dataGridView, IOptionTasks optionTasks, params OlItemType[] allowedFolderType)
    {
      var folderColumn = new DataGridViewTextBoxColumn();
      folderColumn.HeaderText = "Selected Outlook Folder";
      folderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      dataGridView.Columns.Add (folderColumn);

      var selectFolderColumn = new DataGridViewButtonColumn();
      selectFolderColumn.UseColumnTextForButtonValue = true;
      selectFolderColumn.Text = "...";
      selectFolderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
      dataGridView.Columns.Add (selectFolderColumn);

      var removeFolderColumn = new DataGridViewButtonColumn();
      removeFolderColumn.UseColumnTextForButtonValue = true;
      removeFolderColumn.Text = "x";
      removeFolderColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
      dataGridView.Columns.Add (removeFolderColumn);

      dataGridView.CellContentClick += (sender, e) =>
      {
        var column = dataGridView.Columns[e.ColumnIndex];
        var row = dataGridView.Rows[e.RowIndex];
        var viewModel = (ResourceDataViewModelBase) row.DataBoundItem;
        var folderCell = row.Cells[folderColumn.Index];

        if (column == selectFolderColumn)
        {
          var folder = optionTasks.PickFolderOrNull();
          if (folder != null)
          {
            if (Array.IndexOf (allowedFolderType, folder.DefaultItemType) == -1)
            {
              MessageBox.Show ($"Folder has to have item type '{String.Join (", ", allowedFolderType)}'.", "Select folder", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return;
            }

            folderCell.Value = folder.Name;
            viewModel.SelectedFolder = new FolderDescriptor (folder.EntryId, folder.StoreId);
          }
        }
        else if (column == removeFolderColumn)
        {
          viewModel.SelectedFolder = null;
          folderCell.Value = null;
        }
      };
    }
Exemplo n.º 35
0
 public GenericProfile(IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, ISettingsFaultFinder settingsFaultFinder, GeneralOptions generalOptions, IViewOptions viewOptions) : base(optionsViewModelParent, outlookAccountPasswordProvider, availableCategories, optionTasks, settingsFaultFinder, generalOptions, viewOptions)
 {
 }
 public IProfileModelFactory CreateModelFactory(IOptionsViewModelParent optionsViewModelParent, IOutlookAccountPasswordProvider outlookAccountPasswordProvider, IReadOnlyList <string> availableCategories, IOptionTasks optionTasks, ISettingsFaultFinder settingsFaultFinder, GeneralOptions generalOptions, IViewOptions viewOptions, OptionModelSessionData sessionData)
 {
     return(this);
 }
 public TestProfile(IOptionTasks optionTasksStub)
 {
     _optionTasksStub = optionTasksStub;
 }
 public TestProfileRegistry(IOptionTasks optionTasksStub)
 {
     AllTypes = new[] { new TestProfile(optionTasksStub) };
 }