コピペ: OmegaChart Fibonacciトレースメント CustomizeDialog.cs 追加修正ポイントには//☆Fibonacci

形式
Plain text
投稿日時
2017-12-27 19:54
公開期間
無期限
  1. using System;
  2. using System.Text;
  3. using System.Drawing;
  4. using System.Collections;
  5. using System.Diagnostics;
  6. using System.ComponentModel;
  7. using System.Windows.Forms;
  8. using Travis.Util;
  9. using Zanetti.Indicators;
  10. using Zanetti.Indicators.Schema;
  11. using Zanetti.UI;
  12. using Zanetti.Commands;
  13. using UtilityLibrary.WinControls;
  14. namespace Zanetti.Forms
  15. {
  16. /// <summary>
  17. /// CustomizeDialog の概要の説明です。
  18. /// </summary>
  19. internal class CustomizeDialog : System.Windows.Forms.Form
  20. {
  21. private const int MAX_ITEMS = 16;
  22. private static int _pageIndex;
  23. private string _fontName;
  24. private float _fontSize;
  25. private FontStyle _fontStyle;
  26. private class CustomizeTag
  27. {
  28. public SchemaItem schemaItem;
  29. public int index; //IndicatorではInstance番号、Screening/PredictionではParameterの番号
  30. public ComboBox styleBox;
  31. public ColPickerComboBox colorPicker;
  32. public TextBox dailyParams;
  33. public TextBox weeklyParams;
  34. public TextBox monthlyParams;
  35. public TextBox yearlyParams;
  36. public int parameterCount;
  37. }
  38. private ArrayList _tags;
  39. private ArrayList _indicators;
  40. private ArrayList _screeningItems;
  41. private ArrayList _predictionItems;
  42. private ArrayList _autoTradingItems;
  43. private Button _resetButton;
  44. private System.Windows.Forms.Button _okButton;
  45. private System.Windows.Forms.TabControl _tabControl;
  46. private System.Windows.Forms.Button _cancelButton;
  47. private System.Windows.Forms.Button _applyButton;
  48. private System.Windows.Forms.TabPage _genericPage;
  49. private System.Windows.Forms.TabPage _chartPage;
  50. private System.Windows.Forms.TabPage _screeningPage;
  51. private System.Windows.Forms.TabPage _theoremPage;
  52. private System.Windows.Forms.TabPage _autoTradingPage;
  53. private System.Windows.Forms.GroupBox _basicColorGroup;
  54. private System.Windows.Forms.GroupBox _scaleLineGroup;
  55. private Label _lFont;
  56. private Label _lCurrentFont;
  57. private Button _selectFont;
  58. private Label _lBackColor;
  59. private ColPickerComboBox _backColorBox;
  60. private Label _lTextColor;
  61. private ColPickerComboBox _textColorBox;
  62. private Label _lFushiColor;
  63. private ColPickerComboBox _fushiColorBox;
  64. private Label _lCandleColor;
  65. private ColPickerComboBox _candleColorBox;
  66. private CheckBox _candleShadowEffect;
  67. private Label _lInsenColor;
  68. private ColPickerComboBox _insenColorBox;
  69. private Label _lCreditLong;
  70. private ComboBox _creditLongStyleBox;
  71. private ColPickerComboBox _creditLongColorBox;
  72. private Label _lCreditShort;
  73. private ComboBox _creditShortStyleBox;
  74. private ColPickerComboBox _creditShortColorBox;
  75. private Label _lVolumeColor;
  76. private ColPickerComboBox _volumeColorBox;
  77. private Label _lAccumulativeVolumeLabel;
  78. private TextBox[] _accumulativeVolumeBox;
  79. private Label _lFreeLineColor;
  80. private ColPickerComboBox _freeLineColorBox;
  81. private Label _lFibonacciColor;//☆Fibonacci
  82. private ColPickerComboBox _fibonacciColorBox;//☆Fibonacci
  83. private Label _lMonthDiv;
  84. private ComboBox _monthDivStyleBox;
  85. private ColPickerComboBox _monthDivColorBox;
  86. private Label _lPriceScale;
  87. private ComboBox _priceScaleStyleBox;
  88. private ColPickerComboBox _priceScaleColorBox;
  89. private Label _lVolumeScale;
  90. private ComboBox _volumeScaleStyleBox;
  91. private ColPickerComboBox _volumeScaleColorBox;
  92. private Label _lOscillatorScale;
  93. private ComboBox _oscillatorScaleStyleBox;
  94. private ColPickerComboBox _oscillatorScaleColorBox;
  95. private Label _lMouseTracking;
  96. private ComboBox _mouseTrackingStyleBox;
  97. private ColPickerComboBox _mouseTrackingColorBox;
  98. private ComboBox _mouseTrackingModeBox;
  99. private ToolTip _toolTip;
  100. private System.ComponentModel.IContainer components;
  101. private string[] descs = new string[] { "日", "週", "月", "年" };
  102. public CustomizeDialog()
  103. {
  104. //
  105. // Windows フォーム デザイナ サポートに必要です。
  106. //
  107. InitializeComponent();
  108. this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
  109. //
  110. // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
  111. //
  112. if (!this.DesignMode)
  113. InitPages();
  114. _tabControl.SelectedIndex = _pageIndex;
  115. _toolTip.ShowAlways = true;
  116. _toolTip.InitialDelay = 1;
  117. _toolTip.AutoPopDelay = 60000;
  118. }
  119. /// <summary>
  120. /// 使用されているリソースに後処理を実行します。
  121. /// </summary>
  122. protected override void Dispose(bool disposing)
  123. {
  124. if (disposing)
  125. {
  126. if (components != null)
  127. {
  128. components.Dispose();
  129. }
  130. }
  131. base.Dispose(disposing);
  132. }
  133. #region Windows フォーム デザイナで生成されたコード
  134. /// <summary>
  135. /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
  136. /// コード エディタで変更しないでください。
  137. /// </summary>
  138. private void InitializeComponent()
  139. {
  140. this.components = new System.ComponentModel.Container();
  141. this._resetButton = new System.Windows.Forms.Button();
  142. this._okButton = new System.Windows.Forms.Button();
  143. this._cancelButton = new System.Windows.Forms.Button();
  144. this._applyButton = new System.Windows.Forms.Button();
  145. this._tabControl = new System.Windows.Forms.TabControl();
  146. this._genericPage = new System.Windows.Forms.TabPage();
  147. this._scaleLineGroup = new System.Windows.Forms.GroupBox();
  148. this._basicColorGroup = new System.Windows.Forms.GroupBox();
  149. this._chartPage = new System.Windows.Forms.TabPage();
  150. this._screeningPage = new System.Windows.Forms.TabPage();
  151. this._theoremPage = new System.Windows.Forms.TabPage();
  152. this._autoTradingPage = new System.Windows.Forms.TabPage();
  153. this._toolTip = new System.Windows.Forms.ToolTip(this.components);
  154. this._tabControl.SuspendLayout();
  155. this._genericPage.SuspendLayout();
  156. this.SuspendLayout();
  157. //
  158. // _resetButton
  159. //
  160. this._resetButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  161. this._resetButton.Location = new System.Drawing.Point(8, 400);
  162. this._resetButton.Name = "_resetButton";
  163. this._resetButton.Size = new System.Drawing.Size(96, 23);
  164. this._resetButton.TabIndex = 3;
  165. this._resetButton.Text = "リセット(&R)";
  166. this._resetButton.Click += new System.EventHandler(this.OnReset);
  167. //
  168. // _okButton
  169. //
  170. this._okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  171. this._okButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  172. this._okButton.Location = new System.Drawing.Point(312, 400);
  173. this._okButton.Name = "_okButton";
  174. this._okButton.Size = new System.Drawing.Size(80, 23);
  175. this._okButton.TabIndex = 0;
  176. this._okButton.Text = "OK";
  177. this._okButton.Click += new System.EventHandler(this.OnOK);
  178. //
  179. // _cancelButton
  180. //
  181. this._cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  182. this._cancelButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  183. this._cancelButton.Location = new System.Drawing.Point(400, 400);
  184. this._cancelButton.Name = "_cancelButton";
  185. this._cancelButton.Size = new System.Drawing.Size(80, 23);
  186. this._cancelButton.TabIndex = 1;
  187. this._cancelButton.Text = "キャンセル";
  188. //
  189. // _applyButton
  190. //
  191. this._applyButton.Enabled = false;
  192. this._applyButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
  193. this._applyButton.Location = new System.Drawing.Point(496, 400);
  194. this._applyButton.Name = "_applyButton";
  195. this._applyButton.Size = new System.Drawing.Size(80, 23);
  196. this._applyButton.TabIndex = 2;
  197. this._applyButton.Text = "適用(&A)";
  198. this._applyButton.Click += new System.EventHandler(this.OnApplyButtonClicked);
  199. //
  200. // _tabControl
  201. //
  202. this._tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  203. | System.Windows.Forms.AnchorStyles.Right)));
  204. this._tabControl.Controls.Add(this._genericPage);
  205. this._tabControl.Location = new System.Drawing.Point(0, 0);
  206. this._tabControl.Name = "_tabControl";
  207. this._tabControl.SelectedIndex = 0;
  208. this._tabControl.Size = new System.Drawing.Size(734, 392);
  209. this._tabControl.TabIndex = 4;
  210. //
  211. // _genericPage
  212. //
  213. this._genericPage.Controls.Add(this._scaleLineGroup);
  214. this._genericPage.Controls.Add(this._basicColorGroup);
  215. this._genericPage.Location = new System.Drawing.Point(4, 22);
  216. this._genericPage.Name = "_genericPage";
  217. this._genericPage.Size = new System.Drawing.Size(726, 366);
  218. this._genericPage.TabIndex = 0;
  219. this._genericPage.Text = "全般";
  220. //
  221. // _scaleLineGroup
  222. //
  223. this._scaleLineGroup.FlatStyle = System.Windows.Forms.FlatStyle.System;
  224. this._scaleLineGroup.Location = new System.Drawing.Point(8, 256);
  225. this._scaleLineGroup.Name = "_scaleLineGroup";
  226. this._scaleLineGroup.Size = new System.Drawing.Size(710, 120);
  227. this._scaleLineGroup.TabIndex = 1;
  228. this._scaleLineGroup.TabStop = false;
  229. this._scaleLineGroup.Text = "区切り線";
  230. //
  231. // _basicColorGroup
  232. //
  233. this._basicColorGroup.FlatStyle = System.Windows.Forms.FlatStyle.System;
  234. this._basicColorGroup.Location = new System.Drawing.Point(8, 8);
  235. this._basicColorGroup.Name = "_basicColorGroup";
  236. this._basicColorGroup.Size = new System.Drawing.Size(710, 240);
  237. this._basicColorGroup.TabIndex = 0;
  238. this._basicColorGroup.TabStop = false;
  239. this._basicColorGroup.Text = "基本スタイル設定";
  240. //
  241. // _chartPage
  242. //
  243. this._chartPage.Location = new System.Drawing.Point(4, 21);
  244. this._chartPage.Name = "_chartPage";
  245. this._chartPage.Size = new System.Drawing.Size(584, 311);
  246. this._chartPage.TabIndex = 0;
  247. this._chartPage.Text = "チャート";
  248. //
  249. // _screeningPage
  250. //
  251. this._screeningPage.Location = new System.Drawing.Point(4, 21);
  252. this._screeningPage.Name = "_screeningPage";
  253. this._screeningPage.Size = new System.Drawing.Size(584, 311);
  254. this._screeningPage.TabIndex = 0;
  255. this._screeningPage.Text = "スクリーニング";
  256. //
  257. // _theoremPage
  258. //
  259. this._theoremPage.Location = new System.Drawing.Point(4, 21);
  260. this._theoremPage.Name = "_theoremPage";
  261. this._theoremPage.Size = new System.Drawing.Size(584, 311);
  262. this._theoremPage.TabIndex = 0;
  263. this._theoremPage.Text = "セオリー検証";
  264. //
  265. // _autoTradingPage
  266. //
  267. this._autoTradingPage.Location = new System.Drawing.Point(4, 21);
  268. this._autoTradingPage.Name = "_autoTradingPage";
  269. this._autoTradingPage.Size = new System.Drawing.Size(584, 311);
  270. this._autoTradingPage.TabIndex = 0;
  271. this._autoTradingPage.Text = "自動売買検証";
  272. //
  273. // CustomizeDialog
  274. //
  275. this.AcceptButton = this._okButton;
  276. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  277. this.CancelButton = this._cancelButton;
  278. this.ClientSize = new System.Drawing.Size(734, 432);
  279. this.Controls.Add(this._tabControl);
  280. this.Controls.Add(this._applyButton);
  281. this.Controls.Add(this._cancelButton);
  282. this.Controls.Add(this._okButton);
  283. this.Controls.Add(this._resetButton);
  284. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  285. this.MaximizeBox = false;
  286. this.MinimizeBox = false;
  287. this.Name = "CustomizeDialog";
  288. this.ShowInTaskbar = false;
  289. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  290. this.Text = "カスタマイズ";
  291. this._tabControl.ResumeLayout(false);
  292. this._genericPage.ResumeLayout(false);
  293. this.ResumeLayout(false);
  294. }
  295. #endregion
  296. private CustomizeTag FindCustomizeTag(ComboBox stylebox)
  297. {
  298. foreach (CustomizeTag tag in _tags)
  299. if (tag.styleBox == stylebox) return tag;
  300. return null;
  301. }
  302. private CustomizeTag FindCustomizeTagByTextBox(TextBox box)
  303. {
  304. foreach (CustomizeTag tag in _tags)
  305. if (tag.dailyParams == box || tag.weeklyParams == box || tag.monthlyParams == box || tag.yearlyParams == box) return tag;
  306. return null;
  307. }
  308. private TabPage InsertTabPage(int index, string caption)
  309. {
  310. TabPage page = new TabPage(caption);
  311. _tabControl.TabPages.Add(page);
  312. page.BackColor = ThemeUtil.TabPaneBackColor;
  313. page.Location = new System.Drawing.Point(4, 21);
  314. page.Size = new System.Drawing.Size(584, 311);
  315. return page;
  316. }
  317. protected override void OnLoad(EventArgs e)
  318. {
  319. base.OnLoad(e);
  320. }
  321. protected override void OnClosed(EventArgs e)
  322. {
  323. base.OnClosed(e);
  324. _pageIndex = _tabControl.SelectedIndex;
  325. }
  326. private void InitPages()
  327. {
  328. _tags = new ArrayList();
  329. _indicators = new ArrayList();
  330. _screeningItems = new ArrayList();
  331. _predictionItems = new ArrayList();
  332. _autoTradingItems = new ArrayList();
  333. Env.Schema.CollectIndicatorSchema(_indicators);
  334. Env.Schema.CollectScreeningSchema(_screeningItems);
  335. Env.Schema.CollectPredictionSchema(_predictionItems);
  336. Env.Schema.CollectAutoTradingSchema(_autoTradingItems);
  337. //高さの決定
  338. int m = 0;
  339. foreach (SchemaItem i in _indicators)
  340. if (i.OwnsConfig) m += i.MaxInstanceCount;
  341. m = MAX_ITEMS; //Math.Max(m, Math.Max(_screeningItems.Count, _predictionItems.Count));
  342. _tabControl.Height = m * 24 + 40;
  343. _okButton.Top = _tabControl.Bottom + 8;
  344. _cancelButton.Top = _tabControl.Bottom + 8;
  345. _resetButton.Top = _tabControl.Bottom + 8;
  346. _applyButton.Top = _tabControl.Bottom + 8;
  347. this.ClientSize = new Size(this.ClientSize.Width, _okButton.Bottom + 8);
  348. //!!オンデマンドでページ初期化できたほうがよい
  349. InitGenericPage();
  350. InitIndicatorPage(1, _indicators);
  351. InitScreeningPage(2, _screeningItems);
  352. InitPredictionPage(3, _predictionItems);
  353. InitAutoTradingPage(4, _autoTradingItems);
  354. }
  355. //基本設定
  356. private void InitGenericPage()
  357. {
  358. _lFont = new Label();
  359. _lCurrentFont = new Label();
  360. _selectFont = new Button();
  361. _lBackColor = new Label();
  362. _backColorBox = new ColPickerComboBox(); ;
  363. _lTextColor = new Label();
  364. _textColorBox = new ColPickerComboBox();
  365. _lFushiColor = new Label();
  366. _fushiColorBox = new ColPickerComboBox();
  367. _lCandleColor = new Label();
  368. _candleColorBox = new ColPickerComboBox();
  369. _candleShadowEffect = new CheckBox();
  370. _lInsenColor = new Label();
  371. _insenColorBox = new ColPickerComboBox();
  372. _lVolumeColor = new Label();
  373. _volumeColorBox = new ColPickerComboBox();
  374. _lAccumulativeVolumeLabel = new Label();
  375. _accumulativeVolumeBox = new TextBox[descs.Length];
  376. _lCreditLong = new Label();
  377. _creditLongStyleBox = new ComboBox();
  378. _creditLongColorBox = new ColPickerComboBox();
  379. _lCreditShort = new Label();
  380. _creditShortStyleBox = new ComboBox();
  381. _creditShortColorBox = new ColPickerComboBox();
  382. _lFreeLineColor = new Label();
  383. _freeLineColorBox = new ColPickerComboBox();
  384. _lFibonacciColor = new Label();//☆Fibonacci
  385. _fibonacciColorBox = new ColPickerComboBox();//☆Fibonacci
  386. _lMonthDiv = new Label();
  387. _monthDivStyleBox = new ComboBox();
  388. _monthDivColorBox = new ColPickerComboBox();
  389. _lPriceScale = new Label();
  390. _priceScaleStyleBox = new ComboBox();
  391. _priceScaleColorBox = new ColPickerComboBox();
  392. _lVolumeScale = new Label();
  393. _volumeScaleStyleBox = new ComboBox();
  394. _volumeScaleColorBox = new ColPickerComboBox();
  395. _lOscillatorScale = new Label();
  396. _oscillatorScaleStyleBox = new ComboBox();
  397. _oscillatorScaleColorBox = new ColPickerComboBox();
  398. _lMouseTracking = new Label();
  399. _mouseTrackingStyleBox = new ComboBox();
  400. _mouseTrackingColorBox = new ColPickerComboBox();
  401. _mouseTrackingModeBox = new ComboBox();
  402. _basicColorGroup.SuspendLayout();
  403. _scaleLineGroup.SuspendLayout();
  404. _genericPage.BackColor = ThemeUtil.TabPaneBackColor;
  405. int top = 16;
  406. int left1 = 8;
  407. int left2 = _tabControl.Width / 2 - 8;
  408. int tabindex = 0;
  409. InitFontUI(left1, top, ref tabindex);
  410. top += 24;
  411. InitBasicColorConfigUI(_lBackColor, "背景色(&B)", _backColorBox, left1, top, ref tabindex, Env.Preference.BackBrush.Color);
  412. InitBasicColorConfigUI(_lTextColor, "テキスト色(&T)", _textColorBox, left2, top, ref tabindex, Env.Preference.TextColor);
  413. top += 24;
  414. InitBasicColorConfigUI(_lFushiColor, "直近高値・安値(&F)", _fushiColorBox, left1, top, ref tabindex, Env.Preference.FushiColor);
  415. //区切り線
  416. Label line = new Label();
  417. line.BorderStyle = BorderStyle.Fixed3D;
  418. line.Top = top + 29;
  419. line.Height = 3;
  420. line.Left = _basicColorGroup.Width / 10;
  421. line.Width = _basicColorGroup.Width * 8 / 10;
  422. _basicColorGroup.Controls.Add(line);
  423. top += 38;
  424. InitBasicColorConfigUI(_lCandleColor, "ロウソク色(&C)", _candleColorBox, left1, top, ref tabindex, Env.Preference.CandlePen.Color);
  425. _candleShadowEffect.Text = "ロウソクの表示に影をつける(&S)";
  426. _candleShadowEffect.FlatStyle = FlatStyle.System;
  427. _candleShadowEffect.Top = top;
  428. _candleShadowEffect.Left = left2 + 16;
  429. _candleShadowEffect.Width = 160;
  430. _candleShadowEffect.TabIndex = tabindex++;
  431. _candleShadowEffect.Checked = Env.Preference.UseCandleEffect;
  432. _candleShadowEffect.CheckedChanged += new EventHandler(EnableApplyButton);
  433. _basicColorGroup.Controls.Add(_candleShadowEffect);
  434. top += 24;
  435. InitBasicColorConfigUI(_lInsenColor, "陰線の色(&I)", _insenColorBox, left1, top, ref tabindex, Env.Preference.InsenBrush.Color);
  436. //区切り線
  437. line = new Label();
  438. line.BorderStyle = BorderStyle.Fixed3D;
  439. line.Top = top + 29;
  440. line.Height = 3;
  441. line.Left = _basicColorGroup.Width / 10;
  442. line.Width = _basicColorGroup.Width * 8 / 10;
  443. _basicColorGroup.Controls.Add(line);
  444. top += 38;
  445. InitBasicLineConfigUI(_lCreditLong, "信用買残(&L)", _creditLongStyleBox, _creditLongColorBox, left1, top, ref tabindex, Env.Preference.CreditLongAppearance.Pen);
  446. InitBasicColorConfigUI(_lVolumeColor, "出来高色(&V)", _volumeColorBox, left2, top, ref tabindex, Env.Preference.VolumeBrush.Color);
  447. top += 24;
  448. InitBasicLineConfigUI(_lCreditShort, "信用売残(&H)", _creditShortStyleBox, _creditShortColorBox, left1, top, ref tabindex, Env.Preference.CreditShortAppearance.Pen);
  449. InitAccumulativeVolumeConfigUI(_lAccumulativeVolumeLabel, "価格帯別出来高(&A)", left2, top, ref tabindex, Env.Preference.AccumulativeVolumePeriod);
  450. top += 24;
  451. InitBasicColorConfigUI(_lFreeLineColor, "自由直線(&K)", _freeLineColorBox, left1, top, ref tabindex, Env.Preference.FreeLineColor);
  452. InitBasicColorConfigUI(_lFibonacciColor, "フィボナッチ", _fibonacciColorBox, left2, top, ref tabindex, Env.Preference.FibonacciColor);//☆Fibonacci
  453. //_freeLineColorBox.Left += 36; //ugly adjustment //☆Fibonacci コメントアウト
  454. top = 16;
  455. _scaleLineGroup.TabIndex = tabindex++;
  456. InitScaleLineConfigUI(_lMonthDiv, "月/四半期(&M)", _monthDivStyleBox, _monthDivColorBox, left1, top, ref tabindex, Env.Preference.MonthDivPen);
  457. InitScaleLineConfigUI(_lMouseTracking, "日付ルーラ(&D)", _mouseTrackingStyleBox, _mouseTrackingColorBox, left2, top, ref tabindex, Env.Preference.MouseTrackingLinePen);
  458. top += 24;
  459. InitScaleLineConfigUI(_lPriceScale, "価格(&P)", _priceScaleStyleBox, _priceScaleColorBox, left1, top, ref tabindex, Env.Preference.PriceScalePen);
  460. top += 24;
  461. InitScaleLineConfigUI(_lVolumeScale, "出来高(&E)", _volumeScaleStyleBox, _volumeScaleColorBox, left1, top, ref tabindex, Env.Preference.VolumeScalePen);
  462. top += 24;
  463. InitScaleLineConfigUI(_lOscillatorScale, "オシレータ(&O)", _oscillatorScaleStyleBox, _oscillatorScaleColorBox, left1, top, ref tabindex, Env.Preference.OscillatorScalePen);
  464. top += 24;
  465. _basicColorGroup.ResumeLayout();
  466. _scaleLineGroup.ResumeLayout();
  467. }
  468. private void InitBasicColorConfigUI(Label label, string caption, ColPickerComboBox cb, int left, int top, ref int tabindex, Color value)
  469. {
  470. label.Top = top;
  471. label.Left = left;
  472. label.Width = 120;
  473. label.Text = caption;
  474. label.TabIndex = tabindex++;
  475. label.TextAlign = ContentAlignment.MiddleLeft;
  476. cb.Top = top;
  477. cb.Left = label.Right;
  478. cb.Width = 120;
  479. cb.TabIndex = tabindex++;
  480. cb.Color = value;
  481. cb.NewColor += new UtilityLibrary.WinControls.ColorPickerDropDown.NewColorEventHandler(EnableApplyButton);
  482. _basicColorGroup.Controls.Add(label);
  483. _basicColorGroup.Controls.Add(cb);
  484. }
  485. private void InitBasicLineConfigUI(Label label, string caption, ComboBox stylebox, ColPickerComboBox colorbox, int left, int top, ref int tabindex, ZPen pen)
  486. {
  487. InitLineConfigUI(_basicColorGroup, label, caption, stylebox, colorbox, left, top, ref tabindex, pen);
  488. }
  489. private void InitScaleLineConfigUI(Label label, string caption, ComboBox stylebox, ColPickerComboBox colorbox, int left, int top, ref int tabindex, ZPen pen)
  490. {
  491. InitLineConfigUI(_scaleLineGroup, label, caption, stylebox, colorbox, left, top, ref tabindex, pen);
  492. }
  493. private void InitLineConfigUI(GroupBox parent, Label label, string caption, ComboBox stylebox, ColPickerComboBox colorbox, int left, int top, ref int tabindex, ZPen pen)
  494. {
  495. label.Top = top;
  496. label.Left = left;
  497. label.Width = 88;
  498. label.Text = caption;
  499. label.TabIndex = tabindex++;
  500. label.TextAlign = ContentAlignment.MiddleLeft;
  501. stylebox.DropDownStyle = ComboBoxStyle.DropDownList;
  502. stylebox.Top = top;
  503. stylebox.Left = label.Right;
  504. stylebox.Width = 52;
  505. stylebox.TabIndex = tabindex++;
  506. stylebox.Items.AddRange(EnumDescAttribute.For(typeof(ZPen.PenStyle)).DescriptionCollection());
  507. stylebox.SelectedIndex = (int)pen.Style;
  508. stylebox.SelectedIndexChanged += new EventHandler(EnableApplyButton);
  509. colorbox.Top = top;
  510. colorbox.Left = stylebox.Right + 16;
  511. colorbox.Width = 120;
  512. colorbox.TabIndex = tabindex++;
  513. colorbox.Color = pen.Color;
  514. colorbox.NewColor += new UtilityLibrary.WinControls.ColorPickerDropDown.NewColorEventHandler(EnableApplyButton);
  515. parent.Controls.Add(label);
  516. parent.Controls.Add(stylebox);
  517. parent.Controls.Add(colorbox);
  518. }
  519. private void InitFontUI(int left, int top, ref int tabindex)
  520. {
  521. _fontName = Env.Preference.FontName;
  522. _fontSize = Env.Preference.FontSize;
  523. _fontStyle = Env.Preference.FontStyle;
  524. _lFont.Left = left;
  525. _lFont.Width = 120;
  526. _lFont.Top = top;
  527. _lFont.TabIndex = tabindex++;
  528. _lFont.Text = "フォント(&F)";
  529. _lFont.TextAlign = ContentAlignment.MiddleLeft;
  530. _basicColorGroup.Controls.Add(_lFont);
  531. _lCurrentFont.Left = left + _lFont.Width;
  532. _lCurrentFont.Width = 120;
  533. _lCurrentFont.Top = top;
  534. _lCurrentFont.TabIndex = tabindex++;
  535. _lCurrentFont.Text = String.Format("{0}/{1:F0}pt", _fontName, _fontSize);
  536. _lCurrentFont.TextAlign = ContentAlignment.MiddleLeft;
  537. _basicColorGroup.Controls.Add(_lCurrentFont);
  538. _selectFont.Left = _lCurrentFont.Right;
  539. _selectFont.Top = top;
  540. _selectFont.FlatStyle = FlatStyle.System;
  541. _selectFont.Text = "選択...";
  542. _selectFont.TabIndex = tabindex++;
  543. _selectFont.Click += new EventHandler(OnSelectFont);
  544. _basicColorGroup.Controls.Add(_selectFont);
  545. }
  546. //価格帯別出来高の設定
  547. private void InitAccumulativeVolumeConfigUI(Label label, string caption, int left, int top, ref int tabindex, ChartFormatSpecificValue value)
  548. {
  549. label.Text = caption;
  550. label.Left = left;
  551. label.Top = top;
  552. label.TabIndex = tabindex++;
  553. label.Width = 120;
  554. label.TextAlign = ContentAlignment.MiddleLeft;
  555. _basicColorGroup.Controls.Add(label);
  556. int x = label.Right;
  557. for (int i = 0; i < descs.Length; i++)
  558. {
  559. TextBox t = new TextBox();
  560. t.Left = x;
  561. t.Top = top;
  562. t.TabIndex = tabindex++;
  563. t.Width = 28;
  564. t.Text = value.GetValue((ChartFormat)i).ToString();
  565. t.Validating += new CancelEventHandler(OnValidatingNumericText);
  566. t.Validated += new EventHandler(EnableApplyButton);
  567. _basicColorGroup.Controls.Add(t);
  568. _accumulativeVolumeBox[i] = t;
  569. x += t.Width;
  570. Label l = new Label();
  571. l.Text = descs[i];
  572. l.Left = x;
  573. l.Top = top;
  574. l.Width = 24;
  575. l.TabIndex = tabindex++;
  576. l.TextAlign = ContentAlignment.MiddleLeft;
  577. _basicColorGroup.Controls.Add(l);
  578. x += l.Width;
  579. }
  580. }
  581. private void CommitPreference()
  582. {
  583. Preference pr = Env.Preference;
  584. pr.FontName = _fontName;
  585. pr.FontSize = _fontSize;
  586. pr.FontStyle = _fontStyle;
  587. pr.BackBrush.Update(_backColorBox.Color);
  588. pr.DefaultBrush.Update(_textColorBox.Color);
  589. pr.CandlePen.Update(_candleColorBox.Color, _backColorBox.Color);
  590. pr.InsenBrush.Update(_insenColorBox.Color);
  591. pr.UseCandleEffect = _candleShadowEffect.Checked;
  592. pr.VolumeBrush.Update(_volumeColorBox.Color);
  593. pr.FushiColor = _fushiColorBox.Color;
  594. pr.FreeLineColor = _freeLineColorBox.Color;
  595. pr.FibonacciColor = _fibonacciColorBox.Color;//☆Fibonacci
  596. pr.MonthDivPen.Update(_monthDivColorBox.Color, (ZPen.PenStyle)_monthDivStyleBox.SelectedIndex);
  597. pr.PriceScalePen.Update(_priceScaleColorBox.Color, (ZPen.PenStyle)_priceScaleStyleBox.SelectedIndex);
  598. pr.VolumeScalePen.Update(_volumeScaleColorBox.Color, (ZPen.PenStyle)_volumeScaleStyleBox.SelectedIndex);
  599. pr.OscillatorScalePen.Update(_oscillatorScaleColorBox.Color, (ZPen.PenStyle)_oscillatorScaleStyleBox.SelectedIndex);
  600. pr.MouseTrackingLinePen.Update(_mouseTrackingColorBox.Color, (ZPen.PenStyle)_mouseTrackingStyleBox.SelectedIndex);
  601. pr.CreditLongAppearance.Pen.Update(_creditLongColorBox.Color, (ZPen.PenStyle)_creditLongStyleBox.SelectedIndex);
  602. pr.CreditShortAppearance.Pen.Update(_creditShortColorBox.Color, (ZPen.PenStyle)_creditShortStyleBox.SelectedIndex);
  603. pr.AccumulativeVolumePeriod.Update(new int[] {
  604. Int32.Parse(_accumulativeVolumeBox[0].Text),
  605. Int32.Parse(_accumulativeVolumeBox[1].Text),
  606. Int32.Parse(_accumulativeVolumeBox[2].Text),
  607. Int32.Parse(_accumulativeVolumeBox[3].Text)});
  608. CommandExec.ResetLayout();
  609. }
  610. //Indicator
  611. private void InitIndicatorPage(int index, ArrayList items)
  612. {
  613. int top = 8;
  614. int tabIndex = 0;
  615. TabPage page = _chartPage;
  616. _tabControl.Controls.Add(page);
  617. page.BackColor = ThemeUtil.TabPaneBackColor;
  618. int item_count = 0;
  619. int page_count = 1;
  620. foreach (SchemaIndicatorItem item in items)
  621. {
  622. if (!item.OwnsConfig) continue;
  623. int ic = item.MaxInstanceCount;
  624. if (item_count + ic > MAX_ITEMS)
  625. { //はみ出しそうなら
  626. _chartPage.Text = String.Format("チャート - {0}", 1);
  627. page = InsertTabPage(page_count, String.Format("チャート - {0}", ++page_count));
  628. top = 8;
  629. tabIndex = 0;
  630. item_count = 0;
  631. }
  632. for (int i = 0; i < ic; i++)
  633. {
  634. CustomizeTag tag = new CustomizeTag();
  635. tag.schemaItem = item;
  636. tag.index = i;
  637. if (i == 0)
  638. {
  639. AddLabel(page, item.Title, tabIndex++, 8, top, 120);
  640. AddHelpButton(page, tabIndex++, 128, top, item.Description);
  641. }
  642. if (ic != 1)
  643. AddLabel(page, (i + 1).ToString(), tabIndex++, 152, top, 16);
  644. if (item.Appearance.Owner == item)
  645. {
  646. tag.styleBox = AddStyleBox(page, item, i, tabIndex++, 176, top, 80);
  647. tag.colorPicker = AddColorPicker(page, item, i, tabIndex++, 264, top, 128);
  648. }
  649. SchemaParameter[] sp = item.OwnedParameters;
  650. if (sp.Length > 0)
  651. {
  652. tag.dailyParams = AddParamBox(page, item, i, ChartFormat.Daily, tabIndex++, 400, top, 48);
  653. AddLabel(page, "日", tabIndex++, 448, top, 16);
  654. tag.weeklyParams = AddParamBox(page, item, i, ChartFormat.Weekly, tabIndex++, 472, top, 48);
  655. AddLabel(page, "週", tabIndex++, 520, top, 16);
  656. tag.monthlyParams = AddParamBox(page, item, i, ChartFormat.Monthly, tabIndex++, 544, top, 48);
  657. AddLabel(page, "月", tabIndex++, 592, top, 16);
  658. tag.yearlyParams = AddParamBox(page, item, i, ChartFormat.Yearly, tabIndex++, 616, top, 48);
  659. AddLabel(page, "年", tabIndex++, 664, top, 16);
  660. tag.parameterCount = sp.Length;
  661. }
  662. if (tag.styleBox != null && (int)IndicatorStyle.None == tag.styleBox.SelectedIndex)
  663. {
  664. tag.colorPicker.Enabled = false;
  665. if (tag.dailyParams != null)
  666. {
  667. tag.dailyParams.Enabled = false;
  668. tag.weeklyParams.Enabled = false;
  669. tag.monthlyParams.Enabled = false;
  670. tag.yearlyParams.Enabled = false;
  671. }
  672. }
  673. item_count++;
  674. top += 24;
  675. _tags.Add(tag);
  676. }
  677. }
  678. }
  679. private Label AddLabel(TabPage parent, string text, int tabIndex, int left, int top, int width)
  680. {
  681. Label label = new Label();
  682. label.TextAlign = ContentAlignment.MiddleLeft;
  683. label.Text = text;
  684. label.TabIndex = tabIndex;
  685. label.Left = left;
  686. label.Top = top - 2;
  687. label.Width = width;
  688. label.Height = 24;
  689. parent.Controls.Add(label);
  690. return label;
  691. }
  692. private ComboBox AddStyleBox(TabPage parent, SchemaIndicatorItem item, int index, int tabIndex, int left, int top, int width)
  693. {
  694. ComboBox box = new ComboBox();
  695. box.DropDownStyle = ComboBoxStyle.DropDownList;
  696. box.Items.AddRange(EnumDescAttribute.For(typeof(IndicatorStyle)).DescriptionCollection());
  697. IndicatorAppearance[] ap = item.Appearance.Appearances;
  698. box.SelectedIndex = ap.Length > index ? (int)ap[index].Style : (int)IndicatorStyle.None;
  699. box.SelectedIndexChanged += new EventHandler(OnIndicatorStyleChanged);
  700. box.TabIndex = tabIndex;
  701. box.Left = left;
  702. box.Top = top;
  703. box.Width = width;
  704. box.Height = 24;
  705. parent.Controls.Add(box);
  706. return box;
  707. }
  708. private ColPickerComboBox AddColorPicker(TabPage parent, SchemaIndicatorItem item, int index, int tabIndex, int left, int top, int width)
  709. {
  710. ColPickerComboBox box = new ColPickerComboBox();
  711. IndicatorAppearance[] ap = item.Appearance.Appearances;
  712. box.Color = ap.Length > index ? ap[index].Color : Color.Empty;
  713. box.NewColor += new UtilityLibrary.WinControls.ColorPickerDropDown.NewColorEventHandler(OnNewColor);
  714. box.TabIndex = tabIndex;
  715. box.Left = left;
  716. box.Top = top;
  717. box.Width = width;
  718. box.Height = 24;
  719. parent.Controls.Add(box);
  720. return box;
  721. }
  722. private TextBox AddParamBox(TabPage parent, SchemaItem item, int index, ChartFormat format, int tabIndex, int left, int top, int width)
  723. {
  724. TextBox box = new TextBox();
  725. string t = "";
  726. for (int i = 0; i < item.ParameterCount; i++)
  727. {
  728. SchemaParameter sp = item.GetParameter(i);
  729. if (sp.Owner != item) continue;
  730. if (t.Length > 0) t += ",";
  731. double[] vs;
  732. switch (format)
  733. {
  734. case ChartFormat.Daily:
  735. default:
  736. vs = sp.DailyValues;
  737. break;
  738. case ChartFormat.Weekly:
  739. vs = sp.WeeklyValues;
  740. break;
  741. case ChartFormat.Monthly:
  742. vs = sp.MonthlyValues;
  743. break;
  744. case ChartFormat.Yearly:
  745. vs = sp.YearlyValues;
  746. break;
  747. }
  748. double v = vs.Length > index ? vs[index] : 1;
  749. t += v.ToString();
  750. }
  751. box.Text = t;
  752. box.TextChanged += new EventHandler(OnParameterTextChanged);
  753. box.Validating += new CancelEventHandler(OnValidatingParameterText);
  754. box.TabIndex = tabIndex;
  755. box.Left = left;
  756. box.Top = top;
  757. box.Width = width;
  758. box.Height = 24;
  759. parent.Controls.Add(box);
  760. return box;
  761. }
  762. private TextBox AddSingleParamBox(TabPage parent, SchemaItem item, int paramindex, ChartFormat format, int tabIndex, int left, int top, int width)
  763. {
  764. TextBox box = new TextBox();
  765. SchemaParameter sp = item.GetParameter(paramindex);
  766. switch (format)
  767. {
  768. case ChartFormat.Daily:
  769. default:
  770. box.Text = sp.DailyValues[0].ToString();
  771. break;
  772. case ChartFormat.Weekly:
  773. box.Text = sp.WeeklyValues[0].ToString();
  774. break;
  775. case ChartFormat.Monthly:
  776. box.Text = sp.MonthlyValues[0].ToString();
  777. break;
  778. case ChartFormat.Yearly:
  779. box.Text = sp.YearlyValues[0].ToString();
  780. break;
  781. }
  782. box.TextChanged += new EventHandler(OnParameterTextChanged);
  783. box.Validating += new CancelEventHandler(OnValidatingParameterText);
  784. box.TabIndex = tabIndex;
  785. box.Left = left;
  786. box.Top = top;
  787. box.Width = width;
  788. box.Height = 24;
  789. parent.Controls.Add(box);
  790. return box;
  791. }
  792. private void AddHelpButton(TabPage page, int tabIndex, int left, int top, string text)
  793. {
  794. if (text.Length == 0) return;
  795. Button btn = new NotClickableButton();
  796. btn.Left = left;
  797. btn.Top = top;
  798. btn.Width = 19;
  799. btn.Height = 19;
  800. btn.FlatStyle = FlatStyle.Flat;
  801. btn.Image = Env.ImageList16.Images[IconConst.HELP];
  802. btn.Text = "";
  803. _toolTip.SetToolTip(btn, text);
  804. btn.TabIndex = tabIndex;
  805. page.Controls.Add(btn);
  806. }
  807. private void CommitIndicators()
  808. {
  809. foreach (CustomizeTag tag in _tags)
  810. {
  811. SchemaItem it = tag.schemaItem;
  812. if (!(it is SchemaIndicatorItem)) continue;
  813. if (tag.styleBox != null)
  814. {
  815. it.Appearance.Appearances[tag.index].Style = (IndicatorStyle)tag.styleBox.SelectedIndex;
  816. it.Appearance.Appearances[tag.index].Color = tag.colorPicker.Color;
  817. }
  818. if (tag.dailyParams != null)
  819. {
  820. double[] dp = Util.ParseDoubles(tag.dailyParams.Text);
  821. double[] wp = Util.ParseDoubles(tag.weeklyParams.Text);
  822. double[] mp = Util.ParseDoubles(tag.monthlyParams.Text);
  823. double[] yp = Util.ParseDoubles(tag.yearlyParams.Text);
  824. int j = 0;
  825. for (int i = 0; i < it.ParameterCount; i++)
  826. {
  827. SchemaParameter p = it.GetParameter(i);
  828. if (p.Owner != it) continue;
  829. p.DailyValues[tag.index] = dp[j];
  830. p.WeeklyValues[tag.index] = wp[j];
  831. p.MonthlyValues[tag.index] = mp[j];
  832. p.YearlyValues[tag.index] = yp[j];
  833. j++;
  834. }
  835. }
  836. }
  837. }
  838. //Screening
  839. private void InitScreeningPage(int index, ArrayList items)
  840. {
  841. int top = 8;
  842. int tabIndex = 0;
  843. TabPage page = _screeningPage;
  844. this._tabControl.Controls.Add(page);
  845. page.BackColor = ThemeUtil.TabPaneBackColor;
  846. int page_count = 1;
  847. int item_count = 0;
  848. foreach (SchemaScreeningItem item in items)
  849. {
  850. if (!item.OwnsConfig) continue;
  851. if (item_count + item.OwnedParameters.Length > MAX_ITEMS)
  852. { //はみ出しそうなら
  853. _screeningPage.Text = String.Format("スクリーニング - {0}", 1);
  854. page = InsertTabPage(page_count, String.Format("スクリーニング - {0}", ++page_count));
  855. top = 8;
  856. tabIndex = 0;
  857. item_count = 0;
  858. }
  859. int i = 0;
  860. foreach (SchemaParameter sp in item.OwnedParameters)
  861. {
  862. CustomizeTag tag = new CustomizeTag();
  863. tag.schemaItem = item;
  864. tag.index = sp.Index;
  865. tag.parameterCount = 1;
  866. if (i == 0)
  867. {
  868. AddLabel(page, item.Title, tabIndex++, 8, top, 128);
  869. AddHelpButton(page, tabIndex++, 136, top, item.Description);
  870. }
  871. AddLabel(page, sp.Name, tabIndex++, 160, top, 64);
  872. tag.dailyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Daily, tabIndex++, 224, top, 48);
  873. AddLabel(page, sp.DailyUnit + " / ", tabIndex++, 272, top, 40);
  874. tag.weeklyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Weekly, tabIndex++, 312, top, 48);
  875. AddLabel(page, sp.WeeklyUnit + " / ", tabIndex++, 360, top, 40);
  876. tag.monthlyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Monthly, tabIndex++, 400, top, 48);
  877. AddLabel(page, sp.MonthlyUnit, tabIndex++, 448, top, 16);//なんで16?
  878. tag.yearlyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Yearly, tabIndex++, 488, top, 48);
  879. AddLabel(page, sp.YearlyUnit, tabIndex++, 536, top, 16);//なんで16?
  880. item_count++;
  881. top += 24;
  882. i++;
  883. _tags.Add(tag);
  884. }
  885. }
  886. }
  887. private void CommitScreenings()
  888. {
  889. foreach (CustomizeTag tag in _tags)
  890. {
  891. SchemaItem it = tag.schemaItem;
  892. if (!(it is SchemaScreeningItem)) continue;
  893. double dp = Double.Parse(tag.dailyParams.Text);
  894. double wp = Double.Parse(tag.weeklyParams.Text);
  895. double mp = Double.Parse(tag.monthlyParams.Text);
  896. double yp = Double.Parse(tag.yearlyParams.Text);
  897. it.GetParameter(tag.index).DailyValues = new double[] { dp };
  898. it.GetParameter(tag.index).WeeklyValues = new double[] { wp };
  899. it.GetParameter(tag.index).MonthlyValues = new double[] { mp };
  900. it.GetParameter(tag.index).YearlyValues = new double[] { yp };
  901. }
  902. }
  903. //Prediction
  904. private void InitPredictionPage(int index, ArrayList items)
  905. {
  906. int top = 8;
  907. int tabIndex = 0;
  908. TabPage page = _theoremPage;
  909. this._tabControl.Controls.Add(page);
  910. page.BackColor = ThemeUtil.TabPaneBackColor;
  911. int item_count = 0;
  912. int page_count = 1;
  913. foreach (SchemaPredictionItem item in items)
  914. {
  915. if (!item.OwnsConfig) continue;
  916. if (item_count + 1 > MAX_ITEMS / 2)
  917. { //はみ出しそうなら
  918. _theoremPage.Text = String.Format("セオリー検証 - {0}", 1);
  919. page = InsertTabPage(page_count, String.Format("セオリー検証 - {0}", ++page_count));
  920. top = 8;
  921. tabIndex = 0;
  922. item_count = 0;
  923. }
  924. AddLabel(page, item.Title, tabIndex++, 8, top, 152);
  925. AddHelpButton(page, tabIndex++, 160, top, item.Description);
  926. AddLabel(page, item.HeaderString, tabIndex++, 184, top, 384);
  927. top += 24;
  928. int i = 0;
  929. int x = 184;
  930. foreach (SchemaParameter sp in item.OwnedParameters)
  931. {
  932. CustomizeTag tag = new CustomizeTag();
  933. tag.schemaItem = item;
  934. tag.index = sp.Index;
  935. tag.parameterCount = 1;
  936. AddLabel(page, String.Format("{{{0}}}=", sp.Index), tabIndex++, x, top, 28);
  937. x += 28;
  938. tag.dailyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Daily, tabIndex++, x, top, 32);
  939. x += 32;
  940. AddLabel(page, sp.DailyUnit, tabIndex++, x, top, 48);
  941. x += 48;
  942. i++;
  943. _tags.Add(tag);
  944. }
  945. top += 24;
  946. item_count++;
  947. }
  948. }
  949. private void CommitPredictions()
  950. {
  951. foreach (CustomizeTag tag in _tags)
  952. {
  953. SchemaItem it = tag.schemaItem;
  954. if (!(it is SchemaPredictionItem)) continue;
  955. double dp = Double.Parse(tag.dailyParams.Text);
  956. it.GetParameter(tag.index).DailyValues = new double[] { dp };
  957. }
  958. }
  959. //AutoTrading
  960. private void InitAutoTradingPage(int index, ArrayList items)
  961. {
  962. int top = 8;
  963. int tabIndex = 0;
  964. TabPage page = _autoTradingPage;
  965. this._tabControl.Controls.Add(page);
  966. page.BackColor = ThemeUtil.TabPaneBackColor;
  967. int item_count = 0;
  968. int page_count = 1;
  969. foreach (SchemaAutoTradingItem item in items)
  970. {
  971. if (!item.OwnsConfig) continue;
  972. if (item_count + 1 > MAX_ITEMS / 2)
  973. { //はみ出しそうなら
  974. _autoTradingPage.Text = String.Format("自動売買検証 - {0}", 1);
  975. page = InsertTabPage(page_count, String.Format("自動売買検証 - {0}", ++page_count));
  976. top = 8;
  977. tabIndex = 0;
  978. item_count = 0;
  979. }
  980. AddLabel(page, item.Title, tabIndex++, 8, top, 152);
  981. AddHelpButton(page, tabIndex++, 160, top, item.Description);
  982. AddLabel(page, item.HeaderString, tabIndex++, 184, top, 384);
  983. top += 24;
  984. int i = 0;
  985. int x = 184;
  986. foreach (SchemaParameter sp in item.OwnedParameters)
  987. {
  988. CustomizeTag tag = new CustomizeTag();
  989. tag.schemaItem = item;
  990. tag.index = sp.Index;
  991. tag.parameterCount = 1;
  992. AddLabel(page, String.Format("{{{0}}}=", sp.Index), tabIndex++, x, top, 28);
  993. x += 28;
  994. tag.dailyParams = AddSingleParamBox(page, item, sp.Index, ChartFormat.Daily, tabIndex++, x, top, 32);
  995. x += 32;
  996. AddLabel(page, sp.DailyUnit, tabIndex++, x, top, 48);
  997. x += 48;
  998. i++;
  999. _tags.Add(tag);
  1000. }
  1001. top += 24;
  1002. item_count++;
  1003. }
  1004. }
  1005. private void CommitAutoTradings()
  1006. {
  1007. foreach (CustomizeTag tag in _tags)
  1008. {
  1009. SchemaItem it = tag.schemaItem;
  1010. if (!(it is SchemaAutoTradingItem)) continue;
  1011. double dp = Double.Parse(tag.dailyParams.Text);
  1012. it.GetParameter(tag.index).DailyValues = new double[] { dp };
  1013. }
  1014. }
  1015. private void OnIndicatorStyleChanged(object sender, EventArgs args)
  1016. {
  1017. ComboBox cb = (ComboBox)sender;
  1018. CustomizeTag tag = FindCustomizeTag(cb);
  1019. bool e = cb.SelectedIndex != (int)IndicatorStyle.None;
  1020. if (tag.colorPicker != null) tag.colorPicker.Enabled = e;
  1021. if (tag.dailyParams != null) tag.dailyParams.Enabled = e;
  1022. if (tag.weeklyParams != null) tag.weeklyParams.Enabled = e;
  1023. if (tag.monthlyParams != null) tag.monthlyParams.Enabled = e;
  1024. if (tag.yearlyParams != null) tag.yearlyParams.Enabled = e;
  1025. _applyButton.Enabled = true;
  1026. }
  1027. private void OnValidatingParameterText(object sender, CancelEventArgs args)
  1028. {
  1029. string p = "";
  1030. try
  1031. {
  1032. TextBox tb = (TextBox)sender;
  1033. CustomizeTag tag = FindCustomizeTagByTextBox(tb);
  1034. string[] t = tb.Text.Split(',');
  1035. if (t.Length != tag.parameterCount)
  1036. {
  1037. Util.Warning(this, String.Format("パラメータは{0}個の整数でなければいけません。", tag.parameterCount));
  1038. args.Cancel = true;
  1039. return;
  1040. }
  1041. foreach (string e in t)
  1042. {
  1043. p = e;
  1044. //今はパラメータはすべて正整数として扱う。
  1045. if (Int32.Parse(e) <= 0) throw new FormatException();
  1046. }
  1047. }
  1048. catch (Exception)
  1049. {
  1050. Util.Warning(this, String.Format("{0}はパラメータとして不正な形式です。", p));
  1051. args.Cancel = true;
  1052. return;
  1053. }
  1054. args.Cancel = false;
  1055. }
  1056. private void OnValidatingNumericText(object sender, CancelEventArgs args)
  1057. {
  1058. string p = ((TextBox)sender).Text;
  1059. try
  1060. {
  1061. if (Int32.Parse(p) <= 0) throw new FormatException();
  1062. }
  1063. catch (Exception)
  1064. {
  1065. Util.Warning(this, String.Format("{0}はパラメータとして不正な形式です。", p));
  1066. args.Cancel = true;
  1067. return;
  1068. }
  1069. args.Cancel = false;
  1070. }
  1071. private void OnSelectFont(object sender, EventArgs args)
  1072. {
  1073. FontDialog dlg = new FontDialog();
  1074. dlg.Font = new Font(_fontName, _fontSize);
  1075. dlg.AllowScriptChange = false;
  1076. dlg.AllowVerticalFonts = false;
  1077. dlg.FixedPitchOnly = true;
  1078. dlg.MaxSize = 24;
  1079. dlg.ShowEffects = false;
  1080. if (dlg.ShowDialog(this) == DialogResult.OK)
  1081. {
  1082. _fontName = dlg.Font.Name;
  1083. _fontSize = dlg.Font.Size;
  1084. _fontStyle = dlg.Font.Style;
  1085. _lCurrentFont.Text = String.Format("{0}/{1:F0}pt", _fontName, _fontSize);
  1086. _applyButton.Enabled = true;
  1087. }
  1088. }
  1089. private void OnReset(object sender, EventArgs args)
  1090. {
  1091. if (Util.AskUserYesNo(this, "すべての設定を初期化します。カスタマイズした内容はすべて失われますがよろしいですか?") == DialogResult.Yes)
  1092. {
  1093. Env.ResetWithoutConfig();
  1094. this.DialogResult = DialogResult.OK;
  1095. Close();
  1096. }
  1097. }
  1098. private void OnOK(object sender, EventArgs args)
  1099. {
  1100. CommitConfigs();
  1101. }
  1102. private void OnApplyButtonClicked(object sender, EventArgs args)
  1103. {
  1104. CommitConfigs();
  1105. CommandExec.RefreshChart();
  1106. _applyButton.Enabled = false;
  1107. }
  1108. private void CommitConfigs()
  1109. {
  1110. CommitPreference();
  1111. CommitIndicators();
  1112. CommitScreenings();
  1113. CommitPredictions();
  1114. CommitAutoTradings();
  1115. }
  1116. private void EnableApplyButton(object sender, NewColorArgs e)
  1117. {
  1118. _applyButton.Enabled = true;
  1119. }
  1120. private void EnableApplyButton(object sender, EventArgs args)
  1121. {
  1122. _applyButton.Enabled = true;
  1123. }
  1124. private void OnParameterTextChanged(object sender, EventArgs args)
  1125. {
  1126. _applyButton.Enabled = true;
  1127. }
  1128. private void OnNewColor(object sender, NewColorArgs args)
  1129. {
  1130. _applyButton.Enabled = true;
  1131. }
  1132. }
  1133. }
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト