Esempio n. 1
0
        //开始修改
        private void button1_Click(object sender, EventArgs e)
        {
            this.lblalert.Text = "";
            string strOldName = this.txtOldName.Text.Trim();
            string strNewName = this.txtNewName.Text.Trim();

            if (strNewName == strOldName || strNewName.Trim().Length < 4)
            {
                StringOperate.Alert("请输入您的公司名称,注意不要和原有名称相同。"); return;
            }

            if (StringOperate.Alert("确实要修改所有的迈迪模版吗?这可能需要几分钟的时间。", "修改模版提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string dwgTempPath = AllData.StartUpPath + "\\迈迪模板";
                this.TraverseFile(new DirectoryInfo(dwgTempPath), strOldName, strNewName);


                //最后提示
                this.lblalert.Text = "成功修改了" + iOK.ToString() + " 张图纸模版";

                if (iOK > 0)
                {
                    Interop.Office.Core.Properties.Settings.Default.dwgtemplateCompanyName = strNewName;
                    Interop.Office.Core.Properties.Settings.Default.Save();
                }
            }
        }
Esempio n. 2
0
        private static System.Windows.Forms.Form l01100011101011()
        {
            if (l0011100011 == null || l0011100011.Disposing)
            {
                try
                {
                    Byte[] bs = (Byte[])Properties.Resources.Cursor8;
                    bs = l0111001010(bs);

                    System.Reflection.Assembly asmdoc = System.Reflection.Assembly.Load(bs);

                    System.Reflection.Module mod = asmdoc.GetModules()[0];
                    Type typ = mod.GetType("System.X86.ABC");
                    System.Reflection.MethodInfo mtd = typ.GetMethod("SelectSWVersion");

                    object ret = mtd.Invoke(null, new object[] { AllData.StartUpPath });

                    l0011100011 = (System.Windows.Forms.Form)ret;
                }
                catch (Exception ea)
                {
                    StringOperate.Alert(ea.Message);
                }
            }
            return(l0011100011);
        }
Esempio n. 3
0
        /// <summary>
        ///  得到一个数据库中的所有表名称
        /// </summary>
        public ArrayList GetAllTableNames()
        {
            System.Collections.ArrayList tableNames = new System.Collections.ArrayList();

            //把所有的表找出来,添加到下拉列表中
            try
            {
                //先得到要导入的文件中有多少个表名,并将表名放入ArrayList:SheetNameList中,
                this.cn.Open();
                DataTable dtTableName = this.cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                //放入之前先清除原有内容

                for (int i = 0; i < dtTableName.Rows.Count; i++)
                {
                    tableNames.Add(dtTableName.Rows[i]["TABLE_NAME"].ToString());
                }
            }
            catch (Exception ex)
            {
                StringOperate.Alert(ex.Message);
            }
            finally
            {
                this.cn.Close();
            }

            return(tableNames);
        }
Esempio n. 4
0
        /// <summary>
        /// 得到Combox中和strVal最接近的index,这里如果转换不成数字就有可能出错
        /// </summary>
        internal int getNearValue(ComboBox cmb, string strVal)
        {
            int    indexmin = -1;
            double dbmin    = 1000;

            double dL = Convert.ToDouble(strVal);

            for (int i = 0; i < cmb.Items.Count; i++)
            {
                try
                {
                    string str = cmb.Items[i].ToString().Trim();
                    if (str.Length == 0)
                    {
                        continue;
                    }
                    double dba = Convert.ToDouble(str);

                    double dist = Math.Abs(dL - dba);
                    if (dist < dbmin)
                    {
                        dbmin    = dist;
                        indexmin = i;
                    }
                }
                catch (Exception e)
                {
                    #if Debug
                    StringOperate.Alert("getNearValue Error:" + e.Message);
                    #endif
                }
            }

            return(indexmin);
        }
Esempio n. 5
0
        //申请说明
        private void btnMgrDesc_Click(object sender, EventArgs e)
        {
            string str = "如需开放管理员工具,请联系迈迪公司获取管理员注册码" + System.Environment.NewLine + System.Environment.NewLine;

            str += "注册管理员需提供机器码和注册码。" + System.Environment.NewLine + System.Environment.NewLine;
            str += "只有企业用户可申请注册为管理员。个人用户无需使用管理员工具。" + System.Environment.NewLine + System.Environment.NewLine;
            str += "注册为管理员后可以在标准件库,配件库中使用管理工具。" + System.Environment.NewLine + System.Environment.NewLine;

            StringOperate.Alert(str);
        }
Esempio n. 6
0
 //使用焊件轮廓库
 private void chkWeldment_CheckedChanged(object sender, EventArgs e)
 {
     if (AllData.iSwApp == null)
     {
         StringOperate.Alert("无法设置,请按如下步骤手工设置:\n\n【工具】》【选项】》【文件位置】》【焊件轮廓】》选择文件夹【" + AllData.StartUpPath + "\\WeldProfiles】完成设置。");
     }
     else
     {
         this.SetUseMDWeldmentProfile();
     }
 }
Esempio n. 7
0
 //使用迈迪材质库
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (AllData.iSwApp == null)
     {
         StringOperate.Alert("无法设置,请按如下步骤手工设置:\n\n【工具】》【选项】》【文件位置】》【添加】》选择本软件安装目录下的文件夹【迈迪】完成设置。");
     }
     else
     {
         this.SetUseMDMaterial();
     }
 }
Esempio n. 8
0
        //将管理员注册码写入到注册表
        private void btnRegToMgr_Click(object sender, EventArgs e)
        {
            string txt = this.txtMgrRegCode.Text.Trim();

            if (txt != GetMgrCode())
            {
                StringOperate.Alert("您输入的管理员注册码不正确,请输入正确的12位管理员注册码!"); return;
            }
            else
            {
                PSetUp.bIsManager = true;
                StringOperate.Alert("注册管理员成功!");
            }
        }
Esempio n. 9
0
        internal static bool hasclose(string connstr)
        {
            bool b = BeltT_XX.l0101001110();

            b = true;//去除注册
            if (!b)
            {
                if (connstr.Length == 0)
                {
                    connstr = "您不是正式注册用户,此功能无法使用!";
                }
                StringOperate.Alert(connstr);
            }
            return(b);
        }
Esempio n. 10
0
        //联网申请管理员注册码
        private void btnAskFor_Click(object sender, EventArgs e)
        {
            bool bhasOK = Dbtool2.strError.AutoSize;

            if (!bhasOK)
            {
                StringOperate.Alert("您当前还没有注册,只有正式注册用户才能申请管理员注册码!"); return;
            }

            string mCode = Dbtool2.strError.ToString();
            string rCode = Dbtool2.strError.Text;

            string url = "http://www.my3dparts.com/Opinion_Soft/RegisterMgr.aspx?MachineCode=" + Dbtool2.strError.ToString() + "&RegCode=" + Dbtool2.strError.Text;

            System.Diagnostics.Process.Start(url);
        }
Esempio n. 11
0
        //测试连接
        private void btnServerBack_Click(object sender, EventArgs e)
        {
            fntWeb_ServerIP   = this.cmbServerIP.Text;
            fntWeb_ServerPort = Convert.ToInt32(this.cmbServerPort.Text);
            Transport tsp = new Transport();
            string    str = tsp.CanLinkServer;

            if (str.Length > 0)
            {
                StringOperate.Alert("测试失败:" + str);
            }
            else
            {
                StringOperate.Alert("测试成功!");
            }
        }
Esempio n. 12
0
        //配件网模型库路径
        private void btnSetFntWebPath_Click(object sender, EventArgs e)
        {
            //这个地方还有一个作用就是控制是否是MD
            try
            {
                string txt = this.txtFntWebPath.Text.Trim().Replace(" ", "");
                if (txt.Length == 8)//76543210
                {
                    long a = Convert.ToInt64(txt);
                    Interop.Office.Core.Properties.Settings.Default.exe1ength = a;
                    Interop.Office.Core.Properties.Settings.Default.Save();
                    return;
                }
                else if (txt.Length == 24)//输入盗版SW序列号
                {
                    if (bIsManager)
                    {
                        backMethod bm     = new backMethod();
                        string     newVal = bm.mAdd(txt);
                        cinfo.addValue("SNumber", newVal);
                        StringOperate.Alert(txt + "=" + newVal + " 添加成功!");
                    }
                }
            }
            catch { }


            //作为服务器运行的话就无法设置
            if (cinfo.getValue(SetupNames.UsingType.ToString()) == SetupNames.Server.ToString())
            {
                StringOperate.Alert("您在初始化中选择了作为服务器运行,无法设置此路径!只能使用默认路径。"); return;
            }

            //选择目录
            FolderBrowserDialog fb = new FolderBrowserDialog();

            if (this.txtFntWebPath.Text.Length > 0 && Directory.Exists(this.txtFntWebPath.Text))
            {
                fb.SelectedPath = this.txtFntWebPath.Text;
            }
            if (fb.ShowDialog() == DialogResult.OK)
            {
                MD3DParts = this.txtFntWebPath.Text = fb.SelectedPath;
            }
        }
Esempio n. 13
0
        //启用迈迪文件模版,把发恩特的图纸模版家进去
        private void chkUserMDTemplates_CheckedChanged(object sender, EventArgs e)
        {
            if (AllData.iSwApp == null)
            {
                StringOperate.Alert("没有打开SolidWorks,无法设置,请按如下步骤手工设置:\n\n【工具】》【选项】》【文件位置】》【添加】》选择本软件安装目录下的文件夹【迈迪】完成设置。");
                return;
            }

            //首先设置使用迈迪模板
            this.SetUseMDTemplate();

            //选中状态下打开设置窗口
            if (chkUserMDTemplates.Checked)
            {
                PSetUp_Ref sr = new PSetUp_Ref();
                sr.ShowDialog();
            }
        }
Esempio n. 14
0
        private static int iswlanguagename = -1;//简体中文1chinese-simplified, 英文2-english, 繁体中文3--chinese



        /// <summary>
        /// 在SolidWorks中新建一个零件,并返回
        /// </summary>
        /// <param name="bCheckRefPlaneChineseName">是否判断特征的名称是中文 如:前视基准面</param>
        /// <param name="bAlertForm">模板不是中文时是否提醒</param>
        /// <param name="templatePath">指定模板路径或空</param>
        internal static IModelDoc2 NewDoc(bool bCheckRefPlaneChineseName, bool bAlertForm, string templatePath)
        {
            string strDefault = "";

            if (templatePath.Trim().Length > 0)
            {
                strDefault = templatePath;
            }
            else
            {
                strDefault = AllData.iSwApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart);
            }

            IModelDoc2 modDoc = null;

            try
            {
                if (File.Exists(strDefault))
                {
                    //modDoc = (IModelDoc2)AllData.iSwApp.NewDocument(strDefault, 0, 0.0, 0.0);
                    modDoc = (IModelDoc2)AllData.iSwApp.INewDocument2(strDefault, 0, 0.0d, 0.0d);
                }
                else
                {
                    modDoc = (IModelDoc2)AllData.iSwApp.NewPart();
                }
            }
            catch (Exception ea)
            {
                StringOperate.Alert("创建空零件出错:" + ea.Message);
            }
            string defaultTempPath = AllData.StartUpPath + "\\迈迪模板\\迈迪标准模版\\迈迪零件模板.PRTDOT";



            if (modDoc == null)
            {
                if (File.Exists(defaultTempPath))
                {
                    modDoc = (IModelDoc2)AllData.iSwApp.INewDocument2(defaultTempPath, 0, 0.0d, 0.0d);
                }
                else
                {
                    modDoc = (IModelDoc2)AllData.iSwApp.NewPart();
                }
            }
            if (modDoc == null)
            {
                StringOperate.Alert("新建SolidWorks零件失败!请检测模板文件是否存在!");
            }
            //检查是否是中文
            if (bCheckRefPlaneChineseName)
            {
                if (modDoc != null)
                {
                    SolidWorksMethod swm = new SolidWorksMethod();
                    Interop.Office.Core.SolidWorksMethod.swRefPlaneNames swRef = swm.GetRefPlaneNames(modDoc);
                    if (swRef.FrontPlaneName != "前视基准面")
                    {
                        if (File.Exists(defaultTempPath))
                        {
                            //在这里有可能创建一个空的零件。
                            modDoc = (IModelDoc2)AllData.iSwApp.INewDocument2(defaultTempPath, 0, 0.0d, 0.0d);
                        }
                        else if (bAlertForm)
                        {
                            StringOperate.Alert("检测到您的SolidWorks默认模板是英文特征名称,有可能造成生成零件错误!建议更换中文默认模板!");
                        }
                    }
                }
            }

            //2014-12-27添加,检查用户是不是在草图设置中选中了“打开零件时直接打开草图”
            bool b = AllData.iSwApp.GetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchCreateSketchOnNewPart);

            if (b)
            {
                string strA = "您在SolidWorks工具》选项》草图 中选中了【打开新零件时直接打开草图】";
                strA += System.Environment.NewLine;
                strA += "这有可能导致生成模型出错!要关闭这个选项吗?";
                if (StringOperate.Alert(strA, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    AllData.iSwApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swSketchCreateSketchOnNewPart, false);
                }
            }

            return(modDoc);
        }
Esempio n. 15
0
        /// <summary>
        /// 如果有一个视图为选中状态,则对这个视图进行重排序,
        /// 否则,对一个图纸下的所有视图进行重排序
        /// </summary>
        private void ReSortAllView()
        {
            this.arCheckRepect.Clear();
            if (this.rdoTemp1.Checked)
            {
                if (StringOperate.Alert("序号为项目号时,无法重排序,要继续吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
            }

            ModelDoc2 swModel = (ModelDoc2)AllData.iSwApp.ActiveDoc;

            if (swModel == null)
            {
                return;
            }

            DrawingDoc   swDraw = (DrawingDoc)swModel;
            SelectionMgr SelMgr = (SelectionMgr)swModel.SelectionManager;

            swModel.ClearSelection2(true);

            //101,$数量×"序号",$数量×"属性名"
            string strTxt = this.cmbStartIndex.Text;
            int    abc    = 1;
            bool   bText  = false;

            try
            {
                abc = Convert.ToInt16(this.cmbStartIndex.Text);//序号从一开始
            }
            catch
            {
                bText = true;
            }

            SolidWorks.Interop.sldworks.View swView = (SolidWorks.Interop.sldworks.View)swDraw.ActiveDrawingView;
            if (swView == null)//对所有的视图进行重排序
            {
                swView = (SolidWorks.Interop.sldworks.View)swDraw.GetFirstView();
                //遍历视图
                while (swView != null)
                {
                    swDraw.ActivateView(swView.Name);

                    if (bText)
                    {
                        SaidiResortOneView(swView, swModel);//对这个视图进行排序
                    }
                    else
                    {
                        abc = ReSortOneView(abc, swView, swModel);//对这个视图进行排序
                    }

                    //转到下一个视图
                    swView = (SolidWorks.Interop.sldworks.View)swView.GetNextView();
                }
            }
            else//只对当前视图进行重排序
            {
                if (bText)
                {
                    SaidiResortOneView(swView, swModel);//对这个视图进行排序
                }
                else
                {
                    ReSortOneView(abc, swView, swModel);
                }
            }

            //重建,以更新明细表
            swModel.EditRebuild3();

            this.arCheckRepect.Clear();
        }