Exemple #1
0
    /// <summary>
    /// 从服务器读取一个文件夹下的所有文件,保存到制定的目录下
    /// </summary>
    internal bool ReadFolderFromServer(string FullPath, string SavePath, int kbyte)
    {
        if (!FullPath.EndsWith("\\"))
        {
            FullPath = FullPath + "\\";
        }
        if (!SavePath.EndsWith("\\"))
        {
            SavePath = SavePath + "\\";
        }

        if (!Directory.Exists(SavePath))
        {
            Directory.CreateDirectory(SavePath);
        }
        Interop.Office.Core.StringOperate pm = new Interop.Office.Core.StringOperate();

        string[] strArr = ReadFileAndFolderName(FullPath);
        foreach (string s in strArr)
        {
            if (s.EndsWith(":"))//文件夹
            {
                string FolderName = s.TrimEnd(new char[] { ':' });
                ReadFolderFromServer(FullPath + FolderName, SavePath + FolderName, 1);
            }
            else
            {
                string str = this.TCPDownFile(FullPath + s, SavePath);
            }
        }

        return(true);
    }
Exemple #2
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);
        }
Exemple #3
0
        /// <summary>
        /// 把一个表格转换为繁体
        /// </summary>
        internal static void Big5Convert(DataGridView dgv)
        {
            if (!PSetUp.bIsBig5Encoding)
            {
                return;
            }
            foreach (DataGridViewColumn dc in dgv.Columns)
            {
                int idx = dc.Index;

                dc.Name       = StringOperate.Big5Convert(dc.Name);
                dc.HeaderText = StringOperate.Big5Convert(dc.HeaderText);

                //dc.ValueType其实获取不出任何信息来,以后再完善吧
                if (dc.ValueType == typeof(System.String))
                {
                    for (int i = 0; i < dgv.Rows.Count; i++)
                    {
                        DataGridViewCell cell = dgv.Rows[i].Cells[idx];
                        if (cell != null && cell.Value != null)
                        {
                            cell.Value = StringOperate.Big5Convert(cell.Value.ToString());
                        }
                    }
                }
            }
        }
Exemple #4
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();
                }
            }
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
0
        /// <summary>
        /// 把中文特征名称转换成英文,或转换成繁体中文。
        /// </summary>
        internal static string CEN(string cnName)
        {
            if (AllData.iSWLanguage <= 1)
            {
                return(cnName);//中文无需转换
            }

            //去除数字,如【草图1>>草图】//如D1@阵列(圆周)1
            string[] strArr = cnName.Split(new char[] { '@' });

            if (AllData.iSWLanguage == 2)
            {
                if (htEnglishEncoding == null)
                {
                    cfgInfo cinfo = new cfgInfo();
                    htEnglishEncoding = cinfo.getAllValue(AllData.StartUpPath + "\\GB2312-English.cfg");
                }

                foreach (string SA in strArr)
                {
                    string SB = StringOperate.RemoveNumber(SA);//阵列(圆周)
                    if (htEnglishEncoding.ContainsKey(SB))
                    {
                        string val = htEnglishEncoding[SB].ToString();
                        if (val.Length > 0)
                        {
                            cnName = cnName.Replace(SB, val);
                        }
                    }
                }
            }
            else if (AllData.iSWLanguage == 3)
            {
                if (htBig5Encoding == null)
                {
                    cfgInfo cinfo = new cfgInfo();
                    htBig5Encoding = cinfo.getAllValue(AllData.StartUpPath + "\\GB2312-BIG5.cfg");
                }

                foreach (string SA in strArr)
                {
                    string SB = StringOperate.RemoveNumber(SA);//阵列(圆周)
                    if (htBig5Encoding.ContainsKey(SB))
                    {
                        string val = htBig5Encoding[SB].ToString();
                        if (val.Length > 0)
                        {
                            cnName = cnName.Replace(SB, val);
                        }
                    }
                    else
                    {
                        cnName = cnName.Replace(SB, Big5Convert(SB));
                    }
                }
            }

            return(cnName);
        }
Exemple #8
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);
        }
Exemple #9
0
 //使用迈迪材质库
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (AllData.iSwApp == null)
     {
         StringOperate.Alert("无法设置,请按如下步骤手工设置:\n\n【工具】》【选项】》【文件位置】》【添加】》选择本软件安装目录下的文件夹【迈迪】完成设置。");
     }
     else
     {
         this.SetUseMDMaterial();
     }
 }
Exemple #10
0
 //使用焊件轮廓库
 private void chkWeldment_CheckedChanged(object sender, EventArgs e)
 {
     if (AllData.iSwApp == null)
     {
         StringOperate.Alert("无法设置,请按如下步骤手工设置:\n\n【工具】》【选项】》【文件位置】》【焊件轮廓】》选择文件夹【" + AllData.StartUpPath + "\\WeldProfiles】完成设置。");
     }
     else
     {
         this.SetUseMDWeldmentProfile();
     }
 }
Exemple #11
0
 /// <summary>
 /// 迈迪专用错误提示,如果是迈迪自己就会提示,否则不提示,写入到日志中
 /// </summary>
 internal static void AlertDebug(string text)
 {
     if (PSetUp.bIsMD)
     {
         MessageBox.Show("迈迪专用提示:" + text);
     }
     else
     {
         string        s   = DateTime.Now.ToString("G") + "   " + text;
         StringOperate sop = new StringOperate();
         sop.WriteTextFileAppend(AllData.StartUpPath + "\\mdlog.txt", s);
     }
 }
Exemple #12
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("注册管理员成功!");
            }
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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("测试成功!");
            }
        }
Exemple #16
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;
            }
        }
Exemple #17
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();
            }
        }
Exemple #18
0
        /// <summary>
        /// 如果设置为繁体,把窗体的所有字符转换为繁体
        /// </summary>
        internal static void Big5Convert(System.Windows.Forms.Form frm)
        {
            if (frm == null)
            {
                return;
            }
            if (PSetUp.bIsBig5Encoding)
            {
                if (frm.Text.Length > 0)
                {
                    frm.Text = StringOperate.ToTraditional(frm.Text);
                }

                if (frm.Controls.ContainsKey("lblNotEncoding"))
                {
                    return;//说明此窗口禁止繁体编码
                }

                Big5ConvertForm_Ref(frm.Controls);
            }
        }
Exemple #19
0
        /// <summary>
        /// 把一个表格转换为繁体
        /// </summary>
        internal static DataTable Big5Convert(DataTable dt)
        {
            if (!PSetUp.bIsBig5Encoding)
            {
                return(dt);
            }
            foreach (DataColumn dc in dt.Columns)
            {
                int idx = dc.Ordinal;

                dc.ColumnName = StringOperate.Big5Convert(dc.ColumnName);
                dc.Caption    = StringOperate.Big5Convert(dc.Caption);

                if (dc.DataType == typeof(System.String))
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i][idx] = StringOperate.Big5Convert(dt.Rows[i][idx].ToString());
                    }
                }
            }

            return(dt);
        }
Exemple #20
0
        /// <summary>
        /// 如果设置为繁体,把控件的所有字体转换为繁体,如果Tag为NoReEncoding就不转换,如果Tag为CanReEncoding就一定要转换,除此之外只转换Label等基本控件
        /// </summary>
        internal static void Big5Convert(Control ctl)
        {
            if (!PSetUp.bIsBig5Encoding)
            {
                return;
            }

            string strTag = (ctl.Tag != null ? ctl.Tag.ToString() : "");

            if (strTag == "NoReEncoding")
            {
                return;
            }

            //不要修改这些类型的控件,以免引起错误,除非有CanReEncoding
            if (strTag == "CanReEncoding")
            {
                if (ctl.GetType() == typeof(System.Windows.Forms.ComboBox))
                {
                    ComboBox cmb = (ComboBox)ctl;
                    cmb.Text = StringOperate.ToTraditional(cmb.Text);
                    for (int i = 0; i < cmb.Items.Count; i++)
                    {
                        cmb.Items[i] = StringOperate.ToTraditional(cmb.Items[i].ToString());
                    }
                    return;
                }
                else if (ctl.GetType() == typeof(System.Windows.Forms.DataGridView))
                {
                    Big5Convert(ctl as DataGridView); return;
                }
                else if (ctl.GetType() == typeof(System.Windows.Forms.TreeView))
                {
                    Big5Convert((TreeView)ctl); return;
                }
            }

            if (ctl.GetType() == typeof(System.Windows.Forms.ContextMenuStrip))
            {
                //继承关系 ContextMenuStrip : ToolStripDropDownMenu: ToolStripDropDown :ToolStrip
                ContextMenuStrip cmenu = (ContextMenuStrip)ctl;
                foreach (ToolStripItem item in cmenu.Items)
                {
                    if (item.GetType() == typeof(ToolStripSeparator))
                    {
                        continue;
                    }

                    if (item.Text.Length > 0)
                    {
                        item.Text = StringOperate.ToTraditional(item.Text);
                    }
                    foreach (ToolStripItem subitem in (item as ToolStripMenuItem).DropDownItems)
                    {
                        if (subitem.Text.Length > 0)
                        {
                            subitem.Text = StringOperate.ToTraditional(subitem.Text);
                        }
                    }
                }
            }
            else if (ctl.GetType() == typeof(System.Windows.Forms.MenuStrip))
            {
                MenuStrip menu = (MenuStrip)ctl;
                foreach (ToolStripItem item in menu.Items)
                {
                    if (item.GetType() == typeof(ToolStripSeparator))
                    {
                        continue;
                    }
                    if (item.GetType() == typeof(ToolStripComboBox))
                    {
                        continue;
                    }

                    if (item.Text.Length > 0)
                    {
                        item.Text = StringOperate.ToTraditional(item.Text);
                    }
                    foreach (ToolStripItem subitem in (item as ToolStripMenuItem).DropDownItems)
                    {
                        if (subitem.Text.Length > 0)
                        {
                            subitem.Text = StringOperate.ToTraditional(subitem.Text);
                        }
                    }
                }
            }
            else if (ctl.Text.Length > 0)
            {
                ctl.Text = StringOperate.ToTraditional(ctl.Text);
            }
        }
Exemple #21
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);
        }
Exemple #22
0
        /// <summary>
        /// 根据文件路径,把文本文件还原成表 ,以UTF8读取//有解密过程,(ref 是不是正版用户专用 false)
        /// </summary>
        internal DataTable readDatFileToTB(string txtPath, ref bool bOnlyReg)
        {
            //读取并解密
            string str = ReadTextFile(txtPath, Encoding.UTF8, true);

            //这一句非常重要,去掉末尾的\r\n换行符,否则导致错误
            str = str.Trim();

            if (str.Length == 0)
            {
                return(null);
            }

            //>=v3.5,有可能添加一列
            bool bAddCol = false;

            if (str.EndsWith("#注册提示:"))
            {
                str      = str.Remove(str.LastIndexOf('#'));
                bAddCol  = true;
                bOnlyReg = true;
            }

            int    iStart = str.IndexOf('≮');
            string start  = (iStart == -1) ? str : str.Remove(iStart);       //表头
            string end    = (iStart == -1) ? "" : str.Substring(iStart + 1); //表内容

            DataTable dt = new DataTable();

            string[] strArr = start.Split('♂');
            for (int i = 0; i < strArr.Length; i += 3)
            {
                string ColName  = strArr[i].Trim();
                string DataType = strArr[i + 1];
                string ReadOnly = strArr[i + 2];
                Type   T        = Type.GetType(DataType);
                if (T == typeof(System.Object))
                {
                    T = typeof(System.String);
                }

                DataColumn dc = new DataColumn(ColName, T);
                dc.ReadOnly = Convert.ToBoolean(ReadOnly);

                if (!dt.Columns.Contains(ColName))
                {
                    dt.Columns.Add(dc);
                }
            }

            int ColCount = dt.Columns.Count;

            string[] ArrVal = end.Split('♂');
            try
            {
                int Mod     = ArrVal.Length % ColCount; //获取余数
                int iLength = ArrVal.Length - Mod;      //最后一行不全
                for (int i = 0; i < ArrVal.Length; i += ColCount)
                {
                    DataRow dr = dt.NewRow();
                    dt.Rows.Add(dr);
                    for (int j = 0; j < ColCount; j++)
                    {
                        if (ArrVal[i + j] != "")
                        {
                            dr[j] = (object)ArrVal[i + j];
                        }
                    }
                }
            }
            catch (Exception ea)
            {
                StringOperate.AlertDebug("表格转换出错:" + ea.Message);
            }

            //>=v3.5,有可能添加一列
            if (bAddCol)
            {
                if (!dt.Columns.Contains("注册提示:"))
                {
                    DataColumn dc = new DataColumn("注册提示:", typeof(System.String));
                    dc.ReadOnly = false;
                    dt.Columns.Add(dc);
                    foreach (DataRow row in dt.Rows)
                    {
                        row["注册提示:"] = "注册后才能使用";
                    }
                }
            }

            return(dt);
        }
Exemple #23
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();
        }