mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data bindings - Highlight current property
Data bindings - Disable data-bound property inputs Data bindings - Use toggle to indicate data bindings being enabled
This commit is contained in:
1 parent
0c25d0bbec
commit
d788183f25
29 files changed
+295
-58
No files matched your search
@@ -3,13 +3,28 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Style>
|
||||
<Style>
|
||||
<Style TargetType="UserControl" >
|
||||
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource MaterialDesignValidationErrorTemplate}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsEnabled}" Value="False">
|
||||
<Setter Property="Opacity" Value="0.5" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Style>
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="Rectangle" x:Key="RectStyle">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=IsEnabled}" Value="False">
|
||||
<Setter Property="StrokeDashArray" Value="2 2" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<!-- Drag handle -->
|
||||
<Border x:Name="DragHandle" BorderThickness="0,0,0,1" Height="19">
|
||||
@@ -17,10 +32,12 @@
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle x:Name="BorderVisual"
|
||||
Style="{StaticResource RectStyle}"
|
||||
Stroke="{DynamicResource MaterialDesignTextBoxBorder}"
|
||||
StrokeThickness="1"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}">
|
||||
</Rectangle>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class LockableToggleButton : ToggleButton
|
||||
{
|
||||
protected override void OnToggle()
|
||||
{
|
||||
if (!IsLocked)
|
||||
{
|
||||
base.OnToggle();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLocked
|
||||
{
|
||||
get { return (bool)GetValue(IsLockedProperty); }
|
||||
set { SetValue(IsLockedProperty, value); }
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for LockToggle. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IsLockedProperty =
|
||||
DependencyProperty.Register("IsLocked", typeof(bool), typeof(LockableToggleButton), new UIPropertyMetadata(false));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ namespace Artemis.UI.Shared
|
||||
ProfileEditorService = profileEditorService;
|
||||
LayerProperty.Updated += LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled += LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled += LayerPropertyOnDataBindingChange;
|
||||
UpdateInputValue();
|
||||
}
|
||||
|
||||
@@ -25,11 +27,14 @@ namespace Artemis.UI.Shared
|
||||
ProfileEditorService = profileEditorService;
|
||||
LayerProperty.Updated += LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged += LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled += LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled += LayerPropertyOnDataBindingChange;
|
||||
UpdateInputValue();
|
||||
}
|
||||
|
||||
public LayerProperty<T> LayerProperty { get; }
|
||||
public IProfileEditorService ProfileEditorService { get; }
|
||||
|
||||
internal override object InternalGuard { get; } = null;
|
||||
|
||||
public bool InputDragging
|
||||
@@ -52,6 +57,8 @@ namespace Artemis.UI.Shared
|
||||
{
|
||||
LayerProperty.Updated -= LayerPropertyOnUpdated;
|
||||
LayerProperty.BaseValueChanged -= LayerPropertyOnUpdated;
|
||||
LayerProperty.DataBindingEnabled -= LayerPropertyOnDataBindingChange;
|
||||
LayerProperty.DataBindingDisabled -= LayerPropertyOnDataBindingChange;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
@@ -65,6 +72,10 @@ namespace Artemis.UI.Shared
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDataBindingsChanged()
|
||||
{
|
||||
}
|
||||
|
||||
protected void ApplyInputValue()
|
||||
{
|
||||
// Force the validator to run
|
||||
@@ -123,6 +134,11 @@ namespace Artemis.UI.Shared
|
||||
ProfileEditorService.UpdateProfilePreview();
|
||||
}
|
||||
|
||||
private void LayerPropertyOnDataBindingChange(object sender, LayerPropertyEventArgs<T> e)
|
||||
{
|
||||
OnDataBindingsChanged();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user