12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using NEIntelligentControl2.Models.BoostStation;
- 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 NEIntelligentControl2.Views.BoostStation
- {
- /// <summary>
- /// 升压站断路器
- /// </summary>
- public partial class Breaker : UserControl, IBoostStationPoint
- {
- public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(Breaker));
- public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(double), typeof(Breaker));
- public bool IsSelected { get => (bool)GetValue(IsSelectedProperty); set => SetValue(IsSelectedProperty, value); }
- public double Value
- {
- get => (double)GetValue(ValueProperty);
- set
- {
- double d = value;
- if (IsNegate)
- {
- d = d == 0 ? 1 : 0;
- }
- SetValue(ValueProperty, d);
- }
- }
- public bool IsTemplete { get; set; }
- public Action<Control> Clicked { get; set; }
- public bool IsEditModel { get; set; }
- public string DataTag { get; set; }
- public int Proportion { get; set; }
- public string Info { get; set; }
- public bool IsNegate { get; set; }
- /// <summary>
- /// 原始宽
- /// </summary>
- private double _Width;
- /// <summary>
- /// 原始高
- /// </summary>
- private double _Height;
- public Breaker()
- {
- Value = -1;
- InitializeComponent();
- _Width = Width;
- _Height = Height;
- }
- private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- IsSelected = !IsSelected && !IsTemplete && IsEditModel;
- Clicked?.Invoke(this);
- }
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
- {
- ToZoom();
- }
- private void ToZoom()
- {
- this.Width = _Width * (1 + Proportion * 0.1);
- this.Height = _Height * (1 + Proportion * 0.1);
- }
- public void Zoom(int times)
- {
- Proportion += times;
- ToZoom();
- }
- }
- }
|