Example #1
0
        //关闭工艺
        private bool CloseProject(bool isSave)
        {
            bool           result    = false;
            List <S_Model> ModelList = XML3DPPM.GetModelList(XmlFile);

            //关闭所有并保存压缩
            foreach (S_Model model in ModelList)
            {
                if (!String.IsNullOrEmpty(model.filename))
                {
                    NXFun.ClosePrt(ToFullPath(model.filename), isSave);
                }
            }
            if (isSave)
            {
                //压缩
                string tempZip = ProPath + "\\" + ProName + ".tmp";
                bool   isSaved = Compress.RAR(NXFun.TDPPMPath + NXFun.RarEXE, tempZip, ProPath + "\\" + ProName);
                if (isSaved)
                {
                    File.Copy(tempZip, ProPath + "\\" + ProName + ".3dppm", true);
                    File.Delete(tempZip);
                    NXFun.DeleteDirectory(ProPath + "\\" + ProName);
                    SetStatusLabel("保存工艺成功!", 2);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = true;
            }
            return(result);
        }
Example #2
0
 //保存工艺
 private bool SaveProject(bool isQuit)
 {
     try
     {
         bool           result    = false;
         List <S_Model> ModelList = XML3DPPM.GetModelList(XmlFile);
         if (isQuit)
         {
             //关闭所有并保存压缩
             foreach (S_Model model in ModelList)
             {
                 if (!String.IsNullOrEmpty(model.filename))
                 {
                     NXFun.ClosePrt(ToFullPath(model.filename), true);
                 }
             }
             //压缩
             string tempZip = ProPath + "\\" + ProName + ".tmp";
             bool   isSaved = Compress.RAR(NXFun.TDPPMPath + NXFun.RarEXE, tempZip, ProPath + "\\" + ProName);
             if (isSaved)
             {
                 File.Copy(tempZip, ProPath + "\\" + ProName + ".3dppm", true);
                 File.Delete(tempZip);
                 NXFun.DeleteDirectory(ProPath + "\\" + ProName);
                 SetStatusLabel("保存工艺成功!", 2);
                 result = true;
             }
             else
             {
                 SetStatusLabel("工艺保存失败!", 1);
                 MessageBox.Show("工艺保存失败!");
                 result = false;
             }
         }
         else
         {
             //仅保存
             foreach (S_Model model in ModelList)
             {
                 if (!String.IsNullOrEmpty(model.filename))
                 {
                     NXFun.SavePrt(ToFullPath(model.filename));
                 }
             }
             //压缩
             string tempZip = ProPath + "\\" + ProName + ".tmp";
             bool   isSaved = Compress.RAR(NXFun.TDPPMPath + NXFun.RarEXE, tempZip, ProPath + "\\" + ProName);
             if (isSaved)
             {
                 File.Copy(tempZip, ProPath + "\\" + ProName + ".3dppm", true);
                 File.Delete(tempZip);
                 SetStatusLabel("保存工艺成功!", 2);
                 result = true;
             }
             else
             {
                 SetStatusLabel("工艺保存失败!", 1);
                 MessageBox.Show("工艺保存失败!");
                 result = false;
             }
         }
         return(result);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Example #3
0
        //打开工艺
        private void OpenProject()
        {
            openFileDialog.Title    = "请选择要打开的工艺文件:";
            openFileDialog.Filter   = "3DPPM 文件 (*.3dppm)|*.3dppm";
            openFileDialog.FileName = "";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string filename = openFileDialog.FileName;
                if (NXFun.IsChina(filename))
                {
                    MessageBox.Show("NX不支持中文路径,请将工艺文件放到英文路径下再打开.");
                    return;
                }
                else
                {
                    //得到工艺路径和文件名;
                    ProPath = Path.GetDirectoryName(filename);
                    ProName = Path.GetFileNameWithoutExtension(filename);
                    XmlFile = ToFullPath(NXFun.ProcessXML);
                    //删除文件夹;
                    bool result = NXFun.DeleteDirectory(ProPath + "\\" + ProName);
                    if (!result)
                    {
                        MessageBox.Show("文件夹" + ProPath + "\\" + ProName + "无法删除,请手动关闭可能已打开的文件并删除该目录。");
                        return;
                    }
                    //判断是否是压缩文件
                    int type = GetFileRealType(filename);
                    switch (type)
                    {
                    case -1:
                        MessageBox.Show("读取文件出错,请确认文件是否有效!");
                        return;

                    case 0:
                        break;

                    case 1:
                        break;

                    default:
                        MessageBox.Show("读取文件出错,请确认文件是否有效!");
                        return;
                    }
                    //解压
                    bool isUnZip = true;
                    if (type == 0)
                    {
                        //按zip格式解压
                        isUnZip = Compress.UnZipFileDictory(filename, "");
                    }
                    else if (type == 1)
                    {
                        //按rar格式解压
                        isUnZip = Compress.UnRAR(NXFun.TDPPMPath + NXFun.RarEXE, filename, ToFullPath(""));
                    }
                    if (!isUnZip)
                    {
                        MessageBox.Show(
                            "工艺文件打开失败!请确认以下几项:\r\n" +
                            "1:文件有是否有效;\r\n" +
                            "2:工艺临时文件夹或其中文件若处于打开状态请关闭。");
                        return;
                    }
                    //检测文件有效性
                    if (!NXFun.isFileExist(XmlFile))
                    {
                        MessageBox.Show("工艺数据文件丢失!请确认文件有效!");
                    }
                    //检测版本有效性,若旧版则自动升级
                    XML3DPPM.Update3dppm(XmlFile, TemplateXML);


                    OpenOrCreateProjectInit();
                    //打开所有模型
                    List <S_Model> ModelList = XML3DPPM.GetModelList(XmlFile);
                    foreach (S_Model model in ModelList)
                    {
                        if (!String.IsNullOrEmpty(model.filename))
                        {
                            NXFun.OpenPrtQuiet(ToFullPath(model.filename));
                        }
                    }
                    SetStatusLabel("工艺打开成功!", 2);
                }
            }
        }