diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs index b3c3e78c3..4cd90aafc 100644 --- a/Artemis/Artemis/Managers/LoopManager.cs +++ b/Artemis/Artemis/Managers/LoopManager.cs @@ -154,7 +154,8 @@ 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)); - Monitor.Exit(_keyboardManager.ActiveKeyboard); + if (_keyboardManager.ActiveKeyboard != null) + Monitor.Exit(_keyboardManager.ActiveKeyboard); } } } \ No newline at end of file diff --git a/Artemis/Artemis/Models/Profiles/Properties/DynamicPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/Properties/DynamicPropertiesModel.cs index 1986b5a83..0d809ec60 100644 --- a/Artemis/Artemis/Models/Profiles/Properties/DynamicPropertiesModel.cs +++ b/Artemis/Artemis/Models/Profiles/Properties/DynamicPropertiesModel.cs @@ -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 } } \ No newline at end of file diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs index 6aaf24fd4..c5da45aa9 100644 --- a/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs +++ b/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs @@ -9,15 +9,19 @@ namespace Artemis.ViewModels.LayerEditor public sealed class LayerDynamicPropertiesViewModel : PropertyChangedBase { private readonly string _property; - private DynamicPropertiesModel _proposed; + private BindableCollection _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 dataModelProps, KeyboardPropertiesModel keyboardProperties) + public LayerDynamicPropertiesViewModel(string property, + BindableCollection 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(); + + var nullTarget = new GeneralHelpers.PropertyCollection {Display = "None"}; + Targets = new BindableCollection {nullTarget}; Targets.AddRange(dataModelProps.Where(p => p.Type == "Int32")); Sources = new BindableCollection(); 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 { "Left to right", "Right to left" }; + else if (property == "Height") + LayerPropertyOptions = new BindableCollection { "Downwards", "Upwards" }; + else if (property == "Opacity") + LayerPropertyOptions = new BindableCollection { "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 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 Targets { get; set; } public BindableCollection Sources { get; set; } diff --git a/Artemis/Artemis/Views/LayerEditor/LayerDynamicPropertiesView.xaml b/Artemis/Artemis/Views/LayerEditor/LayerDynamicPropertiesView.xaml index 7d12dd290..d1cf69cc1 100644 --- a/Artemis/Artemis/Views/LayerEditor/LayerDynamicPropertiesView.xaml +++ b/Artemis/Artemis/Views/LayerEditor/LayerDynamicPropertiesView.xaml @@ -23,10 +23,11 @@ - + + @@ -51,7 +52,8 @@ + Margin="10,0" VerticalAlignment="Center" Height="22" + IsEnabled="{Binding Path=ControlsEnabled}"> @@ -61,7 +63,8 @@ - + @@ -80,7 +83,13 @@ - + + + + \ No newline at end of file