コード例 #1
0
        /// <summary>
        /// 粘贴行为树
        /// </summary>
        private void PasteBehaviorTree()
        {
            try
            {
                BehaviorTreeListContent content = XmlUtility.StringToObject <BehaviorTreeListContent>(Clipboard.GetText());

                for (int i = 0; i < content.DataList.Count; i++)
                {
                    BehaviorTreeDesigner behaviorTree = content.DataList[i];
                    string behaviorTreeID             = "New_" + DateTime.Now.Ticks;
                    do
                    {
                        behaviorTreeID = "New_" + DateTime.Now.Ticks;
                    } while (BehaviorTreeData.ExistBehaviorTree(behaviorTreeID));

                    behaviorTree.ID = behaviorTreeID;
                    TreeViewManager.AddBehaviorTree(behaviorTree);
                }

                ShowInfo("您粘贴了" + content.DataList.Count + "个行为树!!!");
            }
            catch (Exception ex)
            {
                ShowInfo("无法进行粘贴,错误信息:" + ex.Message);
                ShowMessage("无法进行粘贴,错误信息:" + ex.Message, "警告");
            }
        }
コード例 #2
0
        /// <summary>
        /// 复制行为树
        /// </summary>
        private void CopyBehaviorTree()
        {
            if (treeView1.SelectedNode != null)
            {
                if (!(treeView1.SelectedNode.Tag is BehaviorTreeItem))
                {
                    ShowMessage("只能复制行为树");
                    return;
                }

                BehaviorTreeListContent content = new BehaviorTreeListContent();
                content.DataList.Add((treeView1.SelectedNode.Tag as BehaviorTreeItem).BehaviorTree);

                if (content.DataList.Count > 0)
                {
                    Clipboard.SetText(XmlUtility.ObjectToString(content));
                }

                MainForm.Instance.ShowInfo("您复制了" + content.DataList.Count.ToString() + "个行为树!!!");
            }
            else
            {
                MainForm.Instance.ShowInfo("您必须选择一个进行复制!!!");
                MainForm.Instance.ShowMessage("您必须选择一个进行复制!!!", "警告");
            }
        }