fix: 待修改项 1~5

master
Tongg 5 months ago
parent 9c7f2838b2
commit 46661419b0
  1. 3
      App.config
  2. 4
      Language/zh_CN.xaml
  3. 34
      LoginWindow.xaml.cs
  4. 25
      Model/Entity/ApiEntity/StatusCodes.cs
  5. 12
      Model/Helper/ConfigurationHelper.cs
  6. 5
      SparkClient.csproj
  7. 15
      ViewModel/Grading/DiamondSelectVM.cs
  8. 6
      ViewModel/Grading/GradingResultVM.cs
  9. 2
      Views/BaseWindow/BaseControl.xaml
  10. 3
      Views/BaseWindow/BaseControl.xaml.cs
  11. 785
      Views/Grading/GradingLoading.xaml
  12. 297
      Views/Grading/GradingLoading.xaml.cs
  13. 2
      Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs
  14. 2
      Views/UserControl/ViewportData/Helper/ViewportManager.cs
  15. 9
      Views/UserControl/ViewportData/ViewportData.cs

@ -14,7 +14,8 @@
<add key="DSSet" value="NA"/>
<add key="ProgressTime" value="50000"/>
</appSettings>
<connectionStrings>
<add name="" connectionString=""/>

@ -224,4 +224,8 @@
<sys:String x:Key="RayTracingFail">图像渲染异常:</sys:String>
<sys:String x:Key="RayTracingFormTitle">仿真心箭图预览</sys:String>
<sys:String x:Key="RayTracingFormMessage">仿真心箭图为模拟渲染,实际请以切工镜观测为准。</sys:String>
<sys:String x:Key="NotNvidia">未找到Nvidia显卡驱动,部分功能可能无法正常运行。</sys:String>
<sys:String x:Key="NotNvidiaVersionLow">Nvidia显卡驱动版本过旧,请尝试升级显卡驱动。(当前:%version,最低:528.33)</sys:String>
</ResourceDictionary>

@ -5,6 +5,7 @@ using System.Data;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using Microsoft.Win32;
using MessageBox = SparkClient.Views.Dialog.MessageBox;
namespace SparkClient;
@ -17,11 +18,42 @@ public partial class LoginWindow : Window
WindowStartupLocation = WindowStartupLocation.CenterScreen;
AccountTextBox.Text = Settings.SelectValueById("SAVE_ACCOUNT");
PasswordBox.Password = Settings.SelectValueById("SAVE_PASSWORD");
checkCUDA();
//checkCUDA();
checkNvidia();
// 检测MSVCRuntime是否安装
checkMSVCRuntime();
}
private void checkNvidia()
{
string nvidiaVersion = "";
const string regPath = @"SOFTWARE\NVIDIA Corporation\Global\NVSMI";
const string keyName = "DisplayDriverVersion";
try
{
// 针对 64 位系统访问注册表
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
using (var key = baseKey.OpenSubKey(regPath))
{
if (key != null)
{
var value = key.GetValue(keyName)?.ToString();
nvidiaVersion = !string.IsNullOrEmpty(value) ? value : "未找到驱动版本";
}
}
}
catch (Exception ex)
{
nvidiaVersion = ex.Message;
Logger.Error("Nvidia检测错误:"+ ex);
}
MessageBox messageBox = new MessageBox();
messageBox.Show(nvidiaVersion);
}
private void checkCUDA()
{
try

@ -1,4 +1,6 @@
namespace SparkClient.Model.Common
using System.Reflection;
namespace SparkClient.Model.Common
{
/// <summary>
/// 存储状态码及其描述信息的常量类。
@ -48,5 +50,26 @@
// 检测到钻石需进行清洁
public const string Recheck = "P021";
public static string GetConstantNameByValue(string value)
{
// 获取 StatusCodes 类型信息
var type = typeof(StatusCodes);
// 遍历所有公共静态常量字段
foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy))
{
// 确保是字符串类型的常量
if (field.IsLiteral && !field.IsInitOnly && field.FieldType == typeof(string))
{
// 获取字段值并比较
if ((string)field.GetValue(null) == value)
{
return field.Name;
}
}
}
return null; // 未找到时返回 null
}
}
}

@ -5,7 +5,11 @@ namespace SparkClient.Model.Helper;
public class ConfigurationHelper
{
static System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
/// <summary>
/// 读取配置Key
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string ReadConfigValue(string key)
{
@ -13,7 +17,11 @@ public class ConfigurationHelper
return name;
}
/// <summary>
/// 写入配置
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void SetConfigValue(string key, string value)
{
config.AppSettings.Settings[key].Value = value;

@ -252,6 +252,11 @@
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Grading\GradingLoading.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>

@ -10,7 +10,6 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using Microsoft.Data.Sqlite;
using SparkClient.Model.Entity;
using SparkClient.Model.Services;
using System.Text;
@ -21,8 +20,6 @@ using Newtonsoft.Json.Linq;
using SparkClient.Model.Common;
using Color = System.Windows.Media.Color;
using MessageBox = SparkClient.Views.Dialog.MessageBox;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.JavaScript;
using SparkClient.Model.Attributes;
namespace SparkClient.ViewModel.Grading;
@ -155,6 +152,12 @@ public class DiamondSelectVM : BaseViewModel
{
if (param != null)
{
string progTime = ConfigurationHelper.ReadConfigValue("ProgressTime");
int iProgTime = 50000;
int.TryParse(progTime, out iProgTime);
int setpTime = iProgTime / 97;
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => loading.ShowDialog()));
await Task.Run(async () =>
{
@ -171,7 +174,7 @@ public class DiamondSelectVM : BaseViewModel
}
// 模拟耗时操作
//System.Threading.Thread.Sleep(50); // 休眠50毫秒
await Task.Delay(515);
await Task.Delay(setpTime);
loading.setValue(i);
progress = i;
}
@ -251,7 +254,9 @@ public class DiamondSelectVM : BaseViewModel
parameter.CrownType = value.Split(" ")[1];
parameter.PavType = value.Split(" ")[2];
parameter.DiamondCode = DiamondCode;
if (!parameter.status.Equals(StatusCodes.Ok))
parameter.error_msg = MultilingualHelper.getString(StatusCodes.GetConstantNameByValue(parameter.status));
//参数实体转json输出
try
{

@ -32,6 +32,7 @@ using System.Windows.Media;
using Brush = System.Drawing.Brush;
using Brushes = System.Drawing.Brushes;
using SparkClient.Model.Attributes;
using SparkClient.Model.Common;
using PaperSize = System.Drawing.Printing.PaperSize;
namespace SparkClient.ViewModel.Grading;
@ -185,6 +186,7 @@ public class GradingResultVM : BaseViewModel
InitView(algorithmResult);
machine = algorithmResult.DeviceId;
username = Settings.SelectValueById("PERMISSIONS");
if (ruleId.StartsWith("IGI"))
{
IsEnabled = true;
@ -193,7 +195,11 @@ public class GradingResultVM : BaseViewModel
{
IsEnabled = false;
}
if (algorithmResult.status.Equals(StatusCodes.Recheck)) IsEnabled = false;
}
DS = ConfigurationManager.AppSettings["DSSet"];
if (IsEnabled)
{

@ -77,7 +77,7 @@
<!-- 次位元素:标题 -->
<TextBlock Grid.Column="1" Text="{DynamicResource ProcName}"
VerticalAlignment="Center" FontWeight="Bold"
VerticalAlignment="Center" FontWeight="Bold" x:Name="tbTitle"
HorizontalAlignment="Left" FontSize="24" >
<TextBlock.Foreground>
<LinearGradientBrush StartPoint="1,0" EndPoint="1,1">

@ -21,6 +21,9 @@ public partial class BaseControl
FocusManager.SetFocusedElement(this, this);
Keyboard.Focus(this);
#if DEBUG
tbTitle.Text = tbTitle.Text + " -【测试版】";
#endif
}
private void Border_Minimize_MouseEnter(object sender, MouseEventArgs e)

@ -0,0 +1,785 @@
<Border x:Class="SparkClient.Views.Grading.GradingLoading"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:SparkClient.Views.Grading"
xmlns:hx="http://helix-toolkit.org/wpf/SharpDX"
xmlns:userControl="clr-namespace:SparkClient.Views.UserControl"
mc:Ignorable="d"
d:DesignWidth="1920"
d:DesignHeight="600"
>
<Border.Resources>
<Style x:Key="BorderRowStyle" TargetType="Border">
<Setter Property="CornerRadius" Value="15" />
<Setter Property="Background" Value="#ffffff" />
<Setter Property="Padding" Value="5 10" />
<Setter Property="Margin" Value="2 3" />
</Style>
<Style x:Key="CustomDataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Margin" Value="0,0,0,2"/>
<Setter Property="Height" Value="50"/>
<!-- 禁用所有系统默认视觉效果 -->
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridRow">
<!-- 核心技巧:用Grid做容器控制视觉层级 -->
<Grid>
<!-- 第1层:基础圆角背景 -->
<Border x:Name="BaseBackground"
CornerRadius="5"
Background="{TemplateBinding Background}"
Margin="2"/>
<!-- 第2层:选中状态圆角层(默认隐藏) -->
<Border x:Name="SelectedHighlight"
CornerRadius="5"
Background="Transparent"
Margin="2"/>
<!-- 第3层:内容展示层(不受覆盖影响) -->
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</SelectiveScrollingGrid.ColumnDefinitions>
<DataGridCellsPresenter Grid.Column="1"/>
<DataGridRowHeader Grid.Column="0"/>
</SelectiveScrollingGrid>
</Grid>
<!-- 状态触发器 -->
<ControlTemplate.Triggers>
<!-- 强制清除HandyControl的默认选中边框 -->
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- 交替行背景色 -->
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#D4FCFF"/>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#E4ECFF"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<Style x:Key="CustomDataGridCellStyle" TargetType="DataGridCell">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<Style x:Key="CenteredTextBlockStyle" TargetType="TextBlock">
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Border.Resources>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" Width="5*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="300" Width="4*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Style="{StaticResource BorderRowStyle}">
<Grid>
<Grid.ColumnDefinitions>
<!-- 保存 -->
<ColumnDefinition Width="Auto"/>
<!-- 导出 -->
<ColumnDefinition Width="Auto"/>
<!-- DS -->
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<!-- 间隔 -->
<ColumnDefinition Width="*"/>
<!-- 标准 -->
<ColumnDefinition Width="Auto"/>
<!-- 形状 -->
<ColumnDefinition Width="Auto"/>
<!-- 管部 -->
<ColumnDefinition Width="Auto"/>
<!-- 亭部 -->
<ColumnDefinition Width="Auto"/>
<!-- 重量 -->
<ColumnDefinition Width="Auto"/>
<!-- 切工等级 -->
<ColumnDefinition Width="Auto"/>
<!-- 对称等级 -->
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 保存按钮 -->
<Button Grid.Column="0" Padding="0" Margin="10 0 0 0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveFileCommand}" ForceCursor="True">
<Border
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0 0 0 0"
Padding="10, 10"
Width="100"
BorderThickness="0"
CornerRadius="20">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#38C8BF" Offset="0"/>
<GradientStop Color="#1FB2A9" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" IsEnabled="False" />
</Border>
</Button>
<!-- 导出按钮 -->
<Button Grid.Column="1" Padding="0" Margin="10 0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveAsCommand}" >
<Border
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0 0 0 0"
Padding="10, 10"
Width="100"
BorderThickness="0"
CornerRadius="20">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#40B1FF" Offset="0"/>
<GradientStop Color="#3C9CE6" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" IsEnabled="False" />
</Border>
</Button>
<!-- DS 下拉列表 -->
<Border Grid.Column="3" Background="#E0E2EE" Width="170" Height="40" CornerRadius="10" Margin="2,20,30,20" >
<Grid Margin="-2,0,2,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- <TextBlock Grid.Column="1" Text="{StaticResource DiamondResultDs}" TextAlignment="Center" VerticalAlignment="Center" -->
<!-- FontSize="16"/> -->
<!-- <ComboBox Grid.Column="2" ItemsSource="{Binding DSList}" DisplayMemberPath="Key" SelectedValuePath="Value" -->
<!-- SelectedValue="{Binding DS, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" -->
<!-- Margin="10 0 0 0" FontSize="16" Width="80" BorderBrush="Black" BorderThickness="0" Height="30"/> -->
</Grid>
</Border>
<!-- 打印按钮 -->
<Button Grid.Column="2" Padding="0" Margin="0,0,10,0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding ThermalPrintCommand}" HorizontalAlignment="Left">
<Border
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="0 0 0 0"
Padding="10, 10"
Width="100"
BorderThickness="0"
CornerRadius="20">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#C26989B7" Offset="0"/>
<GradientStop Color="#C26989B7" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" />
</Border>
</Button>
<!-- 卡片 -->
<!-- 标准 -->
<Border Grid.Column="5" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0" IsEnabled="False">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<!-- 形状 -->
<Border Grid.Column="6" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Shape}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<!-- 冠部 -->
<Border Grid.Column="7" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding CrownType}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<!-- 亭部 -->
<Border Grid.Column="8" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding PavType}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<!-- 重量 -->
<Border Grid.Column="9" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Wight}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<!-- 切工等级 -->
<Border Grid.Column="10" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<Border Grid.Row="2" Background="Transparent" CornerRadius="5" Width="100">
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Padding="5"/>
</Border>
</Grid>
</Border>
<!-- 切工等级 -->
<Border Grid.Column="11" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center"
FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
<Border Grid.Row="2" Background="Transparent" CornerRadius="5" Width="100">
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SymLevelTotal}"
FontSize="20" Foreground="Black" Padding="5"/>
</Border>
</Grid>
</Border>
</Grid>
</Border>
<Border Grid.Row="2" Grid.Column="0" Style="{StaticResource BorderRowStyle}" >
<DataGrid ItemsSource="{Binding DtResults,Mode=TwoWay}" FontSize="20" Visibility="Hidden"
AutoGenerateColumns="False"
HeadersVisibility="Column"
Background="Transparent"
BorderThickness="0"
CanUserSortColumns="False"
CanUserResizeColumns="False"
GridLinesVisibility="None"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
FocusVisualStyle="{x:Null}"
IsReadOnly="True"
RowStyle="{StaticResource CustomDataGridRowStyle}"
ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
CellStyle="{StaticResource CustomDataGridCellStyle}"
AlternationCount="2">
<DataGrid.Resources>
<Style TargetType="ScrollBar">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn Header="" Width="2*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="{Binding TestItemName}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<Popup x:Name="RowPopup"
Placement="Bottom"
AllowsTransparency="True"
PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType=FrameworkElement}}"
Visibility="Collapsed"
VerticalOffset="20"
HorizontalOffset="80">
<Border Width="1500" Height="130" Background="White" CornerRadius="5" BorderThickness="1" BorderBrush="Gray">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" HorizontalAlignment="Right" Margin="5" Click="CloseAllPopup_Click" Padding="0" BorderBrush="Transparent"
Background="Transparent" BorderThickness="0">
<Image Source="pack://application:,,,/Resource/Images/UIResource/01-8.png" MouseLeave="UIElement_OnMouseLeave" MouseEnter="UIElement_OnMouseEnter" Width="30" />
</Button>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="Transparent" Width="120" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.itemName}"
FontSize="22" Foreground="Black" FontWeight="Bold" TextWrapping="Wrap" Margin="0 0 0 5"/>
</Grid>
</Border>
<Border Grid.Column="1" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridAvgValue}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Avg}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="2" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridDeviationValue}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Dev}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="3" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridMinValue}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Min}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="4" Background="#EBEEF5" Width="100" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridMaxValue}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Max}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="13" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridCutLevel}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.CutLevel}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="14" Background="#EBEEF5" Width="100" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridSymLevel}"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.SymLevel}"
FontSize="20" Foreground="#0063FF"/>
</Grid>
</Border>
<Border Grid.Column="5" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="1"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item1}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="0">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="0">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="6" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="2"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item2}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="1">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="1">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="7" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="3"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item3}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="2">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="2">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="8" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="4"
FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item4}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="3">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="3">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="9" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="5"
FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item5}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="4">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="4">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="10" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="6"
FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item6}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="5">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="5">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="11" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="7"
FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item7}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="6">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="6">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
<Border Grid.Column="12" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="8"
FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
<TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item8}"
FontSize="20" Foreground="#0063FF">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="7">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="7">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
</Grid>
</Grid>
</Border>
</Popup>
<!-- 点击区域,触发打开(或切换) Popup 事件 -->
<Border x:Name="ClickArea"
Background="Transparent"
MouseLeftButtonUp="ClickArea_MouseLeftButtonUp"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- 第2~5列 -->
<DataGridTextColumn Header="{StaticResource DiamondResultGridAvgValue}" Binding="{Binding Avg}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
<DataGridTextColumn Header="{StaticResource DiamondResultGridDeviationValue}" Binding="{Binding Dev}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
<DataGridTextColumn Header="{StaticResource DiamondResultGridMinValue}" Binding="{Binding Min}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
<DataGridTextColumn Header="{StaticResource DiamondResultGridMaxValue}" Binding="{Binding Max}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
<!-- 第6列 -->
<DataGridTextColumn Header="{StaticResource DiamondResultGridCutLevel}" Binding="{Binding CutLevel}" Width="*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<!-- 第五列:SYM等级,下拉框示例,可编辑 -->
<DataGridTemplateColumn Width="*" Header="{DynamicResource DiamondResultGridSymLevel}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding GradeList}"
IsEnabled="{Binding isEnabled}"
DisplayMemberPath="{DynamicResource NameType}"
SelectedValuePath="GRADE_ORDER"
SelectedValue="{Binding SymLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="ChangSymLevel"
FontSize="20"
Foreground="DarkSlateGray"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="120">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="TestItemId" Binding="{Binding TestItemId}" Visibility="Hidden"/>
</DataGrid.Columns>
</DataGrid>
</Border>
<GridSplitter Grid.Row="2" Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="Transparent" IsEnabled="False"></GridSplitter>
<Border Grid.Row="2" Grid.Column="2" Background="White" Style="{StaticResource BorderRowStyle}">
<Grid>
<Grid.RowDefinitions>
<!-- <RowDefinition Height="50"></RowDefinition> -->
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- <userControl:Viewport3D ViewportData="{Binding ViewportData}"></userControl:Viewport3D> -->
</Grid>
</Border>
</Grid>
</Border>

@ -0,0 +1,297 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Forms.VisualStyles;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using log4net;
using SparkClient.ViewModel.Grading;
using GeometryModel3D = HelixToolkit.Wpf.SharpDX.GeometryModel3D;
namespace SparkClient.Views.Grading;
public partial class GradingLoading
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(GradingResult));
// List<Viewport3DTriangleEntity> triangles = new List<Viewport3DTriangleEntity>();
List<GeometryModel3D> mouseAddModels = new List<GeometryModel3D>();
// 用于记录当前所有已存在的Popup
private List<Popup> _allPopups = new List<Popup>();
public GradingLoading()
{
InitializeComponent();
// 在Window最外层捕获鼠标点击,判断是否点击在Popup之外,如果是则关闭所有Popup
this.PreviewMouseLeftButtonDown += Window_PreviewMouseLeftButtonDown;
//DataContext = new GradingResultVM(null);
// this.Viewport3Dx.EffectsManager = new DefaultEffectsManager();
// this.Viewport3Dx.Camera = new PerspectiveCamera()
// {
// Position = new Point3D(0, 0, 5),
// LookDirection = new Vector3D(0, 0, -1),
// UpDirection = new Vector3D(0, 1, 0),
// FarPlaneDistance = 1000,
// NearPlaneDistance = 0.1
// };
// Loaded += (sender, args) =>
// {
// var entities = Viewport3DHelper.InitDemo(Viewport3Dx);
// triangles.AddRange(entities);
// };
}
/// <summary>
/// 点击模型
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Viewport3Dx_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// // 获取鼠标点击位置
// var mousePosition = e.GetPosition(Viewport3Dx);
//
// // 查找鼠标点击的 3D 对象
// var hits = Viewport3Dx.FindHits(mousePosition);
//
// // 如果没有命中任何 3D 对象
// if (hits == null || hits.Count == 0)
// {
// Console.WriteLine("未点击到任何模型");
// foreach (var item in mouseAddModels)
// {
// Viewport3Dx.Items.Remove(item);
// }
// mouseAddModels.Clear();
// return;
// }
//
// // 获取第一个命中的对象
// var hit = hits[0];
//
// // 检查是否是 MeshGeometryModel3D
// if (hit.ModelHit is MeshGeometryModel3D modelHit)
// {
// foreach (var item in mouseAddModels)
// {
// Viewport3Dx.Items.Remove(item);
// }
// mouseAddModels.Clear();
// // 获取几何信息
// var geometry = modelHit.Geometry as MeshGeometry3D;
// if (geometry != null)
// {
// // 获取命中的三角形索引
// var triangleIndex = hit.TriangleIndices;
//
// // 获取三角形顶点
// var vertex1 = geometry.Positions[triangleIndex.Item1];
// var vertex2 = geometry.Positions[triangleIndex.Item2];
// var vertex3 = geometry.Positions[triangleIndex.Item3];
//
// string strPoint = vertex1.X + ","+ vertex1.Y+","+ vertex1.Z + ";"+ vertex2.X + ","+ vertex2.Y + ","+ vertex2.Z+";"+vertex3.X + ","+ vertex3.Y + ","+ vertex3.Z;
// string triangleCode = Viewport3DTriangleEntity.GenerateMD5Hash(strPoint);
//
// //命中实体
// Viewport3DTriangleEntity res = triangles.Find(e => triangleCode.Equals(e.TriangleCode));
//
// if (res == null)
// return;
//
// //命中面
// List<Viewport3DTriangleEntity> facet = triangles.Where(e => res.PlaneCode.Equals(e.PlaneCode)).ToList();
// var colorFacet = new Color4(1.0f, 1.0f, 0.0f, 1.0f);
// var data1 = Viewport3DHelper.GenerateEmissiveModelByEntity(Viewport3Dx,facet,colorFacet);
// mouseAddModels.AddRange(data1);
// //命中面标线
// var data2 = Viewport3DHelper.GenerateLineTextModelByEntity(Viewport3Dx, facet);
// mouseAddModels.AddRange(data2);
// //命中同类面
// List<Viewport3DTriangleEntity> facetType = triangles.Where(e => res.PlaneType.Equals(e.PlaneType)).ToList();
// //排除自己
// facet.ForEach(e=>facetType.Remove(e));
// var colorFacetType = new Color4(0.9f, 0.9f, 0.7f, 1.0f);
// var data3 = Viewport3DHelper.GenerateEmissiveModelByEntity(Viewport3Dx,facetType,colorFacetType);
// mouseAddModels.AddRange(data3);
// }
// }
// else
// {
// Console.WriteLine("点击的对象不是 MeshGeometryModel3D");
// }
}
private void ChangSymLevel(object sender, SelectionChangedEventArgs e)
{
var d = DataContext as GradingResultVM;
d.ChangeSym(null);
}
// private void dataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
// {
// detailPopup.IsOpen = false;
// // 获取点击的目标元素
// var element = sender as FrameworkElement;
//
// var cell = FindVisualParent<DataGridCell>(element);
// if (cell == null) return;
//
// var row = FindVisualParent<DataGridRow>(cell);
// if (row == null) return;
//
// if (element != null)
// {
// // 将 firstCell 的边界转换为屏幕坐标系
// var firstCellBounds = cell.PointToScreen(new Point(0, 0));
//
// // 计算Popup的位置
// var popupPosition = new Point(firstCellBounds.X + cell.RenderSize.Width, firstCellBounds.Y + cell.RenderSize.Height);
// var selectObject = row.Item as DataInfo;
// string testItemId = selectObject.TestItemId;
// var d = DataContext as GradingResultVM;
// RowDetail rowDetail = d.getSelectData(testItemId);
// // 设置Popup的位置
// detailPopup.HorizontalOffset = popupPosition.X;
// detailPopup.VerticalOffset = popupPosition.Y;
// detailPopup.IsOpen = true;
// RowDetail.Items.Clear();
// RowDetail.Items.Add(rowDetail);
// }
// }
// 辅助方法:查找父元素
private T FindVisualParent<T>(DependencyObject child) where T : DependencyObject
{
var parentObject = VisualTreeHelper.GetParent(child);
if (parentObject == null) return null;
if (parentObject is T parent)
{
return parent;
}
else
{
return FindVisualParent<T>(parentObject);
}
}
// private void Window_MouseDown(object sender, MouseButtonEventArgs e)
// {
// detailPopup.IsOpen = false;
// }
//
// private void Window_MouseDown(object sender, RoutedEventArgs e)
// {
// detailPopup.IsOpen = false;
// }
private void ClickArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var border = sender as Border;
if (border == null) return;
var parentGrid = border.Parent as Grid;
if (parentGrid == null) return;
var popup = parentGrid.FindName("RowPopup") as Popup;
if (popup == null) return;
popup.DataContext = this.DataContext;
// 先关闭所有已显示的 Popup
CloseAllPopups();
var oo = FindVisualParent<DataGridRow>(parentGrid);
if(oo == null) return;
var d = DataContext as GradingResultVM;
RowDetail rowDetail = d.getSelectData((oo.Item as DataInfo).TestItemId);
if (!_allPopups.Contains(popup))
{
_allPopups.Add(popup);
}
// 显示新Popup
popup.IsOpen = true;
popup.Visibility = Visibility.Visible;
}
private void CloseAllPopups()
{
foreach (var p in _allPopups)
{
p.IsOpen = false;
p.Visibility = Visibility.Collapsed;
}
}
private void CloseAllPopup_Click(object sender, RoutedEventArgs e)
{
CloseAllPopups();
}
private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// originalSource 是点击处的控件
var clickedElement = e.OriginalSource as DependencyObject;
// 遍历所有已知 Popup
bool isClickOnAnyPopup = false;
foreach (var p in _allPopups)
{
// 如果此 Popup 不可见或未打开,就不用检查了
if (!p.IsOpen)
continue;
// 判断点击处是否在此 Popup 内
if (IsDescendantOf(p.Child, clickedElement))
{
// 找到一个 Popup 包含这个点击
isClickOnAnyPopup = true;
break;
}
}
// 如果没点击到任何 Popup,就关闭全部
if (!isClickOnAnyPopup)
{
CloseAllPopups();
}
}
private bool IsDescendantOf(DependencyObject parent, DependencyObject clicked)
{
if (parent == null || clicked == null)
return false;
// 从 clicked 开始不断向上找 VisualTree
var current = clicked;
while (current != null)
{
if (current == parent)
{
return true;
}
current = VisualTreeHelper.GetParent(current);
}
return false;
}
private void UIElement_OnMouseLeave(object sender, MouseEventArgs e)
{
if (sender is Image image)
{
image.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/UIResource/01-8.png"));
}
}
private void UIElement_OnMouseEnter(object sender, MouseEventArgs e)
{
if (sender is Image image)
{
image.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/UIResource/01-8-1.png"));
}
}
}

@ -311,7 +311,7 @@ public class ViewportHelperPro
/// <param name="entities"></param>
public static List<LineGeometryModel3D> GentrateLineByEntity(Viewport3DX viewport, List<Viewport3DTriangleEntity> entities, Color4? color = null, double thickness = 1.0)
{
List<LineGeometryModel3D> result = GentrateLineByEntity(entities, color, thickness);
List<LineGeometryModel3D> result = GentrateLineByEntity(entities, ViewportManager.isUglyDiamond ? new Color4(new Color3(1f, 0,0)):color, thickness);
result.ForEach(e => viewport.Items.Add(e));
return result;
}

@ -15,6 +15,8 @@ namespace SparkClient.Views.UserControl.ViewportData.Helper;
public class ViewportManager
{
public static bool isUglyDiamond = false;
/// <summary>
/// 视图中三角形实体们
/// </summary>

@ -145,6 +145,15 @@ public class ViewportData
facetsFinal.Add(item);
}
if (json["status"].ToString().Equals("P021"))
{
ViewportManager.isUglyDiamond = true;
}
else
{
ViewportManager.isUglyDiamond = false;
}
ViewportManager.ViewportTriangle.Clear();
ViewportManager.ViewportTriangle.AddRange(facetsFinal);
ViewportManager.ColorConfig = ColorConfig;

Loading…
Cancel
Save