public void OpenBrushSettings() { BaseLayerBrush layerBrush = LayerPropertyGroup.LayerBrush; LayerBrushConfigurationDialog configurationViewModel = (LayerBrushConfigurationDialog)layerBrush.ConfigurationDialog; if (configurationViewModel == null) { return; } try { // Limit to one constructor, there's no need to have more and it complicates things anyway ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors(); if (constructors.Length != 1) { throw new ArtemisUIException("Brush configuration dialogs must have exactly one constructor"); } // Find the BaseLayerBrush parameter, it is required by the base constructor so its there for sure ParameterInfo brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType)); ConstructorArgument argument = new(brushParameter.Name, layerBrush); BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel)layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument); _layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel, configurationViewModel); _windowManager.ShowDialog(_layerBrushSettingsWindowVm); // Save changes after the dialog closes _profileEditorService.UpdateSelectedProfile(); } catch (Exception e) { _dialogService.ShowExceptionDialog("An exception occured while trying to show the brush's settings window", e); } }
public void AddFolder() { if (!SupportsChildren) { throw new ArtemisUIException("Cannot add a folder to a profile element of type " + ProfileElement.GetType().Name); } ProfileElement.AddChild(new Folder(ProfileElement.Profile, ProfileElement, "New folder")); UpdateProfileElements(); _profileEditorService.UpdateSelectedProfile(); }
public async void RenameEffect() { object result = await _dialogService.ShowDialogAt <RenameViewModel>( "PropertyTreeDialogHost", new Dictionary <string, object> { { "subject", "effect" }, { "currentName", LayerPropertyGroup.LayerEffect.Name } } ); if (result is string newName) { LayerPropertyGroup.LayerEffect.Name = newName; LayerPropertyGroup.LayerEffect.HasBeenRenamed = true; _profileEditorService.UpdateSelectedProfile(); } }