FormulaManager.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. namespace IndexFormula.Finance.Win
  2. {
  3. using IndexFormula.Finance;
  4. using MuchInfo.Chart.Data.EnumTypes;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.IO;
  10. using System.Threading;
  11. using System.Windows.Forms;
  12. /// <summary>
  13. /// 当前数据公式应用窗口
  14. /// ShowForm()后,直接取FormulaManager.CurrentFormulas来获取得到的公式
  15. /// </summary>
  16. [ToolboxItem(false)]
  17. public partial class FormulaManager : Form
  18. {
  19. private System.Windows.Forms.Button btnCancel;
  20. private System.Windows.Forms.Button btnDelete;
  21. private System.Windows.Forms.Button btnDown;
  22. private System.Windows.Forms.Button btnMore;
  23. private System.Windows.Forms.Button btnOK;
  24. private System.Windows.Forms.Button btnSource;
  25. private System.Windows.Forms.Button btnUp;
  26. private System.Windows.Forms.CheckBox cbSecondYAxis;
  27. private IContainer components;
  28. private System.Windows.Forms.ComboBox ddlFavoriteFormula;
  29. private bool DisableChangeEvent;
  30. private System.Windows.Forms.GroupBox gbCurrent;
  31. private System.Windows.Forms.GroupBox gbParam;
  32. public System.Windows.Forms.ImageList ilFormula;
  33. private System.Windows.Forms.ImageList ilIcon;
  34. private System.Windows.Forms.ListBox lbFormulaList;
  35. private string[] ListedFormulas = new string[] {
  36. "MAIN", "MainArea", "VOLMA", "MACD", "RSI", "CMF", "TRIX", "CCI", "FastSTO", "SlowSTO", "ATR", "OBV", "ULT", "DPO", "WR", "PPO",
  37. "PVO", "StochRSI", "AD"
  38. };
  39. private string[] OverlayFormulas = new string[] {
  40. "MAIN", "MainArea", "HL", "MA", "EMA", "BB", "AreaBB", "SAR", "ZIGLABEL", "ZIG", "ZIGICON", "ZIGW", "ZIGSR", "SR", "SRAxisY", "COMPARE",
  41. "COMPARE2", "Fibonnaci", "LinRegr", "TradingIcon"
  42. };
  43. private System.Windows.Forms.ToolTip tpBtnDown;
  44. private System.Windows.Forms.ToolTip tpBtnUp;
  45. private System.Windows.Forms.ToolTip tpDelete;
  46. private System.Windows.Forms.ToolTip tpSource;
  47. public FormulaManager()
  48. {
  49. this.InitializeComponent();
  50. switch (SetLanguage.currentLanguage)
  51. {
  52. case ChartLanguageType.SimplifiedChinese:
  53. this.tpBtnUp.SetToolTip(this.btnUp, "上移");
  54. this.tpBtnDown.SetToolTip(this.btnDown, "下移");
  55. this.tpDelete.SetToolTip(this.btnDelete, "删除");
  56. this.tpSource.SetToolTip(this.btnSource, "源代码");
  57. break;
  58. case ChartLanguageType.TraditionalChinese:
  59. this.tpBtnUp.SetToolTip(this.btnUp, "上移");
  60. this.tpBtnDown.SetToolTip(this.btnDown, "下移");
  61. this.tpDelete.SetToolTip(this.btnDelete, "刪除");
  62. this.tpSource.SetToolTip(this.btnSource, "源代碼");
  63. break;
  64. case ChartLanguageType.English:
  65. this.tpBtnUp.SetToolTip(this.btnUp, "Move Up");
  66. this.tpBtnDown.SetToolTip(this.btnDown, "Move Down");
  67. this.tpDelete.SetToolTip(this.btnDelete, "Delete");
  68. this.tpSource.SetToolTip(this.btnSource, "Source Code");
  69. break;
  70. }
  71. //SetLanguage.CurrentUICulture();
  72. }
  73. private void AddFavorite(string[] Formulas)
  74. {
  75. this.ddlFavoriteFormula.Items.Clear();
  76. switch (SetLanguage.currentLanguage)
  77. {
  78. case ChartLanguageType.SimplifiedChinese:
  79. this.ddlFavoriteFormula.Items.Add("选择要添加新的公式");
  80. break;
  81. case ChartLanguageType.TraditionalChinese:
  82. this.ddlFavoriteFormula.Items.Add("選擇要添加新的公式");
  83. break;
  84. case ChartLanguageType.English:
  85. this.ddlFavoriteFormula.Items.Add("Select to add new formula");
  86. break;
  87. }
  88. foreach (string str in Formulas)
  89. {
  90. FormulaBase formulaByName = FormulaBase.GetFormulaByName(str);
  91. foreach (object obj2 in this.ddlFavoriteFormula.Items)
  92. {
  93. if (obj2.GetType() == formulaByName.GetType())
  94. {
  95. continue;
  96. }
  97. }
  98. this.ddlFavoriteFormula.Items.Add(formulaByName);
  99. }
  100. this.ddlFavoriteFormula.SelectedIndex = 0;
  101. }
  102. private void AddFormulas()
  103. {
  104. FormulaBase selectedItem = (FormulaBase)this.ddlFavoriteFormula.SelectedItem;
  105. if (selectedItem != null)
  106. {
  107. this.AddFormulas(selectedItem.CreateName);
  108. }
  109. }
  110. private void AddFormulas(string Name)
  111. {
  112. this.lbFormulaList.Items.Add(Name);
  113. this.SelectLastFormula();
  114. }
  115. private void btnDelete_Click(object sender, EventArgs e)
  116. {
  117. this.DeleteFormulas();
  118. }
  119. private void btnDown_Click(object sender, EventArgs e)
  120. {
  121. this.MoveFormula(1);
  122. }
  123. private void btnMore_Click(object sender, EventArgs e)
  124. {
  125. string name = new SelectFormula().Select(null, null, false);
  126. if (name != null)
  127. {
  128. this.AddFormulas(name);
  129. }
  130. }
  131. private void btnSource_Click(object sender, EventArgs e)
  132. {
  133. int selectedIndex = this.lbFormulaList.SelectedIndex;
  134. if (selectedIndex >= 0)
  135. {
  136. EditFormula(FormulaBase.GetFormulaByName((string)this.lbFormulaList.Items[selectedIndex]));
  137. }
  138. }
  139. /// <summary>
  140. /// 编辑公式
  141. /// </summary>
  142. /// <param name="fb"></param>
  143. /// <returns></returns>
  144. public static bool EditFormula(FormulaBase fb)
  145. {
  146. string formulaFile = PluginManager.GetFormulaFile(fb);
  147. if (formulaFile != null)
  148. {
  149. string directoryName = Path.GetDirectoryName(formulaFile);
  150. formulaFile = Path.GetFileNameWithoutExtension(formulaFile).Replace('_', '.');
  151. formulaFile = directoryName + @"\" + formulaFile;
  152. if (File.Exists(formulaFile))
  153. {
  154. Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(SetLanguage.languageName);
  155. FormulaSourceEditor.Open(formulaFile, fb.GetType().ToString());
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. private void btnUp_Click(object sender, EventArgs e)
  162. {
  163. this.MoveFormula(-1);
  164. }
  165. private void cbSecondYAxis_CheckedChanged(object sender, EventArgs e)
  166. {
  167. this.DisableChangeEvent = true;
  168. try
  169. {
  170. if (this.lbFormulaList.SelectedItem != null)
  171. {
  172. string str = this.lbFormulaList.SelectedItem.ToString();
  173. this.lbFormulaList.Items[this.lbFormulaList.SelectedIndex] = str.TrimEnd(new char[] { '!' }) + (this.cbSecondYAxis.Checked ? "!" : "");
  174. }
  175. }
  176. finally
  177. {
  178. this.DisableChangeEvent = false;
  179. }
  180. }
  181. private void cbSecondYAxis_Click(object sender, EventArgs e)
  182. {
  183. }
  184. private void ddlFavoriteFormula_SelectedIndexChanged(object sender, EventArgs e)
  185. {
  186. if (this.ddlFavoriteFormula.SelectedIndex > 0)
  187. {
  188. this.AddFormulas();
  189. this.ddlFavoriteFormula.SelectedIndex = 0;
  190. }
  191. }
  192. private void DeleteFormulas()
  193. {
  194. this.DisableChangeEvent = true;
  195. int selectedIndex = this.lbFormulaList.SelectedIndex;
  196. if (selectedIndex >= 0)
  197. {
  198. try
  199. {
  200. this.lbFormulaList.Items.RemoveAt(selectedIndex);
  201. }
  202. finally
  203. {
  204. this.DisableChangeEvent = false;
  205. }
  206. this.SetSelectFormula(selectedIndex);
  207. }
  208. }
  209. protected override void Dispose(bool disposing)
  210. {
  211. if (disposing && (this.components != null))
  212. {
  213. this.components.Dispose();
  214. }
  215. base.Dispose(disposing);
  216. }
  217. private void InitializeComponent()
  218. {
  219. this.components = new System.ComponentModel.Container();
  220. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormulaManager));
  221. this.ddlFavoriteFormula = new System.Windows.Forms.ComboBox();
  222. this.btnCancel = new System.Windows.Forms.Button();
  223. this.gbCurrent = new System.Windows.Forms.GroupBox();
  224. this.cbSecondYAxis = new System.Windows.Forms.CheckBox();
  225. this.btnDown = new System.Windows.Forms.Button();
  226. this.btnUp = new System.Windows.Forms.Button();
  227. this.btnSource = new System.Windows.Forms.Button();
  228. this.lbFormulaList = new System.Windows.Forms.ListBox();
  229. this.gbParam = new System.Windows.Forms.GroupBox();
  230. this.btnDelete = new System.Windows.Forms.Button();
  231. this.ilIcon = new System.Windows.Forms.ImageList(this.components);
  232. this.btnOK = new System.Windows.Forms.Button();
  233. this.btnMore = new System.Windows.Forms.Button();
  234. this.ilFormula = new System.Windows.Forms.ImageList(this.components);
  235. this.tpBtnUp = new System.Windows.Forms.ToolTip(this.components);
  236. this.tpBtnDown = new System.Windows.Forms.ToolTip(this.components);
  237. this.tpDelete = new System.Windows.Forms.ToolTip(this.components);
  238. this.tpSource = new System.Windows.Forms.ToolTip(this.components);
  239. this.gbCurrent.SuspendLayout();
  240. this.SuspendLayout();
  241. //
  242. // ddlFavoriteFormula
  243. //
  244. this.ddlFavoriteFormula.DisplayMember = "CombineName";
  245. this.ddlFavoriteFormula.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  246. resources.ApplyResources(this.ddlFavoriteFormula, "ddlFavoriteFormula");
  247. this.ddlFavoriteFormula.Name = "ddlFavoriteFormula";
  248. this.ddlFavoriteFormula.SelectedIndexChanged += new System.EventHandler(this.ddlFavoriteFormula_SelectedIndexChanged);
  249. //
  250. // btnCancel
  251. //
  252. resources.ApplyResources(this.btnCancel, "btnCancel");
  253. this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  254. this.btnCancel.Name = "btnCancel";
  255. //
  256. // gbCurrent
  257. //
  258. resources.ApplyResources(this.gbCurrent, "gbCurrent");
  259. this.gbCurrent.Controls.Add(this.cbSecondYAxis);
  260. this.gbCurrent.Controls.Add(this.btnDown);
  261. this.gbCurrent.Controls.Add(this.btnUp);
  262. this.gbCurrent.Controls.Add(this.btnSource);
  263. this.gbCurrent.Controls.Add(this.lbFormulaList);
  264. this.gbCurrent.Controls.Add(this.gbParam);
  265. this.gbCurrent.Controls.Add(this.btnDelete);
  266. this.gbCurrent.Name = "gbCurrent";
  267. this.gbCurrent.TabStop = false;
  268. //
  269. // cbSecondYAxis
  270. //
  271. resources.ApplyResources(this.cbSecondYAxis, "cbSecondYAxis");
  272. this.cbSecondYAxis.Name = "cbSecondYAxis";
  273. this.cbSecondYAxis.CheckedChanged += new System.EventHandler(this.cbSecondYAxis_CheckedChanged);
  274. this.cbSecondYAxis.Click += new System.EventHandler(this.cbSecondYAxis_Click);
  275. //
  276. // btnDown
  277. //
  278. resources.ApplyResources(this.btnDown, "btnDown");
  279. this.btnDown.Image = global::IndexFormula.Finance.Win.Properties.Resources.arrow_down;
  280. this.btnDown.Name = "btnDown";
  281. this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
  282. //
  283. // btnUp
  284. //
  285. resources.ApplyResources(this.btnUp, "btnUp");
  286. this.btnUp.Image = global::IndexFormula.Finance.Win.Properties.Resources.arrow_up;
  287. this.btnUp.Name = "btnUp";
  288. this.btnUp.Click += new System.EventHandler(this.btnUp_Click);
  289. //
  290. // btnSource
  291. //
  292. resources.ApplyResources(this.btnSource, "btnSource");
  293. this.btnSource.Image = global::IndexFormula.Finance.Win.Properties.Resources.application_edit;
  294. this.btnSource.Name = "btnSource";
  295. this.btnSource.Click += new System.EventHandler(this.btnSource_Click);
  296. //
  297. // lbFormulaList
  298. //
  299. resources.ApplyResources(this.lbFormulaList, "lbFormulaList");
  300. this.lbFormulaList.DisplayMember = "Description";
  301. this.lbFormulaList.Name = "lbFormulaList";
  302. this.lbFormulaList.ValueMember = "Name";
  303. this.lbFormulaList.SelectedIndexChanged += new System.EventHandler(this.lbOverlayList_SelectedIndexChanged);
  304. //
  305. // gbParam
  306. //
  307. resources.ApplyResources(this.gbParam, "gbParam");
  308. this.gbParam.Name = "gbParam";
  309. this.gbParam.TabStop = false;
  310. //
  311. // btnDelete
  312. //
  313. resources.ApplyResources(this.btnDelete, "btnDelete");
  314. this.btnDelete.Image = global::IndexFormula.Finance.Win.Properties.Resources.Delete;
  315. this.btnDelete.Name = "btnDelete";
  316. this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
  317. //
  318. // ilIcon
  319. //
  320. this.ilIcon.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  321. resources.ApplyResources(this.ilIcon, "ilIcon");
  322. this.ilIcon.TransparentColor = System.Drawing.Color.Transparent;
  323. //
  324. // btnOK
  325. //
  326. resources.ApplyResources(this.btnOK, "btnOK");
  327. this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
  328. this.btnOK.Name = "btnOK";
  329. //
  330. // btnMore
  331. //
  332. resources.ApplyResources(this.btnMore, "btnMore");
  333. this.btnMore.Name = "btnMore";
  334. this.btnMore.Click += new System.EventHandler(this.btnMore_Click);
  335. //
  336. // ilFormula
  337. //
  338. this.ilFormula.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  339. resources.ApplyResources(this.ilFormula, "ilFormula");
  340. this.ilFormula.TransparentColor = System.Drawing.Color.Transparent;
  341. //
  342. // FormulaManager
  343. //
  344. this.AcceptButton = this.btnOK;
  345. resources.ApplyResources(this, "$this");
  346. this.CancelButton = this.btnCancel;
  347. this.Controls.Add(this.btnMore);
  348. this.Controls.Add(this.ddlFavoriteFormula);
  349. this.Controls.Add(this.btnCancel);
  350. this.Controls.Add(this.gbCurrent);
  351. this.Controls.Add(this.btnOK);
  352. this.Name = "FormulaManager";
  353. this.gbCurrent.ResumeLayout(false);
  354. this.ResumeLayout(false);
  355. }
  356. private void lbOverlayList_SelectedIndexChanged(object sender, EventArgs e)
  357. {
  358. if (!this.DisableChangeEvent)
  359. {
  360. string str;
  361. this.ParamToTextBox((string)this.lbFormulaList.SelectedItem, out str);
  362. }
  363. }
  364. private void MoveFormula(int Delta)
  365. {
  366. this.DisableChangeEvent = true;
  367. try
  368. {
  369. int selectedIndex = this.lbFormulaList.SelectedIndex;
  370. int num2 = selectedIndex + Delta;
  371. if (((selectedIndex >= 0) && (num2 >= 0)) && (num2 < this.lbFormulaList.Items.Count))
  372. {
  373. object item = this.lbFormulaList.Items[selectedIndex];
  374. this.lbFormulaList.Items.RemoveAt(selectedIndex);
  375. this.lbFormulaList.Items.Insert(selectedIndex + Delta, item);
  376. this.lbFormulaList.SelectedIndex = num2;
  377. }
  378. }
  379. finally
  380. {
  381. this.DisableChangeEvent = false;
  382. }
  383. }
  384. public void ParamToTextBox(string NameAndParam, out string FormulaName)
  385. {
  386. this.cbSecondYAxis.Checked = NameAndParam.EndsWith("!");
  387. FormulaBase formulaByName = FormulaBase.GetFormulaByName(NameAndParam.TrimEnd(new char[] { '!' }));
  388. FormulaName = formulaByName.FormulaName;
  389. SelectFormula.AddParamToGroupBox(this.gbParam, this.ilFormula, formulaByName, new EventHandler(this.tbP4_Leave));
  390. }
  391. private void SelectFirstFormula()
  392. {
  393. this.SetSelectFormula(0);
  394. }
  395. private void SelectLastFormula()
  396. {
  397. this.SetSelectFormula(this.lbFormulaList.Items.Count - 1);
  398. }
  399. private void SetSelectFormula(int Index)
  400. {
  401. if (Index < 0)
  402. {
  403. Index = 0;
  404. }
  405. if (Index >= this.lbFormulaList.Items.Count)
  406. {
  407. Index = this.lbFormulaList.Items.Count - 1;
  408. }
  409. if ((Index >= 0) && (Index < this.lbFormulaList.Items.Count))
  410. {
  411. this.lbFormulaList.SelectedIndex = Index;
  412. }
  413. }
  414. public DialogResult ShowForm()
  415. {
  416. this.AddFavorite(this.ListedFormulas);
  417. return this.ShowForm(null, string.Empty);
  418. }
  419. /// <summary>
  420. /// 弹出编辑当前公式对话框
  421. /// </summary>
  422. /// <param name="formulas">当前图表用到的公式集</param>
  423. /// <param name="SelectedFormula">当前选中图表的应用公式</param>
  424. /// <returns>返回对话框</returns>
  425. public DialogResult ShowForm(string[] formulas, string selectedFormula)
  426. {
  427. if (formulas != null)
  428. {
  429. string[] strArray = formulas;
  430. if (strArray != null)
  431. {
  432. this.CurrentFormulas = string.Join("#", strArray);
  433. string createName = "";
  434. if (selectedFormula != null)
  435. {
  436. createName = selectedFormula;
  437. }
  438. this.SelectedFormula = createName;
  439. ArrayList list = new ArrayList();
  440. list.AddRange(strArray);
  441. //以下稍作修改,合并2个常用的公式供一般性选择
  442. list.AddRange(CombinationArray(this.OverlayFormulas, this.ListedFormulas));
  443. //if (fa.IsMain()) //是否为基本主要的。这个函数需要界面数据,暂时不作实现
  444. //{
  445. // list.AddRange(this.OverlayFormulas);
  446. //}
  447. //else
  448. //{
  449. // list.AddRange(this.ListedFormulas);
  450. //}
  451. this.AddFavorite((string[])list.ToArray(typeof(string)));
  452. }
  453. }
  454. return base.ShowDialog();
  455. }
  456. public DialogResult ShowForm(FormulaArea fa, FormulaBase SelectedFormula)
  457. {
  458. if (fa != null)
  459. {
  460. string[] strArray = fa.FormulaToStrings();
  461. if (strArray != null)
  462. {
  463. this.CurrentFormulas = string.Join("#", strArray);
  464. string createName = "";
  465. if (SelectedFormula != null)
  466. {
  467. createName = SelectedFormula.CreateName;
  468. }
  469. this.SelectedFormula = createName;
  470. ArrayList list = new ArrayList();
  471. list.AddRange(strArray);
  472. if (fa.IsMain())
  473. {
  474. list.AddRange(this.OverlayFormulas);
  475. }
  476. else
  477. {
  478. list.AddRange(this.ListedFormulas);
  479. }
  480. this.AddFavorite((string[])list.ToArray(typeof(string)));
  481. }
  482. }
  483. return base.ShowDialog();
  484. }
  485. /// <summary>
  486. /// 合并两组字符串
  487. /// </summary>
  488. /// <param name="array1">字符串1</param>
  489. /// <param name="array2">字符串2</param>
  490. /// <returns>返回合并后字符串</returns>
  491. private string[] CombinationArray(string[] array1, string[] array2)
  492. {
  493. List<string> comArray = new List<string>();
  494. comArray.AddRange(array1);
  495. foreach (string str in array2)
  496. {
  497. if (!comArray.Contains(str))
  498. {
  499. comArray.Add(str);
  500. }
  501. }
  502. return comArray.ToArray();
  503. }
  504. public bool IsMain(int AxisYIndex)
  505. {
  506. //以下主要判断数据的类型
  507. //for (int i = 0; i < this.FormulaDataArray.Count; i++)
  508. //{
  509. // if ((((this[i].RenderType == FormulaRenderType.STOCK) || (this[i].RenderType == FormulaRenderType.MONOSTOCK)) || (string.Compare(this[i].Name, "Main", true) == 0)) && ((AxisYIndex < 0) || (this[i].AxisYIndex == AxisYIndex)))
  510. // {
  511. // return true;
  512. // }
  513. //}
  514. //return false;
  515. return true;
  516. }
  517. private void tbP4_Leave(object sender, EventArgs e)
  518. {
  519. string str = this.TextBoxToParam((string)this.lbFormulaList.SelectedItem);
  520. if (str != "")
  521. {
  522. this.DisableChangeEvent = true;
  523. try
  524. {
  525. this.lbFormulaList.Items[this.lbFormulaList.SelectedIndex] = str;
  526. }
  527. finally
  528. {
  529. this.DisableChangeEvent = false;
  530. }
  531. }
  532. }
  533. private string TextBoxToParam(string FormulaName)
  534. {
  535. int index = FormulaName.IndexOf('(');
  536. if (index >= 0)
  537. {
  538. FormulaName = FormulaName.Substring(0, index);
  539. }
  540. string param = SelectFormula.GetParam(this.gbParam);
  541. if (FormulaBase.GetFormulaByName(FormulaName) != null)
  542. {
  543. return (FormulaName + param);
  544. }
  545. return "";
  546. }
  547. public string CurrentFormulas
  548. {
  549. get
  550. {
  551. string str = "";
  552. foreach (string str2 in this.lbFormulaList.Items)
  553. {
  554. if (str != "")
  555. {
  556. str = str + "#";
  557. }
  558. str = str + str2;
  559. }
  560. return str;
  561. }
  562. set
  563. {
  564. this.lbFormulaList.Items.Clear();
  565. if ((value != "") && (value != null))
  566. {
  567. foreach (string str in value.Split(new char[] { '#' }))
  568. {
  569. this.AddFormulas(str);
  570. }
  571. this.SelectFirstFormula();
  572. }
  573. }
  574. }
  575. public string SelectedFormula
  576. {
  577. get
  578. {
  579. if (this.lbFormulaList.SelectedIndex > 0)
  580. {
  581. return this.lbFormulaList.Items[this.lbFormulaList.SelectedIndex].ToString();
  582. }
  583. return "";
  584. }
  585. set
  586. {
  587. int index = this.lbFormulaList.Items.IndexOf(value);
  588. if (index >= 0)
  589. {
  590. this.lbFormulaList.SelectedIndex = index;
  591. }
  592. }
  593. }
  594. }
  595. }