Pastebin: OmegaChart 日付固定表示 Command.cs 追加修正ポイントには//☆FixedDisplayYMD

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

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text