aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Views/MachineTechView.xaml
blob: 784bd56fb1e2871995cba907d03c4100d06d2ef0 (plain)
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<UserControl x:Class="Tango.MachineStudio.Technician.Views.MachineTechView"
             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:vm="clr-namespace:Tango.MachineStudio.Technician.ViewModels"
             xmlns:global="clr-namespace:Tango.MachineStudio.Technician"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:fa="http://schemas.fontawesome.io/icons/"
             xmlns:editors="clr-namespace:Tango.Editors;assembly=Tango.Editors"
             xmlns:techItems="clr-namespace:Tango.MachineStudio.Technician.TechItems"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:templates="clr-namespace:Tango.MachineStudio.Technician.PropertiesTemplates"
             xmlns:items="clr-namespace:Tango.MachineStudio.Technician.TechItems"
             xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Tango.MachineStudio.Technician.Views"
             mc:Ignorable="d" 
             d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MachineTechViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MachineTechViewVM}">

    <UserControl.Resources>
        <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="150"/>
                <RowDefinition Height="199*"/>
            </Grid.RowDefinitions>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="1*"/>
                </Grid.RowDefinitions>

                <Menu Padding="5" Background="#C6ECECEC" Visibility="{Binding HideMenu,Converter={StaticResource BooleanToVisibilityInverseConverter}}">
                    <MenuItem Header="File">
                        <MenuItem Command="{Binding OpenProjectCommand}" MinWidth="180" Header="Open" VerticalContentAlignment="Center">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="FolderOpen" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Save" Command="{Binding SaveProjectCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Save" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Save as" Command="{Binding SaveAsProjectCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Save" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem Header="Edit">
                        <MenuItem Header="Cut (Ctrl+X)" Command="{Binding ElementName=editor,Path=CutCommand}" MinWidth="210">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Cut" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Copy (Ctrl+C)" Command="{Binding ElementName=editor,Path=CopyCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Copy" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Paste (Ctrl+V)" Command="{Binding ElementName=editor,Path=PasteCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Paste" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Undo (Ctrl+Z)" Command="{Binding ElementName=editor,Path=UndoCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Undo" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Redo (Ctrl+Y)" Command="{Binding ElementName=editor,Path=RedoCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="RotateRight" Width="16"></fa:ImageAwesome>
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Delete (DELETE)" Command="{Binding ElementName=editor,Path=DeleteCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Recycle" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Select All (Ctrl+A)" Command="{Binding ElementName=editor,Path=SelectAllCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Th" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem Header="View">
                        <MenuItem Header="Zoom In" Command="{Binding ElementName=editor,Path=ZoomCommand}" CommandParameter="0.1">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="SearchPlus" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="Zoom Out" Command="{Binding ElementName=editor,Path=ZoomCommand}" CommandParameter="-0.1">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="SearchMinus" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                        <Separator/>
                        <MenuItem Header="Reset Zoom" Command="{Binding ElementName=editor,Path=ResetZoomCommand}">
                            <MenuItem.Icon>
                                <fa:ImageAwesome Icon="Search" Width="16" />
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem Header="Components">
                        <MenuItem.ItemContainerStyle>
                            <Style TargetType="MenuItem" BasedOn="{x:Null}">
                                <Setter Property="Background" Value="Transparent"></Setter>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="Transparent"></Setter>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </MenuItem.ItemContainerStyle>
                        <ListBox Margin="-27 0 -22 0" MinWidth="180" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding AvailableTechItems}" SelectedItem="{Binding SelectedTechItem}" HorizontalContentAlignment="Stretch">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <Border Width="24" Height="24" BorderThickness="1" CornerRadius="100">
                                            <Border.Style>
                                                <Style TargetType="Border">
                                                    <Setter Property="Background" Value="Transparent"></Setter>
                                                    <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter>
                                                    <Setter Property="BorderThickness" Value="1"></Setter>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True">
                                                            <Setter Property="Background" Value="White"></Setter>
                                                            <Setter Property="BorderBrush" Value="#FF7575"></Setter>
                                                            <Setter Property="BorderThickness" Value="2"></Setter>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Border.Style>
                                            <Image Source="{Binding Image}" RenderOptions.BitmapScalingMode="Fant"></Image>
                                        </Border>
                                        <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </MenuItem>
                </Menu>

                <Grid Grid.Row="1">
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Margin="20 0 0 0">
                        <ListBox ItemContainerStyle="{StaticResource basicListBoxItem}" ItemsSource="{Binding AvailableTechItems}" SelectedItem="{Binding SelectedTechItem,Mode=TwoWay}" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal"></StackPanel>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate DataType="{x:Type techItems:TechItem}">
                                    <Border Cursor="Hand" ToolTip="{Binding Description}" RenderTransformOrigin="0.5,0.5" Width="70" Padding="10" Margin="5" Height="70" BorderThickness="1" CornerRadius="100">
                                        <Border.Style>
                                            <Style TargetType="Border">
                                                <Setter Property="RenderTransform">
                                                    <Setter.Value>
                                                        <ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
                                                    </Setter.Value>
                                                </Setter>
                                                <Setter Property="Background" Value="Transparent"></Setter>
                                                <Setter Property="BorderBrush" Value="{StaticResource AccentColorBrush}"></Setter>
                                                <Setter Property="BorderThickness" Value="1"></Setter>
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True">
                                                        <Setter Property="Background" Value="White"></Setter>
                                                        <Setter Property="BorderBrush" Value="#FF7575"></Setter>
                                                        <Setter Property="BorderThickness" Value="2"></Setter>
                                                        <DataTrigger.EnterActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1.1" Duration="00:00:0.2"></DoubleAnimation>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1.1" Duration="00:00:0.2"></DoubleAnimation>
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.EnterActions>
                                                        <DataTrigger.ExitActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.2"></DoubleAnimation>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="00:00:0.2"></DoubleAnimation>
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.ExitActions>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Border.Style>
                                        <Image Source="{Binding Image}" RenderOptions.BitmapScalingMode="Fant"></Image>
                                    </Border>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>

                    <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0 0 255 10" VerticalAlignment="Bottom">
                        <ListBox x:Name="listMode" SelectedIndex="0" Style="{StaticResource MaterialDesignToolToggleListBox}">
                            <ListBoxItem Height="40" Width="60" HorizontalContentAlignment="Center" ToolTip="Edit Mode">
                                <materialDesign:PackIcon HorizontalAlignment="Center" Width="30" Height="30"  Kind="Pencil" />
                            </ListBoxItem>
                            <ListBoxItem Height="40" Width="60" HorizontalContentAlignment="Center" ToolTip="Action Mode" MouseUp="OnActionModeClicked">
                                <materialDesign:PackIcon HorizontalAlignment="Center" Width="30" Height="30"  Kind="HandPointingRight" />
                            </ListBoxItem>
                        </ListBox>
                    </StackPanel>
                </Grid>
            </Grid>

            <Grid Grid.Row="1" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="220"/>
                </Grid.ColumnDefinitions>

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <editors:ElementsEditor 
                        x:Name="editor"
                        Elements="{Binding Elements}"
                        ElementCreation="ElementsEditor_ElementCreation"  
                        ElementsRemoved="ElementsEditor_ElementsRemoved"
                        AfterPaste="ElementsEditor_AfterPaste"
                        RulerHeight="32" 
                        EditorWidth="1920"
                        EditorHeight="1080"
                        FontSize="10" 
                        Background="Transparent" 
                        EditorBackground="#70FFFFFF" 
                        RulerBackground="Transparent" 
                        Foreground="{StaticResource AccentColorBrush}" 
                        SelectionFillBrush="#338D8D8D" 
                        SelectionStrokeBrush="{StaticResource AccentColorBrush}" 
                        BorderBrush="{StaticResource AccentColorBrush}" 
                        BorderThickness="1">

                        <editors:ElementsEditor.Style>
                            <Style TargetType="editors:ElementsEditor">
                                <Setter Property="IsEditable" Value="True"></Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ElementName=listMode,Path=SelectedIndex}" Value="1">
                                        <Setter Property="IsEditable" Value="False"></Setter>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </editors:ElementsEditor.Style>

                        <editors:ElementsEditor.ContextMenu>
                            <ContextMenu DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
                                <MenuItem Header="Cut (Ctrl+X)" Command="{Binding CutCommand}" MinWidth="210">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Cut" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <MenuItem Header="Copy (Ctrl+C)" Command="{Binding CopyCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Copy" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <MenuItem Header="Paste (Ctrl+V)" Command="{Binding PasteCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Paste" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <Separator/>
                                <MenuItem Header="Undo (Ctrl+Z)" Command="{Binding UndoCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Undo" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <MenuItem Header="Redo (Ctrl+Y)" Command="{Binding RedoCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="RotateRight" Width="16"></fa:ImageAwesome>
                                    </MenuItem.Icon>
                                </MenuItem>
                                <Separator/>
                                <MenuItem Header="Delete (DELETE)" Command="{Binding DeleteCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Recycle" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                                <Separator/>
                                <MenuItem Header="Select All (Ctrl+A)" Command="{Binding SelectAllCommand}">
                                    <MenuItem.Icon>
                                        <fa:ImageAwesome Icon="Th" Width="16" />
                                    </MenuItem.Icon>
                                </MenuItem>
                            </ContextMenu>
                        </editors:ElementsEditor.ContextMenu>
                    </editors:ElementsEditor>

                    <Slider Grid.Column="1" Orientation="Vertical" Margin="5" Maximum="3" Minimum="0.2" Value="{Binding ElementName=editor,Path=ScaleFactor}"></Slider>
                </Grid>

                <Grid Grid.Column="1">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Top" Margin="0 -30 0 0" DataContext="{Binding ElementName=editor,Path=SelectedElement.HostedElement}" Text="{Binding TechName}" FontSize="16" FontWeight="Bold" FontStyle="Italic"></TextBlock>
                        <GroupBox DockPanel.Dock="Top" Header="BOUNDS" Padding="5">
                            <StackPanel>
                                <!--Position-->
                                <UniformGrid Columns="2" Margin="0 5 0 0">
                                    <StackPanel Margin="0 0 5 0">
                                        <TextBlock>Left</TextBlock>
                                        <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Left}"></mahapps:NumericUpDown>
                                    </StackPanel>
                                    <StackPanel Margin="5 0 0 0">
                                        <TextBlock>Top</TextBlock>
                                        <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="0" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Top}"></mahapps:NumericUpDown>
                                    </StackPanel>
                                </UniformGrid>

                                <!--Size-->
                                <UniformGrid Columns="2" Margin="0 20 0 0">
                                    <StackPanel Margin="0 0 5 0">
                                        <TextBlock>Width</TextBlock>
                                        <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorWidth}" Value="{Binding ElementName=editor,Path=SelectedElement.Width}"></mahapps:NumericUpDown>
                                    </StackPanel>
                                    <StackPanel Margin="5 0 0 0">
                                        <TextBlock>Height</TextBlock>
                                        <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Margin="0 5 0 0" Minimum="10" Maximum="{Binding ElementName=editor,Path=EditorHeight}" Value="{Binding ElementName=editor,Path=SelectedElement.Height}"></mahapps:NumericUpDown>
                                    </StackPanel>
                                </UniformGrid>

                                <!--<Angle-->
                                <Grid Margin="0 20 0 0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="22*"></ColumnDefinition>
                                        <ColumnDefinition Width="20*"></ColumnDefinition>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock VerticalAlignment="Center" Margin="0 0 10 0" HorizontalAlignment="Left">Angle</TextBlock>
                                    <mahapps:NumericUpDown Grid.Column="1" HorizontalContentAlignment="Center" BorderBrush="Gainsboro" Foreground="Gray" Maximum="360" Minimum="-360" HasDecimals="False" Margin="0 5 0 0" Value="{Binding ElementName=editor,Path=SelectedElement.Angle}"></mahapps:NumericUpDown>
                                </Grid>
                            </StackPanel>
                        </GroupBox>

                        <ContentControl Margin="0 10 0 0" DataContext="{Binding ElementName=editor,Path=SelectedElement.HostedElement}" Content="{Binding ElementName=editor,Path=SelectedElement.HostedElement}">
                            <ContentControl.Resources>
                                <DataTemplate DataType="{x:Type sys:Nullable}">

                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:MonitorItem}">
                                    <templates:MonitorTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:MotorGroupItem}">
                                    <templates:MotorGroupTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:ThreadMotionItem}">
                                    <templates:ThreadMotionTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:DigitalOutItem}">
                                    <templates:DigitalOutTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:DispenserItem}">
                                    <templates:DispenserTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:MotorItem}">
                                    <templates:MotorTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:MeterItem}">
                                    <templates:MeterTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:SingleGraphItem}">
                                    <templates:SingleGraphTemplate/>
                                </DataTemplate>
                                <DataTemplate DataType="{x:Type items:MultiGraphItem}">
                                    <templates:MultiGraphTemplate/>
                                </DataTemplate>
                            </ContentControl.Resources>
                        </ContentControl>
                    </DockPanel>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</UserControl>