Esempio n. 1
0
        //加载工作区
        public void LoadWorkSpace()
        {
            //读取行为树类信息
            NodeClasses = XmlUtility.Read <NodeClasses>(GetNodeClassPath());
            if (NodeClasses == null)
            {
                NodeClasses = new NodeClasses();
                NodeClasses.ResetEnums();
                NodeClasses.ResetNodes();
                XmlUtility.Save(MainForm.Instance.GetNodeClassPath(), MainForm.Instance.NodeClasses);
            }

            NodeClassesStringContent = XmlUtility.ObjectToString(NodeClasses);

            this.Text = Settings.Default.EditorTitle;
            if (string.IsNullOrEmpty(Settings.Default.WorkDirectory) || string.IsNullOrEmpty(Settings.Default.WorkSpaceName))
            {
                return;
            }

            WorkSpaceData = XmlUtility.Read <WorkSpaceData>(GetWorkSpacePath());

            if (WorkSpaceData == null)
            {
                return;
            }

            if (WorkSpaceData != null)
            {
                this.Text = string.Format("{0}[{1}]", Settings.Default.EditorTitle, WorkSpaceData.WorkSpaceName);
            }

            //读取行为树数据
            LoadBehaviorTreeData();
        }
Esempio n. 2
0
        //打开工作区
        public void OpenWorkSpace()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = string.Format("工作区配置|*{0}", Settings.Default.WorkSpaceSetupSuffix);
            openFileDialog.Title  = "打开工作区";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string workSpaceFile = openFileDialog.FileName.Trim();
                if (File.Exists(workSpaceFile))
                {
                    DirectoryInfo dirInfo       = new DirectoryInfo(workSpaceFile);
                    string        workDirectory = dirInfo.Parent.FullName;
                    WorkSpaceData = XmlUtility.Read <WorkSpaceData>(workSpaceFile);
                    if (WorkSpaceData != null)
                    {
                        Settings.Default.WorkDirectory = workDirectory;
                        Settings.Default.WorkSpaceName = WorkSpaceData.WorkSpaceName;
                        Settings.Default.Save();
                        Text = string.Format("{0}[{1}]", Settings.Default.EditorTitle, WorkSpaceData.WorkSpaceName);
                        ShowInfo("打开工作区,时间:" + DateTime.Now);

                        //读取行为树类信息
                        NodeClasses = XmlUtility.Read <NodeClasses>(GetNodeClassPath());
                        if (NodeClasses == null)
                        {
                            NodeClasses = new NodeClasses();
                            NodeClasses.ResetNodes();
                            XmlUtility.Save(GetNodeClassPath(), NodeClasses);
                        }

                        NodeClassesStringContent = XmlUtility.ObjectToString(NodeClasses);

                        //读取行为树数据
                        LoadBehaviorTreeData();

                        CreateTreeViewManager();
                    }
                }
            }
        }