diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs index 298e824f3..34a3be646 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs @@ -9,6 +9,7 @@ RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new FloatDataBindingConverter(), "End"); CurrentValueSet += OnCurrentValueSet; + DefaultValue = new FloatRange(); } /// @@ -25,7 +26,7 @@ private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e) { // Don't allow the int range to be null - BaseValue ??= DefaultValue ?? new FloatRange(0, 0); + BaseValue ??= DefaultValue ?? new FloatRange(); } } } \ No newline at end of file diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs index 474fa33e1..0b1942356 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs @@ -9,6 +9,7 @@ RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new IntDataBindingConverter(), "End"); CurrentValueSet += OnCurrentValueSet; + DefaultValue = new IntRange(); } /// @@ -25,7 +26,7 @@ private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e) { // Don't allow the int range to be null - BaseValue ??= DefaultValue ?? new IntRange(0, 0); + BaseValue ??= DefaultValue ?? new IntRange(); } } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/FloatRange.cs b/src/Artemis.Core/Models/Profile/LayerProperties/FloatRange.cs index 3df43ae4d..2e696d7af 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/FloatRange.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/FloatRange.cs @@ -9,6 +9,14 @@ namespace Artemis.Core { private readonly Random _rand; + /// + /// Creates a new instance of the class + /// + public FloatRange() + { + _rand = new Random(); + } + /// /// Creates a new instance of the class /// diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/IntRange.cs b/src/Artemis.Core/Models/Profile/LayerProperties/IntRange.cs index ebe6a4d80..e93e6a349 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/IntRange.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/IntRange.cs @@ -9,6 +9,14 @@ namespace Artemis.Core { private readonly Random _rand; + /// + /// Creates a new instance of the class + /// + public IntRange() + { + _rand = new Random(); + } + /// /// Creates a new instance of the class /// diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index afe35710d..ba025df39 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -34,7 +34,7 @@ namespace Artemis.Core CurrentValue = default!; DefaultValue = default!; - _baseValue = default!; + _baseValue = typeof(T).IsValueType ? default! : Activator.CreateInstance(); _keyframes = new List>(); } diff --git a/src/Artemis.UI.Shared/Plugins/LayerBrushes/LayerBrushConfigurationDialog.cs b/src/Artemis.UI.Shared/Plugins/LayerBrushes/LayerBrushConfigurationDialog.cs index e792dbe75..daf80ed91 100644 --- a/src/Artemis.UI.Shared/Plugins/LayerBrushes/LayerBrushConfigurationDialog.cs +++ b/src/Artemis.UI.Shared/Plugins/LayerBrushes/LayerBrushConfigurationDialog.cs @@ -6,6 +6,18 @@ namespace Artemis.UI.Shared.LayerBrushes /// public class LayerBrushConfigurationDialog : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel { + /// + public LayerBrushConfigurationDialog() + { + } + + /// + public LayerBrushConfigurationDialog(int dialogWidth, int dialogHeight) + { + DialogWidth = dialogWidth; + DialogHeight = dialogHeight; + } + /// public override Type Type => typeof(T); } @@ -15,6 +27,16 @@ namespace Artemis.UI.Shared.LayerBrushes /// public abstract class LayerBrushConfigurationDialog : ILayerBrushConfigurationDialog { + /// + /// The default width of the dialog + /// + public int DialogWidth { get; set; } = 800; + + /// + /// The default height of the dialog + /// + public int DialogHeight { get; set; } = 800; + /// /// The type of view model the tab contains /// diff --git a/src/Artemis.UI.Shared/Plugins/LayerEffects/LayerEffectConfigurationDialog.cs b/src/Artemis.UI.Shared/Plugins/LayerEffects/LayerEffectConfigurationDialog.cs index 81bcdb2af..bb043fa93 100644 --- a/src/Artemis.UI.Shared/Plugins/LayerEffects/LayerEffectConfigurationDialog.cs +++ b/src/Artemis.UI.Shared/Plugins/LayerEffects/LayerEffectConfigurationDialog.cs @@ -6,6 +6,19 @@ namespace Artemis.UI.Shared.LayerEffects /// public class LayerEffectConfigurationDialog : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel { + + /// + public LayerEffectConfigurationDialog() + { + } + + /// + public LayerEffectConfigurationDialog(int dialogWidth, int dialogHeight) + { + DialogWidth = dialogWidth; + DialogHeight = dialogHeight; + } + /// public override Type Type => typeof(T); } @@ -15,11 +28,15 @@ namespace Artemis.UI.Shared.LayerEffects /// public abstract class LayerEffectConfigurationDialog : ILayerEffectConfigurationDialog { - // TODO: See if this is still in use /// - /// The layer effect this dialog belongs to + /// The default width of the dialog /// - public BaseLayerEffect? LayerEffect { get; set; } + public int DialogWidth { get; set; } = 800; + + /// + /// The default height of the dialog + /// + public int DialogHeight { get; set; } = 800; /// /// The type of view model the tab contains diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs index 30d8fd822..eb77d5816 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs @@ -75,7 +75,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree ConstructorArgument argument = new(brushParameter.Name, layerBrush); BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument); - _layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel); + _layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel, configurationViewModel); _windowManager.ShowDialog(_layerBrushSettingsWindowVm); } catch (Exception e) @@ -102,7 +102,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree ConstructorArgument argument = new(effectParameter.Name, layerEffect); EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument); - _layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel); + _layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel, configurationViewModel); _windowManager.ShowDialog(_layerEffectSettingsWindowVm); } catch (Exception e) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowView.xaml b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowView.xaml index d0b42c891..b904b2b45 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowView.xaml @@ -12,8 +12,10 @@ Background="{DynamicResource MaterialDesignPaper}" FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto" UseLayoutRounding="True" - Width="800" - Height="800" + MinWidth="400" + MinHeight="400" + Width="{Binding Width}" + Height="{Binding Height}" d:DesignHeight="800" d:DesignWidth="800" d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}" diff --git a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowViewModel.cs index 682be6025..c183050ab 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerBrushSettingsWindowViewModel.cs @@ -6,10 +6,27 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows { public class LayerBrushSettingsWindowViewModel : Conductor { - public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel) + private int _height; + private int _width; + + public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel, LayerBrushConfigurationDialog configuration) { ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel)); ActiveItem.Closed += ActiveItemOnClosed; + Width = configuration.DialogWidth; + Height = configuration.DialogHeight; + } + + public int Width + { + get => _width; + set => SetAndNotify(ref _width, value); + } + + public int Height + { + get => _height; + set => SetAndNotify(ref _height, value); } private void ActiveItemOnClosed(object sender, CloseEventArgs e) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowView.xaml b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowView.xaml index ca3cdda83..2af4dc2ed 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowView.xaml @@ -12,8 +12,10 @@ Background="{DynamicResource MaterialDesignPaper}" FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto" UseLayoutRounding="True" - Width="800" - Height="800" + MinWidth="400" + MinHeight="400" + Width="{Binding Width}" + Height="{Binding Height}" d:DesignHeight="800" d:DesignWidth="800" d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}" diff --git a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowViewModel.cs index 6d2438bdf..de2144edd 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Windows/LayerEffectSettingsWindowViewModel.cs @@ -6,10 +6,27 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows { public class LayerEffectSettingsWindowViewModel : Conductor { - public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel) + private int _height; + private int _width; + + public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel, LayerEffectConfigurationDialog configuration) { ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel)); ActiveItem.Closed += ActiveItemOnClosed; + Width = configuration.DialogWidth; + Height = configuration.DialogHeight; + } + + public int Width + { + get => _width; + set => SetAndNotify(ref _width, value); + } + + public int Height + { + get => _height; + set => SetAndNotify(ref _height, value); } private void ActiveItemOnClosed(object sender, CloseEventArgs e)