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

Format
Plain text
Post date
2017-12-27 19:56
Période de publication
Illimité
  1. using System;
  2. using System.Collections;
  3. using System.Text;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Windows.Forms;
  7. using Travis.Storage;
  8. using Zanetti.UI;
  9. using Zanetti.Forms;
  10. using Zanetti.Commands;
  11. using Zanetti.Data;
  12. using Zanetti.DataSource;
  13. using Zanetti.Parser;
  14. using Zanetti.Config;
  15. using Zanetti.Arithmetic;
  16. using Zanetti.Indicators;
  17. using Zanetti.Indicators.Schema;
  18. namespace Zanetti
  19. {
  20. /// <summary>
  21. /// Env の概要の説明です。
  22. /// </summary>
  23. internal class Env
  24. {
  25. private static Preference _preference;
  26. private static Options _options;
  27. private static LayoutInfo _layoutInfo;
  28. private static Bookmark _bookmark;
  29. private static FreeLineCollection _freeLines;
  30. private static FibonacciCollection _fibonacci;//☆Fibonacci
  31. private static BrandCollection _brandCollection;
  32. private static ArithmeticLibrary _arithmeticLibrary;
  33. private static ZanettiSchema _schema;
  34. private static IndicatorSet _currentIndicatorSet;
  35. private static MainFrame _mainFrame;
  36. private static KitTestDialog _kitTestDialog;
  37. private static CommandCollection _command;
  38. private static BrandHistory _history;
  39. private static StorageNode _rootStorageNode;
  40. private static ImageList _imageList16;
  41. public static Preference Preference
  42. {
  43. get
  44. {
  45. return _preference;
  46. }
  47. }
  48. public static Options Options
  49. {
  50. get
  51. {
  52. return _options;
  53. }
  54. }
  55. public static LayoutInfo Layout
  56. {
  57. get
  58. {
  59. return _layoutInfo;
  60. }
  61. }
  62. public static BrandCollection BrandCollection
  63. {
  64. get
  65. {
  66. return _brandCollection;
  67. }
  68. }
  69. public static ZanettiSchema Schema
  70. {
  71. get
  72. {
  73. return _schema;
  74. }
  75. }
  76. public static IndicatorSet CurrentIndicators
  77. {
  78. get
  79. {
  80. return _currentIndicatorSet;
  81. }
  82. set
  83. {
  84. _currentIndicatorSet = value;
  85. }
  86. }
  87. public static ArithmeticLibrary ArithmeticLibrary
  88. {
  89. get
  90. {
  91. return _arithmeticLibrary;
  92. }
  93. }
  94. public static MainFrame Frame
  95. {
  96. get
  97. {
  98. return _mainFrame;
  99. }
  100. }
  101. public static KitTestDialog KitTestDialog
  102. {
  103. get
  104. {
  105. return _kitTestDialog;
  106. }
  107. set
  108. {
  109. _kitTestDialog = value;
  110. }
  111. }
  112. public static CommandCollection Command
  113. {
  114. get
  115. {
  116. return _command;
  117. }
  118. }
  119. public static BrandHistory BrandHistory
  120. {
  121. get
  122. {
  123. return _history;
  124. }
  125. }
  126. public static Bookmark Bookmark
  127. {
  128. get
  129. {
  130. return _bookmark;
  131. }
  132. }
  133. public static FreeLineCollection FreeLines
  134. {
  135. get
  136. {
  137. return _freeLines;
  138. }
  139. }
  140. public static FibonacciCollection Fibonacci//☆Fibonacci
  141. {
  142. get
  143. {
  144. return _fibonacci;
  145. }
  146. }
  147. //パース済み設定ファイルのルート ネーミングはちとおかしいが
  148. public static StorageNode RootStorageNode
  149. {
  150. get
  151. {
  152. return _rootStorageNode;
  153. }
  154. }
  155. public static ImageList ImageList16
  156. {
  157. get
  158. {
  159. if (_imageList16 == null)
  160. {
  161. ImageListForm frm = new ImageListForm();
  162. _imageList16 = frm.ImageList16;
  163. }
  164. return _imageList16;
  165. }
  166. }
  167. [STAThread]
  168. public static void Main(string[] args)
  169. {
  170. try
  171. {
  172. InitEnv();
  173. Application.Run(_mainFrame);
  174. SaveEnv();
  175. }
  176. catch (Exception ex)
  177. {
  178. Util.ReportCriticalError(ex);
  179. }
  180. }
  181. private static void InitEnv()
  182. {
  183. Application.EnableVisualStyles();
  184. string dir = GetAppDir() + "data";
  185. if (!Directory.Exists(dir))
  186. Directory.CreateDirectory(dir);
  187. ThemeUtil.Init();
  188. _brandCollection = new BrandCollection();
  189. _arithmeticLibrary = new ArithmeticLibrary();
  190. _arithmeticLibrary.InitBuiltins();
  191. _schema = new ZanettiSchema();
  192. _options = new Options();
  193. _bookmark = new Bookmark();
  194. _freeLines = new FreeLineCollection();
  195. _fibonacci = new FibonacciCollection();//☆Fibonacci
  196. _history = new BrandHistory();
  197. InitialAction act = new InitialAction();
  198. _brandCollection.Load(GetAppDir() + "index.txt");
  199. _rootStorageNode = null;
  200. string option_file = GetAppDir() + "options.conf";
  201. if (!File.Exists(option_file))
  202. {
  203. _options.Init();
  204. _bookmark.Clear();
  205. }
  206. else
  207. {
  208. StreamReader reader = null;
  209. try
  210. {
  211. reader = new StreamReader(option_file, Encoding.Default);
  212. _rootStorageNode = new TextNodeReader(reader).Read().GetChildAt(0);
  213. StorageNode options = _rootStorageNode.FindChildNode("options");
  214. if (options == null)
  215. _options.Init();
  216. else
  217. _options.Load(options);
  218. StorageNode bookmark = _rootStorageNode.FindChildNode("bookmark-group");
  219. if (bookmark == null)
  220. _bookmark.Clear();
  221. else
  222. _bookmark.Load(bookmark);
  223. _freeLines.Load(_rootStorageNode);
  224. _fibonacci.Load(_rootStorageNode);//☆Fibonacci
  225. }
  226. catch (Exception ex)
  227. {
  228. act.AddErrorMessage("オプションファイルの読み込みに失敗しました。" + ex.Message);
  229. }
  230. finally
  231. {
  232. if (reader != null) reader.Close();
  233. }
  234. }
  235. _preference = new Preference(_rootStorageNode == null ? null : _rootStorageNode.FindChildNode("preference"));
  236. _command = new CommandCollection(_rootStorageNode == null ? null : _rootStorageNode.FindChildNode("command"));
  237. _currentIndicatorSet = new IndicatorSet(_options.ChartFormat); //最低限の内容で初期化
  238. _layoutInfo = new LayoutInfo();
  239. act.BrandCode = (int)BuiltInIndex.Nikkei225;
  240. _mainFrame = new MainFrame();
  241. _mainFrame.StartPosition = FormStartPosition.Manual;
  242. _mainFrame.InitialAction = act;
  243. _mainFrame.Size = Env.Options.FrameLocation.Size;
  244. _mainFrame.Location = Env.Options.FrameLocation.Location;
  245. _mainFrame.WindowState = _options.WindowState;
  246. _mainFrame.Init();
  247. //ここまできたら起動回数を1ふやす
  248. _options.LauchCount++;
  249. }
  250. //Commandから呼ぶためのスキーマ再構成
  251. public static void ReloadSchema()
  252. {
  253. _schema = new ZanettiSchema();
  254. _schema.Load(GetAppDir() + "extension", _rootStorageNode == null ? null : _rootStorageNode.FindChildNode("params"));
  255. }
  256. public static void ResetWithoutConfig()
  257. {
  258. _schema = new ZanettiSchema();
  259. _schema.Load(GetAppDir() + "extension", null);
  260. _preference = new Preference(null);
  261. }
  262. public static void SaveEnv()
  263. {
  264. string option_file = GetAppDir() + "options.conf";
  265. StreamWriter writer = null;
  266. try
  267. {
  268. writer = new StreamWriter(option_file, false, Encoding.Default);
  269. StorageNode root = new StorageNode();
  270. root.Name = "omega-chart-options";
  271. _options.SaveTo(root);
  272. _bookmark.SaveTo(root);
  273. _preference.SaveTo(root);
  274. _schema.SaveTo(root);
  275. _freeLines.SaveTo(root);
  276. _fibonacci.SaveTo(root);//☆Fibonacci
  277. new TextNodeWriter(writer).Write(root);
  278. writer.Close();
  279. }
  280. catch (Exception ex)
  281. {
  282. Util.SilentReportCriticalError(ex);
  283. Util.Warning("オプションの保存に失敗しました。" + ex.Message);
  284. }
  285. finally
  286. {
  287. if (writer != null) writer.Close();
  288. }
  289. }
  290. private static string _appDir;
  291. public static string GetAppDir()
  292. {
  293. if (_appDir == null)
  294. _appDir = AppDomain.CurrentDomain.BaseDirectory;
  295. return _appDir;
  296. }
  297. internal class Constants
  298. {
  299. #if DOJIMA
  300. public const string AppTitle = Zanetti.Dojima.DojimaUtil.AppTitle;
  301. #else
  302. public const string AppTitle = "Omega Chart";
  303. #endif
  304. public const int LaunchCountForPrompt = 30;
  305. public const int MIN_CANDLE_WIDTH = 1;
  306. public const int MAX_CANDLE_WIDTH = 17;
  307. }
  308. }
  309. internal class InitialAction
  310. {
  311. private bool _indexConstructionRequired;
  312. private bool _performed;
  313. private string _message;
  314. private int _brandCode;
  315. private ArrayList _errorMessages = new ArrayList();
  316. public bool IndexConstructionRequired
  317. {
  318. get
  319. {
  320. return _indexConstructionRequired;
  321. }
  322. }
  323. public string Message
  324. {
  325. get
  326. {
  327. return _message;
  328. }
  329. }
  330. public IEnumerable ErrorMessages
  331. {
  332. get
  333. {
  334. return _errorMessages;
  335. }
  336. }
  337. public bool Performed
  338. {
  339. get
  340. {
  341. return _performed;
  342. }
  343. set
  344. {
  345. _performed = value;
  346. }
  347. }
  348. public int BrandCode
  349. {
  350. get
  351. {
  352. return _brandCode;
  353. }
  354. set
  355. {
  356. _brandCode = value;
  357. }
  358. }
  359. public void SetIndexConstructionRequired(string msg)
  360. {
  361. _indexConstructionRequired = true;
  362. _message = msg;
  363. }
  364. public void AddErrorMessage(string value)
  365. {
  366. _errorMessages.Add(value);
  367. }
  368. }
  369. }
Télécharger Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text