问题描述
我有一个名为 B = [' _ ','|_\\','|_/']
n = len(B)
for i in range(n):
print(B[i])
的 CustomActivity,并且有一个快捷方式(即 CTRL+D),我希望能够将选定的活动移动到 CommentOutActivity
中。>
我已经实现了快捷方式部分来触发该方法。但是,我无法以编程方式移动活动。这是我想要做的图像: 这是我的代码尝试:
CommentOutActivity
代码没有给出任何错误。事实上,当我再次使用 var selectedActivities = _workflowDesigner
.Context.Items.GetValue<Selection>()
.Selectedobjects
.Select(c => c.GetCurrentValue() as System.Activities.Activity)
.ToList()
;
if (selectedActivities.Any())
{
//Get the Parent
var firstSelectedActivity = selectedActivities.First();
//Parent property is internal so I had to invoke it like this
PropertyInfo propParent = firstSelectedActivity.GetType().GetProperty("Parent",BindingFlags.NonPublic | BindingFlags.Instance);
var parentActivity = propParent?.GetValue(firstSelectedActivity);
if (parentActivity != null)
{
//My custom Activity
var commentOutActivity = new CommentOut();
//First add the selected activities into CommentOut
foreach (var selectedItem in selectedActivities)
{
typeof(System.Activities.Activity)
.getmethod("AddChild",BindingFlags.NonPublic | BindingFlags.Instance)
?.Invoke(commentOutActivity,new object[] { selectedItem });
}
//Get Parent's children so we can remove them from there
PropertyInfo propChildren = parentActivity.GetType().GetProperty("Children",BindingFlags.NonPublic | BindingFlags.Instance);
var children = propChildren?.GetValue(parentActivity) as IList<System.Activities.Activity>;
if (children != null)
{
//Removing the from where they were before
foreach (var selectedItem in selectedActivities)
{
children.Remove(selectedItem);
}
children.Add(commentOutActivity);
}
//An attempt to update the view but does NOT work
_workflowDesigner.View.UpdateLayout();
}
}
调用它时,我看到了调试对象中的更改,但不在视图中。
我需要两件主要的事情:
- 将所选项目移动到我的
CTRL+D
-
放置我的
CommentOutActivity
FirsT Selected Activity 所在的位置。例如,在图片中,注释就在CommentOutActivity
Activity 下
此外,如果您必须在此处查看 WriteLine
源代码:
CommentOutActivity
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)