using HandyControl.Controls; using log4net; using BrilliantSightClient.ViewModel; using BrilliantSightClient.ViewModel.Dialog; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Microsoft.Win32; namespace BrilliantSightClient.Views.Dialog { /// /// JsonImport.xaml 的交互逻辑 /// public partial class ImageSelect { private static readonly ILog Logger = LogManager.GetLogger(typeof(ImageSelect)); public BaseViewModel ViewModel = null; public ImageSelect() { InitializeComponent(); WindowStartupLocation = WindowStartupLocation.CenterScreen; // 动态设置圆角裁剪 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_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 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) { DialogResult = false; this.Close(); } private void open_Click(object sender, RoutedEventArgs e) { var dialog = new OpenFolderDialog { Title = "请选择部署位置" }; bool? result = dialog.ShowDialog(); if (result == true) { FilePath.Text = dialog.FolderName; } } private void Ok_Click(object sender, RoutedEventArgs e) { if (FilePath.Text.Trim().Length > 0) { DialogResult = true; this.Close(); } else { Growl.Error("请选择图片路径"); } } 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 }; } } }