ConnectionView.xaml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <UserControl x:Class="EfemRT.Backends.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:local="clr-namespace:EfemRT.Backends"
  7. mc:Ignorable="d"
  8. d:DesignHeight="300" d:DesignWidth="300">
  9. <UserControl.Resources>
  10. <local:BoolBackgroundConverter x:Key="BoolBackgroundConverter"/>
  11. <SolidColorBrush x:Key="DataGrid_Cell_BD" Color="Gray"/>
  12. <Style x:Key="Lamp-Button" TargetType="{x:Type local:IoButton}">
  13. <Setter Property="Width" Value="16"/>
  14. <Setter Property="Height" Value="16"/>
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type local:IoButton}">
  18. <Grid>
  19. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Content=""/>
  20. <Ellipse Stroke="Gray" StrokeThickness="2"
  21. Fill="DarkGray" />
  22. <Ellipse x:Name="Highlight" Stroke="Gray" StrokeThickness="2"
  23. Fill="Lime" />
  24. </Grid>
  25. <ControlTemplate.Triggers>
  26. <Trigger Property="IsChecked" Value="True">
  27. <Setter Property="Visibility" TargetName="Highlight" Value="Visible"/>
  28. </Trigger>
  29. <Trigger Property="IsChecked" Value="False">
  30. <Setter Property="Visibility" TargetName="Highlight" Value="Collapsed"/>
  31. </Trigger>
  32. <Trigger Property="IsMouseOver" Value="False">
  33. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  34. </Trigger>
  35. </ControlTemplate.Triggers>
  36. </ControlTemplate>
  37. </Setter.Value>
  38. </Setter>
  39. </Style>
  40. <Style x:Key="Sepcial_ListBoxItem" TargetType="{x:Type ListBoxItem}">
  41. <Setter Property="Background" Value="Transparent"/>
  42. <Setter Property="Margin" Value="0"/>
  43. <Setter Property="Padding" Value="0"/>
  44. <Setter Property="BorderThickness" Value="0"/>
  45. <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  46. <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  50. <Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
  51. <Grid>
  52. <Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
  53. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  54. </Grid>
  55. </Border>
  56. <ControlTemplate.Triggers>
  57. <Trigger Property="IsSelected" Value="true">
  58. <Setter Property="Opacity" TargetName="Highlight" Value="1"/>
  59. <Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
  60. <Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
  61. <Setter Property="Margin" TargetName="Highlight" Value="0,0,1,1"/>
  62. </Trigger>
  63. <Trigger Property="IsMouseOver" Value="True">
  64. <Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
  65. </Trigger>
  66. <Trigger Property="IsEnabled" Value="false">
  67. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  68. </Trigger>
  69. </ControlTemplate.Triggers>
  70. </ControlTemplate>
  71. </Setter.Value>
  72. </Setter>
  73. <Style.Triggers>
  74. <Trigger Property="ListBox.AlternationIndex" Value="0">
  75. <Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
  76. </Trigger>
  77. <Trigger Property="ListBox.AlternationIndex" Value="1">
  78. <Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
  79. </Trigger>
  80. </Style.Triggers>
  81. </Style>
  82. <DataTemplate x:Key="DOTemplate">
  83. <Grid Margin="-1,-1,0,0" Height="23" Background="{Binding IsChecked, ElementName=ckHold, Converter={StaticResource BoolBackgroundConverter}}">
  84. <Grid.ColumnDefinitions>
  85. <ColumnDefinition Width="40"></ColumnDefinition>
  86. <ColumnDefinition Width="300"></ColumnDefinition>
  87. <ColumnDefinition Width="100"></ColumnDefinition>
  88. <ColumnDefinition Width="45"></ColumnDefinition>
  89. <ColumnDefinition Width="100"></ColumnDefinition>
  90. <ColumnDefinition Width="15"></ColumnDefinition>
  91. </Grid.ColumnDefinitions>
  92. <Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1" Padding="5,1" >
  93. <CheckBox x:Name="ckHold" IsChecked="{Binding Path=HoldValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="25" Height="25" ></CheckBox>
  94. </Border>
  95. <Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
  96. <TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
  97. </Border>
  98. <Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
  99. <TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBlock>
  100. </Border>
  101. <Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
  102. <local:IoButton ON="{Binding Path=IsConnected}" Style="{StaticResource Lamp-Button}" IsChecked="{Binding IsConnected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  103. </Border>
  104. <Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
  105. <Button Content="Connect" Command="{Binding RelativeSource={RelativeSource FindAncestor,
  106. AncestorType={x:Type ListBox}}, Path=DataContext.ConnectCommand}" 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="Left">
  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>