using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.IO; using System.Windows.Forms; using Microsoft.Win32; using SAGY.DotNetUtils; using SAGY.DotNetUtils.Configration; using SAGY.DotNetUtils.WinForms; using SAGY.RevitUtility; namespace SAGY.RevitMenu { public class ChangeProduct : BaseForm { private static Dictionary _mConfigParam; private static Dictionary _mConfigProduct; private Button btn_Cancle; private Button btn_OK; private IContainer components; private DataGridView dataGridView1; private GroupBox groupBox1; private DataGridViewTextBoxColumn ParamName; private DataGridViewTextBoxColumn Path; private DataGridViewTextBoxColumn ProName; private DataGridViewTextBoxColumn Ver; public ChangeProduct() { this.InitializeComponent(); } private void btn_Cancle_Click(object sender, EventArgs e) { base.Close(); } private void btn_OK_Click(object sender, EventArgs e) { if ((this.dataGridView1.CurrentRow != null) && (this.dataGridView1.CurrentRow.Index != -1)) { string str = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["Path"].Value.ToString(); string str2 = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["ParamName"].Value.ToString(); Process process = new Process(); string fileName = str + @"DLL\TSZ.Revit.exe"; string str4 = RevitStartHelper.GetRevitProductVer1(VersionAdapter.RevitApiVersion); ProcessStartInfo info = new ProcessStartInfo(fileName, str4 + " " + str2); process.StartInfo = info; process.Start(); } base.Close(); } private void ChangeProduct_Load(object sender, EventArgs e) { string path = AppBaseInfo.AppRunPath + @"\DLL\TSZ.Revit.exe"; if (File.Exists(path)) { FileInfo info = new FileInfo(path); this.Text = "当前程序版本:" + info.LastWriteTime.ToString("yyyy-MM-dd"); } foreach (string str2 in Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TszCAD").GetSubKeyNames()) { string str3; RegistryKey key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TszCAD\" + str2); if ((key2 != null) && ConfigProduct.TryGetValue(str2.Substring(str2.LastIndexOf("-", StringComparison.Ordinal) + 1), out str3)) { string str4 = key2.GetValue("Path").ToString(); string str5 = str4 + @"DLL\TSZ.Revit.exe"; if (File.Exists(str5)) { FileInfo info2 = new FileInfo(str5); string str6 = info2.LastWriteTime.ToString("yyyy-MM-dd"); this.dataGridView1.Rows.Add(1); int num = this.dataGridView1.Rows.Count - 1; string str7 = str2.Split(new char[] { '-' })[0]; this.dataGridView1.Rows[num].Cells["Ver"].Value = str7.Substring(str7.Length - 4) + "(" + str6 + ")"; ProductEnum featuresBit = (ProductEnum) Enum.Parse(typeof(ProductEnum), str3); this.dataGridView1.Rows[num].Cells["ProName"].Value = ProductUtil.GetModuleName(featuresBit); ConfigParam.TryGetValue(str2.Substring(str2.LastIndexOf("-", StringComparison.Ordinal) + 1), out str3); this.dataGridView1.Rows[num].Cells["ParamName"].Value = str3; this.dataGridView1.Rows[num].Cells["Path"].Value = str4; } } } } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { ComponentResourceManager manager = new ComponentResourceManager(typeof(ChangeProduct)); this.btn_Cancle = new Button(); this.btn_OK = new Button(); this.groupBox1 = new GroupBox(); this.dataGridView1 = new DataGridView(); this.Ver = new DataGridViewTextBoxColumn(); this.ProName = new DataGridViewTextBoxColumn(); this.ParamName = new DataGridViewTextBoxColumn(); this.Path = new DataGridViewTextBoxColumn(); this.groupBox1.SuspendLayout(); ((ISupportInitialize) this.dataGridView1).BeginInit(); base.SuspendLayout(); this.btn_Cancle.Location = new Point(0xe4, 0x128); this.btn_Cancle.Name = "btn_Cancle"; this.btn_Cancle.Size = new Size(0x4b, 0x17); this.btn_Cancle.TabIndex = 5; this.btn_Cancle.Text = "关闭"; this.btn_Cancle.UseVisualStyleBackColor = true; this.btn_Cancle.Click += new EventHandler(this.btn_Cancle_Click); this.btn_OK.Location = new Point(0x93, 0x128); this.btn_OK.Name = "btn_OK"; this.btn_OK.Size = new Size(0x4b, 0x17); this.btn_OK.TabIndex = 4; this.btn_OK.Text = "启动"; this.btn_OK.UseVisualStyleBackColor = true; this.btn_OK.Click += new EventHandler(this.btn_OK_Click); this.groupBox1.Controls.Add(this.dataGridView1); this.groupBox1.Location = new Point(11, 15); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new Size(0x12a, 0x113); this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; this.groupBox1.Text = "已安装产品"; this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.BackgroundColor = System.Drawing.Color.White; this.dataGridView1.BorderStyle = BorderStyle.Fixed3D; this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.Ver, this.ProName, this.ParamName, this.Path }); this.dataGridView1.GridColor = System.Drawing.Color.White; this.dataGridView1.Location = new Point(6, 20); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 0x17; this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new Size(0x11e, 0xf9); this.dataGridView1.TabIndex = 0; this.Ver.DataPropertyName = "Ver"; this.Ver.HeaderText = "版本"; this.Ver.Name = "Ver"; this.Ver.ReadOnly = true; this.Ver.Width = 120; this.ProName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; this.ProName.DataPropertyName = "ProName"; this.ProName.HeaderText = "名称"; this.ProName.Name = "ProName"; this.ProName.ReadOnly = true; this.ParamName.DataPropertyName = "ParamName"; this.ParamName.HeaderText = "ParamName"; this.ParamName.Name = "ParamName"; this.ParamName.ReadOnly = true; this.ParamName.Visible = false; this.Path.DataPropertyName = "Path"; this.Path.HeaderText = "路径"; this.Path.Name = "Path"; this.Path.ReadOnly = true; this.Path.Visible = false; base.AutoScaleDimensions = new SizeF(6f, 12f); base.ClientSize = new Size(0x141, 0x14c); base.Controls.Add(this.btn_Cancle); base.Controls.Add(this.btn_OK); base.Controls.Add(this.groupBox1); base.MaximizeBox = false; base.MinimizeBox = false; base.Name = "ChangeProduct"; base.StartPosition = FormStartPosition.CenterScreen; this.Text = "产品切换"; base.Load += new EventHandler(this.ChangeProduct_Load); this.groupBox1.ResumeLayout(false); ((ISupportInitialize) this.dataGridView1).EndInit(); base.ResumeLayout(false); } public static Dictionary ConfigParam { get { Dictionary dictionary; if (_mConfigParam == null) { dictionary = new Dictionary(); dictionary.Add("TSRA", "TSRA"); dictionary.Add("TSRS", "TSRS"); dictionary.Add("TSPT", "TSPT"); dictionary.Add("T3PT", "T3PT"); dictionary.Add("TS3DSR", "TS3DSR"); dictionary.Add("TSCC", "TSCC"); dictionary.Add("TSCF", "TSCF"); dictionary.Add("TSDCP", "TSDCP"); dictionary.Add("TSRFA", "TSRFA"); dictionary.Add("TSRMEP", "TSRMEP"); dictionary.Add("地下特种结构", "TSIPS"); } return (_mConfigParam = dictionary); } } public static Dictionary ConfigProduct { get { Dictionary dictionary; if (_mConfigProduct == null) { dictionary = new Dictionary(); dictionary.Add("TSRA", "TSRA"); dictionary.Add("TSRS", "TSRS"); dictionary.Add("TSPT", "TSPTREVIT"); dictionary.Add("T3PT", "T3PTREVIT"); dictionary.Add("TS3DSR", "TS3DSR"); dictionary.Add("TSCC", "TSCC"); dictionary.Add("TSCF", "TSCF"); dictionary.Add("TSDCP", "TSDCP"); dictionary.Add("TSRFA", "TSRFA"); dictionary.Add("TSRMEP", "TSRMEP"); dictionary.Add("地下特种结构", "TSIPS"); } return (_mConfigProduct = dictionary); } } } }