| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;namespace Venus_Themes.CustomControls{    public class CommonValveControl : Control    {        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)        {            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));    }}
 |