using System; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; using NavisworksTransport.Utils; namespace NavisworksTransport.UI.WPF.Views { public partial class EditRotationWindow : Window, INotifyPropertyChanged { private double _rotationAngle; public double RotationAngle { get => _rotationAngle; set { if (_rotationAngle != value) { _rotationAngle = value; OnPropertyChanged(); } } } public EditRotationWindow(double currentAngle) { try { InitializeComponent(); RotationAngle = currentAngle; DataContext = this; } catch (Exception ex) { LogManager.Error($"角度修正对话框初始化失败: {ex.Message}", ex); MessageBox.Show($"角度修正对话框初始化失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error); } } private void OnQuickAngleClick(object sender, RoutedEventArgs e) { if (sender is System.Windows.Controls.Button button) { LogManager.Debug($"[快捷角度] 点击按钮: {button.Content}, Tag类型: {button.Tag?.GetType()}, Tag值: {button.Tag}"); if (button.Tag != null) { if (button.Tag is int intTag) { RotationAngle = intTag; LogManager.Debug($"[快捷角度] 设置角度为: {intTag}°"); } else if (button.Tag is string stringTag && double.TryParse(stringTag, out double angle)) { RotationAngle = angle; LogManager.Debug($"[快捷角度] 设置角度为: {angle}°"); } else if (button.Tag is double doubleTag) { RotationAngle = doubleTag; LogManager.Debug($"[快捷角度] 设置角度为: {doubleTag}°"); } } } } private void OnResetClick(object sender, RoutedEventArgs e) { RotationAngle = 0.0; } private void OnConfirmClick(object sender, RoutedEventArgs e) { DialogResult = true; Close(); } private void OnCancelClick(object sender, RoutedEventArgs e) { DialogResult = false; Close(); } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }