using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Models { /// /// FuBiao.xaml 的交互逻辑 /// public partial class FuBiao : UserControl { public float Narrow_Enlarge { get; set; } = 1.5f; //包装器 public float Rotate_X { get { return (float)this.GetValue(Rotate_XProperty); } set { this.SetValue(Rotate_XProperty, value); } } public static readonly DependencyProperty Rotate_XProperty = DependencyProperty.Register("Rotate_X", typeof(float), typeof(FuBiao), new PropertyMetadata(default(float), new PropertyChangedCallback(OnPropertyChanged))); public float Rotate_Y { get { return (float)this.GetValue(Rotate_YProperty); } set { this.SetValue(Rotate_YProperty, value); } } public static readonly DependencyProperty Rotate_YProperty = DependencyProperty.Register("Rotate_Y", typeof(float), typeof(FuBiao), new PropertyMetadata(default(float), new PropertyChangedCallback(OnPropertyChanged))); public float Rotate_Z { get { return (float)this.GetValue(Rotate_ZProperty); } set { this.SetValue(Rotate_ZProperty, value); } } public static readonly DependencyProperty Rotate_ZProperty = DependencyProperty.Register("Rotate_Z", typeof(float), typeof(FuBiao), new PropertyMetadata(default(float), new PropertyChangedCallback(OnPropertyChanged))); //字体颜色 public Brush Text_Color { get { return (Brush)GetValue(Text_ColorProperty); } set { SetValue(Text_ColorProperty, value); } } // Using a DependencyProperty as the backing store for _color. This enables animation, styling, binding, etc... public static readonly DependencyProperty Text_ColorProperty = DependencyProperty.Register("Text_Color", typeof(Brush), typeof(FuBiao), new PropertyMetadata(default(Brush), new PropertyChangedCallback(OnPropertyChanged))); //字体大小 public int Font_Size { get { return (int)GetValue(Font_SizeProperty); } set { SetValue(Font_SizeProperty, value); } } public static readonly DependencyProperty Font_SizeProperty = DependencyProperty.Register("Font_Size", typeof(int), typeof(FuBiao), new PropertyMetadata(default(int), new PropertyChangedCallback(OnPropertyChanged))); public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as FuBiao).Refresh(); } public FuBiao() { InitializeComponent(); } private void Refresh() { //this.an.Text = Rotate_X.ToString(); this.rotateX.Angle = Rotate_X; this.rotateY.Angle = Rotate_Y; this.rotateZ.Angle = Rotate_Z; this.TextX.Text = "X轴" + Rotate_X.ToString() + "°"; this.TextY.Text = "Y轴" + Rotate_Y.ToString() + "°"; this.TextZ.Text = "Z轴" + Rotate_Z.ToString() + "°"; this.TextX.Foreground = Text_Color; this.TextY.Foreground = Text_Color; this.TextZ.Foreground = Text_Color; this.TextX.FontSize = Font_Size; this.TextY.FontSize = Font_Size; this.TextZ.FontSize = Font_Size; this.narrow_enlarge.ScaleX = Narrow_Enlarge; this.narrow_enlarge.ScaleY = Narrow_Enlarge; this.narrow_enlarge.ScaleZ = Narrow_Enlarge; } //缩小 private void Narrow_Click(object sender, RoutedEventArgs e) { if (Narrow_Enlarge > 1 ) { Narrow_Enlarge -= 0.1f; Refresh(); } } //放大 private void Enlarge_Click(object sender, RoutedEventArgs e) { if (Narrow_Enlarge < 2) { Narrow_Enlarge += 0.1f; Refresh(); } } } }