using ivf_tl_Entity.Entity.Mark; using ivf_tl_Entity.Enums; 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 ivf_tl_Manage.UserControls { /// /// MarkTreeUserControl.xaml 的交互逻辑 /// public partial class MarkTreeUserControl : UserControl { public event Func MarkOperEvent; public MarkTreeUserControl() { InitializeComponent(); } public MarkEntity MarkSource { get { return (MarkEntity)GetValue(MarkSourceProperty); } set { SetValue(MarkSourceProperty, value); } } // Using a DependencyProperty as the backing store for MarkSource. This enables animation, styling, binding, etc... public static readonly DependencyProperty MarkSourceProperty = DependencyProperty.Register("MarkSource", typeof(MarkEntity), typeof(MarkTreeUserControl), new PropertyMetadata(null)); private static void MarkSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (!(d is MarkTreeUserControl source)) return; if (!(e.NewValue is MarkEntity newValue)) return; //source.items.MarkSource = newValue; } public Brush BackgroundSource { get { return (Brush)GetValue(BackgroundSourceProperty); } set { SetValue(BackgroundSourceProperty, value); } } // Using a DependencyProperty as the backing store for BackgroundSource. This enables animation, styling, binding, etc... public static readonly DependencyProperty BackgroundSourceProperty = DependencyProperty.Register("BackgroundSource", typeof(Brush), typeof(MarkTreeUserControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent))); public Brush RectangleFill { get { return (Brush)GetValue(RectangleFillProperty); } set { SetValue(RectangleFillProperty, value); } } // Using a DependencyProperty as the backing store for RectangleFill. This enables animation, styling, binding, etc... public static readonly DependencyProperty RectangleFillProperty = DependencyProperty.Register("RectangleFill", typeof(Brush), typeof(MarkTreeUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA")))); /// /// 展开关闭事件 /// /// private void Item_ExpandedEvent(MarkEntity obj) { if (obj.IsExpanded) { foreach (var item in obj.children) { if (item.IsExpanded) item.IsExpanded = false; if (item.ParentMark == null) item.ParentMark = obj; } list.DetailItemSouce = obj.children; } else { list.DetailItemSouce = null; } } private bool MarkTreeItemUserControl_MarkOperEvent(MarkEntity arg1, string arg2) { var aa = MarkOperEvent?.Invoke(arg1, arg2) == true; if (aa == true && arg2 == "del") { if (arg1.ParentMark == MarkSource && !MarkSource.children.Any()) { this.test1.ex(); } } return aa; } } }