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!;
|
||||
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>>();
|
||||
}
|
||||
|
||||
|
||||
@ -12,10 +12,8 @@
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||
UseLayoutRounding="True"
|
||||
MinWidth="400"
|
||||
MinHeight="400"
|
||||
Width="{Binding Width}"
|
||||
Height="{Binding Height}"
|
||||
Height="800"
|
||||
Width="800"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance windows:LayerBrushSettingsWindowViewModel}"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Artemis.UI.Shared.LayerBrushes;
|
||||
using Stylet;
|
||||
|
||||
@ -6,28 +7,35 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
||||
{
|
||||
public class LayerBrushSettingsWindowViewModel : Conductor<BrushConfigurationViewModel>
|
||||
{
|
||||
private int _height;
|
||||
private int _width;
|
||||
private readonly LayerBrushConfigurationDialog _configuration;
|
||||
|
||||
public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel, LayerBrushConfigurationDialog configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
||||
ActiveItem.Closed += ActiveItemOnClosed;
|
||||
Width = configuration.DialogWidth;
|
||||
Height = configuration.DialogHeight;
|
||||
}
|
||||
|
||||
public int Width
|
||||
#region Overrides of Screen
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
get => _width;
|
||||
set => SetAndNotify(ref _width, value);
|
||||
// Setting the width/height via a binding and depending on WindowStartupLocation does not work
|
||||
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
|
||||
{
|
||||
get => _height;
|
||||
set => SetAndNotify(ref _height, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
UseLayoutRounding="True"
|
||||
MinWidth="400"
|
||||
MinHeight="400"
|
||||
Width="{Binding Width}"
|
||||
Height="{Binding Height}"
|
||||
Width="800"
|
||||
Height="800"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance windows:LayerEffectSettingsWindowViewModel}"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using Artemis.UI.Shared.LayerEffects;
|
||||
using Stylet;
|
||||
|
||||
@ -6,28 +7,35 @@ namespace Artemis.UI.Screens.ProfileEditor.Windows
|
||||
{
|
||||
public class LayerEffectSettingsWindowViewModel : Conductor<EffectConfigurationViewModel>
|
||||
{
|
||||
private int _height;
|
||||
private int _width;
|
||||
private LayerEffectConfigurationDialog _configuration;
|
||||
|
||||
public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel, LayerEffectConfigurationDialog configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel));
|
||||
ActiveItem.Closed += ActiveItemOnClosed;
|
||||
Width = configuration.DialogWidth;
|
||||
Height = configuration.DialogHeight;
|
||||
}
|
||||
|
||||
public int Width
|
||||
#region Overrides of Screen
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
get => _width;
|
||||
set => SetAndNotify(ref _width, value);
|
||||
// Setting the width/height via a binding and depending on WindowStartupLocation does not work
|
||||
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
|
||||
{
|
||||
get => _height;
|
||||
set => SetAndNotify(ref _height, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void ActiveItemOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user