-
-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathDataBlockViewControl.xaml
237 lines (226 loc) · 13 KB
/
DataBlockViewControl.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<UserControl x:Class="TestProjectFileFunctions.DataBlockViewControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TestProjectFileFunctions"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Step7V51="clr-namespace:DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks.Step7V5;assembly=DotNetSiemensPLCToolBoxLibrary"
xmlns:Step7V11="clr-namespace:DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks;assembly=DotNetSiemensPLCToolBoxLibrary"
xmlns:step7V11="clr-namespace:DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks.Step7V11;assembly=DotNetSiemensPLCToolBoxLibrary"
d:DesignHeight="300"
d:DesignWidth="500"
mc:Ignorable="d">
<UserControl.Resources>
<Style TargetType="TreeViewItem">
<Style.Resources>
<!-- Resources omitted for clarity… -->
</Style.Resources>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<StackPanel Margin="0" Orientation="Vertical">
<!-- Presents the Content -->
<Border Name="sel"
Margin="0"
Padding="0">
<ContentPresenter Name="PART_Header"
Margin="0"
ContentSource="Header" />
</Border>
<!-- Presents the Children -->
<Border Margin="0" Padding="0">
<ItemsPresenter x:Name="ItemsHost" Margin="0" />
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<!--
When the item is selected in the TreeView, use the
"selected" colors and give it a drop shadow.
-->
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="sel" Property="Background" Value="Blue" />
<!-- Setters omitted for clarity... -->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- Make each TreeViewItem show it's children in a StackPanel. -->
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Margin="0"
HorizontalAlignment="Left"
IsItemsHost="True" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True" />
</Style>
<local:TreeviewDepthWidthConverter x:Key="lengthConverter" Width="19" />
<local:TreeviewDepthWidthConverter x:Key="length2Converter"
Width="330"
preWidth="19" />
</UserControl.Resources>
<Grid Margin="0" Background="White">
<!--
<StackPanel Height="20" Orientation="Horizontal" Margin="0">
<Border Padding="2" BorderThickness="1,1,1,1" BorderBrush="Black">
<TextBlock TextAlignment="Right" Text="Address" Margin="0" Width="45"/>
</Border>
<Border Padding="2" Width="330" BorderThickness="1,1,1,1" BorderBrush="Black">
<TextBlock Text="Name" Margin="0"/>
</Border>
<Border Padding="2" BorderThickness="1,1,1,1" BorderBrush="Black" Width="80">
<TextBlock Text="DataType" Margin="0"/>
</Border>
<Border Padding="2" BorderThickness="1,1,1,1" BorderBrush="Black" Width="300">
<TextBlock Text="Value" Margin="0"/>
</Border>
</StackPanel>
-->
<TreeView VirtualizingStackPanel.IsVirtualizing="True" Name="MyTree"
Margin="0,30,0,0"
Padding="0">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type step7V11:TIADataRow}" ItemsSource="{Binding Children}">
<Grid Margin="0">
<StackPanel Margin="0" Orientation="Horizontal">
<Border BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Width="45"
Margin="0"
Text="{Binding BlockAddress}"
TextAlignment="Right" />
</Border>
<Border Width="{Binding Converter={StaticResource lengthConverter}}" Margin="0" />
<Border Width="{Binding Converter={StaticResource length2Converter}}"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding Name}"
ToolTip="{Binding StructuredName}" />
</Border>
<Border Width="300"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding SymbolicVisuAccessKey}"
ToolTip="{Binding SymbolicVisuAccessKey}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding DataTypeAsString}"
ToolTip="{Binding DataTypeAsString}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding StartValueAsString}"
ToolTip="{Binding StartValueAsString}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding ValueAsString}"
ToolTip="{Binding ValueAsString}" />
</Border>
<Border Width="300"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding Comment}"
ToolTip="{Binding Comment}" />
</Border>
<Border Width="300"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0" Text="{Binding Path=LibNoDaveValue.Value}" />
</Border>
</StackPanel>
</Grid>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type Step7V51:S7DataRow}" ItemsSource="{Binding Children}">
<Grid Margin="0">
<StackPanel Margin="0" Orientation="Horizontal">
<Border BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Width="45"
Margin="0"
Text="{Binding BlockAddress}"
TextAlignment="Right" />
</Border>
<Border Width="{Binding Converter={StaticResource lengthConverter}}" Margin="0" />
<Border Width="{Binding Converter={StaticResource length2Converter}}"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding Name}"
ToolTip="{Binding StructuredName}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding DataTypeAsString}"
ToolTip="{Binding DataTypeAsString}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding StartValueAsString}"
ToolTip="{Binding StartValueAsString}" />
</Border>
<Border Width="180"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding ValueAsString}"
ToolTip="{Binding ValueAsString}" />
</Border>
<Border Width="300"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0"
Text="{Binding Comment}"
ToolTip="{Binding Comment}" />
</Border>
<Border Width="300"
BorderBrush="Black"
BorderThickness="1,1,1,1"
Padding="2">
<TextBlock Margin="0" Text="{Binding Path=LibNoDaveValue.Value}" />
</Border>
</StackPanel>
</Grid>
</HierarchicalDataTemplate>
</TreeView.Resources>
<TreeView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</TreeView.ItemsPanel>
</TreeView>
<RadioButton x:Name="chkProjectString" Content="Structure from Project String" HorizontalAlignment="Left" Margin="5,5,0,0" VerticalAlignment="Top" IsChecked="True" Checked="chkProjectString_Checked"/>
<RadioButton x:Name="chkMC7Code" Content="Structure from MC7 Code" HorizontalAlignment="Left" Margin="262,5,0,0" VerticalAlignment="Top" Checked="chkMC7Code_Checked"/>
</Grid>
</UserControl>