ChangeProduct.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Windows.Forms;
  8. using Microsoft.Win32;
  9. using SAGY.DotNetUtils;
  10. using SAGY.DotNetUtils.Configration;
  11. using SAGY.DotNetUtils.WinForms;
  12. using SAGY.RevitUtility;
  13. namespace SAGY.RevitMenu
  14. {
  15. public class ChangeProduct : BaseForm
  16. {
  17. private static Dictionary<string, string> _mConfigParam;
  18. private static Dictionary<string, string> _mConfigProduct;
  19. private Button btn_Cancle;
  20. private Button btn_OK;
  21. private IContainer components;
  22. private DataGridView dataGridView1;
  23. private GroupBox groupBox1;
  24. private DataGridViewTextBoxColumn ParamName;
  25. private DataGridViewTextBoxColumn Path;
  26. private DataGridViewTextBoxColumn ProName;
  27. private DataGridViewTextBoxColumn Ver;
  28. public ChangeProduct()
  29. {
  30. this.InitializeComponent();
  31. }
  32. private void btn_Cancle_Click(object sender, EventArgs e)
  33. {
  34. base.Close();
  35. }
  36. private void btn_OK_Click(object sender, EventArgs e)
  37. {
  38. if ((this.dataGridView1.CurrentRow != null) && (this.dataGridView1.CurrentRow.Index != -1))
  39. {
  40. string str = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["Path"].Value.ToString();
  41. string str2 = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells["ParamName"].Value.ToString();
  42. Process process = new Process();
  43. string fileName = str + @"DLL\TSZ.Revit.exe";
  44. string str4 = RevitStartHelper.GetRevitProductVer1(VersionAdapter.RevitApiVersion);
  45. ProcessStartInfo info = new ProcessStartInfo(fileName, str4 + " " + str2);
  46. process.StartInfo = info;
  47. process.Start();
  48. }
  49. base.Close();
  50. }
  51. private void ChangeProduct_Load(object sender, EventArgs e)
  52. {
  53. string path = AppBaseInfo.AppRunPath + @"\DLL\TSZ.Revit.exe";
  54. if (File.Exists(path))
  55. {
  56. FileInfo info = new FileInfo(path);
  57. this.Text = "当前程序版本:" + info.LastWriteTime.ToString("yyyy-MM-dd");
  58. }
  59. foreach (string str2 in Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TszCAD").GetSubKeyNames())
  60. {
  61. string str3;
  62. RegistryKey key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\TszCAD\" + str2);
  63. if ((key2 != null) && ConfigProduct.TryGetValue(str2.Substring(str2.LastIndexOf("-", StringComparison.Ordinal) + 1), out str3))
  64. {
  65. string str4 = key2.GetValue("Path").ToString();
  66. string str5 = str4 + @"DLL\TSZ.Revit.exe";
  67. if (File.Exists(str5))
  68. {
  69. FileInfo info2 = new FileInfo(str5);
  70. string str6 = info2.LastWriteTime.ToString("yyyy-MM-dd");
  71. this.dataGridView1.Rows.Add(1);
  72. int num = this.dataGridView1.Rows.Count - 1;
  73. string str7 = str2.Split(new char[] { '-' })[0];
  74. this.dataGridView1.Rows[num].Cells["Ver"].Value = str7.Substring(str7.Length - 4) + "(" + str6 + ")";
  75. ProductEnum featuresBit = (ProductEnum) Enum.Parse(typeof(ProductEnum), str3);
  76. this.dataGridView1.Rows[num].Cells["ProName"].Value = ProductUtil.GetModuleName(featuresBit);
  77. ConfigParam.TryGetValue(str2.Substring(str2.LastIndexOf("-", StringComparison.Ordinal) + 1), out str3);
  78. this.dataGridView1.Rows[num].Cells["ParamName"].Value = str3;
  79. this.dataGridView1.Rows[num].Cells["Path"].Value = str4;
  80. }
  81. }
  82. }
  83. }
  84. protected override void Dispose(bool disposing)
  85. {
  86. if (disposing && (this.components != null))
  87. {
  88. this.components.Dispose();
  89. }
  90. base.Dispose(disposing);
  91. }
  92. private void InitializeComponent()
  93. {
  94. ComponentResourceManager manager = new ComponentResourceManager(typeof(ChangeProduct));
  95. this.btn_Cancle = new Button();
  96. this.btn_OK = new Button();
  97. this.groupBox1 = new GroupBox();
  98. this.dataGridView1 = new DataGridView();
  99. this.Ver = new DataGridViewTextBoxColumn();
  100. this.ProName = new DataGridViewTextBoxColumn();
  101. this.ParamName = new DataGridViewTextBoxColumn();
  102. this.Path = new DataGridViewTextBoxColumn();
  103. this.groupBox1.SuspendLayout();
  104. ((ISupportInitialize) this.dataGridView1).BeginInit();
  105. base.SuspendLayout();
  106. this.btn_Cancle.Location = new Point(0xe4, 0x128);
  107. this.btn_Cancle.Name = "btn_Cancle";
  108. this.btn_Cancle.Size = new Size(0x4b, 0x17);
  109. this.btn_Cancle.TabIndex = 5;
  110. this.btn_Cancle.Text = "关闭";
  111. this.btn_Cancle.UseVisualStyleBackColor = true;
  112. this.btn_Cancle.Click += new EventHandler(this.btn_Cancle_Click);
  113. this.btn_OK.Location = new Point(0x93, 0x128);
  114. this.btn_OK.Name = "btn_OK";
  115. this.btn_OK.Size = new Size(0x4b, 0x17);
  116. this.btn_OK.TabIndex = 4;
  117. this.btn_OK.Text = "启动";
  118. this.btn_OK.UseVisualStyleBackColor = true;
  119. this.btn_OK.Click += new EventHandler(this.btn_OK_Click);
  120. this.groupBox1.Controls.Add(this.dataGridView1);
  121. this.groupBox1.Location = new Point(11, 15);
  122. this.groupBox1.Name = "groupBox1";
  123. this.groupBox1.Size = new Size(0x12a, 0x113);
  124. this.groupBox1.TabIndex = 3;
  125. this.groupBox1.TabStop = false;
  126. this.groupBox1.Text = "已安装产品";
  127. this.dataGridView1.AllowUserToAddRows = false;
  128. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  129. this.dataGridView1.BorderStyle = BorderStyle.Fixed3D;
  130. this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  131. this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.Ver, this.ProName, this.ParamName, this.Path });
  132. this.dataGridView1.GridColor = System.Drawing.Color.White;
  133. this.dataGridView1.Location = new Point(6, 20);
  134. this.dataGridView1.MultiSelect = false;
  135. this.dataGridView1.Name = "dataGridView1";
  136. this.dataGridView1.ReadOnly = true;
  137. this.dataGridView1.RowHeadersVisible = false;
  138. this.dataGridView1.RowTemplate.Height = 0x17;
  139. this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  140. this.dataGridView1.Size = new Size(0x11e, 0xf9);
  141. this.dataGridView1.TabIndex = 0;
  142. this.Ver.DataPropertyName = "Ver";
  143. this.Ver.HeaderText = "版本";
  144. this.Ver.Name = "Ver";
  145. this.Ver.ReadOnly = true;
  146. this.Ver.Width = 120;
  147. this.ProName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
  148. this.ProName.DataPropertyName = "ProName";
  149. this.ProName.HeaderText = "名称";
  150. this.ProName.Name = "ProName";
  151. this.ProName.ReadOnly = true;
  152. this.ParamName.DataPropertyName = "ParamName";
  153. this.ParamName.HeaderText = "ParamName";
  154. this.ParamName.Name = "ParamName";
  155. this.ParamName.ReadOnly = true;
  156. this.ParamName.Visible = false;
  157. this.Path.DataPropertyName = "Path";
  158. this.Path.HeaderText = "路径";
  159. this.Path.Name = "Path";
  160. this.Path.ReadOnly = true;
  161. this.Path.Visible = false;
  162. base.AutoScaleDimensions = new SizeF(6f, 12f);
  163. base.ClientSize = new Size(0x141, 0x14c);
  164. base.Controls.Add(this.btn_Cancle);
  165. base.Controls.Add(this.btn_OK);
  166. base.Controls.Add(this.groupBox1);
  167. base.MaximizeBox = false;
  168. base.MinimizeBox = false;
  169. base.Name = "ChangeProduct";
  170. base.StartPosition = FormStartPosition.CenterScreen;
  171. this.Text = "产品切换";
  172. base.Load += new EventHandler(this.ChangeProduct_Load);
  173. this.groupBox1.ResumeLayout(false);
  174. ((ISupportInitialize) this.dataGridView1).EndInit();
  175. base.ResumeLayout(false);
  176. }
  177. public static Dictionary<string, string> ConfigParam
  178. {
  179. get
  180. {
  181. Dictionary<string, string> dictionary;
  182. if (_mConfigParam == null)
  183. {
  184. dictionary = new Dictionary<string, string>();
  185. dictionary.Add("TSRA", "TSRA");
  186. dictionary.Add("TSRS", "TSRS");
  187. dictionary.Add("TSPT", "TSPT");
  188. dictionary.Add("T3PT", "T3PT");
  189. dictionary.Add("TS3DSR", "TS3DSR");
  190. dictionary.Add("TSCC", "TSCC");
  191. dictionary.Add("TSCF", "TSCF");
  192. dictionary.Add("TSDCP", "TSDCP");
  193. dictionary.Add("TSRFA", "TSRFA");
  194. dictionary.Add("TSRMEP", "TSRMEP");
  195. dictionary.Add("地下特种结构", "TSIPS");
  196. }
  197. return (_mConfigParam = dictionary);
  198. }
  199. }
  200. public static Dictionary<string, string> ConfigProduct
  201. {
  202. get
  203. {
  204. Dictionary<string, string> dictionary;
  205. if (_mConfigProduct == null)
  206. {
  207. dictionary = new Dictionary<string, string>();
  208. dictionary.Add("TSRA", "TSRA");
  209. dictionary.Add("TSRS", "TSRS");
  210. dictionary.Add("TSPT", "TSPTREVIT");
  211. dictionary.Add("T3PT", "T3PTREVIT");
  212. dictionary.Add("TS3DSR", "TS3DSR");
  213. dictionary.Add("TSCC", "TSCC");
  214. dictionary.Add("TSCF", "TSCF");
  215. dictionary.Add("TSDCP", "TSDCP");
  216. dictionary.Add("TSRFA", "TSRFA");
  217. dictionary.Add("TSRMEP", "TSRMEP");
  218. dictionary.Add("地下特种结构", "TSIPS");
  219. }
  220. return (_mConfigProduct = dictionary);
  221. }
  222. }
  223. }
  224. }