mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Project - Cleaned up some test code
UI - Added scaffolding for databindings
This commit is contained in:
1 parent
47ba6fcf5e
commit
9e4ae9bbe1
28 files changed
+437
-453
No files matched your search
+271
@@ -0,0 +1,271 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DataBindingView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
xmlns:utilities="clr-namespace:Artemis.UI.Utilities"
|
||||
xmlns:dd="urn:gong-wpf-dragdrop"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DisplayConditions.xaml" />
|
||||
<ResourceDictionary>
|
||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
||||
<DataTemplate x:Key="DataModelDataTemplate">
|
||||
<Control x:Name="TemplateControl" Focusable="False" Template="{StaticResource DataModelSelectionTemplate}" />
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding Data.ShowDataModelValues.Value, Source={StaticResource DataContextProxy}}" Value="True">
|
||||
<Setter TargetName="TemplateControl" Property="Template" Value="{StaticResource DataModelSelectionTemplateWithValues}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<Grid Margin="10 0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0.75*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Margin="0 5 5 0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="-3 0 0 0">
|
||||
<Label FontSize="10" Foreground="{StaticResource MaterialDesignNavigationItemSubheader}" Margin="0 0 0 2">Source</Label>
|
||||
<Button Background="#ab47bc"
|
||||
BorderBrush="#ab47bc"
|
||||
Style="{StaticResource DisplayConditionButton}"
|
||||
ToolTip="{Binding SelectedLeftSideProperty.DisplayPropertyPath}"
|
||||
HorizontalAlignment="Left">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu ItemsSource="{Binding LeftSideDataModel.Children}" IsOpen="{Binding LeftSideDataModelOpen, Mode=OneWayToSource}">
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||
<Setter Property="ItemsSource" Value="{Binding Children}" />
|
||||
<Setter Property="Command" Value="{Binding Data.SelectLeftPropertyCommand, Source={StaticResource DataContextProxy}}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||
<Setter Property="CommandTarget" Value="{Binding}" />
|
||||
<Setter Property="IsEnabled" Value="{Binding IsMatchingFilteredTypes}" />
|
||||
<Setter Property="IsSubmenuOpen" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource DataModelDataTemplate}" />
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding SelectedLeftSideProperty.PropertyDescription.Name}"
|
||||
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||
<TextBlock Text="« Select a property »"
|
||||
FontStyle="Italic"
|
||||
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}" />
|
||||
</Grid>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<ComboBox Grid.Row="1"
|
||||
Style="{StaticResource MaterialDesignFloatingHintComboBox}"
|
||||
materialDesign:HintAssist.Hint="Mode"
|
||||
MinWidth="128">
|
||||
<ComboBoxItem>
|
||||
Replace value
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
Add to value
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
Subtract from value
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
|
||||
<StackPanel Grid.Row="2">
|
||||
<TextBox Style="{StaticResource MaterialDesignFloatingHintTextBox}"
|
||||
Text="200"
|
||||
materialDesign:TextFieldAssist.HasClearButton="True"
|
||||
materialDesign:TextFieldAssist.SuffixText="ms"
|
||||
materialDesign:HintAssist.Hint="Smoothing time" />
|
||||
</StackPanel>
|
||||
|
||||
<ComboBox Grid.Row="3"
|
||||
Style="{StaticResource MaterialDesignFloatingHintComboBox}"
|
||||
materialDesign:HintAssist.Hint="Smoothing type"
|
||||
MinWidth="128">
|
||||
<ComboBoxItem>
|
||||
Ease in
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
Ease out
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
Ease in and out
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
|
||||
<materialDesign:Card Grid.Row="4" Grid.ColumnSpan="2" Margin="0 5 0 0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Margin="10 10 4 0">
|
||||
Test result
|
||||
</TextBlock>
|
||||
<Separator Grid.Row="1" Style="{StaticResource MaterialDesignLightSeparator}" Margin="0" />
|
||||
<Grid Grid.Row="2" Margin="10 4 10 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Margin="0 2">Input</TextBlock>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Margin="0 2" FontFamily="Consolas">1250</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0 2">Output</TextBlock>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0 2" FontFamily="Consolas">909</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid Margin="5 26 0 0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Style="{StaticResource MaterialDesignFlatMidBgButton}"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="12"
|
||||
Padding="6 4"
|
||||
Height="22">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Margin="0 -1 4 0" Kind="Plus" />
|
||||
<TextBlock>
|
||||
Add modifier
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<!-- ItemsSource="{Binding ModifierViewModels}" -->
|
||||
<ListBox Grid.Row="1"
|
||||
materialDesign:RippleAssist.IsDisabled="True"
|
||||
dd:DragDrop.IsDragSource="True"
|
||||
dd:DragDrop.IsDropTarget="True"
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
dd:DragDrop.DropHandler="{Binding}"
|
||||
HorizontalContentAlignment="Stretch">
|
||||
<!-- <ListBox.ItemTemplate> -->
|
||||
<!-- <DataTemplate> -->
|
||||
<!-- <ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" /> -->
|
||||
<!-- </DataTemplate> -->
|
||||
<!-- </ListBox.ItemTemplate> -->
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
ToolTip="Delete the modifier"
|
||||
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="#E74C4C"
|
||||
Width="25"
|
||||
Height="25"
|
||||
Command="{s:Action Delete}">
|
||||
<materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
|
||||
</Button>
|
||||
<Button Grid.Column="1"
|
||||
ToolTip="Swap modifier type to static/dynamic"
|
||||
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="{StaticResource SecondaryAccentBrush}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
Command="{s:Action SwapType}">
|
||||
<materialDesign:PackIcon Kind="SwapHorizontalVariant" Width="18" Height="18" />
|
||||
</Button>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
||||
Background="#7B7B7B"
|
||||
BorderBrush="#7B7B7B"
|
||||
Content="{Binding SelectedOperator.Description}">
|
||||
<!-- Click="PropertyButton_OnClick" -->
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu ItemsSource="{Binding Operators}">
|
||||
<ContextMenu.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="{Binding Icon}" VerticalAlignment="Center" Margin="0 0 15 0" />
|
||||
<TextBlock Text="{Binding Description}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContextMenu.ItemTemplate>
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||
<Setter Property="Command" Value="{Binding Data.SelectOperatorCommand, Source={StaticResource DataContextProxy}}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||
<Setter Property="CommandTarget" Value="{Binding}" />
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
<Button Grid.Column="3"
|
||||
Background="#ab47bc"
|
||||
BorderBrush="#ab47bc"
|
||||
Style="{StaticResource DisplayConditionButton}"
|
||||
ToolTip="{Binding SelectedLeftSideProperty.DisplayPropertyPath}"
|
||||
HorizontalAlignment="Left">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu ItemsSource="{Binding LeftSideDataModel.Children}" IsOpen="{Binding LeftSideDataModelOpen, Mode=OneWayToSource}">
|
||||
<ContextMenu.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||
<Setter Property="ItemsSource" Value="{Binding Children}" />
|
||||
<Setter Property="Command" Value="{Binding Data.SelectLeftPropertyCommand, Source={StaticResource DataContextProxy}}" />
|
||||
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||
<Setter Property="CommandTarget" Value="{Binding}" />
|
||||
<Setter Property="IsEnabled" Value="{Binding IsMatchingFilteredTypes}" />
|
||||
<Setter Property="IsSubmenuOpen" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource DataModelDataTemplate}" />
|
||||
</Style>
|
||||
</ContextMenu.ItemContainerStyle>
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding SelectedLeftSideProperty.PropertyDescription.Name}"
|
||||
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||
<TextBlock Text="« Select a property »"
|
||||
FontStyle="Italic"
|
||||
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}" />
|
||||
</Grid>
|
||||
</Button>
|
||||
</Grid>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
+2
-2
@@ -4,9 +4,9 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsTabViewModel : PropertyChangedBase
|
||||
public class DataBindingViewModel : PropertyChangedBase
|
||||
{
|
||||
public DataBindingsTabViewModel(BaseLayerProperty layerProperty, PropertyInfo dataBindingProperty)
|
||||
public DataBindingViewModel(BaseLayerProperty layerProperty, PropertyInfo dataBindingProperty)
|
||||
{
|
||||
DisplayName = dataBindingProperty.Name.ToUpper();
|
||||
LayerProperty = layerProperty;
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DataBindingsTabView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DataBindingsTabsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<TabControl ItemsSource="{Binding Tabs}" DisplayMemberPath="DisplayName" Style="{StaticResource MaterialDesignTabControl}" >
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsTabsViewModel : PropertyChangedBase
|
||||
{
|
||||
public DataBindingsTabsViewModel()
|
||||
{
|
||||
Tabs = new BindableCollection<DataBindingViewModel>();
|
||||
}
|
||||
public BindableCollection<DataBindingViewModel> Tabs { get; set; }
|
||||
}
|
||||
}
|
||||
+5
-12
@@ -9,16 +9,9 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:DataBindingsViewModel}">
|
||||
<TabControl Margin="0 -1 0 0"
|
||||
ItemsSource="{Binding Tabs}"
|
||||
DisplayMemberPath="DisplayName"
|
||||
Style="{StaticResource MaterialDesignTabControl}">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect FadeIn}">
|
||||
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</materialDesign:TransitioningContent>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
<Grid>
|
||||
<!-- Use tabs for multiple properties only, only one of these VMs is set -->
|
||||
<ContentControl s:View.Model="{Binding DataBindingsTabsViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding DataBindingViewModel}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+31
-6
@@ -1,25 +1,50 @@
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingsViewModel : PropertyChangedBase
|
||||
{
|
||||
private DataBindingViewModel _dataBindingViewModel;
|
||||
private DataBindingsTabsViewModel _dataBindingsTabsViewModel;
|
||||
|
||||
public DataBindingsViewModel(BaseLayerProperty layerProperty)
|
||||
{
|
||||
Tabs = new BindableCollection<DataBindingsTabViewModel>();
|
||||
LayerProperty = layerProperty;
|
||||
|
||||
Initialise();
|
||||
}
|
||||
|
||||
public BindableCollection<DataBindingsTabViewModel> Tabs { get; set; }
|
||||
public BaseLayerProperty LayerProperty { get; }
|
||||
|
||||
public DataBindingViewModel DataBindingViewModel
|
||||
{
|
||||
get => _dataBindingViewModel;
|
||||
set => SetAndNotify(ref _dataBindingViewModel, value);
|
||||
}
|
||||
|
||||
public DataBindingsTabsViewModel DataBindingsTabsViewModel
|
||||
{
|
||||
get => _dataBindingsTabsViewModel;
|
||||
set => SetAndNotify(ref _dataBindingsTabsViewModel, value);
|
||||
}
|
||||
|
||||
private void Initialise()
|
||||
{
|
||||
foreach (var dataBindingProperty in LayerProperty.GetDataBindingProperties())
|
||||
Tabs.Add(new DataBindingsTabViewModel(LayerProperty, dataBindingProperty));
|
||||
var properties = LayerProperty.GetDataBindingProperties();
|
||||
if (properties.Count == 0)
|
||||
return;
|
||||
|
||||
if (properties.Count == 1)
|
||||
{
|
||||
DataBindingViewModel = new DataBindingViewModel(LayerProperty, properties.First());
|
||||
}
|
||||
else
|
||||
{
|
||||
DataBindingsTabsViewModel = new DataBindingsTabsViewModel();
|
||||
foreach (var dataBindingProperty in LayerProperty.GetDataBindingProperties())
|
||||
DataBindingsTabsViewModel.Tabs.Add(new DataBindingViewModel(LayerProperty, dataBindingProperty));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user