定义选中前、选中及请求打开独立设计器的事件

This commit is contained in:
zengwenjie
2025-09-18 16:45:44 +08:00
parent c85bb43830
commit dd4cf22db8
7 changed files with 142 additions and 11 deletions

View File

@@ -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
}
}