Pastebin: OmegaChart Fibonacciトレースメント Command.cs 追加修正ポイントには//☆Fibonacci

Format
Plain text
Post date
2017-12-27 19:53
Zeitraum der Veröffentlichung
Unbegrenzt
  1. using System;
  2. using System.Xml;
  3. using System.IO;
  4. using System.Drawing;
  5. using System.Diagnostics;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections;
  9. using System.Security.Cryptography;
  10. using Zanetti.Arithmetic;
  11. using Zanetti.Data;
  12. using Zanetti.DataSource;
  13. using Zanetti.Forms;
  14. using Zanetti.Config;
  15. using Zanetti.SystemTrading.Screening;
  16. using Zanetti.SystemTrading.AutoTrading;
  17. using Zanetti.Prediction;
  18. using Zanetti.Indicators;
  19. using Zanetti.UI;
  20. using Zanetti.Parser;
  21. using Travis.Storage;
  22. using Travis.Util;
  23. using Travis.PKI;
  24. using Crownwood.Magic.Common;
  25. using Crownwood.Magic.Controls;
  26. using Crownwood.Magic.Docking;
  27. using TabControl = Crownwood.Magic.Controls.TabControl;
  28. //using Crownwood.DotNetMagic.Menus;
  29. namespace Zanetti.Commands
  30. {
  31. /* 新しいコマンドを追加するときは次のことをすること
  32. *
  33. * 1) Command.CIDのEnum値に追加
  34. * 2) Command#Init, Execを修正
  35. * 3) コマンドがメニューやツールバーを持つ場合は、MenuItemとCommandの関連付けなどを追加
  36. */
  37. internal enum CommandResult
  38. {
  39. Succeeded,
  40. Ignored,
  41. Failed
  42. }
  43. //キーカスタマイズダイアログではこの順番で表示される
  44. internal enum CID
  45. {
  46. None = 0,
  47. //ダイアログ表示
  48. ShowDownloadDialog,
  49. ShowInitializeDialog,
  50. ShowPrintDialog,
  51. ShowCustomizeDialog,
  52. ShowScreeningDialog,
  53. ShowPredictionDialog,
  54. ShowAutoTradingDialog,
  55. ShowAddBookmarkDialog,
  56. ShowAboutBox,
  57. ShowExtensionKitDialog,
  58. ShowTestKitDialog,
  59. ShowSearchBrandDialog,
  60. ShowKeyConfigDialog,
  61. ShowEnvironmentDialog,
  62. RegisterUserCode,
  63. //スタイル変更
  64. SetStyleDaily,
  65. SetStyleWeekly,
  66. SetStyleMonthly,
  67. SetStyleYearly,
  68. SetStyleHalfDaily, //堂島用
  69. ShrinkCandleWidth,
  70. ExpandCandleWidth,
  71. ToggleLogarithmStyle,
  72. ToggleInverseStyle,
  73. ClearFreeLines,
  74. ToggleBookmarkPane,
  75. ToggleSplitAdjuster,
  76. ToggleScaleLock,
  77. TogglePriceEnabled,
  78. ToggleAccumulativeVolumeEnabled,
  79. //移動
  80. MoveToFirstDate,
  81. MoveToLastDate,
  82. MoveToPrevPage,
  83. MoveToNextPage,
  84. MoveToPrevDate, //ロウソク1本分の移動
  85. MoveToNextDate,
  86. ShowPrevBrand, //現在見えているペインでの銘柄移動
  87. ShowNextBrand,
  88. ShowPrevCode, //コード順での移動
  89. ShowNextCode,
  90. Back,
  91. Front,
  92. //データ関係
  93. UpdateCurrentData,
  94. DownloadIndexFile,
  95. ExportBrand,
  96. ExportHalfDaily,
  97. //Web
  98. OpenWeb,
  99. OpenCompanyInfoSite_Yahoo,
  100. OpenCompanyInfoSite_Infoseek,
  101. OpenCompanyInfoSite_Nikkei,
  102. OpenCompanyInfoSite_Livedoor,
  103. //その他
  104. Quit,
  105. ReloadKit,
  106. //これより前にあるコマンドはキーカスタマイズ等の一覧で出てくる。後のコマンドは出てこない。
  107. VisibleCount,
  108. ShowInputCode,
  109. ShowSpecifiedBrand,
  110. //サポート用コマンド
  111. #if ENABLE_SUPPORT_COMMAND
  112. SupRebuildIndex,
  113. SupCreateKey,
  114. SupReload,
  115. SupCreateCert,
  116. SupStatistics,
  117. SupShrinkData,
  118. #endif
  119. //終端
  120. Count
  121. }
  122. internal class Command : ICloneable
  123. {
  124. private CID _id;
  125. private string _description;
  126. private Keys _shortcut;
  127. public CID ID
  128. {
  129. get
  130. {
  131. return _id;
  132. }
  133. }
  134. public string Description
  135. {
  136. get
  137. {
  138. return _description;
  139. }
  140. }
  141. public Keys Shortcut
  142. {
  143. get
  144. {
  145. return _shortcut;
  146. }
  147. }
  148. public object Clone()
  149. {
  150. return new Command(_id, _description, _shortcut);
  151. }
  152. /// これはCommandCollectionからしか呼ばない。
  153. public void SetChortcut(Keys key)
  154. {
  155. _shortcut = key;
  156. }
  157. public bool Visible
  158. {
  159. get
  160. {
  161. return _id < CID.VisibleCount;
  162. }
  163. }
  164. public Command(CID id, string description, Keys shortcut)
  165. {
  166. _id = id;
  167. _description = description;
  168. _shortcut = shortcut;
  169. }
  170. public CommandResult Exec()
  171. {
  172. switch (_id)
  173. {
  174. //ダイアログ表示
  175. case CID.ShowDownloadDialog:
  176. return CommandExec.ShowDownloadDialog();
  177. case CID.ShowInitializeDialog:
  178. return CommandExec.ShowInitializeDialog();
  179. case CID.ShowPrintDialog:
  180. return CommandExec.ShowPrintDialog();
  181. case CID.ShowCustomizeDialog:
  182. return CommandExec.ShowCustomizeDialog();
  183. case CID.ShowScreeningDialog:
  184. return CommandExec.ShowScreeningDialog();
  185. case CID.ShowPredictionDialog:
  186. return CommandExec.ShowPredictionDialog();
  187. case CID.ShowAutoTradingDialog:
  188. return CommandExec.ShowAutoTradingDialog();
  189. case CID.ShowAddBookmarkDialog:
  190. return CommandExec.ShowAddBookmarkDialog();
  191. case CID.ShowAboutBox:
  192. return CommandExec.AboutBox();
  193. case CID.ShowExtensionKitDialog:
  194. return CommandExec.ShowExtensionKitDialog();
  195. case CID.ShowTestKitDialog:
  196. return CommandExec.ShowKitTestDialog();
  197. case CID.ShowSearchBrandDialog:
  198. return CommandExec.ShowSearchBrandDialog();
  199. case CID.ShowKeyConfigDialog:
  200. return CommandExec.ShowKeyConfigDialog();
  201. case CID.ShowEnvironmentDialog:
  202. return CommandExec.ShowEnvironmentDialog();
  203. case CID.RegisterUserCode:
  204. return CommandExec.RegisterUserCode();
  205. //スタイル変更
  206. case CID.SetStyleDaily:
  207. return CommandExec.SetChartFormat(ChartFormat.Daily);
  208. case CID.SetStyleWeekly:
  209. return CommandExec.SetChartFormat(ChartFormat.Weekly);
  210. case CID.SetStyleMonthly:
  211. return CommandExec.SetChartFormat(ChartFormat.Monthly);
  212. case CID.SetStyleYearly:
  213. return CommandExec.SetChartFormat(ChartFormat.Yearly);
  214. #if DOJIMA
  215. case CID.SetStyleHalfDaily:
  216. return CommandExec.SetChartFormat(ChartFormat.HalfDaily);
  217. case CID.ExportHalfDaily:
  218. return CommandExec.ExportHalfDailyData();
  219. #endif
  220. case CID.ShrinkCandleWidth:
  221. return CommandExec.ShrinkCandleWidth();
  222. case CID.ExpandCandleWidth:
  223. return CommandExec.ExpandCandleWidth();
  224. case CID.ToggleLogarithmStyle:
  225. return CommandExec.SetLogarithmStyle(!Env.Preference.LogScale);
  226. case CID.ToggleInverseStyle:
  227. return CommandExec.SetInverseStyle(!Env.Preference.InverseChart);
  228. case CID.ClearFreeLines:
  229. return CommandExec.ClearFreeLines();
  230. case CID.ToggleBookmarkPane:
  231. return CommandExec.ShowBookmarkPane(!Env.Frame.IsBookmarkPaneVisible);
  232. case CID.ToggleSplitAdjuster:
  233. return CommandExec.SetSplitAdjuster(!Env.Preference.AdjustSplit);
  234. case CID.ToggleScaleLock:
  235. return CommandExec.SetScaleLock(!Env.Preference.ScaleLock);
  236. case CID.TogglePriceEnabled:
  237. return CommandExec.SetPriceEnabled(!Env.Preference.ShowPrice);
  238. case CID.ToggleAccumulativeVolumeEnabled:
  239. return CommandExec.SetAccumulativeVolumeEnabled(!Env.Preference.ShowAccumulativeVolume);
  240. //移動
  241. case CID.MoveToFirstDate:
  242. return CommandExec.JumpDate(Keys.Home);
  243. case CID.MoveToLastDate:
  244. return CommandExec.JumpDate(Keys.End);
  245. case CID.MoveToNextPage:
  246. return CommandExec.JumpDate(Keys.PageDown);
  247. case CID.MoveToPrevPage:
  248. return CommandExec.JumpDate(Keys.PageUp);
  249. case CID.MoveToNextDate:
  250. return CommandExec.JumpDate(Keys.Right);
  251. case CID.MoveToPrevDate:
  252. return CommandExec.JumpDate(Keys.Left);
  253. case CID.ShowNextBrand:
  254. return CommandExec.ShowNextBrand();
  255. case CID.ShowPrevBrand:
  256. return CommandExec.ShowPrevBrand();
  257. case CID.ShowNextCode:
  258. return CommandExec.ShowNextCode();
  259. case CID.ShowPrevCode:
  260. return CommandExec.ShowPrevCode();
  261. case CID.Back:
  262. return CommandExec.Back(1);
  263. case CID.Front:
  264. return CommandExec.Front(1);
  265. //データ関係
  266. case CID.DownloadIndexFile:
  267. return CommandExec.DownloadIndexFile();
  268. case CID.UpdateCurrentData:
  269. return CommandExec.UpdateCurrentData();
  270. case CID.ExportBrand:
  271. return CommandExec.ExportBrand();
  272. //Web
  273. case CID.OpenWeb:
  274. return CommandExec.OpenWeb();
  275. case CID.OpenCompanyInfoSite_Yahoo:
  276. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Yahoo);
  277. case CID.OpenCompanyInfoSite_Infoseek:
  278. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Infoseek);
  279. case CID.OpenCompanyInfoSite_Nikkei:
  280. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Nikkei);
  281. case CID.OpenCompanyInfoSite_Livedoor:
  282. return CommandExec.OpenCompanyInfoPage(CompanyInfoSite.Livedoor);
  283. //その他
  284. case CID.Quit:
  285. return CommandExec.Quit();
  286. case CID.ReloadKit:
  287. return CommandExec.Reload(null);
  288. #if ENABLE_SUPPORT_COMMAND
  289. case CID.SupRebuildIndex:
  290. {
  291. Data.StaticGrouping.Run();
  292. return CommandResult.Succeeded;
  293. }
  294. case CID.SupReload:
  295. return CommandExec.Reload(null);
  296. case CID.SupCreateKey:
  297. return CommandExec.CreateKey();
  298. case CID.SupCreateCert:
  299. return CommandExec.GenerateUserCode();
  300. case CID.SupStatistics:
  301. return CommandExec.StatisticsTest();
  302. case CID.SupShrinkData:
  303. return CommandExec.ShrinkData();
  304. #endif
  305. default:
  306. Debug.WriteLine("Unknown command " + _id);
  307. return CommandResult.Ignored;
  308. }
  309. }
  310. }
  311. internal class CommandCollection : ICloneable
  312. {
  313. //Collection
  314. private Hashtable _keyToCommand;
  315. private Command[] _idArray;
  316. public CommandCollection(StorageNode keys)
  317. {
  318. Init(keys);
  319. }
  320. public void Reset()
  321. {
  322. Init(null);
  323. }
  324. private CommandCollection()
  325. {
  326. _keyToCommand = new Hashtable();
  327. _idArray = new Command[(int)CID.Count];
  328. }
  329. public object Clone()
  330. {
  331. CommandCollection r = new CommandCollection();
  332. foreach (Command cmd in _idArray)
  333. {
  334. Command nc = (Command)cmd.Clone();
  335. r._idArray[(int)nc.ID] = nc;
  336. if (nc.Shortcut != Keys.None) r._keyToCommand[nc.Shortcut] = nc;
  337. }
  338. return r;
  339. }
  340. private void Init(StorageNode keys)
  341. {
  342. _keyToCommand = new Hashtable();
  343. _idArray = new Command[(int)CID.Count];
  344. //ダイアログ表示
  345. AddCommand(CID.ShowDownloadDialog, "データのダウンロード", keys, Keys.Control | Keys.O);
  346. AddCommand(CID.ShowInitializeDialog, "データの初期化", keys, Keys.None);
  347. AddCommand(CID.ShowPrintDialog, "印刷", keys, Keys.Control | Keys.P);
  348. AddCommand(CID.ShowCustomizeDialog, "カスタマイズ", keys, Keys.Control | Keys.T);
  349. AddCommand(CID.ShowScreeningDialog, "スクリーニング", keys, Keys.Control | Keys.S);
  350. AddCommand(CID.ShowAutoTradingDialog, "自動売買検証", keys, Keys.Control | Keys.V);
  351. AddCommand(CID.ShowPredictionDialog, "セオリー検証", keys, Keys.None);
  352. AddCommand(CID.ShowAddBookmarkDialog, "ブックマークへの追加", keys, Keys.None);
  353. AddCommand(CID.ShowAboutBox, "バージョン情報の表示", keys, Keys.None);
  354. AddCommand(CID.ShowKeyConfigDialog, "キー割り当てのカスタマイズ", keys, Keys.None);
  355. AddCommand(CID.ShowEnvironmentDialog, "環境設定", keys, Keys.None);
  356. AddCommand(CID.ShowExtensionKitDialog, "拡張キット一覧", keys, Keys.None);
  357. AddCommand(CID.ShowTestKitDialog, "拡張キットテスト", keys, Keys.None);
  358. AddCommand(CID.ShowSearchBrandDialog, "銘柄の検索", keys, Keys.Control | Keys.F);
  359. AddCommand(CID.RegisterUserCode, "Contribution Certificateの登録", keys, Keys.None);
  360. //スタイル変更
  361. AddCommand(CID.SetStyleDaily, "日足表示", keys, Keys.Control | Keys.D);
  362. AddCommand(CID.SetStyleWeekly, "週足表示", keys, Keys.Control | Keys.W);
  363. AddCommand(CID.SetStyleMonthly, "月足表示", keys, Keys.Control | Keys.M);
  364. AddCommand(CID.SetStyleYearly, "年足表示", keys, Keys.Control | Keys.Y);
  365. AddCommand(CID.SetStyleHalfDaily, "半日足表示", keys, Keys.Control | Keys.H);
  366. AddCommand(CID.ShrinkCandleWidth, "ロウソク幅の縮小", keys, Keys.Control | Keys.OemMinus);
  367. AddCommand(CID.ExpandCandleWidth, "ロウソク幅の拡大", keys, Keys.Control | Keys.Oemplus);
  368. AddCommand(CID.ToggleLogarithmStyle, "対数表示切替", keys, Keys.Control | Keys.L);
  369. AddCommand(CID.ToggleInverseStyle, "上下反転表示切替", keys, Keys.Control | Keys.R);
  370. AddCommand(CID.ClearFreeLines, "自由直線のクリア", keys, Keys.None);
  371. AddCommand(CID.ToggleBookmarkPane, "ブックマーク表示の切替", keys, Keys.Control | Keys.B);
  372. AddCommand(CID.ToggleSplitAdjuster, "分割の考慮切替", keys, Keys.None);
  373. AddCommand(CID.ToggleScaleLock, "縮尺の固定", keys, Keys.None);
  374. AddCommand(CID.TogglePriceEnabled, "価格と凡例の表示", keys, Keys.None);
  375. AddCommand(CID.ToggleAccumulativeVolumeEnabled, "価格帯出来高の表示", keys, Keys.None);
  376. //移動
  377. AddCommand(CID.MoveToFirstDate, "最初の日付へ移動", keys, Keys.Home);
  378. AddCommand(CID.MoveToLastDate, "最後の日付へ移動", keys, Keys.End);
  379. //このブロックはKeyConfigDialogでカスタマイズできる。1コマンドずつの独立ではないことに注意
  380. AddCommand(CID.MoveToNextPage, "1画面先の日付へ移動", keys, Keys.None);
  381. AddCommand(CID.MoveToPrevPage, "1画面前の日付へ移動", keys, Keys.None);
  382. AddCommand(CID.MoveToNextDate, "1日次へ", keys, Keys.None);
  383. AddCommand(CID.MoveToPrevDate, "1日前へ", keys, Keys.None);
  384. AddCommand(CID.ShowNextBrand, "次の表示順銘柄", keys, Keys.None);
  385. AddCommand(CID.ShowPrevBrand, "前の表示順銘柄", keys, Keys.None);
  386. AddCommand(CID.ShowNextCode, "次のコード順銘柄", keys, Keys.None);
  387. AddCommand(CID.ShowPrevCode, "前のコード順銘柄", keys, Keys.None);
  388. AddCommand(CID.Back, "戻る", keys, Keys.Back);
  389. AddCommand(CID.Front, "進む", keys, Keys.Shift | Keys.Back);
  390. AddCommand(CID.ShowInputCode, "コード入力", keys, Keys.None);
  391. //データ関係
  392. AddCommand(CID.DownloadIndexFile, "インデックスファイルのダウンロード", keys, Keys.None);
  393. AddCommand(CID.UpdateCurrentData, "現在の銘柄を更新", keys, Keys.F5);
  394. AddCommand(CID.ExportBrand, "データのエクスポート", keys, Keys.None);
  395. AddCommand(CID.ExportHalfDaily, "半日足データのエクスポート", keys, Keys.None);
  396. //Web
  397. AddCommand(CID.OpenWeb, "OmegaChartのWebを開く", keys, Keys.None);
  398. AddCommand(CID.OpenCompanyInfoSite_Yahoo, "Yahooの企業情報ページを開く", keys, Keys.None);
  399. AddCommand(CID.OpenCompanyInfoSite_Infoseek, "Infoseekの企業情報ページを開く", keys, Keys.None);
  400. AddCommand(CID.OpenCompanyInfoSite_Nikkei, "日経の企業情報ページを開く", keys, Keys.None);
  401. AddCommand(CID.OpenCompanyInfoSite_Livedoor, "livedoorの企業情報ページを開く", keys, Keys.None);
  402. //その他
  403. AddCommand(CID.Quit, "OmegaChartの終了", keys, Keys.Control | Keys.Shift | Keys.X);
  404. AddCommand(CID.ReloadKit, "拡張キットのリロード", keys, Keys.None);
  405. //サポート用コマンド
  406. #if ENABLE_SUPPORT_COMMAND
  407. AddCommand(CID.SupRebuildIndex, "Active500などのindex再作成", keys, Keys.None);
  408. AddCommand(CID.SupReload, "リロード", keys, Keys.None);
  409. AddCommand(CID.SupCreateKey, "キーの再作成", keys, Keys.None);
  410. AddCommand(CID.SupCreateCert, "Contribution Cert作成", keys, Keys.None);
  411. AddCommand(CID.SupStatistics, "Statistics", keys, Keys.None);
  412. AddCommand(CID.SupShrinkData, "データ縮小", keys, Keys.None);
  413. #endif
  414. }
  415. private void AddCommand(CID cid, string desc, StorageNode keys, Keys def)
  416. {
  417. Keys k = keys == null ? def : Util.ParseKey(keys[cid.ToString()]);
  418. Command cmd = new Command(cid, desc, k);
  419. _idArray[(int)cid] = cmd;
  420. if (k != Keys.None) _keyToCommand[k] = cmd;
  421. }
  422. public Command Get(CID cid)
  423. {
  424. Command r = _idArray[(int)cid];
  425. Debug.Assert(r != null);
  426. return r;
  427. }
  428. public CommandResult Exec(CID cid)
  429. {
  430. Command cmd = Get(cid);
  431. Debug.Assert(cmd != null);
  432. return cmd.Exec();
  433. }
  434. public CommandResult Exec(Keys key)
  435. {
  436. Command cmd = _keyToCommand[key] as Command;
  437. CID cid;
  438. if (cmd != null)
  439. return cmd.Exec();
  440. else if ((cid = Env.Options.KeyConfig.Translate(key)) != CID.None)
  441. {
  442. return Exec(cid);
  443. }
  444. else if (Keys.D0 <= key && key <= Keys.D9)
  445. {
  446. CommandExec.PromptInputCode(false, (char)('0' + (key - Keys.D0)));
  447. return CommandResult.Succeeded;
  448. }
  449. else if (Keys.NumPad0 <= key && key <= Keys.NumPad9)
  450. {
  451. CommandExec.PromptInputCode(false, (char)('0' + (key - Keys.NumPad0)));
  452. return CommandResult.Succeeded;
  453. }
  454. else
  455. return CommandResult.Ignored;
  456. }
  457. public CommandResult Exec(ref Message m)
  458. {
  459. if (m.Msg == Win32.WM_KEYDOWN)
  460. {
  461. int k = m.WParam.ToInt32();
  462. return Exec((Keys)k | Control.ModifierKeys); //VKシリーズ定数と同じと仮定
  463. }
  464. else if (m.Msg == Win32.WM_MOUSEWHEEL)
  465. {
  466. return ExecMouseWheel(m.WParam.ToInt32() >> 16);
  467. }
  468. else
  469. return CommandResult.Ignored;
  470. }
  471. public CommandResult ExecMouseWheel(int delta)
  472. {
  473. CID cid;
  474. if ((cid = Env.Options.KeyConfig.TranslateWheel(delta)) != CID.None)
  475. {
  476. return Exec(cid);
  477. }
  478. else
  479. return CommandResult.Ignored;
  480. }
  481. public IEnumerator Enum()
  482. {
  483. return _idArray.GetEnumerator();
  484. }
  485. public void SetKeyAssign(Command cmd, Keys newkey)
  486. {
  487. Debug.Assert(_keyToCommand[newkey] == null);
  488. _keyToCommand[cmd.Shortcut] = null;
  489. _keyToCommand[newkey] = cmd;
  490. cmd.SetChortcut(newkey);
  491. }
  492. public void SaveTo(StorageNode node)
  493. {
  494. foreach (Command cmd in _idArray)
  495. {
  496. if (cmd.Shortcut != Keys.None)
  497. node[cmd.ID.ToString()] = Util.FormatShortcut(cmd.Shortcut);
  498. }
  499. }
  500. }
  501. internal class CommandExec
  502. {
  503. public static CommandResult ShowBrand(AbstractBrand b)
  504. {
  505. AbstractBrand old = Env.Frame.ChartCanvas.GetBrand();
  506. if (old != null) Env.BrandHistory.Update(old);
  507. CommandResult r = ShowBrandInternal(b);
  508. return r;
  509. }
  510. private static CommandResult ShowBrandInternal(AbstractBrand b)
  511. {
  512. Env.Preference.ScaleLock = false;
  513. RefreshChart();
  514. Env.Frame.ChartCanvas.LoadBrand(b, true);
  515. KitTestDialog kittest = Env.Frame.CurrentModelessDialog as KitTestDialog;
  516. if (kittest != null) kittest.UpdateBrandName();
  517. return CommandResult.Succeeded;
  518. }
  519. public static CommandResult Back(int step)
  520. {
  521. if (!Env.BrandHistory.HasBack) return CommandResult.Ignored;
  522. AbstractBrand b = Env.BrandHistory.Back(Env.Frame.ChartCanvas.GetBrand(), step);
  523. return ShowBrandInternal(b);
  524. }
  525. public static CommandResult Front(int step)
  526. {
  527. if (!Env.BrandHistory.HasFront) return CommandResult.Ignored;
  528. AbstractBrand b = Env.BrandHistory.Redo(Env.Frame.ChartCanvas.GetBrand(), step);
  529. return ShowBrandInternal(b);
  530. }
  531. public static CommandResult ClearFreeLines()
  532. {
  533. Env.FreeLines.Clear(Env.Frame.ChartCanvas.GetBrand(), Env.CurrentIndicators.Format, Env.Preference.LogScale);
  534. Env.Fibonacci.Clear(Env.Frame.ChartCanvas.GetBrand(), Env.CurrentIndicators.Format, Env.Preference.LogScale);//☆Fibonacci
  535. Env.Frame.ChartCanvas.DrawingEngine.ClearScale();
  536. Env.Frame.ChartCanvas.Invalidate();
  537. return CommandResult.Succeeded;
  538. }
  539. public static CommandResult ShowDownloadDialog()
  540. {
  541. return ShowDownloadDialog(null);
  542. }
  543. public static CommandResult ShowDownloadDialog(DownloadOrder order)
  544. {
  545. MainFrame f = Env.Frame;
  546. //!!ModelessDialog機構はまだ未完成
  547. DownloadDialog dlg = new DownloadDialog(order);
  548. #if PRIVATE_FEATURE //自分専用:ダウンロードしたら即hottestでスクリーニング
  549. if(Control.ModifierKeys==Keys.Control) {
  550. dlg.RunScreeningNow = true;
  551. dlg.Text = "自分専用ダウンロード 即スクリーニング";
  552. }
  553. #endif
  554. dlg.Owner = f;
  555. Rectangle rc = f.DesktopBounds;
  556. dlg.Left = (rc.Left + rc.Right) / 2 - dlg.Width / 2;
  557. dlg.Top = (rc.Top + rc.Bottom) / 2 - dlg.Height / 2;
  558. //f.CurrentModelessDialog = dlg;
  559. dlg.Show();
  560. return CommandResult.Succeeded;
  561. }
  562. public static CommandResult ShowInitializeDialog()
  563. {
  564. InitializeData dlg = new InitializeData();
  565. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  566. {
  567. return RefreshChart();
  568. }
  569. else
  570. return CommandResult.Failed;
  571. }
  572. private static CodeInput _codeInput;
  573. public static void PromptInputCode(bool fromMenu, char ch)
  574. {
  575. if (_codeInput == null) _codeInput = new CodeInput(); //2回目から再利用
  576. if (!fromMenu) _codeInput.StockCode = (int)(ch - '0');
  577. if (_codeInput.ShowDialog(Env.Frame) == DialogResult.OK)
  578. {
  579. AbstractBrand br = Env.BrandCollection.FindBrand(_codeInput.StockCode);
  580. if (br != null)
  581. ShowBrand(br);
  582. if (fromMenu)
  583. Util.Information(Env.Frame, "このメニューを使うかわりに、通常の画面で4桁の数値を打ち込めば銘柄を指定することができます。");
  584. }
  585. }
  586. public static CommandResult ShowPrintDialog()
  587. {
  588. new PrintSupport().ShowPrintDialog();
  589. return CommandResult.Succeeded;
  590. }
  591. public static CommandResult ShowCustomizeDialog()
  592. {
  593. CustomizeDialog dlg = new CustomizeDialog();
  594. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  595. {
  596. RefreshChart(null);
  597. }
  598. return CommandResult.Succeeded;
  599. }
  600. public static CommandResult ExportBrand()
  601. {
  602. ExportDialog dlg = new ExportDialog();
  603. dlg.ShowDialog(Env.Frame);
  604. return CommandResult.Succeeded;
  605. }
  606. public static CommandResult ShowScreeningDialog()
  607. {
  608. if (Env.Frame.CurrentModelessDialog != null)
  609. {
  610. Util.Warning(Env.Frame, "現在ダウンロードを実行中のため、スクリーニングはできません。");
  611. return CommandResult.Succeeded;
  612. }
  613. ScreeningDialog dlg = new ScreeningDialog();
  614. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  615. {
  616. if (dlg.ScreeningOrder.Result != null)
  617. {
  618. if (dlg.ScreeningOrder.Result.ResultCount > 0)
  619. {
  620. ScreeningResultPane pane = new ScreeningResultPane(dlg.ScreeningOrder);
  621. AddDockingPane(pane, dlg.ScreeningOrder.Name, pane.RequiredWidth, IconConst.SEARCH);
  622. }
  623. }
  624. }
  625. return CommandResult.Succeeded;
  626. }
  627. public static CommandResult ShowPredictionDialog()
  628. {
  629. PredictionDialog dlg = new PredictionDialog();
  630. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  631. {
  632. if (dlg.Result != null)
  633. {
  634. if (dlg.Result.HitCount == 0)
  635. {
  636. Util.Warning(Env.Frame, "条件に該当するデータはありませんでした。");
  637. }
  638. else
  639. {
  640. PredictionResultPane pane = new PredictionResultPane(dlg.Result);
  641. AddDockingPane(pane, dlg.Result.Item.Title, pane.RequiredWidth, IconConst.COPY);
  642. }
  643. }
  644. }
  645. return CommandResult.Succeeded;
  646. }
  647. public static CommandResult ShowAutoTradingDialog()
  648. {
  649. AutoTradingDialog dlg = new AutoTradingDialog();
  650. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  651. {
  652. if (dlg.Result != null)
  653. {
  654. AutoTradingResultPane pane = new AutoTradingResultPane(dlg.Result);
  655. AddDockingPane(pane, dlg.Result.Item.Title, pane.RequiredWidth, IconConst.COPY);
  656. }
  657. }
  658. return CommandResult.Succeeded;
  659. }
  660. private static Content AddDockingPane(Control content, string title, int width, int imgindex)
  661. {
  662. DockingManager m = Env.Frame.DockingManager;
  663. WindowContentTabbed wc = FindTabControl(m, State.DockLeft);
  664. Content c;
  665. if (wc == null)
  666. {
  667. c = m.Contents.Add(content, title);
  668. c.DisplaySize = new Size(width + 16, 500);
  669. c.FloatingSize = new Size(width + 16, 500);
  670. m.AddContentWithState(c, State.DockLeft);
  671. }
  672. else
  673. {
  674. c = m.Contents.Add(content, title);
  675. //通常のタブがあればそこに追加
  676. if (wc.TabControl.HideTabsMode == TabControl.HideTabsModes.HideUsingLogic)
  677. m.AddContentToWindowContent(c, wc);
  678. c.BringToFront();
  679. }
  680. c.ImageList = Env.ImageList16;
  681. c.ImageIndex = imgindex;
  682. return c;
  683. }
  684. private static WindowContentTabbed FindTabControl(DockingManager m, State s)
  685. {
  686. foreach (Content c in m.Contents)
  687. {
  688. WindowContentTabbed t = c.ParentWindowContent as WindowContentTabbed;
  689. if (t != null && t.State == s) return t;
  690. }
  691. return null;
  692. }
  693. public static CommandResult ShowAddBookmarkDialog()
  694. {
  695. SelectBookmarkFolder dlg = new SelectBookmarkFolder();
  696. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  697. {
  698. AbstractBrand br = Env.Frame.ChartCanvas.GetBrand();
  699. if (dlg.ResultFolder.ContainsCode(br.Code, false))
  700. Util.Warning(Env.Frame, "既に同じ銘柄が登録されています。");
  701. else
  702. {
  703. Content cnt = Env.Frame.BookmarkPaneContent;
  704. if (cnt != null && !cnt.Visible)
  705. ShowBookmarkPane(true);
  706. dlg.ResultFolder.AddChild(new BrandBookmark(dlg.ResultFolder, br.Code), null);
  707. }
  708. }
  709. return CommandResult.Succeeded;
  710. }
  711. public static CommandResult ShowBookmarkPane(bool show)
  712. {
  713. if (show)
  714. {
  715. foreach (Content content in Env.Frame.DockingManager.Contents)
  716. {
  717. if (content.Control is BookmarkPane)
  718. {
  719. content.BringToFront();
  720. return CommandResult.Failed;
  721. }
  722. }
  723. BookmarkPane pane = new BookmarkPane();
  724. Env.Frame.BookmarkPaneContent = AddDockingPane(pane, "お気に入り", 150, IconConst.STAR);
  725. }
  726. else
  727. {
  728. foreach (Content content in Env.Frame.DockingManager.Contents)
  729. {
  730. if (content.Control is BookmarkPane)
  731. {
  732. Env.Frame.DockingManager.Contents.Remove(content);
  733. return CommandResult.Failed;
  734. }
  735. }
  736. //Env.Frame.DockingManager.Contents.Remove(Env.Frame.BookmarkPaneContent);
  737. //Env.Frame.BookmarkPaneContent = null;
  738. //Env.Frame.DockingManager.HideContent(Env.Frame.BookmarkPaneContent);
  739. }
  740. return CommandResult.Succeeded;
  741. }
  742. public static CommandResult SetSplitAdjuster(bool adjust)
  743. {
  744. Env.BrandCollection.ClearAllFarms();
  745. Env.Preference.AdjustSplit = adjust;
  746. return ResetLayout();
  747. }
  748. public static CommandResult SetScaleLock(bool lock_)
  749. {
  750. Env.BrandCollection.ClearAllFarms();
  751. Env.Preference.ScaleLock = lock_;
  752. return ResetLayout();
  753. }
  754. public static CommandResult SetPriceEnabled(bool value)
  755. {
  756. Env.Preference.ShowPrice = value;
  757. return ResetLayout();
  758. }
  759. public static CommandResult SetAccumulativeVolumeEnabled(bool value)
  760. {
  761. Env.Preference.ShowAccumulativeVolume = value;
  762. return ResetLayout();
  763. }
  764. //!!Keysを使うのはやめたいところ
  765. public static CommandResult JumpDate(Keys key)
  766. {
  767. DataFarm farm = Env.Frame.ChartCanvas.GetBrand().ReserveFarm();
  768. if (farm.IsEmpty) return CommandResult.Failed;
  769. int limit = farm.TotalLength;
  770. int w = Env.Layout.DisplayColumnCount;
  771. int n = Env.Frame.ChartCanvas.FirstDateIndex;
  772. int cursor = n;
  773. switch (key)
  774. {
  775. case Keys.Home:
  776. n = 0;
  777. cursor = n;
  778. break;
  779. case Keys.End:
  780. n = limit - w;
  781. if (n < 0) n = 0;
  782. cursor = limit - 1;
  783. break;
  784. case Keys.PageUp:
  785. n -= w;
  786. if (n < 0) n = 0;
  787. cursor = n;
  788. break;
  789. case Keys.PageDown:
  790. n += w;
  791. if (n > limit - w) n = limit - w;
  792. if (n < 0) n = 0;
  793. cursor = n + w - 1;
  794. break;
  795. case Keys.Left:
  796. n -= 5;
  797. if (n < 0) n = 0;
  798. cursor = n;
  799. break;
  800. case Keys.Right:
  801. n += 5;
  802. if (n > limit - w) n = limit - w;
  803. if (n < 0) n = 0;
  804. cursor = n + w - 1;
  805. break;
  806. }
  807. Env.Frame.ChartCanvas.SetDateIndex(n, cursor);
  808. return CommandResult.Succeeded;
  809. }
  810. public static CommandResult OpenWeb()
  811. {
  812. try
  813. {
  814. Process.Start("http://www.omegachart.org/");
  815. }
  816. catch (Exception)
  817. {
  818. }
  819. return CommandResult.Succeeded;
  820. }
  821. public static CommandResult AboutBox()
  822. {
  823. AboutBox dlg = new AboutBox();
  824. dlg.ShowDialog(Env.Frame);
  825. return CommandResult.Succeeded;
  826. }
  827. public static CommandResult ShowExtensionKitDialog()
  828. {
  829. ExtensionKitListDialog dlg = new ExtensionKitListDialog();
  830. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  831. {
  832. Env.SaveEnv();
  833. Reload(null);
  834. }
  835. return CommandResult.Succeeded;
  836. }
  837. public static CommandResult ShowKeyConfigDialog()
  838. {
  839. KeyConfigDialog dlg = new KeyConfigDialog();
  840. dlg.ShowDialog(Env.Frame);
  841. return CommandResult.Succeeded;
  842. }
  843. public static CommandResult ShowEnvironmentDialog()
  844. {
  845. EnvironmentDialog dlg = new EnvironmentDialog();
  846. dlg.ShowDialog(Env.Frame);
  847. return CommandResult.Succeeded;
  848. }
  849. public static CommandResult ShowKitTestDialog()
  850. {
  851. KitTestDialog dlg = Env.KitTestDialog;
  852. if (dlg == null)
  853. {
  854. dlg = new KitTestDialog();
  855. Rectangle rc = Env.Frame.DesktopBounds;
  856. dlg.Left = (rc.Left + rc.Right) / 2 - dlg.Width / 2;
  857. dlg.Top = (rc.Top + rc.Bottom) / 2 - dlg.Height / 2;
  858. }
  859. if (dlg.Visible) return CommandResult.Ignored;
  860. Env.Frame.CurrentModelessDialog = dlg;
  861. dlg.Owner = Env.Frame;
  862. dlg.Show();
  863. return CommandResult.Succeeded;
  864. }
  865. public static CommandResult ShowSearchBrandDialog()
  866. {
  867. SearchBrandDialog dlg = new SearchBrandDialog();
  868. dlg.ShowDialog(Env.Frame);
  869. return CommandResult.Succeeded;
  870. }
  871. //IndicatorSetの再構築と再表示
  872. public static CommandResult RefreshChart()
  873. {
  874. RefreshChart(null);
  875. return CommandResult.Succeeded;
  876. }
  877. public static CommandResult RefreshChart(IIndicatorCustomizer ic)
  878. {
  879. Env.Frame.Cursor = Cursors.WaitCursor;
  880. ChartCanvas cnv = Env.Frame.ChartCanvas;
  881. AbstractBrand br = cnv.GetBrand();
  882. ChartFormat format = Env.Options.ChartFormat;
  883. #if DOJIMA
  884. //派生銘柄時の半日足は許可しない 原理的にはできるはずだが
  885. if(br is DerivedBrand && format==ChartFormat.HalfDaily)
  886. format = ChartFormat.Daily;
  887. #endif
  888. Env.BrandCollection.ClearAllFarms();
  889. Env.Preference.Refresh();
  890. IndicatorSetBuilder bld = new IndicatorSetBuilder();
  891. bld.Customizer = ic;
  892. bld.Construct(Env.Options.ChartFormat);
  893. Env.CurrentIndicators = bld.Result;
  894. cnv.ReloadFromPreference();
  895. cnv.LoadBrand(br, false);
  896. ResetLayout();
  897. Env.Frame.Cursor = Cursors.Default;
  898. return CommandResult.Succeeded;
  899. }
  900. public static CommandResult ResetLayout()
  901. {
  902. Env.Layout.Init();
  903. Env.Frame.ChartCanvas.ResetLayout();
  904. Env.Frame.Invalidate(true);
  905. return CommandResult.Succeeded;
  906. }
  907. public static CommandResult Reload(IIndicatorCustomizer ic)
  908. {
  909. Env.ReloadSchema();
  910. RefreshChart(ic);
  911. //Util.Information(Env.Frame, "リロードしました");
  912. return CommandResult.Succeeded;
  913. }
  914. public static CommandResult Quit()
  915. {
  916. Env.Frame.Close();
  917. return CommandResult.Succeeded;
  918. }
  919. //署名関係
  920. public static CommandResult CreateKey()
  921. {
  922. RSAKeyPair kp = RSAKeyPair.GenerateNew(256, new Random());
  923. //PrivateKey保存
  924. StreamWriter wr = new StreamWriter(Env.GetAppDir() + "privatekey.txt");
  925. wr.WriteLine(kp.D.ToHexString());
  926. wr.WriteLine(kp.P.ToHexString());
  927. wr.WriteLine(kp.Q.ToHexString());
  928. wr.WriteLine(kp.U.ToHexString());
  929. wr.Close();
  930. //PublicKeyダンプ
  931. RSAPublicKey pub = (RSAPublicKey)kp.PublicKey;
  932. Debug.WriteLine("Pubkey-Mod=" + pub.Modulus.ToHexString());
  933. Debug.WriteLine("Pubkey-Exp=" + pub.Exponent.ToHexString());
  934. return CommandResult.Succeeded;
  935. }
  936. public static CommandResult SignKit()
  937. {
  938. OpenFileDialog dlg = new OpenFileDialog();
  939. dlg.Title = "XMLフォーマットの拡張キット選択";
  940. if (dlg.ShowDialog(Env.Frame) == DialogResult.OK)
  941. {
  942. string fn = dlg.FileName;
  943. StorageNode node = new DOMNodeReader(XmlUtil.LoadDOM(fn)).Read();
  944. Stream strm = new FileStream(fn + ".bin", FileMode.Create, FileAccess.Write);
  945. new BinaryNodeWriter(strm).Write(node);
  946. strm.Close();
  947. SignFile(fn + ".bin", fn + ".signed");
  948. }
  949. return CommandResult.Succeeded;
  950. }
  951. public static CommandResult SignFile(string fn, string destfile)
  952. {
  953. StreamReader re = new StreamReader(Env.GetAppDir() + "privatekey.txt");
  954. BigInteger d = new BigInteger(re.ReadLine(), 16);
  955. BigInteger p = new BigInteger(re.ReadLine(), 16);
  956. BigInteger q = new BigInteger(re.ReadLine(), 16);
  957. BigInteger u = new BigInteger(re.ReadLine(), 16);
  958. RSAPublicKey pub = ZPublicKey.PubKeyForExtensionKit;
  959. RSAKeyPair kp = new RSAKeyPair(pub.Exponent, d, pub.Modulus, u, p, q);
  960. byte[] data = new byte[(int)new FileInfo(fn).Length];
  961. FileStream s = new FileStream(fn, FileMode.Open, FileAccess.Read);
  962. s.Read(data, 0, data.Length);
  963. s.Close();
  964. Debug.WriteLine("Signed length=" + data.Length);
  965. byte[] hash = new SHA1CryptoServiceProvider().ComputeHash(data, 0, data.Length);
  966. byte[] signature = kp.Sign(hash);
  967. kp.Verify(signature, hash);
  968. Stream strm = new FileStream(destfile, FileMode.Create, FileAccess.Write);
  969. strm.Write(data, 0, data.Length);
  970. strm.Write(signature, 0, signature.Length);
  971. strm.Close();
  972. return CommandResult.Succeeded;
  973. }
  974. public static CommandResult GenerateUserCode()
  975. {
  976. RegistrationDialog dlg = new RegistrationDialog();
  977. dlg.GeneratingCode = true;
  978. dlg.ShowDialog(Env.Frame);
  979. return CommandResult.Succeeded;
  980. }
  981. public static CommandResult RegisterUserCode()
  982. {
  983. RegistrationDialog dlg = new RegistrationDialog();
  984. dlg.GeneratingCode = false;
  985. dlg.ShowDialog(Env.Frame);
  986. return CommandResult.Succeeded;
  987. }
  988. public static CommandResult OpenCompanyInfoPage(CompanyInfoSite type)
  989. {
  990. try
  991. {
  992. string url = null;
  993. int code = Env.Frame.ChartCanvas.GetBrand().Code;
  994. switch (type)
  995. {
  996. case CompanyInfoSite.Yahoo:
  997. url = String.Format("http://profile.yahoo.co.jp/biz/fundamental/{0}.html", code);
  998. break;
  999. case CompanyInfoSite.Infoseek:
  1000. url = String.Format("http://money.www.infoseek.co.jp/MnStock?qt={0}&sv=MN&pg=mn_creport.html", code);
  1001. break;
  1002. case CompanyInfoSite.Nikkei:
  1003. url = String.Format("http://company.nikkei.co.jp/index.cfm?scode={0}", code);
  1004. break;
  1005. case CompanyInfoSite.Livedoor:
  1006. url = String.Format("http://finance.livedoor.com/quote/profile?c={0}", code);
  1007. break;
  1008. }
  1009. Process.Start(url);
  1010. return CommandResult.Succeeded;
  1011. }
  1012. catch (Exception ex)
  1013. {
  1014. Util.ReportCriticalError(ex);
  1015. return CommandResult.Failed;
  1016. }
  1017. }
  1018. //!!このあたりのペアはdelegateを使うなどしてまとめたい
  1019. public static CommandResult ShowNextCode()
  1020. {
  1021. AbstractBrand br = Env.BrandCollection.FindNextBrand(
  1022. Env.Frame.ChartCanvas.GetBrand().Code);
  1023. ShowBrand(br);
  1024. return CommandResult.Succeeded;
  1025. }
  1026. public static CommandResult ShowPrevCode()
  1027. {
  1028. AbstractBrand br = Env.BrandCollection.FindPrevBrand(
  1029. Env.Frame.ChartCanvas.GetBrand().Code);
  1030. ShowBrand(br);
  1031. return CommandResult.Succeeded;
  1032. }
  1033. public static CommandResult ShowNextBrand()
  1034. {
  1035. BrandListPane pane = Env.Frame.CurrentBrandListPane;
  1036. if (pane != null)
  1037. {
  1038. AbstractBrand br = pane.NextBrand;
  1039. if (br != null)
  1040. return ShowBrand(br);
  1041. else
  1042. return CommandResult.Failed;
  1043. }
  1044. return CommandResult.Ignored;
  1045. }
  1046. public static CommandResult ShowPrevBrand()
  1047. {
  1048. BrandListPane pane = Env.Frame.CurrentBrandListPane;
  1049. if (pane != null)
  1050. {
  1051. AbstractBrand br = pane.PrevBrand;
  1052. if (br != null)
  1053. return ShowBrand(br);
  1054. else
  1055. return CommandResult.Failed;
  1056. }
  1057. return CommandResult.Ignored;
  1058. }
  1059. public static CommandResult ShrinkCandleWidth()
  1060. {
  1061. int hcw = Env.Preference.HalfCandleWidth;
  1062. if (--hcw < 1)
  1063. {
  1064. hcw = 1;
  1065. }
  1066. Env.Preference.CandleWidth = hcw * 2;
  1067. ResetLayout();
  1068. return CommandResult.Succeeded;
  1069. }
  1070. public static CommandResult ExpandCandleWidth()
  1071. {
  1072. int hcw = Env.Preference.HalfCandleWidth;
  1073. if (++hcw > 20)
  1074. { // 特に意味なし
  1075. hcw = 20;
  1076. }
  1077. Env.Preference.CandleWidth = hcw * 2;
  1078. ResetLayout();
  1079. return CommandResult.Succeeded;
  1080. }
  1081. public static CommandResult SetCandleWidth(int width)
  1082. {
  1083. Env.Preference.CandleWidth = width;
  1084. ResetLayout();
  1085. return CommandResult.Succeeded;
  1086. }
  1087. public static CommandResult SetLogarithmStyle(bool value)
  1088. {
  1089. Env.Preference.LogScale = value;
  1090. ResetLayout();
  1091. return CommandResult.Succeeded;
  1092. }
  1093. public static CommandResult SetInverseStyle(bool value)
  1094. {
  1095. Env.Preference.InverseChart = value;
  1096. ResetLayout();
  1097. return CommandResult.Succeeded;
  1098. }
  1099. public static CommandResult SetChartFormat(ChartFormat fmt)
  1100. {
  1101. if (Env.Options.ChartFormat == fmt) return CommandResult.Ignored;
  1102. Env.Options.ChartFormat = fmt;
  1103. RefreshChart();
  1104. return CommandResult.Succeeded;
  1105. }
  1106. public static CommandResult UpdateCurrentData()
  1107. {
  1108. #if KENMILLE
  1109. Env.Frame.ChartCanvas.ChartTitle.UpdateCurrentBrand();
  1110. return CommandResult.Succeeded;
  1111. #else
  1112. return CommandResult.Failed;
  1113. #endif
  1114. }
  1115. public static CommandResult DownloadIndexFile()
  1116. {
  1117. using (var dlg = new DownloadIndexFileDialog())
  1118. dlg.ShowDialog();
  1119. return CommandResult.Succeeded;
  1120. }
  1121. #if DOJIMA
  1122. public static CommandResult ExportHalfDailyData() {
  1123. if(Env.CurrentIndicators.Format!=ChartFormat.HalfDaily) {
  1124. Util.Warning("半日足を表示した状態でのみエクスポートできます");
  1125. return CommandResult.Failed;
  1126. }
  1127. SaveFileDialog dlg = new SaveFileDialog();
  1128. dlg.Title = "半日足データのエクスポート";
  1129. dlg.Filter = "CSV Files(*.csv)|*.csv";
  1130. dlg.DefaultExt = "csv";
  1131. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  1132. string filename = dlg.FileName;
  1133. DailyDataFarm f = (DailyDataFarm)Env.Frame.ChartCanvas.GetBrand().ReserveFarm();
  1134. Dojima.DojimaUtil.HalfDailyDataFarmCache.Get(f).ExportInCSV(filename);
  1135. return CommandResult.Succeeded;
  1136. }
  1137. else
  1138. return CommandResult.Ignored;
  1139. }
  1140. #endif
  1141. //初期データの縮小
  1142. public static CommandResult ShrinkData()
  1143. {
  1144. Env.Frame.Text = "データ縮小中";
  1145. int date = 20050701; //ここ以降の日付のみ切り出す
  1146. string dir = "shrinked";
  1147. if (!Directory.Exists(dir))
  1148. Directory.CreateDirectory("shrinked");
  1149. IDictionaryEnumerator ie = Env.BrandCollection.GetEnumerator();
  1150. while (ie.MoveNext())
  1151. {
  1152. BasicBrand br = ie.Value as BasicBrand;
  1153. if (br != null)
  1154. {
  1155. DailyDataFarm f = new DailyDataFarm();
  1156. f.LoadFor(br);
  1157. if (!f.IsEmpty)
  1158. {
  1159. int index = f.DateToIndex(date);
  1160. FileStream fs = new FileStream(dir + "\\" + br.CodeAsString, FileMode.Create, FileAccess.Write);
  1161. fs.Write(f.RawDataImage, index * DataFarm.RECORD_LENGTH, (f.TotalLength - index) * DataFarm.RECORD_LENGTH);
  1162. fs.Close();
  1163. }
  1164. }
  1165. }
  1166. Util.Information(Env.Frame, "終了");
  1167. return CommandResult.Succeeded;
  1168. }
  1169. //試作:統計情報
  1170. public static CommandResult StatisticsTest()
  1171. {
  1172. //RunPrivateScreening();
  1173. //MyStatistics.Do();
  1174. return CommandResult.Succeeded;
  1175. }
  1176. #if PRIVATE_FEATURE
  1177. public static void RunPrivateScreening() {
  1178. ScreeningItem item = FindScreeningItem("hottest");
  1179. ScreeningOrder so = new ScreeningOrder(item.Header, item);
  1180. so.Execute();
  1181. ScreeningResult sr = so.Result as ScreeningResult; //!!asがいやらしい
  1182. Util.Information(Env.Frame, "完了");
  1183. if(sr.ResultCount > 0) {
  1184. ScreeningResultPane pane = new ScreeningResultPane(so);
  1185. AddDockingPane(pane, item.Header, pane.RequiredWidth, IconConst.SEARCH);
  1186. }
  1187. }
  1188. private static ScreeningItem FindScreeningItem(string name) {
  1189. foreach(ScreeningItem item in Env.CurrentIndicators.GetScreeningItems()) {
  1190. if(item.Header=="要注意銘柄") return item;
  1191. }
  1192. return null;
  1193. }
  1194. #endif
  1195. }
  1196. }
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text