86 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						||
using System.Collections.Generic;
 | 
						||
using System.ComponentModel;
 | 
						||
using System.Linq;
 | 
						||
using System.Runtime.CompilerServices;
 | 
						||
using System.Text;
 | 
						||
using System.Threading.Tasks;
 | 
						||
 | 
						||
namespace Deedy.Activity
 | 
						||
{
 | 
						||
    public class DeedyLayout : IDeedyLayout
 | 
						||
    {
 | 
						||
        public string DEClass { get; protected internal set; } = "";
 | 
						||
        public string DETitle { get; set; } = "";
 | 
						||
        public string DERemark { get; set; } = "";
 | 
						||
        public string DEIdentify { get; set; } = "";
 | 
						||
        public IDeedyElement? DeedyParent { get; protected internal set; }
 | 
						||
        public DeedyElementCollection Children { get; set; } = new();
 | 
						||
 | 
						||
        public IDeedyElement DeedyRoot => (this.DeedyParent == null) ? this : this.DeedyParent.DeedyRoot;
 | 
						||
 | 
						||
        public DeedyElementCollection Elements { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
 | 
						||
 | 
						||
        public event PropertyChangedEventHandler? PropertyChanged;
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 发送属性变更通知
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="propertyName">发生变更的属性</param>
 | 
						||
        protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
 | 
						||
        /// <summary>
 | 
						||
        /// 读取一个字段的值
 | 
						||
        /// </summary>
 | 
						||
        /// <typeparam name="T">值的类型,可以通过参数进行自动判定</typeparam>
 | 
						||
        /// <param name="field">字段的引用【注意:此参数通过引用传递】</param>
 | 
						||
        /// <param name="propertyName">属性名称;如果在属性的读取访问器中调用可以自动注入</param>
 | 
						||
        /// <returns>字段中的值</returns>
 | 
						||
        protected virtual T GetField<T>(ref T field, [CallerMemberName] string? propertyName = null)
 | 
						||
        {
 | 
						||
            //TODO:这里处理内部属性获取逻辑(包括运行时参数映射逻辑)
 | 
						||
            return field;
 | 
						||
        }
 | 
						||
        /// <summary>
 | 
						||
        /// 检查新值是否与原值相等,如果不相等便赋值并发出通知
 | 
						||
        /// </summary>
 | 
						||
        /// <typeparam name="T">值的类型,可以通过参数进行自动判定</typeparam>
 | 
						||
        /// <param name="field">字段的引用【注意:此参数通过引用传递】</param>
 | 
						||
        /// <param name="value">字段的新值</param>
 | 
						||
        /// <param name="propertyName">要进行变更通知的属性名称;如果在属性的设置访问器中调用可以自动注入</param>
 | 
						||
        /// <returns>值是否有变更</returns>
 | 
						||
        protected virtual bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
 | 
						||
        {
 | 
						||
            if (EqualityComparer<T>.Default.Equals(field, value)) return false;
 | 
						||
            //TODO:这里处理内部属性变更逻辑(包括运行时参数映射逻辑)
 | 
						||
            field = value;
 | 
						||
            OnPropertyChanged(propertyName);
 | 
						||
            return true;
 | 
						||
        }
 | 
						||
 | 
						||
        public void Append(IDeedyElement deedyElement)
 | 
						||
        {
 | 
						||
            throw new NotImplementedException();
 | 
						||
        }
 | 
						||
 | 
						||
        public void Remove(IDeedyElement deedyElement)
 | 
						||
        {
 | 
						||
            throw new NotImplementedException();
 | 
						||
        }
 | 
						||
 | 
						||
        public void InsertInFront(IDeedyElement deedyElement)
 | 
						||
        {
 | 
						||
            throw new NotImplementedException();
 | 
						||
        }
 | 
						||
 | 
						||
        public void InsertAtRear(IDeedyElement deedyElement)
 | 
						||
        {
 | 
						||
            throw new NotImplementedException();
 | 
						||
        }
 | 
						||
 | 
						||
        public void SwapIndex(IDeedyElement element1, IDeedyElement element2)
 | 
						||
        {
 | 
						||
            throw new NotImplementedException();
 | 
						||
        }
 | 
						||
    }
 | 
						||
}
 |