FormulaSourceEditor.cs 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550
  1. namespace IndexFormula.Finance.Win
  2. {
  3. using IndexFormula.Finance;
  4. using MuchInfo.Chart.Data.EnumTypes;
  5. using System;
  6. using System.CodeDom.Compiler;
  7. using System.ComponentModel;
  8. using System.Drawing;
  9. using System.IO;
  10. using System.Windows;
  11. using System.Windows.Forms;
  12. [ToolboxItem(false)]
  13. public class FormulaSourceEditor : Form
  14. {
  15. private Button btnClose;
  16. private Button btnCompile;
  17. private Button btnDebug;
  18. private Button btnFormula;
  19. private Button btnInsertMethod;
  20. private CheckBox cbIsMainView;
  21. private CheckBox cbNotRealNameSpace;
  22. private ComboBox cbParamType;
  23. private IContainer components;
  24. private static FormulaSourceEditor CurrentEditor;
  25. private bool DisableChange;
  26. private string filename = "";
  27. private TreeView FormulaTree;
  28. private FormulaSpace fs;
  29. private ColumnHeader HeaderColumn;
  30. private ColumnHeader HeaderLine;
  31. private ColumnHeader HeaderMessage;
  32. private ColumnHeader HeaderName;
  33. private ColumnHeader HeaderNumber;
  34. private ImageList ilFormula;
  35. private TreeNode LastNode;
  36. private ListBox lbIntelliSence;
  37. private Label lDefaultValue;
  38. private Label lFormulaProgramCode;
  39. private Label lFormulaProgramDesc;
  40. private Label lFormulaProgramName;
  41. private Label lFullName;
  42. private Label lMaxValue;
  43. private Label lMinValue;
  44. private Label lNamespaceDescription;
  45. private Label lNamespaceName;
  46. private Label lOverride = new Label();
  47. private Label lParamDesc;
  48. private Label lParamName;
  49. private Label lParamType;
  50. private ListView lvErrors;
  51. private Label lVersion;
  52. private MenuItem menuItem1;
  53. private MenuItem menuItem4;
  54. private MenuItem miCompile;
  55. private MenuItem miExit;
  56. private MenuItem miNew;
  57. private MenuItem miOpen;
  58. private MenuItem miSave;
  59. private MenuItem miSaveAs;
  60. private MainMenu mmFumular;
  61. private bool modified;
  62. private OpenFileDialog odFormula;
  63. private Panel pnBottom;
  64. private Panel pnCode;
  65. private Panel pnFormula;
  66. private Panel pnNamespace;
  67. private Panel pnProgram;
  68. private Panel pnTop;
  69. private SaveFileDialog sdFormula;
  70. private Splitter spFormula;
  71. private Splitter spProgram;
  72. private TextBox tbDefaultValue;
  73. private RichTextBox tbFormulaProgramCode;
  74. private TextBox tbFormulaProgramDesc;
  75. private TextBox tbFormulaProgramName;
  76. private TextBox tbMaxValue;
  77. private TextBox tbMinValue;
  78. private TextBox tbNamespaceDesc;
  79. private TextBox tbNamespaceName;
  80. private TextBox tbParamDesc;
  81. private TextBox tbParamName;
  82. private TextBox tbProgramFullName;
  83. private TextBox tbVersion;
  84. private TabControl tcFormula;
  85. private TabPage tpFormulaProgram;
  86. private TabPage tpNamespace;
  87. private ContextMenuStrip cmTree;
  88. private ToolStripMenuItem miAddNamespace;
  89. private ToolStripMenuItem miAddFormulaProgram;
  90. private ToolStripMenuItem miAddParam;
  91. private ToolStripMenuItem miDeleteNode;
  92. private TabPage tpParameter;
  93. public FormulaSourceEditor()
  94. {
  95. this.InitializeComponent();
  96. this.fs = new FormulaSpace("FML");
  97. this.fs.Description = "Namespace description";
  98. this.fs.Version = "1.0.0.0";
  99. this.LoadToTree(this.fs);
  100. this.lOverride.Parent = this.pnFormula;
  101. this.lOverride.Width = 0x7d0;
  102. this.lOverride.Height = 0x18;
  103. this.lOverride.Top = this.tcFormula.Top;
  104. this.lOverride.Left = 0;
  105. this.lOverride.BringToFront();
  106. this.lOverride.BackColor = Color.WhiteSmoke;
  107. this.lOverride.Font = new Font("verdana", 11f, FontStyle.Bold);
  108. this.lOverride.ForeColor = Color.DarkGray;
  109. this.AddChangeEvent(this);
  110. }
  111. private void AddChangeEvent(Control c)
  112. {
  113. if (c is TextBox)
  114. {
  115. ((TextBox)c).TextChanged += new EventHandler(this.cbIsMainView_CheckedChanged);
  116. }
  117. else if (c is CheckBox)
  118. {
  119. ((CheckBox)c).TextChanged += new EventHandler(this.cbIsMainView_CheckedChanged);
  120. }
  121. else if (c is RichTextBox)
  122. {
  123. ((RichTextBox)c).TextChanged += new EventHandler(this.cbIsMainView_CheckedChanged);
  124. }
  125. foreach (Control control in c.Controls)
  126. {
  127. this.AddChangeEvent(control);
  128. }
  129. }
  130. private void AddError(CompilerErrorCollection ces, FormulaProgram fp)
  131. {
  132. this.lvErrors.Items.Clear();
  133. foreach (CompilerError error in ces)
  134. {
  135. ListViewItem item = null;
  136. if (fp != null)
  137. {
  138. item = this.lvErrors.Items.Add(fp.Name);
  139. item.Tag = fp;
  140. }
  141. else
  142. {
  143. FormulaProgram programByLineNum = this.fs.GetProgramByLineNum(error.Line);
  144. if (programByLineNum != null)
  145. {
  146. item = this.lvErrors.Items.Add(programByLineNum.Name);
  147. programByLineNum.AdjustErrors(error);
  148. item.Tag = programByLineNum;
  149. }
  150. else
  151. {
  152. item = this.lvErrors.Items.Add("");
  153. }
  154. }
  155. if (item != null)
  156. {
  157. item.SubItems.Add(error.Line.ToString());
  158. item.SubItems.Add(error.Column.ToString());
  159. item.SubItems.Add(error.ErrorNumber.ToString());
  160. item.SubItems.Add(error.ErrorText);
  161. }
  162. }
  163. }
  164. private void btnClose_Click(object sender, EventArgs e)
  165. {
  166. base.Close();
  167. }
  168. private void btnCompile_Click(object sender, EventArgs e)
  169. {
  170. this.Compile();
  171. }
  172. private void btnDebug_Click(object sender, EventArgs e)
  173. {
  174. FormulaProgram tag = (FormulaProgram)this.FormulaTree.SelectedNode.Tag;
  175. try
  176. {
  177. tag.Compile();
  178. this.lvErrors.Items.Clear();
  179. this.lvErrors.Items.Add("OK!");
  180. }
  181. catch (FormulaErrorException exception)
  182. {
  183. this.AddError(exception.ces, tag);
  184. }
  185. }
  186. private void btnFormula_Click(object sender, EventArgs e)
  187. {
  188. string str = new SelectFormula().Select(null, null, true);
  189. if (str != null)
  190. {
  191. Clipboard.SetDataObject("\"" + str + "\"");
  192. this.tbFormulaProgramCode.Paste();
  193. }
  194. }
  195. private void btnInsertMethod_Click(object sender, EventArgs e)
  196. {
  197. string data = new SelectMethod().Select(null);
  198. if (data != null)
  199. {
  200. Clipboard.SetDataObject(data);
  201. this.tbFormulaProgramCode.Paste();
  202. }
  203. }
  204. private void cbIsMainView_CheckedChanged(object sender, EventArgs e)
  205. {
  206. if (!this.DisableChange)
  207. {
  208. this.Modified = true;
  209. }
  210. }
  211. /// <summary>
  212. /// 编译成DLL
  213. /// </summary>
  214. /// <returns></returns>
  215. private bool Compile()
  216. {
  217. bool flag;
  218. try
  219. {
  220. long ticks = DateTime.Now.Ticks;
  221. this.SaveDataToNode();
  222. string curFileDir = Path.GetDirectoryName(this.filename);
  223. string curFileName = Path.GetFileName(this.filename);
  224. string sourceFile = string.Format("{0}\\{1}", curFileDir, curFileName.Replace('.', '_') + ".cs");
  225. string dllFile = string.Format("{0}\\{1}", curFileDir, curFileName.Replace('.', '_') + ".dll");
  226. this.fs.SaveCShartSource(sourceFile);
  227. string ReferenceRoot = Environment.CurrentDirectory;
  228. this.fs.Compile(dllFile, ReferenceRoot);
  229. this.lvErrors.Items.Clear();
  230. this.lvErrors.Items.Add("OK! - " + ((DateTime.Now.Ticks - ticks) / 0x2710L) + "ms");
  231. flag = true;
  232. }
  233. catch (FormulaErrorException exception)
  234. {
  235. this.AddError(exception.ces, null);
  236. flag = false;
  237. }
  238. finally
  239. {
  240. this.LocateFirstProgram();
  241. }
  242. return flag;
  243. }
  244. protected override void Dispose(bool disposing)
  245. {
  246. if (disposing && (this.components != null))
  247. {
  248. this.components.Dispose();
  249. }
  250. base.Dispose(disposing);
  251. }
  252. private TreeNode FindNode(TreeNode tn, FormulaProgram fp)
  253. {
  254. if (tn.Tag == fp)
  255. {
  256. return tn;
  257. }
  258. foreach (TreeNode node in tn.Nodes)
  259. {
  260. TreeNode node2 = this.FindNode(node, fp);
  261. if (node2 != null)
  262. {
  263. return node2;
  264. }
  265. }
  266. return null;
  267. }
  268. private TreeNode FindNode(TreeNode tn, string ProgramName)
  269. {
  270. if ((tn.Tag is FormulaProgram) && ((tn.Tag as FormulaProgram).Name == ProgramName))
  271. {
  272. return tn;
  273. }
  274. foreach (TreeNode node in tn.Nodes)
  275. {
  276. TreeNode node2 = this.FindNode(node, ProgramName);
  277. if (node2 != null)
  278. {
  279. return node2;
  280. }
  281. }
  282. return null;
  283. }
  284. private void FormulaEditor_Activated(object sender, EventArgs e)
  285. {
  286. this.tbFormulaProgramCode.Focus();
  287. }
  288. private void FormulaEditor_Closing(object sender, CancelEventArgs e)
  289. {
  290. if (this.Modified)
  291. {
  292. e.Cancel = true;
  293. }
  294. }
  295. private void FormulaEditor_Load(object sender, EventArgs e)
  296. {
  297. this.cbParamType.Items.Clear();
  298. this.cbParamType.Items.AddRange(Enum.GetNames(typeof(FormulaParamType)));
  299. string[] commandLineArgs = Environment.GetCommandLineArgs();
  300. if (commandLineArgs.Length == 2)
  301. {
  302. this.LoadEditor(commandLineArgs[1], null);
  303. }
  304. else if (commandLineArgs.Length == 3)
  305. {
  306. this.LoadEditor(commandLineArgs[1], commandLineArgs[2]);
  307. }
  308. }
  309. private void FormulaTree_AfterSelect(object sender, TreeViewEventArgs e)
  310. {
  311. this.DisableChange = true;
  312. try
  313. {
  314. if (e.Node.Tag is FormulaSpace)
  315. {
  316. FormulaSpace tag = (FormulaSpace)e.Node.Tag;
  317. if (e.Node.Parent == null && tag.Name == "FML")
  318. {
  319. tbNamespaceName.Enabled = false;
  320. cbNotRealNameSpace.Enabled = false;
  321. }
  322. else
  323. {
  324. tbNamespaceName.Enabled = true;
  325. cbNotRealNameSpace.Enabled = true;
  326. }
  327. this.tbNamespaceName.Text = tag.Name;
  328. this.tbNamespaceDesc.Text = tag.Description;
  329. this.tbVersion.Visible = e.Node.Parent == null;
  330. this.lVersion.Visible = this.tbVersion.Visible;
  331. this.tbVersion.Text = tag.Version;
  332. this.cbNotRealNameSpace.Checked = tag.GroupOnly;
  333. this.tcFormula.SelectedTab = this.tpNamespace;
  334. this.lOverride.Text = "Namespace properties:" + tag.Name;
  335. }
  336. else if (e.Node.Tag is FormulaProgram)
  337. {
  338. FormulaProgram program = (FormulaProgram)e.Node.Tag;
  339. this.tbFormulaProgramName.Text = program.Name;
  340. this.tbProgramFullName.Text = program.FullName;
  341. if (program.Code != null)
  342. {
  343. this.tbFormulaProgramCode.Lines = this.Trim(program.Code.Split(new char[] { '\n' }));
  344. }
  345. else
  346. {
  347. this.tbFormulaProgramCode.Text = "";
  348. }
  349. if (program.Description != null)
  350. {
  351. this.tbFormulaProgramDesc.Lines = this.Trim(program.Description.Split(new char[] { '\n' }));
  352. }
  353. else
  354. {
  355. this.tbFormulaProgramDesc.Text = "";
  356. }
  357. this.cbIsMainView.Checked = program.IsMainView;
  358. this.tcFormula.SelectedTab = this.tpFormulaProgram;
  359. this.lOverride.Text = "Formula script code:" + program.Name;
  360. }
  361. else if (e.Node.Tag is FormulaParam)
  362. {
  363. FormulaParam param = (FormulaParam)e.Node.Tag;
  364. this.tbParamName.Text = param.Name;
  365. this.tbParamDesc.Text = param.Description;
  366. this.tbMinValue.Text = param.MinValue;
  367. this.tbMaxValue.Text = param.MaxValue;
  368. this.tbDefaultValue.Text = param.DefaultValue;
  369. this.cbParamType.SelectedIndex = (int)param.ParamType;
  370. this.tcFormula.SelectedTab = this.tpParameter;
  371. this.lOverride.Text = "Formula script parameter:" + param.Name;
  372. }
  373. this.FormulaTree.Focus();
  374. this.LastNode = e.Node;
  375. }
  376. finally
  377. {
  378. this.DisableChange = false;
  379. }
  380. }
  381. private void FormulaTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
  382. {
  383. this.SaveDataToNode(this.LastNode);
  384. }
  385. private void FormulaTree_MouseDown(object sender, MouseEventArgs e)
  386. {
  387. if (e.Button == MouseButtons.Right)
  388. {
  389. TreeNode nodeAt = this.FormulaTree.GetNodeAt(e.X, e.Y);
  390. if (nodeAt == null)
  391. {
  392. nodeAt = this.FormulaTree.SelectedNode;
  393. }
  394. else
  395. {
  396. this.FormulaTree.SelectedNode = nodeAt;
  397. }
  398. if (nodeAt.Tag is FormulaSpace)
  399. {
  400. this.miAddFormulaProgram.Visible = true;
  401. this.miAddNamespace.Visible = true;
  402. this.miAddParam.Visible = false;
  403. }
  404. else if (nodeAt.Tag is FormulaProgram)
  405. {
  406. this.miAddFormulaProgram.Visible = false;
  407. this.miAddNamespace.Visible = false;
  408. this.miAddParam.Visible = true;
  409. }
  410. else if (nodeAt.Tag is FormulaParam)
  411. {
  412. this.miAddFormulaProgram.Visible = false;
  413. this.miAddNamespace.Visible = false;
  414. this.miAddParam.Visible = false;
  415. }
  416. this.cmTree.Show(this.FormulaTree, new Point(e.X, e.Y));
  417. }
  418. }
  419. private void InitializeComponent()
  420. {
  421. this.components = new System.ComponentModel.Container();
  422. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormulaSourceEditor));
  423. this.FormulaTree = new System.Windows.Forms.TreeView();
  424. this.ilFormula = new System.Windows.Forms.ImageList(this.components);
  425. this.tcFormula = new System.Windows.Forms.TabControl();
  426. this.tpNamespace = new System.Windows.Forms.TabPage();
  427. this.pnNamespace = new System.Windows.Forms.Panel();
  428. this.cmTree = new System.Windows.Forms.ContextMenuStrip(this.components);
  429. this.miAddNamespace = new System.Windows.Forms.ToolStripMenuItem();
  430. this.miAddFormulaProgram = new System.Windows.Forms.ToolStripMenuItem();
  431. this.miAddParam = new System.Windows.Forms.ToolStripMenuItem();
  432. this.miDeleteNode = new System.Windows.Forms.ToolStripMenuItem();
  433. this.tbVersion = new System.Windows.Forms.TextBox();
  434. this.lVersion = new System.Windows.Forms.Label();
  435. this.cbNotRealNameSpace = new System.Windows.Forms.CheckBox();
  436. this.lNamespaceDescription = new System.Windows.Forms.Label();
  437. this.tbNamespaceDesc = new System.Windows.Forms.TextBox();
  438. this.lNamespaceName = new System.Windows.Forms.Label();
  439. this.tbNamespaceName = new System.Windows.Forms.TextBox();
  440. this.tpFormulaProgram = new System.Windows.Forms.TabPage();
  441. this.spProgram = new System.Windows.Forms.Splitter();
  442. this.pnProgram = new System.Windows.Forms.Panel();
  443. this.btnFormula = new System.Windows.Forms.Button();
  444. this.btnInsertMethod = new System.Windows.Forms.Button();
  445. this.btnCompile = new System.Windows.Forms.Button();
  446. this.lbIntelliSence = new System.Windows.Forms.ListBox();
  447. this.lFullName = new System.Windows.Forms.Label();
  448. this.tbProgramFullName = new System.Windows.Forms.TextBox();
  449. this.btnDebug = new System.Windows.Forms.Button();
  450. this.lFormulaProgramDesc = new System.Windows.Forms.Label();
  451. this.tbFormulaProgramDesc = new System.Windows.Forms.TextBox();
  452. this.cbIsMainView = new System.Windows.Forms.CheckBox();
  453. this.tbFormulaProgramName = new System.Windows.Forms.TextBox();
  454. this.lFormulaProgramName = new System.Windows.Forms.Label();
  455. this.lFormulaProgramCode = new System.Windows.Forms.Label();
  456. this.pnCode = new System.Windows.Forms.Panel();
  457. this.tbFormulaProgramCode = new System.Windows.Forms.RichTextBox();
  458. this.lvErrors = new System.Windows.Forms.ListView();
  459. this.HeaderName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  460. this.HeaderLine = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  461. this.HeaderColumn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  462. this.HeaderNumber = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  463. this.HeaderMessage = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  464. this.tpParameter = new System.Windows.Forms.TabPage();
  465. this.cbParamType = new System.Windows.Forms.ComboBox();
  466. this.lParamType = new System.Windows.Forms.Label();
  467. this.tbParamDesc = new System.Windows.Forms.TextBox();
  468. this.lParamDesc = new System.Windows.Forms.Label();
  469. this.tbParamName = new System.Windows.Forms.TextBox();
  470. this.lParamName = new System.Windows.Forms.Label();
  471. this.tbMaxValue = new System.Windows.Forms.TextBox();
  472. this.tbMinValue = new System.Windows.Forms.TextBox();
  473. this.tbDefaultValue = new System.Windows.Forms.TextBox();
  474. this.lDefaultValue = new System.Windows.Forms.Label();
  475. this.lMaxValue = new System.Windows.Forms.Label();
  476. this.lMinValue = new System.Windows.Forms.Label();
  477. this.mmFumular = new System.Windows.Forms.MainMenu(this.components);
  478. this.menuItem1 = new System.Windows.Forms.MenuItem();
  479. this.miNew = new System.Windows.Forms.MenuItem();
  480. this.miOpen = new System.Windows.Forms.MenuItem();
  481. this.miSave = new System.Windows.Forms.MenuItem();
  482. this.miSaveAs = new System.Windows.Forms.MenuItem();
  483. this.miCompile = new System.Windows.Forms.MenuItem();
  484. this.menuItem4 = new System.Windows.Forms.MenuItem();
  485. this.miExit = new System.Windows.Forms.MenuItem();
  486. this.odFormula = new System.Windows.Forms.OpenFileDialog();
  487. this.sdFormula = new System.Windows.Forms.SaveFileDialog();
  488. this.pnFormula = new System.Windows.Forms.Panel();
  489. this.pnTop = new System.Windows.Forms.Panel();
  490. this.spFormula = new System.Windows.Forms.Splitter();
  491. this.pnBottom = new System.Windows.Forms.Panel();
  492. this.btnClose = new System.Windows.Forms.Button();
  493. this.tcFormula.SuspendLayout();
  494. this.tpNamespace.SuspendLayout();
  495. this.pnNamespace.SuspendLayout();
  496. this.cmTree.SuspendLayout();
  497. this.tpFormulaProgram.SuspendLayout();
  498. this.pnProgram.SuspendLayout();
  499. this.pnCode.SuspendLayout();
  500. this.tpParameter.SuspendLayout();
  501. this.pnFormula.SuspendLayout();
  502. this.pnTop.SuspendLayout();
  503. this.pnBottom.SuspendLayout();
  504. this.SuspendLayout();
  505. //
  506. // FormulaTree
  507. //
  508. resources.ApplyResources(this.FormulaTree, "FormulaTree");
  509. this.FormulaTree.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  510. this.FormulaTree.FullRowSelect = true;
  511. this.FormulaTree.HideSelection = false;
  512. this.FormulaTree.ImageList = this.ilFormula;
  513. this.FormulaTree.Name = "FormulaTree";
  514. this.FormulaTree.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.FormulaTree_BeforeSelect);
  515. this.FormulaTree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.FormulaTree_AfterSelect);
  516. this.FormulaTree.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FormulaTree_MouseDown);
  517. //
  518. // ilFormula
  519. //
  520. this.ilFormula.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilFormula.ImageStream")));
  521. this.ilFormula.TransparentColor = System.Drawing.Color.Transparent;
  522. this.ilFormula.Images.SetKeyName(0, "");
  523. this.ilFormula.Images.SetKeyName(1, "");
  524. this.ilFormula.Images.SetKeyName(2, "");
  525. //
  526. // tcFormula
  527. //
  528. resources.ApplyResources(this.tcFormula, "tcFormula");
  529. this.tcFormula.AllowDrop = true;
  530. this.tcFormula.Controls.Add(this.tpNamespace);
  531. this.tcFormula.Controls.Add(this.tpFormulaProgram);
  532. this.tcFormula.Controls.Add(this.tpParameter);
  533. this.tcFormula.Name = "tcFormula";
  534. this.tcFormula.SelectedIndex = 0;
  535. this.tcFormula.TabStop = false;
  536. //
  537. // tpNamespace
  538. //
  539. resources.ApplyResources(this.tpNamespace, "tpNamespace");
  540. this.tpNamespace.Controls.Add(this.pnNamespace);
  541. this.tpNamespace.Name = "tpNamespace";
  542. //
  543. // pnNamespace
  544. //
  545. resources.ApplyResources(this.pnNamespace, "pnNamespace");
  546. this.pnNamespace.ContextMenuStrip = this.cmTree;
  547. this.pnNamespace.Controls.Add(this.tbVersion);
  548. this.pnNamespace.Controls.Add(this.lVersion);
  549. this.pnNamespace.Controls.Add(this.cbNotRealNameSpace);
  550. this.pnNamespace.Controls.Add(this.lNamespaceDescription);
  551. this.pnNamespace.Controls.Add(this.tbNamespaceDesc);
  552. this.pnNamespace.Controls.Add(this.lNamespaceName);
  553. this.pnNamespace.Controls.Add(this.tbNamespaceName);
  554. this.pnNamespace.Name = "pnNamespace";
  555. //
  556. // cmTree
  557. //
  558. resources.ApplyResources(this.cmTree, "cmTree");
  559. this.cmTree.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  560. this.miAddNamespace,
  561. this.miAddFormulaProgram,
  562. this.miAddParam,
  563. this.miDeleteNode});
  564. this.cmTree.Name = "cmTree";
  565. //
  566. // miAddNamespace
  567. //
  568. resources.ApplyResources(this.miAddNamespace, "miAddNamespace");
  569. this.miAddNamespace.Name = "miAddNamespace";
  570. this.miAddNamespace.Click += new System.EventHandler(this.miAddNamespace_Click);
  571. //
  572. // miAddFormulaProgram
  573. //
  574. resources.ApplyResources(this.miAddFormulaProgram, "miAddFormulaProgram");
  575. this.miAddFormulaProgram.Name = "miAddFormulaProgram";
  576. this.miAddFormulaProgram.Click += new System.EventHandler(this.miAddFormulaProgram_Click);
  577. //
  578. // miAddParam
  579. //
  580. resources.ApplyResources(this.miAddParam, "miAddParam");
  581. this.miAddParam.Name = "miAddParam";
  582. this.miAddParam.Click += new System.EventHandler(this.miAddParam_Click);
  583. //
  584. // miDeleteNode
  585. //
  586. resources.ApplyResources(this.miDeleteNode, "miDeleteNode");
  587. this.miDeleteNode.Name = "miDeleteNode";
  588. this.miDeleteNode.Click += new System.EventHandler(this.miDeleteNode_Click);
  589. //
  590. // tbVersion
  591. //
  592. resources.ApplyResources(this.tbVersion, "tbVersion");
  593. this.tbVersion.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  594. this.tbVersion.Name = "tbVersion";
  595. //
  596. // lVersion
  597. //
  598. resources.ApplyResources(this.lVersion, "lVersion");
  599. this.lVersion.Name = "lVersion";
  600. //
  601. // cbNotRealNameSpace
  602. //
  603. resources.ApplyResources(this.cbNotRealNameSpace, "cbNotRealNameSpace");
  604. this.cbNotRealNameSpace.Name = "cbNotRealNameSpace";
  605. //
  606. // lNamespaceDescription
  607. //
  608. resources.ApplyResources(this.lNamespaceDescription, "lNamespaceDescription");
  609. this.lNamespaceDescription.BackColor = System.Drawing.SystemColors.Control;
  610. this.lNamespaceDescription.Name = "lNamespaceDescription";
  611. //
  612. // tbNamespaceDesc
  613. //
  614. resources.ApplyResources(this.tbNamespaceDesc, "tbNamespaceDesc");
  615. this.tbNamespaceDesc.BackColor = System.Drawing.SystemColors.Info;
  616. this.tbNamespaceDesc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  617. this.tbNamespaceDesc.Name = "tbNamespaceDesc";
  618. //
  619. // lNamespaceName
  620. //
  621. resources.ApplyResources(this.lNamespaceName, "lNamespaceName");
  622. this.lNamespaceName.BackColor = System.Drawing.SystemColors.Control;
  623. this.lNamespaceName.Name = "lNamespaceName";
  624. //
  625. // tbNamespaceName
  626. //
  627. resources.ApplyResources(this.tbNamespaceName, "tbNamespaceName");
  628. this.tbNamespaceName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  629. this.tbNamespaceName.Name = "tbNamespaceName";
  630. //
  631. // tpFormulaProgram
  632. //
  633. resources.ApplyResources(this.tpFormulaProgram, "tpFormulaProgram");
  634. this.tpFormulaProgram.Controls.Add(this.spProgram);
  635. this.tpFormulaProgram.Controls.Add(this.pnProgram);
  636. this.tpFormulaProgram.Controls.Add(this.lvErrors);
  637. this.tpFormulaProgram.Name = "tpFormulaProgram";
  638. //
  639. // spProgram
  640. //
  641. resources.ApplyResources(this.spProgram, "spProgram");
  642. this.spProgram.Name = "spProgram";
  643. this.spProgram.TabStop = false;
  644. //
  645. // pnProgram
  646. //
  647. resources.ApplyResources(this.pnProgram, "pnProgram");
  648. this.pnProgram.Controls.Add(this.btnFormula);
  649. this.pnProgram.Controls.Add(this.btnInsertMethod);
  650. this.pnProgram.Controls.Add(this.btnCompile);
  651. this.pnProgram.Controls.Add(this.lbIntelliSence);
  652. this.pnProgram.Controls.Add(this.lFullName);
  653. this.pnProgram.Controls.Add(this.tbProgramFullName);
  654. this.pnProgram.Controls.Add(this.btnDebug);
  655. this.pnProgram.Controls.Add(this.lFormulaProgramDesc);
  656. this.pnProgram.Controls.Add(this.tbFormulaProgramDesc);
  657. this.pnProgram.Controls.Add(this.cbIsMainView);
  658. this.pnProgram.Controls.Add(this.tbFormulaProgramName);
  659. this.pnProgram.Controls.Add(this.lFormulaProgramName);
  660. this.pnProgram.Controls.Add(this.lFormulaProgramCode);
  661. this.pnProgram.Controls.Add(this.pnCode);
  662. this.pnProgram.Name = "pnProgram";
  663. //
  664. // btnFormula
  665. //
  666. resources.ApplyResources(this.btnFormula, "btnFormula");
  667. this.btnFormula.Name = "btnFormula";
  668. this.btnFormula.Click += new System.EventHandler(this.btnFormula_Click);
  669. //
  670. // btnInsertMethod
  671. //
  672. resources.ApplyResources(this.btnInsertMethod, "btnInsertMethod");
  673. this.btnInsertMethod.Name = "btnInsertMethod";
  674. this.btnInsertMethod.Click += new System.EventHandler(this.btnInsertMethod_Click);
  675. //
  676. // btnCompile
  677. //
  678. resources.ApplyResources(this.btnCompile, "btnCompile");
  679. this.btnCompile.Name = "btnCompile";
  680. this.btnCompile.Click += new System.EventHandler(this.btnCompile_Click);
  681. //
  682. // lbIntelliSence
  683. //
  684. resources.ApplyResources(this.lbIntelliSence, "lbIntelliSence");
  685. this.lbIntelliSence.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  686. this.lbIntelliSence.Name = "lbIntelliSence";
  687. this.lbIntelliSence.TabStop = false;
  688. this.lbIntelliSence.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lbIntelliSence_KeyDown);
  689. //
  690. // lFullName
  691. //
  692. resources.ApplyResources(this.lFullName, "lFullName");
  693. this.lFullName.Name = "lFullName";
  694. //
  695. // tbProgramFullName
  696. //
  697. resources.ApplyResources(this.tbProgramFullName, "tbProgramFullName");
  698. this.tbProgramFullName.BackColor = System.Drawing.Color.SeaShell;
  699. this.tbProgramFullName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  700. this.tbProgramFullName.Name = "tbProgramFullName";
  701. //
  702. // btnDebug
  703. //
  704. resources.ApplyResources(this.btnDebug, "btnDebug");
  705. this.btnDebug.Name = "btnDebug";
  706. this.btnDebug.Click += new System.EventHandler(this.btnDebug_Click);
  707. //
  708. // lFormulaProgramDesc
  709. //
  710. resources.ApplyResources(this.lFormulaProgramDesc, "lFormulaProgramDesc");
  711. this.lFormulaProgramDesc.Name = "lFormulaProgramDesc";
  712. //
  713. // tbFormulaProgramDesc
  714. //
  715. resources.ApplyResources(this.tbFormulaProgramDesc, "tbFormulaProgramDesc");
  716. this.tbFormulaProgramDesc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  717. this.tbFormulaProgramDesc.Name = "tbFormulaProgramDesc";
  718. this.tbFormulaProgramDesc.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  719. //
  720. // cbIsMainView
  721. //
  722. resources.ApplyResources(this.cbIsMainView, "cbIsMainView");
  723. this.cbIsMainView.Name = "cbIsMainView";
  724. this.cbIsMainView.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  725. //
  726. // tbFormulaProgramName
  727. //
  728. resources.ApplyResources(this.tbFormulaProgramName, "tbFormulaProgramName");
  729. this.tbFormulaProgramName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  730. this.tbFormulaProgramName.Name = "tbFormulaProgramName";
  731. this.tbFormulaProgramName.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  732. //
  733. // lFormulaProgramName
  734. //
  735. resources.ApplyResources(this.lFormulaProgramName, "lFormulaProgramName");
  736. this.lFormulaProgramName.Name = "lFormulaProgramName";
  737. //
  738. // lFormulaProgramCode
  739. //
  740. resources.ApplyResources(this.lFormulaProgramCode, "lFormulaProgramCode");
  741. this.lFormulaProgramCode.Name = "lFormulaProgramCode";
  742. //
  743. // pnCode
  744. //
  745. resources.ApplyResources(this.pnCode, "pnCode");
  746. this.pnCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  747. this.pnCode.Controls.Add(this.tbFormulaProgramCode);
  748. this.pnCode.Name = "pnCode";
  749. this.pnCode.TabStop = true;
  750. //
  751. // tbFormulaProgramCode
  752. //
  753. resources.ApplyResources(this.tbFormulaProgramCode, "tbFormulaProgramCode");
  754. this.tbFormulaProgramCode.BackColor = System.Drawing.SystemColors.Info;
  755. this.tbFormulaProgramCode.BorderStyle = System.Windows.Forms.BorderStyle.None;
  756. this.tbFormulaProgramCode.Name = "tbFormulaProgramCode";
  757. this.tbFormulaProgramCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbFormulaProgramCode_KeyDown);
  758. this.tbFormulaProgramCode.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  759. //
  760. // lvErrors
  761. //
  762. resources.ApplyResources(this.lvErrors, "lvErrors");
  763. this.lvErrors.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  764. this.lvErrors.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  765. this.HeaderName,
  766. this.HeaderLine,
  767. this.HeaderColumn,
  768. this.HeaderNumber,
  769. this.HeaderMessage});
  770. this.lvErrors.FullRowSelect = true;
  771. this.lvErrors.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
  772. this.lvErrors.Name = "lvErrors";
  773. this.lvErrors.UseCompatibleStateImageBehavior = false;
  774. this.lvErrors.View = System.Windows.Forms.View.Details;
  775. this.lvErrors.DoubleClick += new System.EventHandler(this.lvErrors_DoubleClick);
  776. //
  777. // HeaderName
  778. //
  779. resources.ApplyResources(this.HeaderName, "HeaderName");
  780. //
  781. // HeaderLine
  782. //
  783. resources.ApplyResources(this.HeaderLine, "HeaderLine");
  784. //
  785. // HeaderColumn
  786. //
  787. resources.ApplyResources(this.HeaderColumn, "HeaderColumn");
  788. //
  789. // HeaderNumber
  790. //
  791. resources.ApplyResources(this.HeaderNumber, "HeaderNumber");
  792. //
  793. // HeaderMessage
  794. //
  795. resources.ApplyResources(this.HeaderMessage, "HeaderMessage");
  796. //
  797. // tpParameter
  798. //
  799. resources.ApplyResources(this.tpParameter, "tpParameter");
  800. this.tpParameter.Controls.Add(this.cbParamType);
  801. this.tpParameter.Controls.Add(this.lParamType);
  802. this.tpParameter.Controls.Add(this.tbParamDesc);
  803. this.tpParameter.Controls.Add(this.lParamDesc);
  804. this.tpParameter.Controls.Add(this.tbParamName);
  805. this.tpParameter.Controls.Add(this.lParamName);
  806. this.tpParameter.Controls.Add(this.tbMaxValue);
  807. this.tpParameter.Controls.Add(this.tbMinValue);
  808. this.tpParameter.Controls.Add(this.tbDefaultValue);
  809. this.tpParameter.Controls.Add(this.lDefaultValue);
  810. this.tpParameter.Controls.Add(this.lMaxValue);
  811. this.tpParameter.Controls.Add(this.lMinValue);
  812. this.tpParameter.Name = "tpParameter";
  813. //
  814. // cbParamType
  815. //
  816. resources.ApplyResources(this.cbParamType, "cbParamType");
  817. this.cbParamType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  818. this.cbParamType.Name = "cbParamType";
  819. //
  820. // lParamType
  821. //
  822. resources.ApplyResources(this.lParamType, "lParamType");
  823. this.lParamType.Name = "lParamType";
  824. //
  825. // tbParamDesc
  826. //
  827. resources.ApplyResources(this.tbParamDesc, "tbParamDesc");
  828. this.tbParamDesc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  829. this.tbParamDesc.Name = "tbParamDesc";
  830. this.tbParamDesc.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  831. //
  832. // lParamDesc
  833. //
  834. resources.ApplyResources(this.lParamDesc, "lParamDesc");
  835. this.lParamDesc.Name = "lParamDesc";
  836. //
  837. // tbParamName
  838. //
  839. resources.ApplyResources(this.tbParamName, "tbParamName");
  840. this.tbParamName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  841. this.tbParamName.Name = "tbParamName";
  842. this.tbParamName.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  843. //
  844. // lParamName
  845. //
  846. resources.ApplyResources(this.lParamName, "lParamName");
  847. this.lParamName.Name = "lParamName";
  848. //
  849. // tbMaxValue
  850. //
  851. resources.ApplyResources(this.tbMaxValue, "tbMaxValue");
  852. this.tbMaxValue.BackColor = System.Drawing.SystemColors.Info;
  853. this.tbMaxValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  854. this.tbMaxValue.Name = "tbMaxValue";
  855. this.tbMaxValue.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  856. //
  857. // tbMinValue
  858. //
  859. resources.ApplyResources(this.tbMinValue, "tbMinValue");
  860. this.tbMinValue.BackColor = System.Drawing.SystemColors.Info;
  861. this.tbMinValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  862. this.tbMinValue.Name = "tbMinValue";
  863. this.tbMinValue.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  864. //
  865. // tbDefaultValue
  866. //
  867. resources.ApplyResources(this.tbDefaultValue, "tbDefaultValue");
  868. this.tbDefaultValue.BackColor = System.Drawing.SystemColors.Info;
  869. this.tbDefaultValue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  870. this.tbDefaultValue.Name = "tbDefaultValue";
  871. this.tbDefaultValue.Leave += new System.EventHandler(this.tbFormulaProgramCode_Leave);
  872. //
  873. // lDefaultValue
  874. //
  875. resources.ApplyResources(this.lDefaultValue, "lDefaultValue");
  876. this.lDefaultValue.Name = "lDefaultValue";
  877. //
  878. // lMaxValue
  879. //
  880. resources.ApplyResources(this.lMaxValue, "lMaxValue");
  881. this.lMaxValue.Name = "lMaxValue";
  882. //
  883. // lMinValue
  884. //
  885. resources.ApplyResources(this.lMinValue, "lMinValue");
  886. this.lMinValue.Name = "lMinValue";
  887. //
  888. // mmFumular
  889. //
  890. this.mmFumular.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  891. this.menuItem1});
  892. resources.ApplyResources(this.mmFumular, "mmFumular");
  893. //
  894. // menuItem1
  895. //
  896. resources.ApplyResources(this.menuItem1, "menuItem1");
  897. this.menuItem1.Index = 0;
  898. this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  899. this.miNew,
  900. this.miOpen,
  901. this.miSave,
  902. this.miSaveAs,
  903. this.miCompile,
  904. this.menuItem4,
  905. this.miExit});
  906. //
  907. // miNew
  908. //
  909. resources.ApplyResources(this.miNew, "miNew");
  910. this.miNew.Index = 0;
  911. this.miNew.Click += new System.EventHandler(this.miNew_Click);
  912. //
  913. // miOpen
  914. //
  915. resources.ApplyResources(this.miOpen, "miOpen");
  916. this.miOpen.Index = 1;
  917. this.miOpen.Click += new System.EventHandler(this.miOpen_Click);
  918. //
  919. // miSave
  920. //
  921. resources.ApplyResources(this.miSave, "miSave");
  922. this.miSave.Index = 2;
  923. this.miSave.Click += new System.EventHandler(this.miSave_Click);
  924. //
  925. // miSaveAs
  926. //
  927. resources.ApplyResources(this.miSaveAs, "miSaveAs");
  928. this.miSaveAs.Index = 3;
  929. this.miSaveAs.Click += new System.EventHandler(this.miSaveAs_Click);
  930. //
  931. // miCompile
  932. //
  933. resources.ApplyResources(this.miCompile, "miCompile");
  934. this.miCompile.Index = 4;
  935. this.miCompile.Click += new System.EventHandler(this.miCompile_Click);
  936. //
  937. // menuItem4
  938. //
  939. resources.ApplyResources(this.menuItem4, "menuItem4");
  940. this.menuItem4.Index = 5;
  941. //
  942. // miExit
  943. //
  944. resources.ApplyResources(this.miExit, "miExit");
  945. this.miExit.Index = 6;
  946. this.miExit.Click += new System.EventHandler(this.miExit_Click);
  947. //
  948. // odFormula
  949. //
  950. this.odFormula.DefaultExt = "fml";
  951. resources.ApplyResources(this.odFormula, "odFormula");
  952. this.odFormula.RestoreDirectory = true;
  953. //
  954. // sdFormula
  955. //
  956. this.sdFormula.DefaultExt = "fml";
  957. resources.ApplyResources(this.sdFormula, "sdFormula");
  958. this.sdFormula.RestoreDirectory = true;
  959. //
  960. // pnFormula
  961. //
  962. resources.ApplyResources(this.pnFormula, "pnFormula");
  963. this.pnFormula.Controls.Add(this.tcFormula);
  964. this.pnFormula.Name = "pnFormula";
  965. //
  966. // pnTop
  967. //
  968. resources.ApplyResources(this.pnTop, "pnTop");
  969. this.pnTop.Controls.Add(this.pnFormula);
  970. this.pnTop.Controls.Add(this.spFormula);
  971. this.pnTop.Controls.Add(this.FormulaTree);
  972. this.pnTop.Name = "pnTop";
  973. //
  974. // spFormula
  975. //
  976. resources.ApplyResources(this.spFormula, "spFormula");
  977. this.spFormula.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
  978. this.spFormula.Name = "spFormula";
  979. this.spFormula.TabStop = false;
  980. //
  981. // pnBottom
  982. //
  983. resources.ApplyResources(this.pnBottom, "pnBottom");
  984. this.pnBottom.Controls.Add(this.btnClose);
  985. this.pnBottom.Name = "pnBottom";
  986. //
  987. // btnClose
  988. //
  989. resources.ApplyResources(this.btnClose, "btnClose");
  990. this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  991. this.btnClose.Name = "btnClose";
  992. this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
  993. //
  994. // FormulaSourceEditor
  995. //
  996. resources.ApplyResources(this, "$this");
  997. this.CancelButton = this.btnClose;
  998. this.Controls.Add(this.pnTop);
  999. this.Controls.Add(this.pnBottom);
  1000. this.Menu = this.mmFumular;
  1001. this.Name = "FormulaSourceEditor";
  1002. this.Activated += new System.EventHandler(this.FormulaEditor_Activated);
  1003. this.Closing += new System.ComponentModel.CancelEventHandler(this.FormulaEditor_Closing);
  1004. this.Load += new System.EventHandler(this.FormulaEditor_Load);
  1005. this.Click += new System.EventHandler(this.btnDebug_Click);
  1006. this.tcFormula.ResumeLayout(false);
  1007. this.tpNamespace.ResumeLayout(false);
  1008. this.pnNamespace.ResumeLayout(false);
  1009. this.pnNamespace.PerformLayout();
  1010. this.cmTree.ResumeLayout(false);
  1011. this.tpFormulaProgram.ResumeLayout(false);
  1012. this.pnProgram.ResumeLayout(false);
  1013. this.pnProgram.PerformLayout();
  1014. this.pnCode.ResumeLayout(false);
  1015. this.tpParameter.ResumeLayout(false);
  1016. this.tpParameter.PerformLayout();
  1017. this.pnFormula.ResumeLayout(false);
  1018. this.pnTop.ResumeLayout(false);
  1019. this.pnBottom.ResumeLayout(false);
  1020. this.ResumeLayout(false);
  1021. }
  1022. private void lbIntelliSence_KeyDown(object sender, KeyEventArgs e)
  1023. {
  1024. if (e.KeyCode == Keys.Escape)
  1025. {
  1026. this.lbIntelliSence.Visible = false;
  1027. }
  1028. else if (e.KeyCode == Keys.Enter)
  1029. {
  1030. Clipboard.SetDataObject(this.lbIntelliSence.SelectedItem.ToString());
  1031. this.tbFormulaProgramCode.Paste();
  1032. this.lbIntelliSence.Visible = false;
  1033. }
  1034. }
  1035. private void LoadEditor(string Filename, string Formula)
  1036. {
  1037. if (File.Exists(Filename))
  1038. {
  1039. this.LoadFromFile(Filename);
  1040. if (Formula != null)
  1041. {
  1042. int num = Formula.LastIndexOf('.');
  1043. if (num >= 0)
  1044. {
  1045. Formula = Formula.Substring(num + 1);
  1046. }
  1047. TreeNode node = this.FindNode(this.FormulaTree.Nodes[0], Formula);
  1048. if (node != null)
  1049. {
  1050. this.FormulaTree.SelectedNode = node;
  1051. this.FormulaTree.SelectedNode.Expand();
  1052. }
  1053. }
  1054. }
  1055. base.ShowDialog();
  1056. }
  1057. private void LoadFromFile(string FileName)
  1058. {
  1059. if (File.Exists(FileName))
  1060. {
  1061. this.fs = FormulaSpace.Read(FileName);
  1062. this.fs.AddVersion();
  1063. this.Filename = FileName;
  1064. this.sdFormula.FileName = this.Filename;
  1065. this.LoadToTree(this.fs);
  1066. this.Modified = false;
  1067. this.FormulaTree.Nodes[0].Expand();
  1068. }
  1069. }
  1070. private void LoadToTree(FormulaSpace fs)
  1071. {
  1072. this.FormulaTree.BeginUpdate();
  1073. try
  1074. {
  1075. this.FormulaTree.Nodes.Clear();
  1076. TreeNode node = new TreeNode("FML", 0, 0);
  1077. this.FormulaTree.Nodes.Add(node);
  1078. this.LoadToTree(this.FormulaTree.Nodes[0], fs);
  1079. }
  1080. finally
  1081. {
  1082. this.FormulaTree.EndUpdate();
  1083. }
  1084. this.FormulaTree.SelectedNode = this.FormulaTree.TopNode;
  1085. }
  1086. private void LoadToTree(TreeNode tn, FormulaParam fp)
  1087. {
  1088. tn.Text = fp.Name;
  1089. tn.Tag = fp;
  1090. }
  1091. private void LoadToTree(TreeNode tn, FormulaProgram p)
  1092. {
  1093. tn.Text = p.Name;
  1094. tn.Tag = p;
  1095. foreach (FormulaParam param in p.Params)
  1096. {
  1097. TreeNode node = new TreeNode();
  1098. node.ImageIndex = 2;
  1099. node.SelectedImageIndex = 2;
  1100. tn.Nodes.Add(node);
  1101. this.LoadToTree(node, param);
  1102. }
  1103. }
  1104. private void LoadToTree(TreeNode tn, FormulaSpace fs)
  1105. {
  1106. tn.Text = fs.Name;
  1107. tn.Tag = fs;
  1108. foreach (FormulaSpace space in fs.Namespaces)
  1109. {
  1110. TreeNode node = new TreeNode();
  1111. node.ImageIndex = 0;
  1112. node.SelectedImageIndex = 0;
  1113. tn.Nodes.Add(node);
  1114. this.LoadToTree(node, space);
  1115. }
  1116. foreach (FormulaProgram program in fs.Programs)
  1117. {
  1118. TreeNode node2 = new TreeNode();
  1119. node2.ImageIndex = 1;
  1120. node2.SelectedImageIndex = 1;
  1121. tn.Nodes.Add(node2);
  1122. this.LoadToTree(node2, program);
  1123. }
  1124. }
  1125. private void LocateFirstProgram()
  1126. {
  1127. TreeNode selectedNode = this.FormulaTree.SelectedNode;
  1128. if (!(selectedNode.Tag is FormulaProgram))
  1129. {
  1130. selectedNode = this.FormulaTree.Nodes[0];
  1131. while (!(selectedNode.Tag is FormulaProgram) && (selectedNode.Nodes.Count > 0))
  1132. {
  1133. selectedNode = selectedNode.Nodes[0];
  1134. }
  1135. }
  1136. this.FormulaTree.SelectedNode = selectedNode;
  1137. }
  1138. private void lvErrors_DoubleClick(object sender, EventArgs e)
  1139. {
  1140. ListViewItem focusedItem = this.lvErrors.FocusedItem;
  1141. if (focusedItem != null)
  1142. {
  1143. FormulaProgram tag = (FormulaProgram)focusedItem.Tag;
  1144. if (tag != null)
  1145. {
  1146. TreeNode node = this.FindNode(this.FormulaTree.Nodes[0], tag);
  1147. if (node != null)
  1148. {
  1149. this.FormulaTree.SelectedNode = node;
  1150. int num = int.Parse(focusedItem.SubItems[1].Text);
  1151. int num2 = int.Parse(focusedItem.SubItems[2].Text);
  1152. for (int i = 0; (i < (num - 1)) && (i < this.tbFormulaProgramCode.Lines.Length); i++)
  1153. {
  1154. num2 += this.tbFormulaProgramCode.Lines[i].Length + 1;
  1155. }
  1156. if (num2 < 0)
  1157. {
  1158. num2 = 0;
  1159. }
  1160. this.tbFormulaProgramCode.SelectionStart = num2;
  1161. this.tbFormulaProgramCode.Focus();
  1162. }
  1163. }
  1164. }
  1165. }
  1166. private void miAddFormulaProgram_Click(object sender, EventArgs e)
  1167. {
  1168. TreeNode selectedNode = this.FormulaTree.SelectedNode;
  1169. FormulaSpace tag = (FormulaSpace)selectedNode.Tag;
  1170. FormulaProgram program = new FormulaProgram();
  1171. tag.Programs.Add(program);
  1172. TreeNode node = new TreeNode("NewCode");
  1173. program.Name = node.Text;
  1174. selectedNode.Nodes.Add(node);
  1175. node.ImageIndex = 1;
  1176. node.SelectedImageIndex = 1;
  1177. node.Tag = program;
  1178. this.FormulaTree.SelectedNode = node;
  1179. }
  1180. private void miAddNamespace_Click(object sender, EventArgs e)
  1181. {
  1182. TreeNode selectedNode = this.FormulaTree.SelectedNode;
  1183. FormulaSpace tag = (FormulaSpace)selectedNode.Tag;
  1184. FormulaSpace space2 = new FormulaSpace();
  1185. tag.Namespaces.Add(space2);
  1186. TreeNode node = new TreeNode("NewSpace");
  1187. space2.Name = node.Text;
  1188. selectedNode.Nodes.Add(node);
  1189. node.ImageIndex = 0;
  1190. node.SelectedImageIndex = 0;
  1191. node.Tag = space2;
  1192. this.FormulaTree.SelectedNode = node;
  1193. }
  1194. private void miAddParam_Click(object sender, EventArgs e)
  1195. {
  1196. TreeNode selectedNode = this.FormulaTree.SelectedNode;
  1197. FormulaProgram tag = (FormulaProgram)selectedNode.Tag;
  1198. FormulaParam fp = new FormulaParam();
  1199. tag.Params.Add(fp);
  1200. TreeNode node = new TreeNode("NewParam");
  1201. fp.Name = node.Text;
  1202. selectedNode.Nodes.Add(node);
  1203. node.ImageIndex = 2;
  1204. node.SelectedImageIndex = 2;
  1205. node.Tag = fp;
  1206. this.FormulaTree.SelectedNode = node;
  1207. }
  1208. private void miCompile_Click(object sender, EventArgs e)
  1209. {
  1210. this.Compile();
  1211. }
  1212. private void miDeleteNode_Click(object sender, EventArgs e)
  1213. {
  1214. TreeNode selectedNode = this.FormulaTree.SelectedNode;
  1215. TreeNode parent = selectedNode.Parent;
  1216. if (parent != null)
  1217. {
  1218. object tag = parent.Tag;
  1219. object obj3 = selectedNode.Tag;
  1220. if (tag is FormulaSpace)
  1221. {
  1222. if (obj3 is FormulaSpace)
  1223. {
  1224. ((FormulaSpace)tag).Namespaces.Remove((FormulaSpace)obj3);
  1225. }
  1226. else if (obj3 is FormulaProgram)
  1227. {
  1228. ((FormulaSpace)tag).Programs.Remove((FormulaProgram)obj3);
  1229. }
  1230. }
  1231. else if ((tag is FormulaProgram) && (obj3 is FormulaParam))
  1232. {
  1233. ((FormulaProgram)tag).Params.Remove((FormulaParam)obj3);
  1234. }
  1235. selectedNode.Remove();
  1236. }
  1237. }
  1238. private void miExit_Click(object sender, EventArgs e)
  1239. {
  1240. base.Close();
  1241. }
  1242. private void miNew_Click(object sender, EventArgs e)
  1243. {
  1244. if (!this.Modified)
  1245. {
  1246. this.Filename = "";
  1247. this.fs = new FormulaSpace("FML");
  1248. this.LoadToTree(this.fs);
  1249. }
  1250. }
  1251. private void miOpen_Click(object sender, EventArgs e)
  1252. {
  1253. if (!this.Modified && (this.odFormula.ShowDialog() == DialogResult.OK))
  1254. {
  1255. try
  1256. {
  1257. this.LoadFromFile(this.odFormula.FileName);
  1258. }
  1259. catch (Exception exception)
  1260. {
  1261. MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  1262. }
  1263. }
  1264. }
  1265. private void miSave_Click(object sender, EventArgs e)
  1266. {
  1267. this.Save();
  1268. }
  1269. private void miSaveAs_Click(object sender, EventArgs e)
  1270. {
  1271. this.SaveAs();
  1272. }
  1273. public static void Open(string Filename, string Formula)
  1274. {
  1275. //if (CurrentEditor == null)
  1276. //{
  1277. CurrentEditor = new FormulaSourceEditor();
  1278. //}
  1279. //SetLanguage.CurrentUICulture();
  1280. CurrentEditor.LoadEditor(Filename, Formula);
  1281. }
  1282. public static void Show(string Filename)
  1283. {
  1284. CurrentEditor = new FormulaSourceEditor();
  1285. CurrentEditor.LoadEditor(Filename, "");
  1286. }
  1287. private bool Save()
  1288. {
  1289. if (this.Filename == "")
  1290. {
  1291. return this.SaveAs();
  1292. }
  1293. try
  1294. {
  1295. if (this.Compile())
  1296. {
  1297. this.SaveDataToNode();
  1298. this.fs.Write(this.Filename);
  1299. this.Modified = false;
  1300. return true;
  1301. }
  1302. }
  1303. catch (Exception exception)
  1304. {
  1305. MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  1306. }
  1307. return false;
  1308. }
  1309. private bool SaveAs()
  1310. {
  1311. bool isNewFile = false; //标识文件是否为最新
  1312. if (!string.IsNullOrEmpty(this.Filename))
  1313. {
  1314. this.sdFormula.FileName = this.Filename;
  1315. }
  1316. else
  1317. {
  1318. isNewFile = true;
  1319. this.sdFormula.FileName = string.Format("{0}\\Plugins\\NewFML.fml", Environment.CurrentDirectory);
  1320. }
  1321. if (this.sdFormula.ShowDialog() == DialogResult.OK)
  1322. {
  1323. this.SaveDataToNode();
  1324. this.Filename = this.sdFormula.FileName;
  1325. this.odFormula.FileName = this.Filename;
  1326. try
  1327. {
  1328. if (this.Compile())
  1329. {
  1330. this.fs.Write(this.Filename);
  1331. this.Modified = false;
  1332. if (isNewFile) //如果为最新文件,那么进行载入程序集
  1333. {
  1334. //载入新存储的DLL
  1335. string directoryName = Path.GetDirectoryName(this.Filename);
  1336. string dllName = string.Format("{0}\\{1}.dll", directoryName, Path.GetFileName(this.Filename).Replace('.', '_'));
  1337. PluginManager.LoadDll(dllName);
  1338. }
  1339. return true;
  1340. }
  1341. }
  1342. catch (Exception exception)
  1343. {
  1344. MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  1345. }
  1346. }
  1347. return false;
  1348. }
  1349. private void SaveDataToNode()
  1350. {
  1351. this.SaveDataToNode(this.FormulaTree.SelectedNode);
  1352. }
  1353. private void SaveDataToNode(TreeNode tn)
  1354. {
  1355. if (tn != null)
  1356. {
  1357. if (tn.Tag is FormulaProgram)
  1358. {
  1359. FormulaProgram tag = tn.Tag as FormulaProgram;
  1360. tag.Name = this.tbFormulaProgramName.Text;
  1361. tag.FullName = this.tbProgramFullName.Text;
  1362. tag.Code = this.tbFormulaProgramCode.Text;
  1363. tag.Description = this.tbFormulaProgramDesc.Text;
  1364. tag.IsMainView = this.cbIsMainView.Checked;
  1365. tn.Text = tag.Name;
  1366. }
  1367. else if (tn.Tag is FormulaSpace)
  1368. {
  1369. FormulaSpace space = tn.Tag as FormulaSpace;
  1370. space.Name = this.tbNamespaceName.Text;
  1371. space.Description = this.tbNamespaceDesc.Text;
  1372. space.Version = this.tbVersion.Text;
  1373. space.GroupOnly = this.cbNotRealNameSpace.Checked;
  1374. tn.Text = space.Name;
  1375. }
  1376. else if (tn.Tag is FormulaParam)
  1377. {
  1378. FormulaParam param = tn.Tag as FormulaParam;
  1379. param.Name = this.tbParamName.Text;
  1380. param.MinValue = this.tbMinValue.Text;
  1381. param.MaxValue = this.tbMaxValue.Text;
  1382. param.DefaultValue = this.tbDefaultValue.Text;
  1383. if (this.cbParamType.Text == "")
  1384. {
  1385. this.cbParamType.SelectedIndex = 0;
  1386. }
  1387. param.ParamType = (FormulaParamType)this.cbParamType.SelectedIndex;
  1388. param.Description = this.tbParamDesc.Text;
  1389. tn.Text = param.Name;
  1390. }
  1391. }
  1392. }
  1393. private void tbFormulaProgramCode_KeyDown(object sender, KeyEventArgs e)
  1394. {
  1395. if ((e.KeyCode == Keys.J) && e.Control)
  1396. {
  1397. this.lbIntelliSence.Items.Clear();
  1398. this.lbIntelliSence.Items.AddRange(FormulaBase.GetAllFormulas());
  1399. int selectionStart = this.tbFormulaProgramCode.SelectionStart;
  1400. int lineFromCharIndex = this.tbFormulaProgramCode.GetLineFromCharIndex(selectionStart);
  1401. Point location = this.pnCode.Location;
  1402. Point positionFromCharIndex = this.tbFormulaProgramCode.GetPositionFromCharIndex(selectionStart);
  1403. positionFromCharIndex.Offset(location.X + 8, location.Y + 14);
  1404. this.lbIntelliSence.Location = positionFromCharIndex;
  1405. this.lbIntelliSence.Visible = true;
  1406. this.lbIntelliSence.Focus();
  1407. }
  1408. }
  1409. private void tbFormulaProgramCode_Leave(object sender, EventArgs e)
  1410. {
  1411. this.SaveDataToNode();
  1412. }
  1413. private string[] Trim(string[] ss)
  1414. {
  1415. for (int i = 0; i < ss.Length; i++)
  1416. {
  1417. ss[i] = ss[i].Trim();
  1418. }
  1419. return ss;
  1420. }
  1421. public static bool EditorVisible
  1422. {
  1423. get
  1424. {
  1425. return ((CurrentEditor != null) && CurrentEditor.Visible);
  1426. }
  1427. }
  1428. public string Filename
  1429. {
  1430. get
  1431. {
  1432. return this.filename;
  1433. }
  1434. set
  1435. {
  1436. this.filename = value;
  1437. this.Text = this.filename;
  1438. }
  1439. }
  1440. private bool Modified
  1441. {
  1442. get
  1443. {
  1444. if (this.modified)
  1445. {
  1446. string messageOwner = string.Empty;
  1447. string messageText = string.Empty;
  1448. switch (SetLanguage.currentLanguage)
  1449. {
  1450. case ChartLanguageType.SimplifiedChinese:
  1451. messageOwner = "内容已修改。是否进行保存?";
  1452. messageText = "确认";
  1453. break;
  1454. case ChartLanguageType.TraditionalChinese:
  1455. messageOwner = "內容已修改。是否進行保存?";
  1456. messageText = "確認";
  1457. break;
  1458. case ChartLanguageType.English:
  1459. messageOwner = "Text modified. Save modifications ?";
  1460. messageText = "Confirmation";
  1461. break;
  1462. }
  1463. switch (MessageBox.Show(messageOwner, messageText, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
  1464. {
  1465. case DialogResult.Yes:
  1466. return !this.Save();
  1467. case DialogResult.No:
  1468. return false;
  1469. }
  1470. return true;
  1471. }
  1472. return false;
  1473. }
  1474. set
  1475. {
  1476. if (this.modified != value)
  1477. {
  1478. this.modified = value;
  1479. if (this.modified)
  1480. {
  1481. if (!this.Text.EndsWith("*"))
  1482. {
  1483. this.Text = this.Text + "*";
  1484. }
  1485. }
  1486. else
  1487. {
  1488. this.Text = this.Filename;
  1489. }
  1490. }
  1491. }
  1492. }
  1493. }
  1494. }