mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Create default instances for properties
UI - Added configurable width/height for brush dialogs
This commit is contained in:
parent
f4e3011957
commit
903e434137
@ -9,6 +9,7 @@
|
|||||||
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new FloatDataBindingConverter<FloatRange>(), "End");
|
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new FloatDataBindingConverter<FloatRange>(), "End");
|
||||||
|
|
||||||
CurrentValueSet += OnCurrentValueSet;
|
CurrentValueSet += OnCurrentValueSet;
|
||||||
|
DefaultValue = new FloatRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -25,7 +26,7 @@
|
|||||||
private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e)
|
private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e)
|
||||||
{
|
{
|
||||||
// Don't allow the int range to be null
|
// Don't allow the int range to be null
|
||||||
BaseValue ??= DefaultValue ?? new FloatRange(0, 0);
|
BaseValue ??= DefaultValue ?? new FloatRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,7 @@
|
|||||||
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new IntDataBindingConverter<IntRange>(), "End");
|
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new IntDataBindingConverter<IntRange>(), "End");
|
||||||
|
|
||||||
CurrentValueSet += OnCurrentValueSet;
|
CurrentValueSet += OnCurrentValueSet;
|
||||||
|
DefaultValue = new IntRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -25,7 +26,7 @@
|
|||||||
private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e)
|
private void OnCurrentValueSet(object? sender, LayerPropertyEventArgs e)
|
||||||
{
|
{
|
||||||
// Don't allow the int range to be null
|
// Don't allow the int range to be null
|
||||||
BaseValue ??= DefaultValue ?? new IntRange(0, 0);
|
BaseValue ??= DefaultValue ?? new IntRange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,14 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
private readonly Random _rand;
|
private readonly Random _rand;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="FloatRange" /> class
|
||||||
|
/// </summary>
|
||||||
|
public FloatRange()
|
||||||
|
{
|
||||||
|
_rand = new Random();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="FloatRange" /> class
|
/// Creates a new instance of the <see cref="FloatRange" /> class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -9,6 +9,14 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
private readonly Random _rand;
|
private readonly Random _rand;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="IntRange" /> class
|
||||||
|
/// </summary>
|
||||||
|
public IntRange()
|
||||||
|
{
|
||||||
|
_rand = new Random();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="IntRange" /> class
|
/// Creates a new instance of the <see cref="IntRange" /> class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ namespace Artemis.Core
|
|||||||
CurrentValue = default!;
|
CurrentValue = default!;
|
||||||
DefaultValue = default!;
|
DefaultValue = default!;
|
||||||
|
|
||||||
_baseValue = default!;
|
_baseValue = typeof(T).IsValueType ? default! : Activator.CreateInstance<T>();
|
||||||
_keyframes = new List<LayerPropertyKeyframe<T>>();
|
_keyframes = new List<LayerPropertyKeyframe<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,18 @@ namespace Artemis.UI.Shared.LayerBrushes
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public class LayerBrushConfigurationDialog<T> : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel
|
public class LayerBrushConfigurationDialog<T> : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel
|
||||||
{
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public LayerBrushConfigurationDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public LayerBrushConfigurationDialog(int dialogWidth, int dialogHeight)
|
||||||
|
{
|
||||||
|
DialogWidth = dialogWidth;
|
||||||
|
DialogHeight = dialogHeight;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Type Type => typeof(T);
|
public override Type Type => typeof(T);
|
||||||
}
|
}
|
||||||
@ -15,6 +27,16 @@ namespace Artemis.UI.Shared.LayerBrushes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class LayerBrushConfigurationDialog : ILayerBrushConfigurationDialog
|
public abstract class LayerBrushConfigurationDialog : ILayerBrushConfigurationDialog
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default width of the dialog
|
||||||
|
/// </summary>
|
||||||
|
public int DialogWidth { get; set; } = 800;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default height of the dialog
|
||||||
|
/// </summary>
|
||||||
|
public int DialogHeight { get; set; } = 800;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of view model the tab contains
|
/// The type of view model the tab contains
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -6,6 +6,19 @@ namespace Artemis.UI.Shared.LayerEffects
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public class LayerEffectConfigurationDialog<T> : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel
|
public class LayerEffectConfigurationDialog<T> : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public LayerEffectConfigurationDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public LayerEffectConfigurationDialog(int dialogWidth, int dialogHeight)
|
||||||
|
{
|
||||||
|
DialogWidth = dialogWidth;
|
||||||
|
DialogHeight = dialogHeight;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override Type Type => typeof(T);
|
public override Type Type => typeof(T);
|
||||||
}
|
}
|
||||||
@ -15,11 +28,15 @@ namespace Artemis.UI.Shared.LayerEffects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class LayerEffectConfigurationDialog : ILayerEffectConfigurationDialog
|
public abstract class LayerEffectConfigurationDialog : ILayerEffectConfigurationDialog
|
||||||
{
|
{
|
||||||
// TODO: See if this is still in use
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The layer effect this dialog belongs to
|
/// The default width of the dialog
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BaseLayerEffect? LayerEffect { get; set; }
|
public int DialogWidth { get; set; } = 800;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default height of the dialog
|
||||||
|
/// </summary>
|
||||||
|
public int DialogHeight { get; set; } = 800;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of view model the tab contains
|
/// The type of view model the tab contains
|
||||||
|
|||||||
@ -75,7 +75,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
|
||||||
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||||
|
|
||||||
_layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel);
|
_layerBrushSettingsWindowVm = new LayerBrushSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||||
_windowManager.ShowDialog(_layerBrushSettingsWindowVm);
|
_windowManager.ShowDialog(_layerBrushSettingsWindowVm);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -102,7 +102,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
|||||||
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
|
||||||
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
|
||||||
|
|
||||||
_layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel);
|
_layerEffectSettingsWindowVm = new LayerEffectSettingsWindowViewModel(viewModel, configurationViewModel);
|
||||||
_windowManager.ShowDialog(_layerEffectSettingsWindowVm);
|
_windowManager.ShowDialog(_layerEffectSettingsWindowVm);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@ -12,8 +12,10 @@
|
|||||||
Background="{DynamicResource MaterialDesignPaper}"
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||||
UseLayoutRounding="True"
|
UseLayoutRounding="True"
|
||||||
Width="800"
|
MinWidth="400"
|
||||||
Height="800"
|
MinHeight="400"
|
||||||
|
Width="{Binding Width}"
|
||||||
|
Height="{Binding Height}"
|
||||||
d:DesignHeight="800"
|
d:DesignHeight="800"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
||||||
|
|||||||
@ -6,10 +6,27 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
|||||||
{
|
{
|
||||||
public class LayerBrushSettingsWindowViewModel : Conductor<BrushConfigurationViewModel>
|
public class LayerBrushSettingsWindowViewModel : Conductor<BrushConfigurationViewModel>
|
||||||
{
|
{
|
||||||
public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel)
|
private int _height;
|
||||||
|
private int _width;
|
||||||
|
|
||||||
|
public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel, LayerBrushConfigurationDialog configuration)
|
||||||
{
|
{
|
||||||
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
||||||
ActiveItem.Closed += ActiveItemOnClosed;
|
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)
|
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
||||||
|
|||||||
@ -12,8 +12,10 @@
|
|||||||
Background="{DynamicResource MaterialDesignPaper}"
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||||
UseLayoutRounding="True"
|
UseLayoutRounding="True"
|
||||||
Width="800"
|
MinWidth="400"
|
||||||
Height="800"
|
MinHeight="400"
|
||||||
|
Width="{Binding Width}"
|
||||||
|
Height="{Binding Height}"
|
||||||
d:DesignHeight="800"
|
d:DesignHeight="800"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}"
|
d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}"
|
||||||
|
|||||||
@ -6,10 +6,27 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
|||||||
{
|
{
|
||||||
public class LayerEffectSettingsWindowViewModel : Conductor<EffectConfigurationViewModel>
|
public class LayerEffectSettingsWindowViewModel : Conductor<EffectConfigurationViewModel>
|
||||||
{
|
{
|
||||||
public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel)
|
private int _height;
|
||||||
|
private int _width;
|
||||||
|
|
||||||
|
public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel, LayerEffectConfigurationDialog configuration)
|
||||||
{
|
{
|
||||||
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
||||||
ActiveItem.Closed += ActiveItemOnClosed;
|
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)
|
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user