Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
52025150
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
52025150
编写于
2月 03, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加复制子树功能
上级
29e84004
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
85 addition
and
23 deletion
+85
-23
CSharp/App/Modules/BehaviorTreeModule/AllTreeView.xaml
CSharp/App/Modules/BehaviorTreeModule/AllTreeView.xaml
+3
-3
CSharp/App/Modules/BehaviorTreeModule/TreeNodeViewModel.cs
CSharp/App/Modules/BehaviorTreeModule/TreeNodeViewModel.cs
+0
-11
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml
+2
-0
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml.cs
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml.cs
+28
-8
CSharp/App/Modules/BehaviorTreeModule/TreeViewModel.cs
CSharp/App/Modules/BehaviorTreeModule/TreeViewModel.cs
+52
-1
未找到文件。
CSharp/App/Modules/BehaviorTreeModule/AllTreeView.xaml
浏览文件 @
52025150
...
...
@@ -19,8 +19,8 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<GroupBox Grid.Row="0" Grid.Column="0" Header="行为树列表:">
<ListBox Name="lbTreeRoots" ItemsSource="{Binding RootList}"
VerticalAlignment="Stretch"
>
<GroupBox Grid.Row="0" Grid.Column="0" Header="行为树列表:"
Margin="0,0,0,289" Grid.RowSpan="2"
>
<ListBox Name="lbTreeRoots" ItemsSource="{Binding RootList}" >
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="打开" Click="MenuItem_Open" />
...
...
@@ -41,7 +41,7 @@
</ListBox.ItemTemplate>
</ListBox>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="0" Header="节点编辑:">
<GroupBox Grid.Row="1" Grid.Column="0" Header="节点编辑:"
Margin="0,116,0,0"
>
<Tree:NodeDataEditor x:Name="nodeDataEditor" VerticalAlignment="Top" />
</GroupBox>
<GridSplitter Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Width="3" ShowsPreview="False" VerticalAlignment="Stretch"
...
...
CSharp/App/Modules/BehaviorTreeModule/TreeNodeViewModel.cs
浏览文件 @
52025150
...
...
@@ -62,17 +62,6 @@ namespace Modules.BehaviorTreeModule
}
}
public
TreeNodeViewModel
(
TreeViewModel
treeViewModel
,
TreeNodeViewModel
parent
,
TreeNodeViewModel
treeNodeViewModel
)
{
this
.
TreeViewModel
=
treeViewModel
;
this
.
data
=
new
TreeNodeData
();
this
.
data
.
Id
=
++
treeViewModel
.
AllTreeViewModel
.
MaxNodeId
;
this
.
data
.
TreeId
=
treeViewModel
.
TreeId
;
this
.
Parent
=
parent
;
this
.
ConnectorX2
=
treeNodeViewModel
.
ConnectorX2
;
this
.
connectorY2
=
treeNodeViewModel
.
ConnectorY2
;
}
public
TreeNodeData
Data
{
get
...
...
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml
浏览文件 @
52025150
...
...
@@ -44,6 +44,8 @@
<ContextMenu>
<MenuItem Header="新建" Click="MenuItem_New" />
<MenuItem Header="删除" Click="MenuItem_Remove" />
<MenuItem Header="复制" Click="MenuItem_Copy" />
<MenuItem Header="粘贴" Click="MenuItem_Paste" />
<MenuItem Header="左移" Click="MenuItem_MoveLeft" />
<MenuItem Header="右移" Click="MenuItem_MoveRight" />
<MenuItem Header="折叠/展开" Click="MenuItem_Fold" />
...
...
CSharp/App/Modules/BehaviorTreeModule/TreeView.xaml.cs
浏览文件 @
52025150
...
...
@@ -119,8 +119,8 @@ namespace Modules.BehaviorTreeModule
private
void
ListBoxItem_PreviewMouseLeftButtonDown
(
object
sender
,
MouseEventArgs
e
)
{
this
.
origMouseDownPoint
=
e
.
GetPosition
(
this
);
var
item
=
(
FrameworkElement
)
sender
;
var
treeNodeViewModel
=
item
.
DataContext
as
TreeNodeViewModel
;
FrameworkElement
item
=
(
FrameworkElement
)
sender
;
TreeNodeViewModel
treeNodeViewModel
=
item
.
DataContext
as
TreeNodeViewModel
;
this
.
listBox
.
SelectedItem
=
treeNodeViewModel
;
this
.
moveFromNode
=
treeNodeViewModel
;
...
...
@@ -138,8 +138,8 @@ namespace Modules.BehaviorTreeModule
{
return
;
}
var
item
=
(
FrameworkElement
)
sender
;
var
moveToNode
=
item
.
DataContext
as
TreeNodeViewModel
;
FrameworkElement
item
=
(
FrameworkElement
)
sender
;
TreeNodeViewModel
moveToNode
=
item
.
DataContext
as
TreeNodeViewModel
;
Log
.
Debug
(
"move to node: {0} {1}"
,
this
.
moveFromNode
.
Id
,
moveToNode
.
Id
);
if
(
this
.
moveFromNode
.
Id
==
moveToNode
.
Id
)
{
...
...
@@ -189,7 +189,7 @@ namespace Modules.BehaviorTreeModule
{
return
;
}
var
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
if
(
treeNodeViewModel
.
IsRoot
)
{
return
;
...
...
@@ -205,7 +205,7 @@ namespace Modules.BehaviorTreeModule
{
return
;
}
var
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
if
(
treeNodeViewModel
.
IsFold
)
{
...
...
@@ -223,7 +223,7 @@ namespace Modules.BehaviorTreeModule
{
return
;
}
var
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
this
.
ViewModel
.
MoveLeft
(
treeNodeViewModel
);
}
...
...
@@ -233,8 +233,28 @@ namespace Modules.BehaviorTreeModule
{
return
;
}
var
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
this
.
ViewModel
.
MoveRight
(
treeNodeViewModel
);
}
private
void
MenuItem_Copy
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
this
.
listBox
.
SelectedItem
==
null
)
{
return
;
}
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
this
.
ViewModel
.
Copy
(
treeNodeViewModel
);
}
private
void
MenuItem_Paste
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
this
.
listBox
.
SelectedItem
==
null
)
{
return
;
}
TreeNodeViewModel
treeNodeViewModel
=
this
.
listBox
.
SelectedItem
as
TreeNodeViewModel
;
this
.
ViewModel
.
Paste
(
treeNodeViewModel
);
}
}
}
\ No newline at end of file
CSharp/App/Modules/BehaviorTreeModule/TreeViewModel.cs
浏览文件 @
52025150
...
...
@@ -25,6 +25,8 @@ namespace Modules.BehaviorTreeModule
public
int
TreeId
{
get
;
private
set
;
}
public
int
copyId
;
public
TreeViewModel
(
AllTreeViewModel
allTreeViewModel
)
{
this
.
AllTreeViewModel
=
allTreeViewModel
;
...
...
@@ -62,7 +64,7 @@ namespace Modules.BehaviorTreeModule
return
treeNodeDatas
;
}
public
AllTreeViewModel
AllTreeViewModel
{
get
;
set
;
}
public
AllTreeViewModel
AllTreeViewModel
{
get
;
private
set
;
}
public
TreeNodeViewModel
Root
{
...
...
@@ -92,6 +94,7 @@ namespace Modules.BehaviorTreeModule
if
(
parent
!=
null
)
{
treeNode
.
Parent
=
parent
;
parent
.
Children
.
Add
(
treeNode
.
Id
);
}
...
...
@@ -266,6 +269,54 @@ namespace Modules.BehaviorTreeModule
treeLayout
.
ExcuteLayout
();
}
public
void
Copy
(
TreeNodeViewModel
copyTreeNodeViewModel
)
{
copyId
=
copyTreeNodeViewModel
.
Id
;
}
public
void
Paste
(
TreeNodeViewModel
pasteTreeNodeViewModel
)
{
if
(
copyId
==
0
)
{
return
;
}
TreeNodeViewModel
copyTreeNodeViewModel
=
treeNodeDict
[
copyId
];
// copy节点不能是paste节点的父级节点
TreeNodeViewModel
tmpNode
=
pasteTreeNodeViewModel
;
while
(
tmpNode
!=
null
)
{
if
(
tmpNode
.
IsRoot
)
{
break
;
}
if
(
tmpNode
.
Id
==
copyTreeNodeViewModel
.
Id
)
{
return
;
}
tmpNode
=
tmpNode
.
Parent
;
}
copyId
=
0
;
CopyTree
(
copyTreeNodeViewModel
,
pasteTreeNodeViewModel
);
}
private
void
CopyTree
(
TreeNodeViewModel
copyTreeNodeViewModel
,
TreeNodeViewModel
parent
)
{
TreeNodeData
newTreeNodeData
=
(
TreeNodeData
)
copyTreeNodeViewModel
.
Data
.
Clone
();
newTreeNodeData
.
Id
=
++
this
.
AllTreeViewModel
.
MaxNodeId
;
newTreeNodeData
.
TreeId
=
this
.
TreeId
;
newTreeNodeData
.
Children
.
Clear
();
TreeNodeViewModel
newTreeNodeViewModel
=
new
TreeNodeViewModel
(
this
,
newTreeNodeData
);
this
.
Add
(
newTreeNodeViewModel
,
parent
);
foreach
(
int
childId
in
copyTreeNodeViewModel
.
Children
)
{
TreeNodeViewModel
child
=
this
.
Get
(
childId
);
this
.
CopyTree
(
child
,
newTreeNodeViewModel
);
}
}
public
object
Clone
()
{
int
treeId
=
++
AllTreeViewModel
.
MaxTreeId
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录