mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Layer brush/effect dialogs - Fixed default location
Layer properties - Give it a best effort to avoid null base values
This commit is contained in:
parent
af496da647
commit
8066586328
@ -34,7 +34,15 @@ namespace Artemis.Core
|
|||||||
CurrentValue = default!;
|
CurrentValue = default!;
|
||||||
DefaultValue = default!;
|
DefaultValue = default!;
|
||||||
|
|
||||||
_baseValue = typeof(T).IsValueType ? default! : Activator.CreateInstance<T>();
|
// We'll try our best...
|
||||||
|
// TODO: Consider alternatives
|
||||||
|
if (typeof(T).IsValueType)
|
||||||
|
_baseValue = default!;
|
||||||
|
else if (typeof(T).GetConstructor(Type.EmptyTypes) != null)
|
||||||
|
_baseValue = Activator.CreateInstance<T>();
|
||||||
|
else
|
||||||
|
_baseValue = default!;
|
||||||
|
|
||||||
_keyframes = new List<LayerPropertyKeyframe<T>>();
|
_keyframes = new List<LayerPropertyKeyframe<T>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,8 @@
|
|||||||
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"
|
||||||
MinWidth="400"
|
Height="800"
|
||||||
MinHeight="400"
|
Width="800"
|
||||||
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}"
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
using Artemis.UI.Shared.LayerBrushes;
|
using Artemis.UI.Shared.LayerBrushes;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -6,28 +7,35 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
|||||||
{
|
{
|
||||||
public class LayerBrushSettingsWindowViewModel : Conductor<BrushConfigurationViewModel>
|
public class LayerBrushSettingsWindowViewModel : Conductor<BrushConfigurationViewModel>
|
||||||
{
|
{
|
||||||
private int _height;
|
private readonly LayerBrushConfigurationDialog _configuration;
|
||||||
private int _width;
|
|
||||||
|
|
||||||
public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel, LayerBrushConfigurationDialog configuration)
|
public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel, LayerBrushConfigurationDialog configuration)
|
||||||
{
|
{
|
||||||
|
_configuration = 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
|
#region Overrides of Screen
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnViewLoaded()
|
||||||
{
|
{
|
||||||
get => _width;
|
// Setting the width/height via a binding and depending on WindowStartupLocation does not work
|
||||||
set => SetAndNotify(ref _width, value);
|
Window window = View as Window;
|
||||||
|
Window mainWindow = Application.Current.MainWindow;
|
||||||
|
if (window == null || mainWindow == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window.Width = _configuration.DialogWidth;
|
||||||
|
window.Height = _configuration.DialogHeight;
|
||||||
|
window.Left = mainWindow.Left + (mainWindow.Width - window.Width) / 2;
|
||||||
|
window.Top = mainWindow.Top + (mainWindow.Height - window.Height) / 2;
|
||||||
|
|
||||||
|
base.OnViewLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Height
|
#endregion
|
||||||
{
|
|
||||||
get => _height;
|
|
||||||
set => SetAndNotify(ref _height, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
UseLayoutRounding="True"
|
UseLayoutRounding="True"
|
||||||
MinWidth="400"
|
MinWidth="400"
|
||||||
MinHeight="400"
|
MinHeight="400"
|
||||||
Width="{Binding Width}"
|
Width="800"
|
||||||
Height="{Binding Height}"
|
Height="800"
|
||||||
d:DesignHeight="800"
|
d:DesignHeight="800"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}"
|
d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}"
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
using Artemis.UI.Shared.LayerEffects;
|
using Artemis.UI.Shared.LayerEffects;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -6,28 +7,35 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
|||||||
{
|
{
|
||||||
public class LayerEffectSettingsWindowViewModel : Conductor<EffectConfigurationViewModel>
|
public class LayerEffectSettingsWindowViewModel : Conductor<EffectConfigurationViewModel>
|
||||||
{
|
{
|
||||||
private int _height;
|
private LayerEffectConfigurationDialog _configuration;
|
||||||
private int _width;
|
|
||||||
|
|
||||||
public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel, LayerEffectConfigurationDialog configuration)
|
public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel, LayerEffectConfigurationDialog configuration)
|
||||||
{
|
{
|
||||||
|
_configuration = 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
|
#region Overrides of Screen
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void OnViewLoaded()
|
||||||
{
|
{
|
||||||
get => _width;
|
// Setting the width/height via a binding and depending on WindowStartupLocation does not work
|
||||||
set => SetAndNotify(ref _width, value);
|
Window window = View as Window;
|
||||||
|
Window mainWindow = Application.Current.MainWindow;
|
||||||
|
if (window == null || mainWindow == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window.Width = _configuration.DialogWidth;
|
||||||
|
window.Height = _configuration.DialogHeight;
|
||||||
|
window.Left = mainWindow.Left + (mainWindow.Width - window.Width) / 2;
|
||||||
|
window.Top = mainWindow.Top + (mainWindow.Height - window.Height) / 2;
|
||||||
|
|
||||||
|
base.OnViewLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Height
|
#endregion
|
||||||
{
|
|
||||||
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