mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Shared UI - Moved initialization code
Color picker - Added toggle to preview color on devices Settings - Added toggable auto-save
This commit is contained in:
1 parent
33373bda57
commit
fa329a9048
16 files changed
+276
-103
No files matched your search
+7
-5
@@ -30,21 +30,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
|
||||
public ConditionalDataBinding<TLayerProperty, TProperty> ConditionalDataBinding { get; }
|
||||
public BindableCollection<DataBindingConditionViewModel<TLayerProperty, TProperty>> ConditionViewModels { get; }
|
||||
public bool SupportsTestValue => false;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
UpdateConditionViewModels();
|
||||
}
|
||||
|
||||
|
||||
public object GetTestValue()
|
||||
{
|
||||
return ConditionalDataBinding.DataBinding.Converter.GetValue();
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void AddCondition(string type)
|
||||
{
|
||||
var condition = ConditionalDataBinding.AddCondition();
|
||||
|
||||
|
||||
// Find the VM of the new condition
|
||||
var viewModel = ConditionViewModels.First(c => c.DataBindingCondition == condition);
|
||||
viewModel.ActiveItem.AddCondition(type);
|
||||
@@ -58,7 +59,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
|
||||
// Remove old VMs
|
||||
var toRemove = ConditionViewModels.Where(c => !ConditionalDataBinding.Conditions.Contains(c.DataBindingCondition)).ToList();
|
||||
foreach (var dataBindingConditionViewModel in toRemove) {
|
||||
foreach (var dataBindingConditionViewModel in toRemove)
|
||||
{
|
||||
ConditionViewModels.Remove(dataBindingConditionViewModel);
|
||||
dataBindingConditionViewModel.Dispose();
|
||||
}
|
||||
@@ -72,7 +74,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
|
||||
// Fix order
|
||||
ConditionViewModels.Sort(c => c.DataBindingCondition.Order);
|
||||
|
||||
|
||||
_updating = false;
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -21,13 +21,13 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<materialDesign:Card Grid.Column="0"
|
||||
UniformCornerRadius="0"
|
||||
materialDesign:ShadowAssist.ShadowDepth="Depth3"
|
||||
materialDesign:ShadowAssist.ShadowEdges="Right"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
Panel.ZIndex="2">
|
||||
<Grid Margin="10 5" >
|
||||
<materialDesign:Card Grid.Column="0"
|
||||
UniformCornerRadius="0"
|
||||
materialDesign:ShadowAssist.ShadowDepth="Depth3"
|
||||
materialDesign:ShadowAssist.ShadowEdges="Right"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
Panel.ZIndex="2">
|
||||
<Grid Margin="10 5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="48" />
|
||||
@@ -39,11 +39,10 @@
|
||||
Style="{StaticResource MaterialDesignFloatingHintComboBox}"
|
||||
materialDesign:HintAssist.Hint="Data binding mode"
|
||||
MinWidth="128"
|
||||
SelectedValue="{Binding SelectedDataBindingMode}"
|
||||
ItemsSource="{Binding DataBindingModes}"
|
||||
SelectedValue="{Binding SelectedDataBindingMode}"
|
||||
ItemsSource="{Binding DataBindingModes}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description" >
|
||||
</ComboBox>
|
||||
DisplayMemberPath="Description" />
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBox Style="{StaticResource MaterialDesignFloatingHintTextBox}"
|
||||
@@ -102,23 +101,24 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Margin="0 2">Input</TextBlock>
|
||||
<TextBlock Margin="0 2" Visibility="{Binding ActiveItem.SupportsTestValue, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">Input</TextBlock>
|
||||
<ContentControl Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
s:View.Model="{Binding TestInputValue}"
|
||||
Margin="0 2"
|
||||
FontFamily="Consolas"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Right" />
|
||||
Grid.Column="1"
|
||||
Visibility="{Binding ActiveItem.SupportsTestValue, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
|
||||
s:View.Model="{Binding TestInputValue}"
|
||||
Margin="0 2"
|
||||
FontFamily="Consolas"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0 2">Output</TextBlock>
|
||||
<ContentControl Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
s:View.Model="{Binding TestResultValue}"
|
||||
Margin="0 2"
|
||||
FontFamily="Consolas"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Right" />
|
||||
<ContentControl Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
s:View.Model="{Binding TestResultValue}"
|
||||
Margin="0 2"
|
||||
FontFamily="Consolas"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</materialDesign:Card>
|
||||
@@ -127,10 +127,10 @@
|
||||
|
||||
<materialDesign:Card Grid.Column="1" UniformCornerRadius="0" Background="{DynamicResource MaterialDesignToolBarBackground}" Panel.ZIndex="1">
|
||||
<Grid Margin="10 5">
|
||||
<ContentControl s:View.Model="{Binding ActiveItem, IsAsync=True}"
|
||||
VerticalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsTabStop="False"/>
|
||||
<ContentControl s:View.Model="{Binding ActiveItem, IsAsync=True}"
|
||||
VerticalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsTabStop="False" />
|
||||
</Grid>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
|
||||
+11
-5
@@ -205,17 +205,23 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
|
||||
private void UpdateTestResult()
|
||||
{
|
||||
if (Registration.DataBinding == null)
|
||||
if (Registration.DataBinding == null || ActiveItem == null)
|
||||
{
|
||||
TestInputValue.UpdateValue(default);
|
||||
TestResultValue.UpdateValue(default);
|
||||
return;
|
||||
}
|
||||
|
||||
var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
|
||||
|
||||
TestInputValue.UpdateValue(currentValue);
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(currentValue) : default);
|
||||
if (ActiveItem.SupportsTestValue)
|
||||
{
|
||||
var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
|
||||
TestInputValue.UpdateValue(currentValue);
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(currentValue) : default);
|
||||
}
|
||||
else
|
||||
{
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(default) : default);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableDataBinding()
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
public DirectDataBinding<TLayerProperty, TProperty> DirectDataBinding { get; }
|
||||
public BindableCollection<DataBindingModifierViewModel<TLayerProperty, TProperty>> ModifierViewModels { get; }
|
||||
public bool SupportsTestValue => true;
|
||||
|
||||
public bool CanAddModifier
|
||||
{
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
public interface IDataBindingModeViewModel : IScreen, IDisposable
|
||||
{
|
||||
void Update();
|
||||
bool SupportsTestValue { get; }
|
||||
object GetTestValue();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user