ConnectionView.xaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.Connections.ConnectionView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:connections="clr-namespace:MECF.Framework.UI.Client.CenterViews.Maitenances.Connections"
  7. mc:Ignorable="d" >
  8. <UserControl.Resources>
  9. <connections:BoolBackgroundConverter x:Key="BoolBackgroundConverter"/>
  10. <SolidColorBrush x:Key="DataGrid_Cell_BD" Color="Gray"/>
  11. <Style x:Key="Lamp-Button" TargetType="{x:Type connections:IoButton}">
  12. <Setter Property="Width" Value="16"/>
  13. <Setter Property="Height" Value="16"/>
  14. <Setter Property="Template">
  15. <Setter.Value>
  16. <ControlTemplate TargetType="{x:Type connections:IoButton}">
  17. <Grid>
  18. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Content=""/>
  19. <Ellipse Stroke="Gray" StrokeThickness="2"
  20. Fill="DarkGray" />
  21. <Ellipse x:Name="Highlight" Stroke="Gray" StrokeThickness="2"
  22. Fill="Lime" />
  23. </Grid>
  24. <ControlTemplate.Triggers>
  25. <Trigger Property="IsChecked" Value="True">
  26. <Setter Property="Visibility" TargetName="Highlight" Value="Visible"/>
  27. </Trigger>
  28. <Trigger Property="IsChecked" Value="False">
  29. <Setter Property="Visibility" TargetName="Highlight" Value="Collapsed"/>
  30. </Trigger>
  31. <Trigger Property="IsMouseOver" Value="False">
  32. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  33. </Trigger>
  34. </ControlTemplate.Triggers>
  35. </ControlTemplate>
  36. </Setter.Value>
  37. </Setter>
  38. </Style>
  39. <Style x:Key="Sepcial_ListBoxItem" TargetType="{x:Type ListBoxItem}">
  40. <Setter Property="Background" Value="Transparent"/>
  41. <Setter Property="Margin" Value="0"/>
  42. <Setter Property="Padding" Value="0"/>
  43. <Setter Property="BorderThickness" Value="0"/>
  44. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  45. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  46. <Setter Property="Template">
  47. <Setter.Value>
  48. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  49. <Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
  50. <Grid>
  51. <Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
  52. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  53. </Grid>
  54. </Border>
  55. <ControlTemplate.Triggers>
  56. <Trigger Property="IsSelected" Value="true">
  57. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  58. <Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
  59. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  60. <Setter Property="Margin" TargetName="Highlight" Value="0,0,1,1"/>
  61. </Trigger>
  62. <Trigger Property="IsMouseOver" Value="True">
  63. <Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
  64. </Trigger>
  65. <Trigger Property="IsEnabled" Value="false">
  66. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  67. </Trigger>
  68. </ControlTemplate.Triggers>
  69. </ControlTemplate>
  70. </Setter.Value>
  71. </Setter>
  72. <Style.Triggers>
  73. <Trigger Property="ListBox.AlternationIndex" Value="0">
  74. <Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
  75. </Trigger>
  76. <Trigger Property="ListBox.AlternationIndex" Value="1">
  77. <Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
  78. </Trigger>
  79. </Style.Triggers>
  80. </Style>
  81. <DataTemplate x:Key="DOTemplate">
  82. <Grid Margin="-1,-1,0,0" Height="45" Background="{Binding IsChecked, ElementName=ckHold, Converter={StaticResource BoolBackgroundConverter}}">
  83. <Grid.ColumnDefinitions>
  84. <ColumnDefinition Width="200"></ColumnDefinition>
  85. <ColumnDefinition Width="200"></ColumnDefinition>
  86. <ColumnDefinition Width="45"></ColumnDefinition>
  87. <ColumnDefinition Width="100"></ColumnDefinition>
  88. <ColumnDefinition Width="100"></ColumnDefinition>
  89. <ColumnDefinition Width="15"></ColumnDefinition>
  90. </Grid.ColumnDefinitions>
  91. <Border Grid.Column="0" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
  92. <TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
  93. </Border>
  94. <Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
  95. <TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBlock>
  96. </Border>
  97. <Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
  98. <connections:IoButton ON="{Binding Path=IsConnected}" Style="{StaticResource Lamp-Button}" IsChecked="{Binding IsConnected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  99. </Border>
  100. <Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
  101. <Button Content="Connect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
  102. AncestorType={x:Type ListBox}}, Path=DataContext.ConnectCommand}" CommandParameter="{Binding Path=Name}" />
  103. </Border>
  104. <Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
  105. <Button Content="Disconnect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
  106. AncestorType={x:Type ListBox}}, Path=DataContext.DisconnectCommand}" CommandParameter="{Binding Path=Name}" />
  107. </Border>
  108. </Grid>
  109. </DataTemplate>
  110. </UserControl.Resources>
  111. <Grid>
  112. <ListBox ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" Width="1900" ItemsSource="{Binding ListConnections}" AlternationCount="2" ItemTemplate="{StaticResource DOTemplate}" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0" Margin="5,0" HorizontalAlignment="Center">
  113. <ListBox.ItemsPanel>
  114. <ItemsPanelTemplate>
  115. <WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
  116. </ItemsPanelTemplate>
  117. </ListBox.ItemsPanel>
  118. </ListBox>
  119. </Grid>
  120. </UserControl>