コピペ: OmegaChart 日付固定表示 Preference.cs 追加修正ポイントには//☆FixedDisplayYMD

形式
Plain text
投稿日時
2018-04-25 18:13
公開期間
無期限
  1. /*
  2. * Copyright (c) Daisuke OKAJIMA All rights reserved.
  3. *
  4. * $Id$
  5. */
  6. using System;
  7. using System.IO;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Text;
  11. using Travis.Storage;
  12. using Travis.Util;
  13. using Zanetti.Indicators;
  14. namespace Zanetti.UI
  15. {
  16. internal class ChartFormatSpecificValue {
  17. private int[] _data;
  18. private const int LENGTH = 4;
  19. public ChartFormatSpecificValue(int[] t) {
  20. if(t.Length==LENGTH)
  21. _data = t; //多くはこれ
  22. else {
  23. _data = new int[LENGTH];
  24. for(int i=0; i<LENGTH; i++) _data[i] = t.Length>i? t[i] : 0;
  25. }
  26. }
  27. public ChartFormatSpecificValue(string value) {
  28. string[] t = value.Split(',');
  29. _data = new int[LENGTH];
  30. for(int i=0; i<LENGTH; i++)
  31. _data[i] = t.Length>i? Int32.Parse(t[i]) : 0;
  32. }
  33. public int GetValue(ChartFormat fmt) {
  34. #if DOJIMA
  35. if(fmt==ChartFormat.HalfDaily) fmt = ChartFormat.Daily;
  36. #endif
  37. int i = (int)fmt;
  38. return i<_data.Length? _data[i] : 0;
  39. }
  40. public void Update(int[] t) {
  41. Debug.Assert(t.Length==LENGTH);
  42. _data = t;
  43. }
  44. public override string ToString() {
  45. StringBuilder b = new StringBuilder();
  46. for(int i=0; i<LENGTH; i++) {
  47. if(i>0) b.Append(",");
  48. b.Append(_data[i].ToString());
  49. }
  50. return b.ToString();
  51. }
  52. }
  53. internal class OscillatorPreference {
  54. //最大3個
  55. public const int LENGTH = 3;
  56. //Groupが存在していても一時的に表示されないという形態を想定して_visibleを導入
  57. private OscillatorGroup _group;
  58. private string _id;
  59. private HeightConfig _config;
  60. private double[] _scaleValues;
  61. private Trans _trans;
  62. public OscillatorPreference(string id) {
  63. string[] t = id.Split(':');
  64. _config = Util.ParseHeightConfig(t[0], HeightConfig.None);
  65. _id = t.Length>1? t[1] : "none";
  66. _scaleValues = new double[3];
  67. }
  68. public OscillatorGroup OscillatorGroup {
  69. get {
  70. if(_group==null) Bind();
  71. return _group;
  72. }
  73. set {
  74. _group = value;
  75. if(_group!=null) _id = value.Name;
  76. }
  77. }
  78. public HeightConfig Config {
  79. get {
  80. if(_group==null) Bind();
  81. if(_group==null)
  82. return HeightConfig.None;
  83. else
  84. return _config; //起動直後にはGroupが存在しないこともある
  85. }
  86. set {
  87. _config = value;
  88. }
  89. }
  90. private void Bind() {
  91. _group = Env.CurrentIndicators.FindOscillatorGroup(_id);
  92. }
  93. public string Format() {
  94. return String.Format("{0}:{1}", _config.ToString(), _group==null? "none" : _id);
  95. }
  96. public double[] ScaleValues {
  97. get {
  98. return _scaleValues;
  99. }
  100. }
  101. public void SetScaleValues(double v0, double v1, double v2) {
  102. _scaleValues[0] = v0;
  103. _scaleValues[1] = v1;
  104. _scaleValues[2] = v2;
  105. }
  106. public Trans Trans {
  107. get {
  108. return _trans;
  109. }
  110. set {
  111. _trans = value;
  112. }
  113. }
  114. //スキーマのリロードなど、読み込みなおしたときは参照を切っておく必要がある
  115. public void Refresh() {
  116. _group = null;
  117. }
  118. }
  119. [EnumDesc(typeof(MouseTrackingLineMode))]
  120. internal enum MouseTrackingLineMode {
  121. [EnumValue(Description="なし")] None,
  122. [EnumValue(Description="日付のみ")] Date,
  123. [EnumValue(Description="日付と価格")]Full
  124. }
  125. //出来高とオシレータの高さ設定
  126. internal enum HeightConfig {
  127. None,
  128. Large,
  129. Middle,
  130. Small
  131. }
  132. /// <summary>
  133. /// Preferenceは、ユーザがカスタマイズ可能な表示に関する設定を収録する。Optionの一部とも言えるが、
  134. /// レイトバインディングするGDIオブジェクトなどもある
  135. /// </summary>
  136. internal class Preference
  137. {
  138. //色関係
  139. private ZBrush _defaultBrush;
  140. private ZPen _defaultPen;
  141. private ZBrush _backBrush;
  142. private ZBrush _volumeBrush;
  143. private ZCandlePen _candlePen;
  144. private ZBrush _insenBrush;
  145. private ZPen _monthDivPen;
  146. private ZPen _mouseTrackingLinePen;
  147. private MouseTrackingLineMode _mouseTrackingLineMode;
  148. private ZPen _priceScalePen;
  149. private ZPen _volumeScalePen;
  150. private ZPen _oscillatorScalePen;
  151. private Color _fushiColor;
  152. private Color _freeLineColor;
  153. private IndicatorAppearance _creditLongAppearance;
  154. private IndicatorAppearance _creditShortAppearance;
  155. // ローソク幅
  156. private int _candleWidth;
  157. //表示設定系
  158. private bool _useCandleEffect;
  159. private bool _inverseChart; // 上下逆
  160. private bool _logScale; // 対数表示
  161. private bool _showPrice;
  162. private HeightConfig _showVolume;
  163. private bool _showAccumulativeVolume; //価格帯別出来高
  164. private bool _adjustSplit; //分割を調整するかどうか
  165. private bool _scaleLock;
  166. //font
  167. private string _fontName;
  168. private float _fontSize;
  169. private FontStyle _fontStyle;
  170. //レイトバインドする物
  171. private bool _fontDirty;
  172. private SizeF _defaultFontPitch;
  173. private SizeF _headerFontPitch;
  174. private Font _defaultFont;
  175. private Font _headerFont;
  176. private IntPtr _defaultHFont;
  177. private IntPtr _headerHFont;
  178. private ZPen _freeLinePen;
  179. private ZPen _freeLineDottedPen;
  180. private ZPen _freeLineBoldPen;
  181. //何日間の高値・安値を節とするか
  182. private int _fushiRange;
  183. //価格帯別出来高
  184. private ChartFormatSpecificValue _accumulativeVolumePeriod;
  185. //オシレータ
  186. private OscillatorPreference[] _oscillatorPreferences;
  187. //☆FixedDisplayYMD
  188. private int _fixedDisplayYMD = int.MaxValue;
  189. public Color FushiColor {
  190. get {
  191. return _fushiColor;
  192. }
  193. set {
  194. _fushiColor = value;
  195. }
  196. }
  197. public string FontName {
  198. get {
  199. return _fontName;
  200. }
  201. set {
  202. _fontName = value;
  203. _fontDirty = true;
  204. }
  205. }
  206. public float FontSize {
  207. get {
  208. return _fontSize;
  209. }
  210. set {
  211. _fontSize = value;
  212. _fontDirty = true;
  213. }
  214. }
  215. public FontStyle FontStyle {
  216. get {
  217. return _fontStyle;
  218. }
  219. set {
  220. _fontStyle = value;
  221. _fontDirty = true;
  222. }
  223. }
  224. public Color TextColor
  225. {
  226. get {
  227. return _defaultBrush.Color;
  228. }
  229. }
  230. public ZBrush DefaultBrush {
  231. get {
  232. return _defaultBrush;
  233. }
  234. }
  235. public ZPen DefaultPen {
  236. get {
  237. return _defaultPen;
  238. }
  239. }
  240. public ZBrush BackBrush {
  241. get {
  242. return _backBrush;
  243. }
  244. }
  245. public ZBrush InsenBrush {
  246. get {
  247. return _insenBrush;
  248. }
  249. }
  250. public ZCandlePen CandlePen {
  251. get {
  252. return _candlePen;
  253. }
  254. }
  255. public ZBrush VolumeBrush {
  256. get {
  257. return _volumeBrush;
  258. }
  259. }
  260. public ZPen MonthDivPen {
  261. get {
  262. return _monthDivPen;
  263. }
  264. }
  265. public ZPen MouseTrackingLinePen {
  266. get {
  267. return _mouseTrackingLinePen;
  268. }
  269. }
  270. public ZPen PriceScalePen {
  271. get {
  272. return _priceScalePen;
  273. }
  274. }
  275. public ZPen VolumeScalePen {
  276. get {
  277. return _volumeScalePen;
  278. }
  279. }
  280. public ZPen OscillatorScalePen {
  281. get {
  282. return _oscillatorScalePen;
  283. }
  284. }
  285. public int FushiRange {
  286. get {
  287. return _fushiRange;
  288. }
  289. }
  290. public IndicatorAppearance CreditLongAppearance {
  291. get {
  292. return _creditLongAppearance;
  293. }
  294. }
  295. public IndicatorAppearance CreditShortAppearance {
  296. get {
  297. return _creditShortAppearance;
  298. }
  299. }
  300. public MouseTrackingLineMode MouseTrackingLineMode {
  301. get {
  302. return _mouseTrackingLineMode;
  303. }
  304. }
  305. // ローソク足幅
  306. public bool InverseChart {
  307. get {
  308. return _inverseChart;
  309. }
  310. set {
  311. _inverseChart = value;
  312. }
  313. }
  314. public bool LogScale{
  315. get {
  316. return _logScale;
  317. }
  318. set {
  319. _logScale = value;
  320. }
  321. }
  322. public bool AdjustSplit {
  323. get {
  324. return _adjustSplit;
  325. }
  326. set {
  327. _adjustSplit = value;
  328. }
  329. }
  330. public bool ShowPrice {
  331. get {
  332. return _showPrice;
  333. }
  334. set {
  335. _showPrice = value;
  336. }
  337. }
  338. public HeightConfig ShowVolume {
  339. get {
  340. return _showVolume;
  341. }
  342. set {
  343. _showVolume = value;
  344. }
  345. }
  346. public bool ShowAccumulativeVolume {
  347. get {
  348. return _showAccumulativeVolume;
  349. }
  350. set {
  351. _showAccumulativeVolume = value;
  352. }
  353. }
  354. public bool ScaleLock {
  355. get {
  356. return _scaleLock;
  357. }
  358. set {
  359. _scaleLock = value;
  360. }
  361. }
  362. public bool UseCandleEffect {
  363. get {
  364. return _useCandleEffect;
  365. }
  366. set {
  367. _useCandleEffect = value;
  368. }
  369. }
  370. //ロウソク幅。奇数でないとだめ
  371. public int CandleWidth {
  372. get {
  373. return _candleWidth;
  374. }
  375. set {
  376. Debug.Assert((_candleWidth & 1)==1);
  377. _candleWidth = value;
  378. }
  379. }
  380. //CandleWidthからの導出
  381. public int DatePitch {
  382. get {
  383. return _candleWidth * 5 / 3; //ロウソクの隙間を空けるためこれくらい
  384. }
  385. }
  386. public int HalfCandleWidth {
  387. get {
  388. return (_candleWidth+1)>>1;
  389. }
  390. }
  391. //自由直線系
  392. public Color FreeLineColor {
  393. get {
  394. return _freeLineColor;
  395. }
  396. set {
  397. _freeLineColor = value;
  398. _freeLinePen = null;
  399. _freeLineDottedPen = null;
  400. }
  401. }
  402. public ZPen FreeLinePen {
  403. get {
  404. if(_freeLinePen==null)
  405. _freeLinePen = new ZPen(_freeLineColor, ZPen.PenStyle.Bold);
  406. return _freeLinePen;
  407. }
  408. }
  409. public ZPen FreeLineDottedPen {
  410. get {
  411. if(_freeLineDottedPen==null)
  412. _freeLineDottedPen = new ZPen(_freeLineColor, ZPen.PenStyle.Dotted);
  413. return _freeLineDottedPen;
  414. }
  415. }
  416. public ZPen FreeLineBoldPen {
  417. get {
  418. if(_freeLineBoldPen==null)
  419. _freeLineBoldPen = new ZPen(_freeLineColor, ZPen.PenStyle.Bold);
  420. return _freeLineBoldPen;
  421. }
  422. }
  423. public ChartFormatSpecificValue AccumulativeVolumePeriod {
  424. get {
  425. return _accumulativeVolumePeriod;
  426. }
  427. set {
  428. _accumulativeVolumePeriod = value;
  429. }
  430. }
  431. public OscillatorPreference[] OscillatorPreferences {
  432. get {
  433. return _oscillatorPreferences;
  434. }
  435. }
  436. //☆FixedDisplayYMD
  437. public int FixedDisplayYMD
  438. {
  439. get
  440. {
  441. return _fixedDisplayYMD;
  442. }
  443. set
  444. {
  445. _fixedDisplayYMD = value;
  446. }
  447. }
  448. //☆FixedDisplayYMD ここまで
  449. public Preference(StorageNode config) {
  450. _fontName = LoadString(config, "font-name", "MS 明朝");
  451. _fontSize = LoadFloat(config, "font-size", 9);
  452. _fontStyle = LoadFontStyle(config, "font-style", FontStyle.Regular);
  453. _defaultBrush = new ZBrush(LoadColor(config, "text-color", Color.White));
  454. _backBrush = new ZBrush(LoadColor(config, "back-color", Color.Black));
  455. _insenBrush = new ZBrush(LoadColor(config, "insen-color", Color.White));
  456. _fushiColor = LoadColor(config, "fushi-color", Color.DarkGray);
  457. _freeLineColor = LoadColor(config, "free-line-color", Color.Pink);
  458. _defaultPen = new ZPen(_defaultBrush.Color, ZPen.PenStyle.Normal);
  459. _useCandleEffect = LoadBool(config, "candle-effect", true);
  460. _logScale = LoadBool(config, "log-scale", false);
  461. _inverseChart = LoadBool(config, "inverse-chart", false);
  462. _adjustSplit = LoadBool(config, "adjust-split", true);
  463. _candleWidth = LoadInt(config, "candle-width", 9);
  464. _candleWidth |= 1; //奇数にする
  465. if(_candleWidth<Env.Constants.MIN_CANDLE_WIDTH) _candleWidth = Env.Constants.MIN_CANDLE_WIDTH; //min
  466. if(_candleWidth>Env.Constants.MAX_CANDLE_WIDTH) _candleWidth = Env.Constants.MAX_CANDLE_WIDTH;
  467. _showPrice = LoadBool(config, "show-price", true);
  468. _showVolume = Util.ParseHeightConfig(LoadString(config, "show-volume", "Large"), HeightConfig.Large);
  469. _showAccumulativeVolume = LoadBool(config, "show-accumulative-volume", true);
  470. _candlePen = new ZCandlePen(LoadColor(config, "candle-color", Color.White), _backBrush.Color);
  471. _monthDivPen = new ZPen(LoadColor(config, "month-div-color", Color.OliveDrab), LoadStyle(config, "month-div-style", ZPen.PenStyle.Normal));
  472. _priceScalePen = new ZPen(LoadColor(config, "price-scale-color", Color.MediumSeaGreen), LoadStyle(config, "price-scale-style", ZPen.PenStyle.Dotted));
  473. _volumeScalePen = new ZPen(LoadColor(config, "volume-scale-color", Color.WhiteSmoke), LoadStyle(config, "volume-scale-style", ZPen.PenStyle.Dotted));
  474. _oscillatorScalePen = new ZPen(LoadColor(config, "oscillator-scale-color", Color.DarkRed), LoadStyle(config, "oscillator-scale-style", ZPen.PenStyle.Dotted));
  475. _volumeBrush = new ZBrush(LoadColor(config, "volume-color", Color.RoyalBlue));
  476. _mouseTrackingLineMode = (MouseTrackingLineMode)Enum.Parse(typeof(MouseTrackingLineMode), LoadString(config, "mouse-tracking-mode", "Full"));
  477. _mouseTrackingLinePen = new ZPen(LoadColor(config, "mouse-tracking-color", Color.LightGray), LoadStyle(config, "mouse-tracking-style", ZPen.PenStyle.Dotted));
  478. _creditLongAppearance = new IndicatorAppearance(LoadStyle(config, "creditlong-style", IndicatorStyle.Line), LoadColor(config, "creditlong-color", Color.Blue));
  479. _creditShortAppearance = new IndicatorAppearance(LoadStyle(config, "creditshort-style", IndicatorStyle.Line), LoadColor(config, "creditshort-color", Color.Red));
  480. _fushiRange = LoadInt(config, "fushi-range", 5);
  481. _fontDirty = true;
  482. _accumulativeVolumePeriod = new ChartFormatSpecificValue(LoadString(config, "accumulative-volume-period", "60,52,24,10"));
  483. _oscillatorPreferences = new OscillatorPreference[OscillatorPreference.LENGTH];
  484. for(int i=0; i<_oscillatorPreferences.Length; i++)
  485. _oscillatorPreferences[i] = new OscillatorPreference(LoadString(config, "oscillator-"+i, "none"));
  486. }
  487. private string LoadString(StorageNode config, string name, string def) {
  488. if(config==null) return def;
  489. return config.GetValue(name, def);
  490. }
  491. private Color LoadColor(StorageNode config, string name, Color def) {
  492. if(config==null) return def;
  493. string cn = config.GetValue(name);
  494. if(cn==null)
  495. return def;
  496. else
  497. return Util.ParseColor(cn, def);
  498. }
  499. private FontStyle LoadFontStyle(StorageNode config, string name, FontStyle def) {
  500. if(config==null) return def;
  501. string cn = config.GetValue(name);
  502. if(cn==null)
  503. return def;
  504. else
  505. return (FontStyle)Enum.Parse(typeof(FontStyle), cn);
  506. }
  507. private int LoadInt(StorageNode config, string name, int def) {
  508. if(config==null) return def;
  509. return Util.ParseInt(config.GetValue(name, ""), def);
  510. }
  511. private bool LoadBool(StorageNode config, string name, bool def) {
  512. if(config==null) return def;
  513. return Util.ParseBool(config.GetValue(name, ""), def);
  514. }
  515. private float LoadFloat(StorageNode config, string name, float def) {
  516. if(config==null) return def;
  517. return Util.ParseFloat(config.GetValue(name, ""), def);
  518. }
  519. private IndicatorStyle LoadStyle(StorageNode config, string name, IndicatorStyle def) {
  520. if(config==null) return def;
  521. return IndicatorAppearance.ParseStyle(config.GetValue(name, ""), def);
  522. }
  523. private ZPen.PenStyle LoadStyle(StorageNode config, string name, ZPen.PenStyle def) {
  524. if(config==null) return def;
  525. string t = config.GetValue(name, "");
  526. if(t=="Normal")
  527. return ZPen.PenStyle.Normal;
  528. else if(t=="Dotted")
  529. return ZPen.PenStyle.Dotted;
  530. else if(t=="Bold")
  531. return ZPen.PenStyle.Bold;
  532. else
  533. return def;
  534. }
  535. public void SaveTo(StorageNode parent) {
  536. StorageNode node = new StorageNode();
  537. node.Name = "preference";
  538. node["font-name"] = _fontName;
  539. node["font-size"] = _fontSize.ToString();
  540. node["font-style"] = _fontStyle.ToString();
  541. node["text-color"] = Util.FormatColor(_defaultBrush.Color);
  542. node["back-color"] = Util.FormatColor(_backBrush.Color);
  543. node["insen-color"] = Util.FormatColor(_insenBrush.Color);
  544. node["fushi-color"] = Util.FormatColor(_fushiColor);
  545. node["free-line-color"] = Util.FormatColor(_freeLineColor);
  546. node["candle-color"] = Util.FormatColor(_candlePen.Color);
  547. node["month-div-color"] = Util.FormatColor(_monthDivPen.Color);
  548. node["month-div-style"] = _monthDivPen.Style.ToString();
  549. node["price-scale-color"] = Util.FormatColor(_priceScalePen.Color);
  550. node["price-scale-style"] = _priceScalePen.Style.ToString();
  551. node["volume-scale-color"] = Util.FormatColor(_volumeScalePen.Color);
  552. node["volume-scale-style"] = _volumeScalePen.Style.ToString();
  553. node["oscillator-scale-color"] = Util.FormatColor(_oscillatorScalePen.Color);
  554. node["oscillator-scale-style"] = _oscillatorScalePen.Style.ToString();
  555. node["volume-color"] = Util.FormatColor(_volumeBrush.Color);
  556. node["mouse-tracking-color"] = Util.FormatColor(_mouseTrackingLinePen.Color);
  557. node["mouse-tracking-style"] = _mouseTrackingLinePen.Style.ToString();
  558. node["mouse-tracking-mode"] = _mouseTrackingLineMode.ToString();
  559. node["fushi-range"] = _fushiRange.ToString();
  560. node["creditlong-style"] = _creditLongAppearance.Pen.Style.ToString();
  561. node["creditlong-color"] = Util.FormatColor(_creditLongAppearance.Pen.Color);
  562. node["creditshort-style"] = _creditShortAppearance.Pen.Style.ToString();
  563. node["creditshort-color"] = Util.FormatColor(_creditShortAppearance.Pen.Color);
  564. node["candle-width"] = _candleWidth.ToString();
  565. node["candle-effect"] = _useCandleEffect.ToString();
  566. node["log-scale"] = _logScale.ToString();
  567. node["inverse-chart"] = _inverseChart.ToString();
  568. node["adjust-split"] = _adjustSplit.ToString();
  569. node["show-price"] = _showPrice.ToString();
  570. node["show-volume"] = _showVolume.ToString();
  571. node["show-accumulative-volume"] = _showAccumulativeVolume.ToString();
  572. node["accumulative-volume-period"] = _accumulativeVolumePeriod.ToString();
  573. for(int i=0; i<_oscillatorPreferences.Length; i++)
  574. node["oscillator-"+i] = _oscillatorPreferences[i].Format();
  575. parent.AddChild(node);
  576. }
  577. public void Refresh() {
  578. for(int i=0; i<_oscillatorPreferences.Length; i++)
  579. _oscillatorPreferences[i].Refresh();
  580. }
  581. /*
  582. #define PS_SOLID 0
  583. #define PS_DASH 1 /* -------
  584. #define PS_DOT 2 /* .......
  585. #define PS_DASHDOT 3 /* _._._._
  586. */
  587. public IntPtr DefaultHFont {
  588. get {
  589. if(_fontDirty) CreateFont();
  590. return _defaultHFont;
  591. }
  592. }
  593. public Font DefaultFont {
  594. get {
  595. if(_fontDirty) CreateFont();
  596. return _defaultFont;
  597. }
  598. }
  599. public IntPtr HeaderHFont {
  600. get {
  601. if(_fontDirty) CreateFont();
  602. return _headerHFont;
  603. }
  604. }
  605. public Font HeaderFont {
  606. get {
  607. if(_fontDirty) CreateFont();
  608. return _headerFont;
  609. }
  610. }
  611. public SizeF DefaultCharPitch {
  612. get {
  613. if(_fontDirty) CreateFont();
  614. return _defaultFontPitch;
  615. }
  616. }
  617. public SizeF HeaderCharPitch {
  618. get {
  619. if(_fontDirty) CreateFont();
  620. return _headerFontPitch;
  621. }
  622. }
  623. private void CreateFont() {
  624. _defaultFont = new Font(_fontName, _fontSize, _fontStyle);
  625. _headerFont = new Font(_fontName, _fontSize, _fontStyle);
  626. Graphics g = Env.Frame.CreateGraphics();
  627. SizeF t1 = g.MeasureString("A", _defaultFont);
  628. SizeF t2 = g.MeasureString("AA", _defaultFont);
  629. _defaultFontPitch = new SizeF(t2.Width-t1.Width, t1.Height);
  630. t1 = g.MeasureString("A", _headerFont);
  631. t2 = g.MeasureString("AA", _headerFont);
  632. _headerFontPitch = new SizeF(t2.Width-t1.Width, t1.Height);
  633. g.Dispose();
  634. _defaultHFont = _defaultFont.ToHfont();
  635. _headerHFont = _headerFont.ToHfont();
  636. _fontDirty = false;
  637. }
  638. }
  639. /// <summary>
  640. /// LayoutInfoは、Preferenceオブジェクトと現在のウィンドウサイズなどを元に計算するレイアウト情報を収録
  641. /// </summary>
  642. internal class LayoutInfo {
  643. //画面構成
  644. private int _volumePaneHeight; //出来高系統を表示する高さ
  645. private int[] _oscillatorPaneHeights; //オシレータの高さ
  646. private int _oscillatorPaneHeightTotal; //その合計
  647. private int _headerHeight; //上部の銘柄名などを表示する領域の高さ
  648. private int _footerHeight; //下部の日付などを表示する領域の高さ
  649. private int _scaleAreaWidth; //目盛りの数値を表示する領域の幅
  650. private int _accumulativeVolumeWidth; //価格帯出来高用の幅
  651. private int _remarkAreaWidth; //現在値と注釈
  652. private int _defaultTextWidth;
  653. private int _defaultTextHeight;
  654. private int _brandInfoHeight;
  655. public void Init() {
  656. //一部はPreferenceから取得
  657. Preference pref = Env.Preference;
  658. _volumePaneHeight = CalcHeight(pref.ShowVolume, 100);
  659. _oscillatorPaneHeightTotal = 0;
  660. _oscillatorPaneHeights = new int[OscillatorPreference.LENGTH];
  661. for(int i=0; i<_oscillatorPaneHeights.Length; i++) {
  662. int h = CalcHeight(pref.OscillatorPreferences[i].Config, 100);
  663. _oscillatorPaneHeights[i] = h;
  664. _oscillatorPaneHeightTotal += h;
  665. }
  666. _headerHeight = 28; //(int)pref.HeaderCharPitch.Height+2;
  667. _footerHeight = (int)pref.DefaultCharPitch.Height+2;
  668. _brandInfoHeight = Math.Min(40, _footerHeight);
  669. _scaleAreaWidth = (int)(pref.DefaultCharPitch.Width * 7);
  670. _accumulativeVolumeWidth = pref.ShowAccumulativeVolume? (int)(pref.DefaultCharPitch.Width * 20) : 0;
  671. _remarkAreaWidth = pref.ShowPrice? (int)(pref.DefaultCharPitch.Width * 23) : 0;
  672. _defaultTextWidth = (int)Math.Ceiling(pref.DefaultCharPitch.Width);
  673. _defaultTextHeight = (int)Math.Ceiling(pref.DefaultCharPitch.Height);
  674. }
  675. public int OscillatorPaneHeightTotal {
  676. get {
  677. return _oscillatorPaneHeightTotal;
  678. }
  679. }
  680. public int VolumePaneHeight {
  681. get {
  682. return _volumePaneHeight;
  683. }
  684. }
  685. public int[] OscillatorPaneHeights {
  686. get {
  687. return _oscillatorPaneHeights;
  688. }
  689. }
  690. public int HeaderHeight {
  691. get {
  692. return _headerHeight;
  693. }
  694. }
  695. public int FooterHeight {
  696. get {
  697. return _footerHeight;
  698. }
  699. }
  700. public int ScaleAreaWidth {
  701. get {
  702. return _scaleAreaWidth;
  703. }
  704. }
  705. public int AccumulativeVolumeWidth {
  706. get {
  707. return _accumulativeVolumeWidth;
  708. }
  709. }
  710. public int RemarkAreaWidth {
  711. get {
  712. return _remarkAreaWidth;
  713. }
  714. }
  715. public int DefaultTextHeight {
  716. get {
  717. return _defaultTextHeight;
  718. }
  719. }
  720. public int DefaultTextWidth {
  721. get {
  722. return _defaultTextWidth;
  723. }
  724. }
  725. //レイアウトがらみ
  726. public Rectangle ChartBodyRect {
  727. get {
  728. return new Rectangle(0, 0, Env.Frame.ChartCanvas.Width-_remarkAreaWidth-_accumulativeVolumeWidth-_scaleAreaWidth, Env.Frame.ChartCanvas.BodyHeight);
  729. }
  730. }
  731. public Rectangle BrandInformationRect {
  732. get {
  733. return new Rectangle(0, _headerHeight, Env.Frame.ChartCanvas.Width-_remarkAreaWidth-_accumulativeVolumeWidth, _brandInfoHeight);
  734. }
  735. }
  736. public Rectangle CurrentValueRect {
  737. get {
  738. return new Rectangle(Env.Frame.ChartCanvas.Width - _remarkAreaWidth, _headerHeight, _remarkAreaWidth, _defaultTextHeight * (GetDrawingEngine().MaximumValueWindowItemCount + 1));
  739. }
  740. }
  741. public Rectangle ExplanationRect {
  742. get {
  743. Rectangle r = this.CurrentValueRect;
  744. r.Y = r.Bottom;
  745. r.Height = Env.Frame.ChartCanvas.BodyHeight - r.Y;
  746. return r;
  747. }
  748. }
  749. public Rectangle AccumulativeVolumeRect {
  750. get {
  751. return new Rectangle(Env.Frame.ChartCanvas.Width - _remarkAreaWidth - _accumulativeVolumeWidth, _headerHeight, _accumulativeVolumeWidth, Env.Frame.ChartCanvas.BodyHeight-_oscillatorPaneHeightTotal-_volumePaneHeight-_footerHeight);
  752. }
  753. }
  754. public int ChartAreaHeight {
  755. get {
  756. return Env.Frame.ChartCanvas.BodyHeight-_headerHeight-_footerHeight;
  757. }
  758. }
  759. public int ChartAreaWidth {
  760. get {
  761. return Env.Frame.ChartCanvas.Width-_remarkAreaWidth-_accumulativeVolumeWidth-_scaleAreaWidth;
  762. }
  763. }
  764. public int ChartAreaBottom {
  765. get {
  766. return Env.Frame.ChartCanvas.BodyHeight-_footerHeight;
  767. }
  768. }
  769. public int DisplayColumnCount {
  770. get {
  771. int n = this.ChartAreaWidth/Env.Preference.DatePitch;
  772. #if DOJIMA
  773. if(Env.CurrentIndicators.Format==ChartFormat.HalfDaily) n /= 2;
  774. #endif
  775. if(n<=1) n = 1;
  776. return n;
  777. }
  778. }
  779. //PreferenceのDatePitchと異なり、ChartFormatを考慮した値になる
  780. public int DatePitch {
  781. get {
  782. int n = Env.Preference.DatePitch;
  783. #if DOJIMA
  784. if(Env.CurrentIndicators.Format==ChartFormat.HalfDaily) n *= 2;
  785. #endif
  786. return n;
  787. }
  788. }
  789. public int CandleMiddleOffset {
  790. get {
  791. return DatePitch / 2;
  792. }
  793. }
  794. private ChartDrawing GetDrawingEngine() {
  795. return Env.Frame.ChartCanvas.DrawingEngine;
  796. }
  797. private static int CalcHeight(HeightConfig value, int max) {
  798. switch(value) {
  799. case HeightConfig.None:
  800. return 0;
  801. case HeightConfig.Large:
  802. return max;
  803. case HeightConfig.Middle:
  804. return max * 3 / 4;
  805. default: //Small
  806. return max / 2;
  807. }
  808. }
  809. }
  810. }
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト