Exemplo n.º 1
0
        /// <summary>
        /// 粘贴行为树
        /// </summary>
        private void PasteAgent()
        {
            try
            {
                AgentListContent content = XmlUtility.StringToObject <AgentListContent>(Clipboard.GetText());

                for (int i = 0; i < content.DataList.Count; i++)
                {
                    AgentDesigner agent   = content.DataList[i];
                    string        agentID = "NewAgent_" + DateTime.Now.Ticks;
                    do
                    {
                        agentID = "NewAgent_" + DateTime.Now.Ticks;
                    } while (TreeData.ExistAgent(agentID));

                    agent.AgentID = agentID;
                    TreeViewManager.AddAgent(agent);
                }

                ShowInfo("您粘贴了" + content.DataList.Count + "棵行为树!!!");
            }
            catch (Exception ex)
            {
                ShowInfo("无法进行粘贴,错误信息:" + ex.Message);
                ShowMessage("无法进行粘贴,错误信息:" + ex.Message, "警告");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 复制Agent
        /// </summary>
        private void CopyAgent()
        {
            if (treeView1.SelectedNode != null)
            {
                if (!(treeView1.SelectedNode.Tag is AgentItem))
                {
                    ShowMessage("只能复制Agent");
                    return;
                }

                AgentListContent content = new AgentListContent();
                content.DataList.Add((treeView1.SelectedNode.Tag as AgentItem).Agent);

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

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