定义选中前、选中及请求打开独立设计器的事件
This commit is contained in:
		@@ -310,13 +310,16 @@ namespace Deedy.Activity
 | 
			
		||||
        {
 | 
			
		||||
            if ((bool)e.NewValue)
 | 
			
		||||
            {
 | 
			
		||||
                //TODO:发送节点选中事件
 | 
			
		||||
                RoutedEventArgs args = new RoutedEventArgs(SelectedEvent, this.ActionElement);
 | 
			
		||||
                this.RaiseEvent_Selected(args);
 | 
			
		||||
 | 
			
		||||
                if (this.ActionElement is IContainerForFunction container)
 | 
			
		||||
                {
 | 
			
		||||
                    if (container.IsEmbedded) this.IsExpanded = true;
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        //TODO:发送打开辅助编辑器事件
 | 
			
		||||
                        RequestOpenDesignerEventArgs reqArgs = new RequestOpenDesignerEventArgs(RequestOpenDesignerEvent, this.ActionElement);
 | 
			
		||||
                        this.RaiseEvent_RequestOpenDesigner(reqArgs);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -582,9 +585,10 @@ namespace Deedy.Activity
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (newValue.IsLockedElement)
 | 
			
		||||
                if (newValue.IsLocked)
 | 
			
		||||
                {
 | 
			
		||||
                    this.IsDraggable = false;
 | 
			
		||||
                    // 功能容器类型的锁定元素允许被选中
 | 
			
		||||
                    this.IsSelectable = newValue is IContainerForFunction;
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
@@ -726,10 +730,14 @@ namespace Deedy.Activity
 | 
			
		||||
            return result;
 | 
			
		||||
        }
 | 
			
		||||
        protected virtual void RemoveDragAdorner()
 | 
			
		||||
        { }
 | 
			
		||||
        {
 | 
			
		||||
            //TODO:移除拖拽装饰器
 | 
			
		||||
        }
 | 
			
		||||
        protected virtual void UpdateDragAdorner(Dock? dock)
 | 
			
		||||
        { }
 | 
			
		||||
        #region 交互事件
 | 
			
		||||
        {
 | 
			
		||||
            //TODO:更新拖拽装饰器
 | 
			
		||||
        }
 | 
			
		||||
        #region 订阅的交互事件
 | 
			
		||||
        protected override void OnDragEnter(DragEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            this.IsDragging = true;
 | 
			
		||||
@@ -821,7 +829,12 @@ namespace Deedy.Activity
 | 
			
		||||
 | 
			
		||||
            if (e.LeftButton == MouseButtonState.Pressed)
 | 
			
		||||
            {
 | 
			
		||||
                this.IsSelected = this.IsSelectable;
 | 
			
		||||
                if (this.IsSelectable)
 | 
			
		||||
                {
 | 
			
		||||
                    CancelRoutedEventArgs args = new CancelRoutedEventArgs(PreviewSelectedEvent, this.ActionElement);
 | 
			
		||||
                    this.RaiseEvent_PreviewSelected(args);
 | 
			
		||||
                    this.IsSelected = !args.Cancel;
 | 
			
		||||
                }
 | 
			
		||||
                if (this.IsDraggable) this._DragStartPoint = e.GetPosition(this);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -839,7 +852,7 @@ namespace Deedy.Activity
 | 
			
		||||
            this.RefreshViewerState(isEventNeedHandle);
 | 
			
		||||
            if (isEventNeedHandle)
 | 
			
		||||
            {
 | 
			
		||||
                if (this.ActionElement == null || this.ActionElement.IsLockedElement) return;
 | 
			
		||||
                if (this.ActionElement == null || this.ActionElement.IsLocked) return;
 | 
			
		||||
 | 
			
		||||
                var position = e.GetPosition(this);
 | 
			
		||||
                ToolTipService.SetPlacement(this, PlacementMode.Relative);
 | 
			
		||||
@@ -885,5 +898,83 @@ namespace Deedy.Activity
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region 声明的交互事件
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 节点被选中
 | 
			
		||||
        /// </summary>
 | 
			
		||||
		/// <remarks>
 | 
			
		||||
        /// 节点被选中:当视图节点被选中时发生
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public static readonly RoutedEvent SelectedEvent = EventManager.RegisterRoutedEvent("Selected", RoutingStrategy.Bubble,
 | 
			
		||||
            typeof(EventHandler<RoutedEventArgs>), typeof(ActionViewer));
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「节点被选中」封装
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public event EventHandler<RoutedEventArgs> Selected
 | 
			
		||||
        {
 | 
			
		||||
            add { AddHandler(SelectedEvent, value); }
 | 
			
		||||
            remove { RemoveHandler(SelectedEvent, value); }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「节点被选中」触发
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="args">事件参数</param>
 | 
			
		||||
        protected virtual void RaiseEvent_Selected(RoutedEventArgs args)
 | 
			
		||||
        {
 | 
			
		||||
            // 事件触发前可以进行一定的处理逻辑
 | 
			
		||||
            RaiseEvent(args);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 节点将要被选中
 | 
			
		||||
        /// </summary>
 | 
			
		||||
		/// <remarks>
 | 
			
		||||
        /// 当节点要被选中前发生,此事件可以被取消
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public static readonly RoutedEvent PreviewSelectedEvent = EventManager.RegisterRoutedEvent("Selected", RoutingStrategy.Tunnel,
 | 
			
		||||
            typeof(EventHandler<CancelRoutedEventArgs>), typeof(ActionViewer));
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「节点将要被选中」封装
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public event EventHandler<CancelRoutedEventArgs> PreviewSelected
 | 
			
		||||
        {
 | 
			
		||||
            add { AddHandler(SelectedEvent, value); }
 | 
			
		||||
            remove { RemoveHandler(SelectedEvent, value); }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「节点将要被选中」触发
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="args">事件参数</param>
 | 
			
		||||
        protected virtual void RaiseEvent_PreviewSelected(CancelRoutedEventArgs args)
 | 
			
		||||
        {
 | 
			
		||||
            // 事件触发前可以进行一定的处理逻辑
 | 
			
		||||
            RaiseEvent(args);
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 请求打开独立的设计器
 | 
			
		||||
        /// </summary>
 | 
			
		||||
		/// <remarks>
 | 
			
		||||
        /// 当一个逻辑容器节点被选中,且要求系统打开独立设计器时发送此事件
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public static readonly RoutedEvent RequestOpenDesignerEvent = EventManager.RegisterRoutedEvent("RequestOpenDesigner", RoutingStrategy.Bubble,
 | 
			
		||||
            typeof(EventHandler<RequestOpenDesignerEventArgs>), typeof(ActionViewer));
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「请求打开独立的设计器」封装
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public event EventHandler<RequestOpenDesignerEventArgs> RequestOpenDesigner
 | 
			
		||||
        {
 | 
			
		||||
            add { AddHandler(RequestOpenDesignerEvent, value); }
 | 
			
		||||
            remove { RemoveHandler(RequestOpenDesignerEvent, value); }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 事件「请求打开独立的设计器」触发
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="args">事件参数</param>
 | 
			
		||||
        protected virtual void RaiseEvent_RequestOpenDesigner(RequestOpenDesignerEventArgs args)
 | 
			
		||||
        {
 | 
			
		||||
            // 事件触发前可以进行一定的处理逻辑
 | 
			
		||||
            RaiseEvent(args);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ namespace Deedy.Activity
 | 
			
		||||
        public string Remark { get; set; } = "";
 | 
			
		||||
        public string Identify { get; set; } = "";
 | 
			
		||||
        public int DepthLevel { get; protected internal set; } = 0;
 | 
			
		||||
        public bool IsLockedElement { get; set; } = false;
 | 
			
		||||
        public bool IsLocked { get; set; } = false;
 | 
			
		||||
        protected internal LogInfo _InstantInfo = LogInfo.Empty;
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 即时消息
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
using System.Windows;
 | 
			
		||||
 | 
			
		||||
namespace Deedy.Activity
 | 
			
		||||
{
 | 
			
		||||
    public class CancelRoutedEventArgs : RoutedEventArgs
 | 
			
		||||
    {
 | 
			
		||||
        public CancelRoutedEventArgs() : base() { }
 | 
			
		||||
        public CancelRoutedEventArgs(RoutedEvent routedEvent) : base(routedEvent) { }
 | 
			
		||||
        public CancelRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { }
 | 
			
		||||
 | 
			
		||||
        public bool Cancel { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Diagnostics.CodeAnalysis;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using System.Windows;
 | 
			
		||||
 | 
			
		||||
namespace Deedy.Activity
 | 
			
		||||
{
 | 
			
		||||
    public class RequestOpenDesignerEventArgs : RoutedEventArgs
 | 
			
		||||
    {
 | 
			
		||||
        public RequestOpenDesignerEventArgs() : base() { }
 | 
			
		||||
        public RequestOpenDesignerEventArgs(RoutedEvent routedEvent) : base(routedEvent) { }
 | 
			
		||||
        public RequestOpenDesignerEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { }
 | 
			
		||||
        [AllowNull]
 | 
			
		||||
        public Type DesignerType { get; set; }
 | 
			
		||||
        [AllowNull]
 | 
			
		||||
        public object DesignerInstance { get; set; }
 | 
			
		||||
        public bool IsNeedPopup { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,7 +9,7 @@ namespace Deedy.Activity
 | 
			
		||||
    public interface IActionElement : IElement
 | 
			
		||||
    {
 | 
			
		||||
        public IActionViewer? ActionViewer { get; }
 | 
			
		||||
        public bool IsLockedElement { get; set; }
 | 
			
		||||
        public bool IsLocked { get; set; }
 | 
			
		||||
        public LogInfo InstantInfo { get; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 | 
			
		||||
        xmlns:local="clr-namespace:Deedy.Testing"
 | 
			
		||||
        mc:Ignorable="d"
 | 
			
		||||
        Title="MainWindow" Height="450" Width="800">
 | 
			
		||||
        Title="MainWindow" Height="450" Width="800" Closing="Window_Closing">
 | 
			
		||||
    <Grid>
 | 
			
		||||
 | 
			
		||||
    </Grid>
 | 
			
		||||
 
 | 
			
		||||
@@ -20,5 +20,10 @@ namespace Deedy.Testing
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user