feat:钻石选择画面

master
sunhonglei 8 months ago
parent 3f5a6140f9
commit cf03d5c5e6
  1. 7
      App.xaml
  2. 17
      Language/zh_CN.xaml
  3. BIN
      Resource/Images/Cushion-shaped.png
  4. BIN
      Resource/Images/Emerald-shape.png
  5. BIN
      Resource/Images/Heart-shaped.png
  6. BIN
      Resource/Images/Odd-shaped.png
  7. BIN
      Resource/Images/Pear-shaped.png
  8. BIN
      Resource/Images/Princess-shaped.png
  9. BIN
      Resource/Images/oval.png
  10. BIN
      Resource/Images/round_3x.png
  11. BIN
      Resource/Images/round_P8-P8.png
  12. 23
      SparkClient.csproj
  13. 60
      ViewModel/BaseWindow/HomeWindowVM.cs
  14. 57
      ViewModel/Dialog/StartDialogVM.cs
  15. 190
      ViewModel/Grading/DiamondSelectVM.cs
  16. 23
      Views/Dialog/LoadingDialog.xaml
  17. 85
      Views/Dialog/StartDialog.xaml
  18. 99
      Views/Dialog/StartDialog.xaml.cs
  19. 86
      Views/Grading/DiamondSelect.xaml

@ -8,7 +8,9 @@
xmlns:configView="clr-namespace:SparkClient.Views.Configuration"
xmlns:gradingView="clr-namespace:SparkClient.Views.Grading"
xmlns:gradingVM="clr-namespace:SparkClient.ViewModel.Grading"
xmlns:viewModel="clr-namespace:SparkClient.ViewModel"
xmlns:viewModel="clr-namespace:SparkClient.ViewModel"
xmlns:dialogVM="clr-namespace:SparkClient.ViewModel.Dialog"
xmlns:dialogView="clr-namespace:SparkClient.Views.Dialog"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
@ -52,6 +54,9 @@
<DataTemplate DataType="{x:Type gradingVM:GradingResultVM}">
<gradingView:GradingResult/>
</DataTemplate>
<DataTemplate DataType="{x:Type dialogVM:StartDialogVM}">
<dialogView:StartDialog/>
</DataTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>

@ -40,6 +40,7 @@
<sys:String x:Key="No">否</sys:String>
<sys:String x:Key="Cancel">取消</sys:String>
<sys:String x:Key="Confirm">确认</sys:String>
<!-- 定级配置画面 -->
<sys:String x:Key="Save_successful_message">数据保存成功</sys:String>
<sys:String x:Key="save_fail_message">数据保存失败</sys:String>
<sys:String x:Key="no_data_message">没有导入数据</sys:String>
@ -48,6 +49,22 @@
<sys:String x:Key="STANDARD_NAME">STANDARD_NAME</sys:String>
<sys:String x:Key="SHAPE_NAME">SHAPE_NAME</sys:String>
<sys:String x:Key="INSTITUTE_NAME">INSTITUTE_NAME</sys:String>
<!-- 开始检测按钮点击后弹窗-->
<sys:String x:Key="UpdateDiamondCode">请输入上传钻石编码</sys:String>
<sys:String x:Key="ok">确定</sys:String>
<sys:String x:Key="Skip">跳过</sys:String>
<sys:String x:Key="NoDiamondCode">没有输入钻石编码</sys:String>
<!-- 钻石选择画面 -->
<sys:String x:Key="圆形">圆形</sys:String>
<sys:String x:Key="心形">心形</sys:String>
<sys:String x:Key="枕形">枕形</sys:String>
<sys:String x:Key="梨形">梨形</sys:String>
<sys:String x:Key="公主方形">公主方形</sys:String>
<sys:String x:Key="椭圆形">椭圆形</sys:String>
<sys:String x:Key="祖母绿形">祖母绿形</sys:String>
<sys:String x:Key="异形钻">异形钻</sys:String>
<!-- loading -->
<sys:String x:Key="wait">正在检测,请等待...</sys:String>
<!--检测结果 报表-->
<sys:String x:Key="Avg">平均</sys:String>

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

@ -23,13 +23,36 @@
</ItemGroup>
<ItemGroup>
<None Remove="Resource\Images\Cushion-shaped.png" />
<None Remove="Resource\Images\Emerald-shape.png" />
<None Remove="Resource\Images\Heart-shaped.png" />
<None Remove="Resource\Images\IGILogo.png" />
<None Remove="Resource\Images\Odd-shaped.png" />
<None Remove="Resource\Images\oval.png" />
<None Remove="Resource\Images\Pear-shaped.png" />
<None Remove="Resource\Images\Princess-shaped.png" />
<None Remove="Resource\Images\round_3x.png" />
<None Remove="Resource\Images\round_P8-P8.png" />
<None Remove="Resource\Images\ze-add-o 1%403x.png" />
<Resource Include="Resource\Images\Cushion-shaped.png" />
<Resource Include="Resource\Images\Emerald-shape.png" />
<Resource Include="Resource\Images\Heart-shaped.png" />
<Resource Include="Resource\Images\IGILogo.png" />
<None Remove="Resource\Images\homebg.png" />
<Resource Include="Resource\Images\homebg.png" />
<Resource Include="Resource\Images\Odd-shaped.png" />
<Resource Include="Resource\Images\oval.png" />
<Resource Include="Resource\Images\Pear-shaped.png" />
<Resource Include="Resource\Images\Princess-shaped.png" />
<Resource Include="Resource\Images\round_3x.png" />
<Resource Include="Resource\Images\round_P8-P8.png" />
<Resource Include="Resource\Images\ze-add-o 1@3x.png" />
<None Update="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="SparkDB.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Remove="Resource\Images\config_3x.png" />
<Resource Include="Resource\Images\config_3x.png" />
<None Remove="Resource\Images\diam_3x.png" />

@ -4,42 +4,44 @@ using System.Windows.Input;
using HandyControl.Controls;
using SparkClient.Model.Helper;
using SparkClient.ViewModel.Configuration;
using SparkClient.ViewModel.Dialog;
using SparkClient.ViewModel.Grading;
using SparkClient.Views.Dialog;
using SparkClient.Views.Grading;
namespace SparkClient.ViewModel.BaseWindow;
public class HomeWindowVM : BaseViewModel
{
public ICommand ShowHelperPageCommand { get; }
public ICommand ShowConfigPageCommand { get; }
public ICommand ShowDiamondSelPageCommand { get; }
public ICommand ShowHelperPageCommand { get; }
public HomeWindowVM()
{
ShowHelperPageCommand = new RelayCommand(ShowHelperPage);
ShowConfigPageCommand = new RelayCommand(ShowConfigPage);
ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage);
}
public ICommand ShowConfigPageCommand { get; }
public ICommand ShowDiamondSelPageCommand { get; }
public void ShowHelperPage(object parameter)
{
BaseControlVM vm = new BaseControlVM(new HelperPageVM(), MultilingualHelper.getString("Help"));
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public HomeWindowVM()
{
ShowHelperPageCommand = new RelayCommand(ShowHelperPage);
ShowConfigPageCommand = new RelayCommand(ShowConfigPage);
ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage);
}
public void ShowConfigPage(object parameter)
{
ConfigMenuPageVM vm = new ConfigMenuPageVM();
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public void ShowDiamlondSelPage(object parameter)
{
BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult"));
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public void ShowHelperPage(object parameter)
{
BaseControlVM vm = new BaseControlVM(new HelperPageVM(), MultilingualHelper.getString("Help"));
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public void ShowConfigPage(object parameter)
{
ConfigMenuPageVM vm = new ConfigMenuPageVM();
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public void ShowDiamlondSelPage(object parameter)
{
StartDialog dialog = new StartDialog();
dialog.ShowDialog();
}
}

@ -0,0 +1,57 @@
using HandyControl.Controls;
using SparkClient.Model.Helper;
using SparkClient.ViewModel.BaseWindow;
using SparkClient.ViewModel.Grading;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace SparkClient.ViewModel.Dialog
{
internal class StartDialogVM : BaseViewModel
{
public ICommand SkipCommand { get; }
public ICommand OkCommand { get; }
private string _inputText;
public string InputText
{
get { return _inputText; }
set { _inputText = value; OnPropertyChanged("Institutes"); }
}
public StartDialogVM()
{
SkipCommand = new RelayCommand(Skip);
OkCommand = new RelayCommand(Ok);
}
public void InitStartDialog(object param)
{
}
public void Skip(object parameter)
{
BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(""), MultilingualHelper.getString("DiamondSelect"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
public void Ok(object parameter)
{
if (InputText != null && InputText.Trim().Length > 0) {
BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(InputText), MultilingualHelper.getString("DiamondSelect"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
else
{
Growl.Error(MultilingualHelper.getString("NoDiamondCode"));
}
}
}
}

@ -1,17 +1,76 @@
using SparkClient.Model.Helper;
using SparkClient.ViewModel.BaseWindow;
using SparkClient.Views.Dialog;
using System;
using System.DirectoryServices.ActiveDirectory;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace SparkClient.ViewModel.Grading;
public class DiamondSelectVM : BaseViewModel
{
public DiamondSelectVM()
private string DiamondCode { get; set; }
private List<ButtonViewModel> _buttons;
private List<ButtonViewModel> _buttons2;
private ICommand ChangeDiamondTypeCommand;
private ICommand StartGradingCommand;
public List<ButtonViewModel> Buttons {
get { return _buttons; }
set
{
_buttons = value;
OnPropertyChanged(nameof(Buttons));
}
}
public List<ButtonViewModel> Buttons2
{
get { return _buttons2; }
set
{
_buttons2 = value;
OnPropertyChanged(nameof(Buttons2));
}
}
public DiamondSelectVM(string DiamondCode)
{
ChangeDiamondTypeCommand = new RelayCommand(ChangeDiamondType);
StartGradingCommand = new RelayCommand(StartGrading);
this.DiamondCode = DiamondCode;
List<ButtonViewModel> tempButtons = new List<ButtonViewModel>();
List<ButtonInfo> buttonInfos = GetButtonInfos();
foreach (var buttonInfo in buttonInfos)
{
var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/" + buttonInfo.ImageName, UriKind.RelativeOrAbsolute));
ButtonViewModel button = new ButtonViewModel() { Text = buttonInfo.ButtonName, ImageSource = bitmap, Type = buttonInfo.Type, Command = ChangeDiamondTypeCommand ,IsEnabled= buttonInfo.IsEnabled, IsHighlighted = false};
tempButtons.Add(button);
}
Buttons = tempButtons;
}
private List<ButtonInfo> GetButtonInfos()
{
List<ButtonInfo> buttonInfos = new List<ButtonInfo>();
buttonInfos.Add(new ButtonInfo() { Type = "round", IsEnabled = true, ImageName = "round_3x.png", ButtonName = MultilingualHelper.getString("圆形") });
buttonInfos.Add(new ButtonInfo() { Type = "Heart", IsEnabled = false, ImageName = "Heart-shaped.png", ButtonName = MultilingualHelper.getString("心形") });
buttonInfos.Add(new ButtonInfo() { Type = "cushion", IsEnabled = false, ImageName = "Cushion-shaped.png", ButtonName = MultilingualHelper.getString("枕形") });
buttonInfos.Add(new ButtonInfo() { Type = "Pear", IsEnabled = false, ImageName = "Pear-shaped.png", ButtonName = MultilingualHelper.getString("梨形") });
buttonInfos.Add(new ButtonInfo() { Type = "Princess", IsEnabled = false, ImageName = "Princess-shaped.png", ButtonName = MultilingualHelper.getString("公主方形") });
buttonInfos.Add(new ButtonInfo() { Type = "oval", IsEnabled = false, ImageName = "oval.png", ButtonName = MultilingualHelper.getString("椭圆形") });
buttonInfos.Add(new ButtonInfo() { Type = "Emerald", IsEnabled = false, ImageName = "Emerald-shape.png", ButtonName = MultilingualHelper.getString("祖母绿形") });
buttonInfos.Add(new ButtonInfo() { Type = "Odd", IsEnabled = false, ImageName = "Odd-shaped.png", ButtonName = MultilingualHelper.getString("异形钻") });
return buttonInfos;
}
/// <summary>
/// 获取钻石列表
/// </summary>
/// <param name="param"></param>
public void InitDiamondList(object param)
{
}
/// <summary>
@ -20,24 +79,143 @@ public class DiamondSelectVM : BaseViewModel
/// <param name="type">钻石类型</param>
public void ChangeDiamondType(object type)
{
if (type!= null)
{
foreach (var item in Buttons.Where(x => x.Type == type))
{
item.IsHighlighted = true;
};
List<ButtonViewModel> tempButtons2 = new List<ButtonViewModel>();
var bitmap = new BitmapImage(new Uri("pack://application:,,,/Resource/Images/round_P8-P8.png", UriKind.RelativeOrAbsolute));
ButtonViewModel button = new ButtonViewModel() { Text = "P8-P8", ImageSource = bitmap, Type = "round", Command = StartGradingCommand };
tempButtons2.Add(button);
Buttons2 = tempButtons2;
}
}
/// <summary>
/// 开始检测(对soc和算法开始通讯)
/// </summary>
/// <param name="param"></param>
public void StartGrading(object param)
public async void StartGrading(object param)
{
}
if (param != null)
{
LoadingDialog loading = new LoadingDialog();
var progressTask = Task.Run(() => Application.Current.Dispatcher.Invoke(() => loading.ShowDialog()));
await Task.Run(async () =>
{
for (int i = 0; i <= 100; i++)
{
// 模拟耗时操作
//System.Threading.Thread.Sleep(50); // 休眠50毫秒
await Task.Delay(1000);
// 更新进度条的值(需要在UI线程上执行)
loading.Dispatcher.Invoke(() =>
{
loading.setValue(i);
});
}
});
loading.Close();
}
}
/// <summary>
/// 跳转至检测结果
/// </summary>
/// <param name="param"></param>
public void GradingResult(object param)
{
BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("GradingResult"));
vm.ShowFunctionButton = System.Windows.Visibility.Hidden;
WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm);
}
}
public class ButtonInfo
{
public string Type { get; set; }
public string ImageName { get; set; }
public string ButtonName { get; set; }
public bool IsEnabled { get; set; }
}
public class ButtonViewModel : BaseViewModel
{
private string _text;
private BitmapImage _imageSource;
private ICommand _command;
private string _type;
private int _col;
private bool _isEnabled;
private bool _isHighlighted;
public string Text
{
get { return _text; }
set
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
public BitmapImage ImageSource
{
get { return _imageSource; }
set
{
_imageSource = value;
OnPropertyChanged(nameof(ImageSource));
}
}
public ICommand Command
{
get { return _command; }
set
{
_command = value;
OnPropertyChanged(nameof(Command));
}
}
public string Type
{
get { return _type; }
set
{
_type = value;
OnPropertyChanged(nameof(Type));
}
}
public int Column
{
get { return _col; }
set
{
_col = value;
OnPropertyChanged(nameof(Column));
}
}
public bool IsEnabled
{
get { return _isEnabled; }
set
{
_isEnabled = value;
OnPropertyChanged(nameof(IsEnabled));
}
}
public bool IsHighlighted
{
get { return _isHighlighted; }
set
{
_isHighlighted = value;
OnPropertyChanged(nameof(IsHighlighted));
}
}
}

@ -0,0 +1,23 @@
<Window x:Class="SparkClient.Views.Dialog.LoadingDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SparkClient.Views.Dialog"
mc:Ignorable="d"
Title="LoadingDialog" Height="450" Width="800"
WindowStyle="None" AllowsTransparency="True" Background="Transparent"
WindowState="Maximized">
<Border Background="#9C7C5E" Opacity="0.8">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" Text="{DynamicResource wait}" FontFamily="PingFangSC-bold" FontSize="36" VerticalAlignment="Center" Background="Transparent" HorizontalAlignment="Center" Foreground="#FFFFFF"/>
<ProgressBar x:Name="ProgressBar" Style="{StaticResource ProgressBarWarning}" Grid.Row="2" Width="544"/>
</Grid>
</Border>
</Window>

@ -0,0 +1,85 @@
<Window x:Class="SparkClient.Views.Dialog.StartDialog"
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:local="clr-namespace:SparkClient.Views.Dialog"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
d:DesignHeight="222" d:DesignWidth="562"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Border CornerRadius="15" Background="White" x:Name="Border" >
<Grid ClipToBounds="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 模拟顶部标题栏 -->
<Grid Grid.Row="0" Background="#795C2A" Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 关闭按钮 -->
<Border Grid.Column="2"
Width="40" Height="30"
Margin=" 0 0 10 0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Background="Transparent"
MouseEnter="Border_Close_MouseEnter"
MouseLeave="Border_MouseLeave">
<Button Background="Transparent" BorderBrush="Transparent" Click="Close_Click">
<Viewbox Stretch="Uniform">
<Path Data="{StaticResource CloseGeometry}"
Fill="Azure"
Stroke="Azure"
StrokeThickness="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="20 0 0 0"
Width="30" />
</Viewbox>
</Button>
</Border>
</Grid>
<StackPanel Grid.Row="1" VerticalAlignment="Center" >
<Grid Height="30" Margin="0 10 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="9*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="1" HorizontalAlignment="Center" Content="{DynamicResource UpdateDiamondCode}" Background="Transparent"
BorderBrush="Transparent"
FontSize="16" FontFamily="AlibabaPuHui-regular" />
<TextBox TextWrapping="Wrap" Name ="Id" Grid.Column="2" Text="{Binding InputText}" />
<TextBlock Text="请输入" Grid.Column="2" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Text, ElementName=Id}" Value="">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="2" Content="{DynamicResource ok}" HorizontalAlignment="Center" Command="{Binding OkCommand}" Click="Ok_Click" />
<Button Grid.Column="3" Content="{DynamicResource Skip}" HorizontalAlignment="Center" Command="{Binding SkipCommand}" Click="Close_Click" />
</Grid>
</StackPanel>
</Grid>
</Border>
</Window>

@ -0,0 +1,99 @@
using HandyControl.Controls;
using SparkClient.Model.Helper;
using SparkClient.ViewModel;
using SparkClient.ViewModel.BaseWindow;
using SparkClient.ViewModel.Dialog;
using SparkClient.ViewModel.Grading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace SparkClient.Views.Dialog
{
/// <summary>
/// StartDialog.xaml 的交互逻辑
/// </summary>
public partial class StartDialog
{
public BaseViewModel ViewModel = null;
public StartDialog()
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
// 动态设置圆角裁剪
this.Loaded += (s, e) => ApplyCornerRadiusClip();
this.SizeChanged += (s, e) => ApplyCornerRadiusClip(); // 保证在大小改变时也裁剪
this.Width = 562;
this.Height = 222;
this.ViewModel = new StartDialogVM();
this.DataContext = this.ViewModel;
}
#region 重写窗体操作按钮
private void Border_Minimize_MouseEnter(object sender, MouseEventArgs e)
{
// 鼠标进入时更改背景色
if (sender is Border border)
{
border.Background = new SolidColorBrush(Color.FromArgb(50, 255, 255, 255));
}
}
private void Border_Close_MouseEnter(object sender, MouseEventArgs e)
{
// 鼠标进入时更改背景色
if (sender is Border border)
{
border.Background = new SolidColorBrush(Color.FromArgb(50, 255, 0, 0));
}
}
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
// 鼠标离开时恢复背景色
if (sender is Border border)
{
border.Background = new SolidColorBrush(Colors.Transparent);
}
}
private void Minimize_Click(object sender, MouseButtonEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
try
{
this.DragMove();
}
catch (InvalidOperationException ex)
{
}
}
}
#endregion
private void Close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Ok_Click(object sender, RoutedEventArgs e)
{
if(Id.Text.Trim().Length>0) { this.Close(); }
}
private void ApplyCornerRadiusClip()
{
// 使用矩形几何生成圆角裁剪
this.Border.Clip = new RectangleGeometry
{
Rect = new Rect(0, 0, this.Border.ActualWidth, this.Border.ActualHeight),
RadiusX = this.Border.CornerRadius.TopLeft, // 使用 Border 的 CornerRadius
RadiusY = this.Border.CornerRadius.TopLeft
};
}
}
}

@ -8,19 +8,91 @@
d:DesignWidth="1000"
d:DesignHeight="600"
mc:Ignorable="d">
<Border.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
</Border.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" Width="1*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="300" Width="5*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="Aqua">
</Border>
<GridSplitter Grid.Column="1" Width="3" HorizontalAlignment="Stretch"></GridSplitter>
<Border Grid.Column="2" Background="Aquamarine">
<TextBlock Text="{Binding Type}" Visibility="Hidden" Name="Type"/>
<ScrollViewer Grid.Column="0" Background="#F7F7F7" Opacity="0.9">
<ItemsControl ItemsSource="{Binding Buttons}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Background="Transparent" Command="{Binding Command}" CommandParameter="{Binding Type}" BorderBrush="Transparent" Width="130" Height="130" IsEnabled="{Binding IsEnabled}">
<Border Background="#BEB6BA" Width="110" Height="110" CornerRadius="10" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="84"/>
<RowDefinition Height="36"/>
</Grid.RowDefinitions>
<Image Source="{Binding ImageSource}" Grid.Row="0" Width="102" Height="84" Margin="5 5 5 0"/>
<TextBlock Text="{Binding Text}" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="14" FontStyle="Normal" FontFamily="PingFangSC-regular" Foreground="#FDFEFD" Margin="5" />
<Border Background="#79410E" Grid.Row="1" Opacity="0.45" CornerRadius="0 0 10 10" Height="25" VerticalAlignment="Top" Visibility="{Binding IsHighlighted, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Visible}">
<TextBlock Text="{Binding Text}" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="14" FontStyle="Normal" FontFamily="PingFangSC-regular" Foreground="#FDFEFD" Margin="5" />
</Border>
</Grid>
</Border>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<Border Grid.Column="2" Background="#F7F7F7" Opacity="0.9">
<ItemsControl ItemsSource="{Binding Buttons2}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Background="Transparent" Command="{Binding Command}" CommandParameter="{Binding Type}" BorderBrush="Transparent" Width="212" Height="130">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<!-- 按钮内容 -->
<Border Background="#BEB6BA" Width="190" Height="110" CornerRadius="10" Margin="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="84"/>
<RowDefinition Height="36"/>
</Grid.RowDefinitions>
<Image Source="{Binding ImageSource}" Grid.Row="0" Width="180" Height="84" Margin="5"/>
<TextBlock Text="{Binding Text}" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="14" FontStyle="Normal" FontFamily="PingFangSC-regular" Foreground="#FDFEFD"/>
</Grid>
</Border>
<!-- 遮罩层 -->
<Border Name="Overlay" Background="#9C7C5E" Opacity="0.8" Width="190" Height="110" CornerRadius="10" Margin="5" Visibility="Collapsed">
<TextBlock Text="开始检测" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="18" FontStyle="Normal" FontFamily="PingFangSC-regular" Foreground="#FFFFFF"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Overlay" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</Grid>
</Border>

Loading…
Cancel
Save