Browse Source

添加通过 不通过样式

ltwork 1 year ago
parent
commit
ffe758f00c

BIN
BlankApp1/BlankApp1/Assets/Images/NoPass.png


BIN
BlankApp1/BlankApp1/Assets/Images/Pass.png


+ 35 - 0
BlankApp1/BlankApp1/Controls/Convert/StringToImageSourceConverter.cs

@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media.Imaging;
+
+namespace PLCTool.Controls.Convert
+{
+    public class StringToImageSourceConverter : IValueConverter
+    {
+        #region Converter
+
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            string path = (string)value;
+            if (!string.IsNullOrEmpty(path))
+            {
+                return new BitmapImage(new Uri(path, UriKind.Absolute));
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+        #endregion
+    }
+}

+ 8 - 0
BlankApp1/BlankApp1/PLCTool.csproj

@@ -9,6 +9,8 @@
   <ItemGroup>
   <ItemGroup>
     <None Remove="Assets\Fonts\iconfont.ttf" />
     <None Remove="Assets\Fonts\iconfont.ttf" />
     <None Remove="Assets\Images\Logo.png" />
     <None Remove="Assets\Images\Logo.png" />
+    <None Remove="Assets\Images\NoPass.png" />
+    <None Remove="Assets\Images\Pass.png" />
     <None Remove="Assets\Images\register.png" />
     <None Remove="Assets\Images\register.png" />
     <None Remove="Assets\Images\wifi信号.png" />
     <None Remove="Assets\Images\wifi信号.png" />
     <None Remove="Assets\Images\电量蓝色.png" />
     <None Remove="Assets\Images\电量蓝色.png" />
@@ -48,6 +50,12 @@
     <Resource Include="Assets\Images\Logo.png">
     <Resource Include="Assets\Images\Logo.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
     </Resource>
+    <Resource Include="Assets\Images\NoPass.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Resource>
+    <Resource Include="Assets\Images\Pass.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Resource>
     <Resource Include="Assets\Images\register.png">
     <Resource Include="Assets\Images\register.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Resource>
     </Resource>

+ 23 - 5
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestResultDetailViewModel.cs

@@ -38,8 +38,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private int testStatus = 0;  //测试状态 
         private int testStatus = 0;  //测试状态 
         private int testResult = 0; //测试结果
         private int testResult = 0; //测试结果
 
 
-
-
+        private string passPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images", "Pass.png");
+        private string noPassPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images", "NoPass.png");
         public TestResultDetailViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper)
         public TestResultDetailViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper)
         {
         {
             _dialog = dialog;
             _dialog = dialog;
@@ -99,7 +99,18 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             string itemName= _basicPlcTestSchemeDtlService.Find((int)dtlId)?.item_name;
                             string itemName= _basicPlcTestSchemeDtlService.Find((int)dtlId)?.item_name;
                             if(!String.IsNullOrEmpty(itemName))
                             if(!String.IsNullOrEmpty(itemName))
                             {
                             {
-                                SchItems.Add(itemName);
+
+                                //在左侧listbox中添加测试项
+                                //查找测试结果
+                                int result = (int)_iBizTestRecordDtlService.Find((int)record.record_dtl_id)?.test_result;
+
+                                SchItems.Add(new ImageAndItemModel()
+                                {
+
+                                    ImgSource = result == 1 ? passPath : noPassPath,
+                                    ItemName = itemName
+                                }); 
+
                                 recordNotNulls.Add(record);
                                 recordNotNulls.Add(record);
                                 //在集合中添加满足条件的测试结果
                                 //在集合中添加满足条件的测试结果
                                 conditionRecordList.Add(new BizTestRecordDtlDto()
                                 conditionRecordList.Add(new BizTestRecordDtlDto()
@@ -112,6 +123,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                 int recordDtlId = Convert.ToInt32((long)recordNotNulls?.First()?.record_dtl_id);
                                 int recordDtlId = Convert.ToInt32((long)recordNotNulls?.First()?.record_dtl_id);
                                 //显示
                                 //显示
                                 DisplayDetail(schDtlId, recordDtlId);
                                 DisplayDetail(schDtlId, recordDtlId);
+
                             }
                             }
                             
                             
                          
                          
@@ -564,8 +576,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         }
         }
 
 
         //所有测试项列表
         //所有测试项列表
-        private List<string> schItems = new List<string>();
-        public List<string> SchItems
+        private List<ImageAndItemModel> schItems = new List<ImageAndItemModel>();
+        public List<ImageAndItemModel> SchItems
         {
         {
             get { return schItems; }
             get { return schItems; }
             set { schItems = value; RaisePropertyChanged(); }
             set { schItems = value; RaisePropertyChanged(); }
@@ -593,4 +605,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         #endregion
         #endregion
 
 
     }
     }
+
+    public class ImageAndItemModel
+    {
+        public string ImgSource { get; set; }
+        public string ItemName { get; set; }
+    }
 }
 }

+ 15 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/TestResultDetailView.xaml

@@ -6,10 +6,14 @@
              xmlns:local="clr-namespace:PLCTool.Views.BusinessManageView"
              xmlns:local="clr-namespace:PLCTool.Views.BusinessManageView"
              xmlns:prism="http://prismlibrary.com/" 
              xmlns:prism="http://prismlibrary.com/" 
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             xmlns:cvt="clr-namespace:PLCTool.Controls.Convert"
              BorderBrush="#CBCBCB" BorderThickness="1"
              BorderBrush="#CBCBCB" BorderThickness="1"
              Height="600" Width="1050" >
              Height="600" Width="1050" >
 
 
     <UserControl.Resources>
     <UserControl.Resources>
+        
+        <cvt:StringToImageSourceConverter x:Key="MyImageConverter"/>
+     
         <Style TargetType="TextBlock" x:Key="textBlockStyle">
         <Style TargetType="TextBlock" x:Key="textBlockStyle">
             <Setter Property="Width" Value="80"/>
             <Setter Property="Width" Value="80"/>
             <Setter Property="FontSize" Value="12"/>
             <Setter Property="FontSize" Value="12"/>
@@ -28,7 +32,18 @@
         <DockPanel Grid.Column="0" LastChildFill="True">
         <DockPanel Grid.Column="0" LastChildFill="True">
             <TextBlock Text="测试项列表:"  Style="{StaticResource NormalTextBlockStyle}" Margin="5,0,5,0" DockPanel.Dock="Top"/>
             <TextBlock Text="测试项列表:"  Style="{StaticResource NormalTextBlockStyle}" Margin="5,0,5,0" DockPanel.Dock="Top"/>
             <ListBox ItemsSource="{Binding SchItems}"  SelectedIndex="{Binding SelectIndex}" >
             <ListBox ItemsSource="{Binding SchItems}"  SelectedIndex="{Binding SelectIndex}" >
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel Orientation="Horizontal">
+                            <Image Source="{Binding Path=ImgSource,Converter={StaticResource MyImageConverter}}" Stretch="Fill" Margin="0,0,5,0"/>
+                            <TextBlock Text="{Binding ItemName}"/>
+                        </StackPanel>
+  
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
+
 
 
+                        
                 <b:Interaction.Triggers>
                 <b:Interaction.Triggers>
                     <b:EventTrigger EventName="SelectionChanged">
                     <b:EventTrigger EventName="SelectionChanged">
                         <b:InvokeCommandAction Command="{Binding ItemChangeCommand}"/>
                         <b:InvokeCommandAction Command="{Binding ItemChangeCommand}"/>

+ 6 - 6
BlankApp1/BlankApp1/Views/MainWindow.xaml

@@ -90,9 +90,9 @@
         <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,0,0,1" />
         <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,0,0,1" />
         <Grid Grid.Row="0"  Cursor="Hand"  >
         <Grid Grid.Row="0"  Cursor="Hand"  >
             <StackPanel Orientation="Horizontal" Margin="9,5,0,2">
             <StackPanel Orientation="Horizontal" Margin="9,5,0,2">
-                <Image Source="../Assets/Images/Logo.png" Height="42" Width="auto" Margin="0,0,5,0"></Image>
                 <TextBlock FontSize="26"  Text="PLC测试平台" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0" />
                 <TextBlock FontSize="26"  Text="PLC测试平台" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0" />
-               
+                <Image Source="../Assets/Images/Logo.png" Height="42" Width="auto"/>
+
             </StackPanel>
             </StackPanel>
             <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" Margin=" 0,0,14,0">
             <StackPanel  Orientation="Horizontal" HorizontalAlignment="Right" Margin=" 0,0,14,0">
                 <TextBlock x:Name="txtTime" Foreground="#ffffff" VerticalAlignment="Center" Margin="0,0,18,0"/>
                 <TextBlock x:Name="txtTime" Foreground="#ffffff" VerticalAlignment="Center" Margin="0,0,18,0"/>
@@ -101,7 +101,7 @@
                 <TextBlock Text="|" Style="{StaticResource txtHeadStyle}" Margin="0,0,17,0" Width="2" Height=" 20"></TextBlock>
                 <TextBlock Text="|" Style="{StaticResource txtHeadStyle}" Margin="0,0,17,0" Width="2" Height=" 20"></TextBlock>
                 <Button  x:Name="btnMin" Content="—"  Click="btnMin_Click"  Style="{StaticResource IconButtonStyle}"/>
                 <Button  x:Name="btnMin" Content="—"  Click="btnMin_Click"  Style="{StaticResource IconButtonStyle}"/>
                 <Button  x:Name="btnMax" Click="btnMax_Click" Content="&#xe60d;" FontFamily="../Assets/Fonts/#iconfont"   Style="{StaticResource IconButtonStyle}"/>
                 <Button  x:Name="btnMax" Click="btnMax_Click" Content="&#xe60d;" FontFamily="../Assets/Fonts/#iconfont"   Style="{StaticResource IconButtonStyle}"/>
-            
+
                 <Button x:Name="btnClose" Content="✕" Click="btnClose_Click" Style="{StaticResource IconButtonStyle}"/>
                 <Button x:Name="btnClose" Content="✕" Click="btnClose_Click" Style="{StaticResource IconButtonStyle}"/>
             </StackPanel>
             </StackPanel>
         </Grid>
         </Grid>
@@ -121,12 +121,12 @@
                                     Command="{Binding NextCommand}" Margin="5,0,0,10"/>
                                     Command="{Binding NextCommand}" Margin="5,0,0,10"/>
                 <RadioButton Content="数据查询" Tag="&#xe600;" Style="{StaticResource NavTabButtonStyle}" 
                 <RadioButton Content="数据查询" Tag="&#xe600;" Style="{StaticResource NavTabButtonStyle}" 
                             CommandParameter="QueryView" Margin="5,0,0,10"/>
                             CommandParameter="QueryView" Margin="5,0,0,10"/>
-              
+
             </StackPanel>
             </StackPanel>
             <Border Grid.Column="1" BorderBrush="#CBCBCB" BorderThickness="1,0,0,0"></Border>
             <Border Grid.Column="1" BorderBrush="#CBCBCB" BorderThickness="1,0,0,0"></Border>
             <ContentControl Grid.Column="0" prism:RegionManager.RegionName="MenuRegion"  />
             <ContentControl Grid.Column="0" prism:RegionManager.RegionName="MenuRegion"  />
             <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ContentRegion" />
             <ContentControl Grid.Column="1" prism:RegionManager.RegionName="ContentRegion" />
-           
+
         </Grid>
         </Grid>
 
 
         <Border Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="#CBCBCB">
         <Border Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="#CBCBCB">
@@ -151,7 +151,7 @@
                 </Path>
                 </Path>
                 <TextBlock Text="V1.2" Style="{StaticResource txtHeadStyle}" Width="60" Margin="30,0,12,0"/>
                 <TextBlock Text="V1.2" Style="{StaticResource txtHeadStyle}" Width="60" Margin="30,0,12,0"/>
             </StackPanel>
             </StackPanel>
-          
+
         </Border>
         </Border>
     </Grid>
     </Grid>
 </Window>
 </Window>