Esempio n. 1
0
        public void AssertViewModelWorks()
        {
            var savedConfig1 = new SavedConfiguration
            {
                Name        = "Saved1",
                Description = "DescSaved1"
            };

            var savedConfig2 = new SavedConfiguration
            {
                Name        = "Saved2",
                Description = "DescSaved2"
            };

            this.settings.SavedConfigurations.Add(savedConfig1);
            this.settings.SavedConfigurations.Add(savedConfig2);

            var vm = new ManageConfigurationsDialogViewModel(this.dialogNavigationService.Object, this.pluginService.Object);

            Assert.AreEqual(this.settings.SavedConfigurations.Count, vm.SavedConfigurations.Count);

            vm.SelectedConfiguration = savedConfig1;

            vm.DeleteSelectedCommand.Execute(null);

            Assert.AreEqual(1, vm.SavedConfigurations.Count);
            Assert.DoesNotThrowAsync(() => vm.OkCommand.ExecuteAsyncTask(null));
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the delete selected command
        /// </summary>
        private void ExecuteDeleteSelected()
        {
            if (this.SelectedConfiguration == null)
            {
                return;
            }

            this.SavedConfigurations.Remove(this.SelectedConfiguration);
            this.SelectedConfiguration = null;
        }
Esempio n. 3
0
        public void AssertViewModelWorks()
        {
            var savedConfiguration = new SavedConfiguration();

            var vm = new SavedConfigurationDialogViewModel(this.dialogNavigationService.Object, this.pluginService.Object, savedConfiguration);

            vm.Name        = "adda";
            vm.Description = "dde";

            Assert.DoesNotThrowAsync(() => vm.OkCommand.ExecuteAsyncTask(null));
        }
Esempio n. 4
0
        /// <summary>
        /// Executes the save of current configuration
        /// </summary>
        private void ExecuteSaveCurrentConfiguration()
        {
            var savedConfiguration = new SavedConfiguration
            {
                RelationshipConfiguration = new RelationshipConfiguration(this.RelationshipConfiguration),
                ShowDirectionality        = this.ShowDirectionality,
                SourceConfigurationX      = new SourceConfiguration(this.SourceXConfiguration),
                SourceConfigurationY      = new SourceConfiguration(this.SourceYConfiguration),
                ShowRelatedOnly           = this.ShowRelatedOnly
            };

            var vm = new SavedConfigurationDialogViewModel <RelationshipMatrixPluginSettings>(this.PluginSettingsService, savedConfiguration);

            var result = this.DialogNavigationService.NavigateModal(vm) as SavedConfigurationResult;

            if (result?.Result == null || !result.Result.Value)
            {
                return;
            }

            this.ReloadSavedConfigurations();
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SavedConfigurationDialogViewModel"/> class.
        /// </summary>
        /// <param name="dialogNavigationService">An instance of <see cref="IDialogNavigationService"/>.</param>
        /// <param name="pluginSettingService">An instance of <see cref="IPluginSettingsService"/>.</param>
        /// <param name="configuration">The configuration to be saved.</param>
        public SavedConfigurationDialogViewModel(IDialogNavigationService dialogNavigationService, IPluginSettingsService pluginSettingService, SavedConfiguration configuration)
        {
            // reset the loading indicator
            this.IsBusy = false;

            this.dialogNavigationService = dialogNavigationService;
            this.pluginSettingService    = pluginSettingService;
            this.savedConfiguration      = configuration;

            var canOk = this.WhenAnyValue(
                vm => vm.Name,
                vm => vm.Description,
                (n, d) =>
                !string.IsNullOrEmpty(n) && !string.IsNullOrEmpty(d));

            this.OkCommand = ReactiveCommand.CreateAsyncTask(canOk, x => this.ExecuteOk(), RxApp.MainThreadScheduler);
            this.OkCommand.ThrownExceptions.Select(ex => ex).Subscribe(x =>
            {
                this.ErrorMessage = x.Message;
            });

            this.CancelCommand = ReactiveCommand.Create();
            this.CancelCommand.Subscribe(_ => this.ExecuteCancel());
        }