mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Dynamic properties extra options implemented UI-wise
This commit is contained in:
parent
2edccddc12
commit
028d22bc7b
@ -154,6 +154,7 @@ namespace Artemis.Managers
|
||||
// debugging TODO: Disable when window isn't shown (in Debug VM, or get rid of it, w/e)
|
||||
_events.PublishOnUIThread(new ChangeBitmap(bitmap));
|
||||
|
||||
if (_keyboardManager.ActiveKeyboard != null)
|
||||
Monitor.Exit(_keyboardManager.ActiveKeyboard);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,6 @@ namespace Artemis.Models.Profiles.Properties
|
||||
|
||||
public enum LayerPropertyType
|
||||
{
|
||||
[Description("None")] None,
|
||||
[Description("% of")] PercentageOf,
|
||||
[Description("% of property")] PercentageOfProperty
|
||||
}
|
||||
@ -91,6 +90,8 @@ namespace Artemis.Models.Profiles.Properties
|
||||
[Description("Left to right")] LeftToRight,
|
||||
[Description("Right to left")] RightToLeft,
|
||||
[Description("Downwards")] Downwards,
|
||||
[Description("Upwards")] Upwards
|
||||
[Description("Upwards")] Upwards,
|
||||
[Description("Increase")] Increase,
|
||||
[Description("Decrease")] Decrease
|
||||
}
|
||||
}
|
||||
@ -9,15 +9,19 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
public sealed class LayerDynamicPropertiesViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly string _property;
|
||||
private DynamicPropertiesModel _proposed;
|
||||
private BindableCollection<string> _layerPropertyOptions;
|
||||
private LayerPropertyType _layerPropertyType;
|
||||
private string _name;
|
||||
private DynamicPropertiesModel _proposed;
|
||||
private string _selectedLayerPropertyOption;
|
||||
private GeneralHelpers.PropertyCollection _selectedSource;
|
||||
private GeneralHelpers.PropertyCollection _selectedTarget;
|
||||
private bool _sourcesIsVisible;
|
||||
private bool _userSourceIsVisible;
|
||||
|
||||
public LayerDynamicPropertiesViewModel(string property, BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps, KeyboardPropertiesModel keyboardProperties)
|
||||
public LayerDynamicPropertiesViewModel(string property,
|
||||
BindableCollection<GeneralHelpers.PropertyCollection> dataModelProps,
|
||||
KeyboardPropertiesModel keyboardProperties)
|
||||
{
|
||||
_property = property;
|
||||
|
||||
@ -27,22 +31,37 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
if (original == null)
|
||||
{
|
||||
Proposed.LayerProperty = property;
|
||||
Proposed.LayerPropertyType = LayerPropertyType.None;
|
||||
Proposed.LayerPropertyType = LayerPropertyType.PercentageOf;
|
||||
}
|
||||
else
|
||||
GeneralHelpers.CopyProperties(Proposed, original);
|
||||
|
||||
Name = property + ":";
|
||||
Targets = new BindableCollection<GeneralHelpers.PropertyCollection>();
|
||||
|
||||
var nullTarget = new GeneralHelpers.PropertyCollection {Display = "None"};
|
||||
Targets = new BindableCollection<GeneralHelpers.PropertyCollection> {nullTarget};
|
||||
Targets.AddRange(dataModelProps.Where(p => p.Type == "Int32"));
|
||||
Sources = new BindableCollection<GeneralHelpers.PropertyCollection>();
|
||||
Sources.AddRange(dataModelProps.Where(p => p.Type == "Int32"));
|
||||
UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
|
||||
SourcesIsVisible = LayerPropertyType == LayerPropertyType.PercentageOfProperty;
|
||||
|
||||
PropertyChanged += OnPropertyChanged;
|
||||
|
||||
// Preselect according to the model
|
||||
SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
|
||||
SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
|
||||
LayerPropertyType = Proposed.LayerPropertyType;
|
||||
// Set up a default for SelectedTarget if it was null
|
||||
if (SelectedTarget.Display == null)
|
||||
SelectedTarget = nullTarget;
|
||||
|
||||
if (property == "Width")
|
||||
LayerPropertyOptions = new BindableCollection<string> { "Left to right", "Right to left" };
|
||||
else if (property == "Height")
|
||||
LayerPropertyOptions = new BindableCollection<string> { "Downwards", "Upwards" };
|
||||
else if (property == "Opacity")
|
||||
LayerPropertyOptions = new BindableCollection<string> { "Increase", "Decrease" };
|
||||
}
|
||||
|
||||
public LayerPropertyType LayerPropertyType
|
||||
@ -86,6 +105,7 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
if (value.Equals(_selectedTarget)) return;
|
||||
_selectedTarget = value;
|
||||
NotifyOfPropertyChange(() => SelectedTarget);
|
||||
NotifyOfPropertyChange(() => ControlsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,6 +120,28 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
}
|
||||
}
|
||||
|
||||
public BindableCollection<string> LayerPropertyOptions
|
||||
{
|
||||
get { return _layerPropertyOptions; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _layerPropertyOptions)) return;
|
||||
_layerPropertyOptions = value;
|
||||
NotifyOfPropertyChange(() => LayerPropertyOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedLayerPropertyOption
|
||||
{
|
||||
get { return _selectedLayerPropertyOption; }
|
||||
set
|
||||
{
|
||||
if (value == _selectedLayerPropertyOption) return;
|
||||
_selectedLayerPropertyOption = value;
|
||||
NotifyOfPropertyChange(() => SelectedLayerPropertyOption);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SourcesIsVisible
|
||||
{
|
||||
get { return _sourcesIsVisible; }
|
||||
@ -122,6 +164,8 @@ namespace Artemis.ViewModels.LayerEditor
|
||||
}
|
||||
}
|
||||
|
||||
public bool ControlsEnabled => SelectedTarget.Display != "None" && SelectedTarget.Path != null;
|
||||
|
||||
public BindableCollection<GeneralHelpers.PropertyCollection> Targets { get; set; }
|
||||
|
||||
public BindableCollection<GeneralHelpers.PropertyCollection> Sources { get; set; }
|
||||
|
||||
@ -23,10 +23,11 @@
|
||||
<Grid>
|
||||
<!-- Height -->
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="65*" />
|
||||
<ColumnDefinition Width="50*" />
|
||||
<ColumnDefinition Width="86*" />
|
||||
<ColumnDefinition Width="65*" />
|
||||
<ColumnDefinition Width="86*" />
|
||||
<ColumnDefinition Width="75*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="Name" Grid.Column="0" Margin="10" FontSize="13.333" VerticalAlignment="Center" Height="18" />
|
||||
|
||||
@ -51,7 +52,8 @@
|
||||
<!-- Dynamic type -->
|
||||
<ComboBox SelectedItem="{Binding Path=LayerPropertyType}" Grid.Column="2"
|
||||
ItemsSource="{Binding Source={StaticResource DynamicPropertyValues}}"
|
||||
Margin="10,0" VerticalAlignment="Center" Height="22">
|
||||
Margin="10,0" VerticalAlignment="Center" Height="22"
|
||||
IsEnabled="{Binding Path=ControlsEnabled}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
||||
@ -61,7 +63,8 @@
|
||||
|
||||
<!-- PercentageOfProperty -->
|
||||
<StackPanel Grid.Column="3" x:Name="SourcesIsVisible" VerticalAlignment="Center">
|
||||
<ComboBox x:Name="Sources" Margin="10,0" MaxDropDownHeight="125" Height="22">
|
||||
<ComboBox x:Name="Sources" Margin="10,0" MaxDropDownHeight="125" Height="22"
|
||||
IsEnabled="{Binding Path=ControlsEnabled}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid MinWidth="522">
|
||||
@ -80,7 +83,13 @@
|
||||
|
||||
<!-- PercentageOf -->
|
||||
<StackPanel Grid.Column="3" x:Name="UserSourceIsVisible" VerticalAlignment="Center">
|
||||
<controls:NumericUpDown Margin="10,0" Height="22" Value="{Binding Path=Proposed.PercentageSource, Mode=TwoWay}" />
|
||||
<controls:NumericUpDown Margin="10,0" Height="22"
|
||||
Value="{Binding Path=Proposed.PercentageSource, Mode=TwoWay}"
|
||||
IsEnabled="{Binding Path=ControlsEnabled}" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Extra option -->
|
||||
<ComboBox Grid.Column="4" x:Name="LayerPropertyOptions" VerticalAlignment="Center" Margin="10,0"
|
||||
IsEnabled="{Binding Path=ControlsEnabled}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Loading…
x
Reference in New Issue
Block a user