20240301_JSEQ_upperpc/JiangsuEarthquakeJM/Models/JunctionBox.xaml.cs

125 lines
4.3 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
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
{
/// <summary>
/// JunctionBox.xaml 的交互逻辑
/// </summary>
public partial class JunctionBox : 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(JunctionBox), 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(JunctionBox), 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(JunctionBox), 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(JunctionBox), 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(JunctionBox), new PropertyMetadata(default(int), new PropertyChangedCallback(OnPropertyChanged)));
public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as JunctionBox).Refresh();
}
public JunctionBox()
{
InitializeComponent();
}
private void Enlarge_Click(object sender, RoutedEventArgs e)
{
if (Narrow_Enlarge < 2.5)
{
Narrow_Enlarge += 0.1f;
Refresh();
}
}
private void Narrow_Click(object sender, RoutedEventArgs e)
{
if (Narrow_Enlarge > 1.5)
{
Narrow_Enlarge -= 0.1f;
Refresh();
}
}
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;
}
}
}