Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIX-3575 Allow default light size preference #611

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Drawing;
using System.Runtime.Serialization;
using Vixen.Module;
using VixenModules.App.CustomPropEditor.Model;

namespace VixenModules.App.CustomPropEditor
{
Expand Down Expand Up @@ -31,6 +32,9 @@ public ModuleLocalDataSet ModuleData
[DataMember]
public Color SelectedLightColor { get; set; } = Color.HotPink;

[DataMember]
public uint DefaultLightSize { get; set; } = ElementModel.DefaultLightSize;

[OnDeserialized]
public void OnDeserialized(StreamingContext c)
{
Expand All @@ -43,6 +47,11 @@ public void OnDeserialized(StreamingContext c)
{
SelectedLightColor = Color.HotPink;
}

if (DefaultLightSize == 0)
{
DefaultLightSize = ElementModel.DefaultLightSize;
}
}
}
}
11 changes: 11 additions & 0 deletions src/Vixen.Modules/App/CustomPropEditor/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,16 @@ public Color SelectedLightColor
}
}

public uint DefaultLightSize
{
get => _data.DefaultLightSize;
set
{
if(value < 1) value = ElementModel.DefaultLightSize;
_data.DefaultLightSize = value;
OnPropertyChanged(nameof(DefaultLightSize));
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace VixenModules.App.CustomPropEditor.Model
[Serializable]
public class ElementModel : BindableBase, IEqualityComparer<ElementModel>, IEquatable<ElementModel>
{
private const int DefaultLightSize = 3;
public const int DefaultLightSize = 3;
private ObservableCollection<Light> _lights;
private ObservableCollection<ElementModel> _children;
private ObservableCollection<Guid> _parents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ public ElementModel AddLightNode(ElementModel target, Point p, int? order = null

}

public ElementModel AddLight(ElementModel target, Point p)
public ElementModel AddLight(ElementModel target, Point p, uint size)
{
if (target != null && !target.IsGroupNode && target.Parents.Any())
{
AddLightToTarget(p, target);
return target;
}

return AddLightNode(target, p);
return AddLightNode(target, p, null, (int)size);
}

private ElementModel FindOrCreateTargetGroupForLight()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ public ConfigurationWindowViewModel()
{

Config = ConfigurationService.Instance().Config;
UpdateColors();
UpdateConfigValues();
Title = "Preferences";
}

private void UpdateColors()
private void UpdateConfigValues()
{
LightColor = Config.LightColor;
SelectedLightColor = Config.SelectedLightColor;
DefaultLightSize = Config.DefaultLightSize;
}


Expand All @@ -45,7 +46,25 @@ public Configuration Config

#endregion

#region LightColor property
#region DefaultLightSize property

/// <summary>
/// Gets or sets the DefaultLightSize value.
/// </summary>
public uint DefaultLightSize
{
get => GetValue<uint>(DefaultLightSizeProperty);
set => SetValue(DefaultLightSizeProperty, value);
}

/// <summary>
/// DefaultLightSize property data.
/// </summary>
public static readonly IPropertyData DefaultLightSizeProperty = RegisterProperty<uint>(nameof(DefaultLightSize));

#endregion

#region DefaultLightSize property

/// <summary>
/// Gets or sets the LightColor value.
Expand Down Expand Up @@ -142,7 +161,9 @@ public Command RestoreDefaultsCommand
/// </summary>
private void RestoreDefaults()
{
RestoreColorDefaults();
LightColor = Color.White;
SelectedLightColor = Color.HotPink;
DefaultLightSize = ElementModel.DefaultLightSize;
}

#endregion
Expand Down Expand Up @@ -192,20 +213,14 @@ private void Ok()

#endregion

private void RestoreColorDefaults()
{
LightColor = Color.White;
SelectedLightColor = Color.HotPink;
}


#region Overrides of ViewModelBase

/// <inheritdoc />
protected override Task<bool> SaveAsync()
{
Config.LightColor = LightColor;
Config.SelectedLightColor = SelectedLightColor;
Config.DefaultLightSize = DefaultLightSize;

return Task.FromResult(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ private void AddLight(Point p)
{
var target = ElementTreeViewModel.SelectedItem;

var model = PropModelServices.Instance().AddLight(target?.ElementModel, p);
var model = PropModelServices.Instance().AddLight(target?.ElementModel, p, DrawingPanelViewModel.Configuration.DefaultLightSize);

if (model == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Light Color" Margin="10,0,0,0" VerticalAlignment="Center"/>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Light Color" VerticalAlignment="Center" Margin="5,5"/>

<Rectangle Grid.Row="0" Grid.Column="1" x:Name="LightColorButton"
MinWidth="50" Height="25" Fill="{Binding LightColor ,Converter={StaticResource ColorToSolidBrushConverter}}"
Expand All @@ -38,15 +39,17 @@
</Rectangle.InputBindings>
</Rectangle>

<TextBlock Grid.Row="1" Grid.Column="0" Text="Selected Color" Margin="10,0,0,0" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Selected Color" VerticalAlignment="Center" Margin="5,5"/>
<Rectangle Grid.Row="1" Grid.Column="1" x:Name="SelectedColorButton"
MinWidth="50" Height="25" Fill="{Binding SelectedLightColor,Converter={StaticResource ColorToSolidBrushConverter}}"
Margin="6,2,2,2">
<Rectangle.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding EditSelectedLightColorCommand}"></MouseBinding>
</Rectangle.InputBindings>
</Rectangle>
</Grid>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Default Light Size" VerticalAlignment="Center" Margin="5,5"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DefaultLightSize}" Margin="6,2,2,2"/>
</Grid>
<WrapPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Button HorizontalAlignment="Right" Width="75" Margin="6" Command="{Binding RestoreDefaultsCommand}">Defaults</Button>
<Button HorizontalAlignment="Right" Width="75" Margin="6" IsDefault="True" Command="{Binding OkCommand}">Ok</Button>
Expand Down