Beispiel #1
0
        private void btnSavePrj_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPrjName.Text))
            {
                MessageBox.Show("请输入项目名称");
                return;
            }

            var filePath = ProjectInfo.ProjectPath + "\\" + txtPrjName.Text;

            foreach (char c in Path.GetInvalidFileNameChars())
            {
                if (txtPrjName.Text.Contains(c.ToString()))
                {
                    MessageBox.Show("项目名中包含不可使用的字符,请重新命名。");
                    return;
                }
            }

            try
            {
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }

                var prjInfo = new ProjectInfo(txtPrjName.Text);

                if (!string.IsNullOrEmpty(_sourceModelFilePath))
                {
                    File.Copy(_sourceModelFilePath, prjInfo.ModelFilePathName, true);
                }

                if (picPreview.Image != null)
                {
                    picPreview.Image.Save(prjInfo.ImageFilePathName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建项目文件夹失败!\n" + ex.Message);
                return;
            }

            ProjectInfo info = new ProjectInfo(txtPrjName.Text);

            info.ModelPoints.Add(new ModelPoint("testPoint"));
            if (!ProjectConfigFileOper.CreatePrjFile(info.Name))
            {
                return;
            }

            if (!ProjectConfigFileOper.SavePrjInfo(info))
            {
                return;
            }

            DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #2
0
        private void OpenProject(string prjName)
        {
            CloseCurrentDrawing();

            _currentProject = ProjectConfigFileOper.LoadPrjInfo(prjName);
            if (_currentProject == null)
            {
                return;
            }

            ShowPointsInGrid();

            vDraw.ActiveDocument.Open(_currentProject.ModelFilePathName);
            InitRenderProperty();

            CreatePoints(_currentProject.ModelPoints, 500);
        }