forked from miroiu/nodify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlackboardKeyEditorView.xaml
152 lines (145 loc) · 7.73 KB
/
BlackboardKeyEditorView.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<UserControl x:Class="Nodify.StateMachine.BlackboardKeyEditorView"
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:Nodify.StateMachine"
xmlns:shared="clr-namespace:Nodify;assembly=Nodify.Shared"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type={x:Type local:BlackboardKeyEditorViewModel}, IsDesignTimeCreatable=True}"
d:Background="{DynamicResource PanelBackgroundBrush}"
d:DesignWidth="400">
<UserControl.Resources>
<DataTemplate x:Key="BooleanTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<CheckBox IsChecked="{Binding Target.Value}"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
</DataTemplate>
<DataTemplate x:Key="IntegerTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<TextBox Text="{Binding Target.Value, UpdateSourceTrigger=LostFocus}" />
</DataTemplate>
<DataTemplate x:Key="DoubleTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<TextBox Text="{Binding Target.Value, UpdateSourceTrigger=LostFocus}" />
</DataTemplate>
<DataTemplate x:Key="StringTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<TextBox Text="{Binding Target.Value, UpdateSourceTrigger=LostFocus}" />
</DataTemplate>
<DataTemplate x:Key="ObjectTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<TextBox Text="{Binding Target.Value, UpdateSourceTrigger=LostFocus}"
IsEnabled="False" />
</DataTemplate>
<DataTemplate x:Key="KeyTemplate"
DataType="{x:Type local:BlackboardKeyEditorViewModel}">
<ComboBox SelectedItem="{Binding Target.Value}"
DisplayMemberPath="Name">
<ComboBox.ItemsSource>
<MultiBinding Converter="{local:FilterBlackboardKeysConverter}">
<Binding Path="AvailableKeys" />
<Binding Path="Target.Type" />
<!--USED TO NOTIFY OF COLLECTION CHANGED-->
<Binding Path="AvailableKeys.Count" />
</MultiBinding>
</ComboBox.ItemsSource>
</ComboBox>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
SharedSizeGroup="KeyName" />
<ColumnDefinition Width="Auto"
SharedSizeGroup="KeyType" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<shared:EditableTextBlock Text="{Binding Target.Name}"
d:Text="My blackboard key"
IsEditing="{Binding IsEditing}"
Foreground="{DynamicResource ForegroundBrush}"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
Margin="1 1 5 1" />
<ComboBox ItemsSource="{Binding Target.Type, Converter={shared:EnumValuesConverter}}"
IsEnabled="{Binding CanChangeKeyType}"
SelectedValue="{Binding Target.Type}"
SelectedValuePath="Value"
DisplayMemberPath="Name"
Grid.Column="1"
Margin="0 0 5 0" />
<Grid Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="150" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentControl Content="{Binding}">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Target.Type}"
Value="Boolean">
<Setter Property="ContentTemplate"
Value="{StaticResource BooleanTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.Type}"
Value="Integer">
<Setter Property="ContentTemplate"
Value="{StaticResource IntegerTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.Type}"
Value="Double">
<Setter Property="ContentTemplate"
Value="{StaticResource DoubleTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.Type}"
Value="String">
<Setter Property="ContentTemplate"
Value="{StaticResource StringTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.Type}"
Value="Object">
<Setter Property="ContentTemplate"
Value="{StaticResource ObjectTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.Type}"
Value="Key">
<Setter Property="ContentTemplate"
Value="{StaticResource KeyTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Target.ValueIsKey}"
Value="True">
<Setter Property="ContentTemplate"
Value="{StaticResource KeyTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
<CheckBox Visibility="{Binding CanChangeInputType, Converter={shared:BooleanToVisibilityConverter}}"
IsChecked="{Binding Target.ValueIsKey}"
ToolTip="Toggle input type"
Grid.Column="1">
<CheckBox.Style>
<Style TargetType="{x:Type CheckBox}"
BasedOn="{StaticResource IconCheckBox}">
<Setter Property="Content"
Value="{StaticResource DiamondIcon}" />
<Style.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Content"
Value="{StaticResource DiamondFillIcon}" />
</Trigger>
</Style.Triggers>
</Style>
</CheckBox.Style>
</CheckBox>
</Grid>
</Grid>
</UserControl>