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.Controls.Primitives; namespace Venus_Themes.CustomControls { public class CommonValveControl : Button { public CommonValveControl() { //this.MouseDoubleClick += CommonValveControl_MouseDoubleClick; } static CommonValveControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CommonValveControl), new FrameworkPropertyMetadata(typeof(CommonValveControl))); } //private void CommonValveControl_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) //{ // Status = !Status; //} public override void OnApplyTemplate() { var devBtn = GetTemplateChild("mainBody") as Grid; devBtn.MouseLeftButtonDown += DevBtn_Click; base.OnApplyTemplate(); } private void DevBtn_Click(object sender, RoutedEventArgs e) { //if (IsCanEdit == true) //{ // Status = !Status; //} } public bool Status { get => (bool)GetValue(StatusProperty); set => SetValue(StatusProperty, value); } public static readonly DependencyProperty StatusProperty = DependencyProperty.Register( "Status", typeof(bool), typeof(CommonValveControl)); public Orientation ValveOrientation { get => (Orientation)GetValue(CommonValveOrientationProperty); set => SetValue(CommonValveOrientationProperty, value); } public static readonly DependencyProperty CommonValveOrientationProperty = DependencyProperty.Register( "ValveOrientation", typeof(Orientation), typeof(CommonValveControl)); public static readonly DependencyProperty IsCanEditProperty = DependencyProperty.Register("IsCanEdit" , typeof(bool), typeof(CommonValveControl)); /// /// 是否可以编辑 /// public bool IsCanEdit { get { return (bool)GetValue(IsCanEditProperty); } set { SetValue(IsCanEditProperty, value); } } } }