Pastebin: OmegaChart Fibonacciトレースメント ChartCanvas.cs 追加修正ポイントには//☆Fibonacci ※差し替え その1

Format
Plain text
Post date
2018-01-13 16:30
Publication Period
Unlimited
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using System.Diagnostics;
  7. using Zanetti.Indicators;
  8. using Zanetti.Data;
  9. using Zanetti.Forms;
  10. namespace Zanetti.UI
  11. {
  12. /// <summary>
  13. /// </summary>
  14. internal class ChartCanvas : System.Windows.Forms.UserControl
  15. {
  16. private AbstractBrand _brand;
  17. private ChartDrawing _drawing;
  18. private ChartTitle _title;
  19. private System.Windows.Forms.HScrollBar _scrollBar;
  20. private Label _complementaryLabel;
  21. private int _diffX = 0;
  22. private int _diffY = 0;
  23. private int _destX = 0;
  24. private int _pivotX = 0;
  25. private int _destY = 0;
  26. private int _pivotY = 0;
  27. /// <summary>
  28. /// 必要なデザイナ変数です。
  29. /// </summary>
  30. private System.ComponentModel.Container components = null;
  31. public ChartCanvas()
  32. {
  33. // この呼び出しは、Windows.Forms フォーム デザイナで必要です。
  34. InitializeComponent();
  35. // TODO: InitializeComponent 呼び出しの後に初期化処理を追加します。
  36. this.BackColor = Env.Preference.BackBrush.Color;
  37. this.SetStyle(ControlStyles.AllPaintingInWmPaint|ControlStyles.DoubleBuffer, true);
  38. _drawing = new ChartDrawing(this);
  39. }
  40. /// <summary>
  41. /// 使用されているリソースに後処理を実行します。
  42. /// </summary>
  43. protected override void Dispose( bool disposing )
  44. {
  45. if( disposing )
  46. {
  47. if(components != null)
  48. {
  49. components.Dispose();
  50. }
  51. }
  52. base.Dispose( disposing );
  53. }
  54. #region コンポーネント デザイナで生成されたコード
  55. /// <summary>
  56. /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
  57. /// コード エディタで変更しないでください。
  58. /// </summary>
  59. private void InitializeComponent()
  60. {
  61. this._scrollBar = new System.Windows.Forms.HScrollBar();
  62. _title = new ChartTitle();
  63. this.SuspendLayout();
  64. //
  65. // _scrollBar
  66. //
  67. this._scrollBar.Dock = System.Windows.Forms.DockStyle.Bottom;
  68. this._scrollBar.Enabled = false;
  69. this._scrollBar.LargeChange = 2;
  70. this._scrollBar.Location = new System.Drawing.Point(0, 83);
  71. this._scrollBar.Maximum = 4;
  72. this._scrollBar.Name = "_scrollBar";
  73. this._scrollBar.Size = new System.Drawing.Size(100, 17);
  74. this._scrollBar.TabIndex = 0;
  75. this._scrollBar.ValueChanged += new System.EventHandler(this.OnScrollBarValueChanged);
  76. _title.Location = new Point(0, 0);
  77. _title.Size = new Size(this.Width, Env.Layout.HeaderHeight);
  78. //
  79. // ChartCanvas
  80. //
  81. this.Controls.Add(this._scrollBar);
  82. this.Controls.Add(this._title);
  83. this.MouseUp += new MouseEventHandler(OnMouseUp);
  84. this.Name = "ChartCanvas";
  85. this.Size = new System.Drawing.Size(100, 100);
  86. this.ResumeLayout(false);
  87. _title.BringToFront();
  88. }
  89. #endregion
  90. public Label ComplementaryLabel {
  91. get {
  92. if(_complementaryLabel==null) {
  93. _complementaryLabel = new Label();
  94. _complementaryLabel.Visible = false;
  95. _complementaryLabel.Font = Env.Preference.DefaultFont;
  96. _complementaryLabel.TextAlign = ContentAlignment.MiddleLeft;
  97. _complementaryLabel.BorderStyle = BorderStyle.FixedSingle;
  98. _complementaryLabel.BackColor = Color.FromKnownColor(KnownColor.Info);
  99. _complementaryLabel.ForeColor = Color.FromKnownColor(KnownColor.InfoText);
  100. this.Controls.Add(_complementaryLabel);
  101. }
  102. return _complementaryLabel;
  103. }
  104. }
  105. public ChartTitle ChartTitle {
  106. get {
  107. return _title;
  108. }
  109. }
  110. public ChartDrawing DrawingEngine {
  111. get {
  112. return _drawing;
  113. }
  114. }
  115. public int BodyHeight {
  116. get {
  117. return this.Height - _scrollBar.Height;
  118. }
  119. }
  120. public void LoadBrand(AbstractBrand br, bool preserve_date) {
  121. int date = -1;
  122. if(preserve_date && _brand!=null) {
  123. DataFarm f = _brand.ReserveFarm();
  124. if(!f.IsEmpty) {
  125. Debug.Assert(_drawing.FirstDateIndex>=0 && _drawing.FirstDateIndex<f.TotalLength);
  126. if(_drawing.FirstDateIndex + Env.Layout.DisplayColumnCount >= f.TotalLength)
  127. date = -1; //最終データが見えているときは「最後が見えている」状態を維持
  128. else
  129. date = f.GetByIndex(_drawing.FirstDateIndex).Date;
  130. }
  131. }
  132. _brand = br;
  133. AdjustScrollBar();
  134. if(_scrollBar.Enabled) {
  135. DataFarm f = br.ReserveFarm();
  136. int v = date==-1? GetTotalDataLength() - Env.Layout.DisplayColumnCount : f.DateToIndex(date);
  137. if(v<0) v = 0;
  138. if(v>_scrollBar.Maximum-_scrollBar.LargeChange+1) v = _scrollBar.Maximum-_scrollBar.LargeChange+1;
  139. _scrollBar.Value = v;
  140. }
  141. _drawing.SetBrand(br);
  142. //_title.InitUI();
  143. }
  144. public AbstractBrand GetBrand() {
  145. return _brand;
  146. }
  147. public int FirstDateIndex {
  148. get {
  149. return _drawing.FirstDateIndex;
  150. }
  151. }
  152. public void MoveToLatest() {
  153. AdjustScrollBar();
  154. int v = 0;
  155. if(_scrollBar.Enabled) v = GetTotalDataLength() - Env.Layout.DisplayColumnCount;
  156. if(v<0) v = 0;
  157. _scrollBar.Value = v;
  158. Invalidate(false);
  159. }
  160. public void SetDateIndex(int first, int cursor) {
  161. _scrollBar.Value = first;
  162. DataFarm f = _brand.ReserveFarm();
  163. if(f.IsEmpty)
  164. _drawing.UpdateDateLineIndex(-1);
  165. else
  166. _drawing.UpdateDateLineIndex(Math.Min(cursor, f.FilledLength-1));
  167. Invalidate(true);
  168. }
  169. public void ForceVisibleDate(int date, bool cut) {
  170. DataFarm f = _brand.ReserveFarm();
  171. if(f.IsEmpty) return;
  172. int index = f.DateToIndex(date);
  173. //スクロールしないと見えない
  174. if(_drawing.FirstDateIndex>index || index>=_drawing.FirstDateIndex+Env.Layout.DisplayColumnCount || cut) {
  175. int nv = index - Env.Layout.DisplayColumnCount/2; //大体真ん中に表示
  176. if(nv<0) nv = 0;
  177. if(nv>=f.TotalLength) nv = f.TotalLength-1;
  178. _scrollBar.Value = nv;
  179. }
  180. _drawing.UpdateDateLineIndex(index);
  181. Invalidate(false);
  182. }
  183. public void ReloadFromPreference() {
  184. Preference pref = Env.Preference;
  185. Color bc = pref.BackBrush.Color;
  186. Color fc = pref.TextColor;
  187. this.BackColor = bc;
  188. this.ForeColor = fc;
  189. if(_complementaryLabel!=null) _complementaryLabel.Font = pref.DefaultFont;
  190. //InitOscillatorGroupUI();
  191. _drawing.ClearScale();
  192. }
  193. public void ResetLayout() {
  194. //_oscillatorGroup.Visible = Env.Options.ShowOscillator;
  195. AdjustScrollBar(); //これは価格帯出来高の表示設定が変化したときだけでもよい
  196. _drawing.ClearScale();
  197. _title.InitUI();
  198. }
  199. //メッセージ処理がらみ
  200. protected override void OnLoad(EventArgs e) {
  201. base.OnLoad (e);
  202. Preference pref = Env.Preference;
  203. }
  204. protected override void OnPaint(PaintEventArgs e) {
  205. base.OnPaint (e);
  206. if(this.DesignMode || _brand==null) return;
  207. _drawing.PaintMain(e.Graphics, e.ClipRectangle);
  208. if(_currentFreeLine!=null && _currentFreeLine.PivotHasEnoughDistanceTo(this.PointToClient(Control.MousePosition))) {
  209. IntPtr hdc = e.Graphics.GetHdc();
  210. _currentFreeLine.Draw(Env.Layout.ChartBodyRect, hdc);
  211. e.Graphics.ReleaseHdc(hdc);
  212. }
  213. //☆Fibonacci
  214. if (_currentFibonacci != null && _currentFibonacci.PivotHasEnoughDistanceTo(this.PointToClient(Control.MousePosition)))
  215. {
  216. IntPtr hdc = e.Graphics.GetHdc();
  217. _currentFibonacci.Draw(_drawing.PriceTrans, Env.Layout.ChartBodyRect, hdc);
  218. e.Graphics.ReleaseHdc(hdc);
  219. }
  220. //☆Fibonacci 追加ここまで
  221. }
  222. protected override void OnResize(EventArgs e) {
  223. base.OnResize (e);
  224. if(!this.DesignMode && _drawing!=null && _brand!=null && Env.Frame.WindowState!=FormWindowState.Minimized) {
  225. bool last_is_visible = !_scrollBar.Enabled || _scrollBar.Value+_scrollBar.LargeChange>=_scrollBar.Maximum;
  226. _drawing.ClearScale();
  227. AdjustScrollBar();
  228. this.SuspendLayout();
  229. Preference pref = Env.Preference;
  230. //_oscillatorGroup.Top = this.BodyHeight - _oscillatorGroup.Height - 8;
  231. //_oscillatorGroup.Left = this.Width - Env.Layout.RemarkAreaWidth+5;
  232. if(!_brand.ReserveFarm().IsEmpty && last_is_visible) { //最新データ見えているときのリサイズはその状態を維持
  233. int v = _brand.ReserveFarm().TotalLength - Env.Layout.DisplayColumnCount;
  234. if(v<0) v = 0;
  235. _scrollBar.Value = v; //このままValueChangedイベントも誘発
  236. }
  237. Invalidate(false);
  238. this.ResumeLayout();
  239. }
  240. }
  241. protected override void OnMouseMove(MouseEventArgs ev) {
  242. base.OnMouseMove (ev);
  243. if(_drawing==null) return;
  244. Preference pref = Env.Preference;
  245. //隠れてしまうIndicatorテキストの表示・非表示
  246. Point p = new Point(ev.X, ev.Y);//this.PointToClient(Control.MousePosition);
  247. if(_complementaryLabel!=null && _complementaryLabel.Visible) {
  248. if(!new Rectangle(_complementaryLabel.Location, _complementaryLabel.Size).Contains(p))
  249. _complementaryLabel.Visible = false;
  250. }
  251. else {
  252. ArrayList ar = _drawing.TipEntries;
  253. if(ar!=null) {
  254. foreach(ComplementaryTextEntry e in ar) {
  255. if(e.rect.Contains(p)) {
  256. Label l = this.ComplementaryLabel;
  257. l.Location = new Point(e.rect.X-2, e.rect.Y-1);
  258. l.Size = new Size(e.rect.Size.Width+5, e.rect.Size.Height+2);
  259. l.Text = e.text;
  260. l.Visible = true;
  261. l.BringToFront();
  262. l.Invalidate();
  263. break;
  264. }
  265. }
  266. }
  267. }
  268. int offset = -1;
  269. if(p.X >= 0 && p.X < Env.Layout.ChartAreaWidth) {
  270. offset = (p.X-Env.Layout.CandleMiddleOffset) / Env.Layout.DatePitch;
  271. DataFarm farm = _brand.ReserveFarm();
  272. if(!farm.IsEmpty && _drawing.FirstDateIndex+offset>=farm.TotalLength) offset = -1;
  273. }
  274. //横線
  275. if(Env.Preference.MouseTrackingLineMode==MouseTrackingLineMode.Full) {
  276. int my = _drawing.NormalizeByYobine(ev.Y);
  277. if(my!=_drawing.PriceLine._lastDrawn) {
  278. int h = Env.Layout.DefaultTextHeight;
  279. Rectangle yr = new Rectangle(0, _drawing.PriceLine._lastDrawn-h/2, this.Width, h);
  280. Invalidate(yr, false);
  281. yr = new Rectangle(0, my-h/2, this.Width, h);
  282. Invalidate(yr, false);
  283. }
  284. _drawing.PriceLine._nextToBeDrawn = my;
  285. }
  286. //必要なエリアのInvalidate
  287. int ld = _drawing.DateLine._lastDrawn;
  288. if(offset==-1) {
  289. if(ld!=-1) {
  290. Rectangle r = Env.Layout.CurrentValueRect;
  291. Invalidate(r, false);
  292. int t = ld - _drawing.FirstDateIndex;
  293. r = new Rectangle((t-1)*Env.Layout.DatePitch, 0, Env.Layout.DatePitch*2, this.Height);
  294. Invalidate(r, false);
  295. }
  296. _drawing.UpdateDateLineIndex(-1);
  297. }
  298. else {
  299. if(_drawing.FirstDateIndex+offset!=ld) {
  300. Rectangle r = Env.Layout.CurrentValueRect;
  301. //r.X += ChartDrawing.VALUEWINDOW_HEADER_WIDTH;
  302. Invalidate(r, false);
  303. //価格帯出来高
  304. if(Env.Preference.ShowAccumulativeVolume)
  305. Invalidate(Env.Layout.AccumulativeVolumeRect, false);
  306. //節の数値のこともあるので広めにInvalidateする
  307. if(ld!=-1) {
  308. int t = ld - _drawing.FirstDateIndex;
  309. //Debug.WriteLine(String.Format("prev offset={0}", t));
  310. r = new Rectangle((t-1)*Env.Layout.DatePitch, 0, Env.Layout.DatePitch*2, this.Height);
  311. Invalidate(r, false);
  312. }
  313. r = new Rectangle((offset-1)*Env.Layout.DatePitch, 0, Env.Layout.DatePitch*2, this.Height);
  314. Invalidate(r, false);
  315. }
  316. _drawing.UpdateDateLineIndex(_drawing.FirstDateIndex + offset);
  317. }
  318. //☆Fibonacci
  319. if (_currentFibonacci != null && ev.Button == MouseButtons.Left && ((Control.ModifierKeys & Keys.Alt) == Keys.Alt))
  320. {
  321. Invalidate(_currentFibonacci.GetInclusion(this.ClientRectangle), false);
  322. _currentFibonacci.Destination = p;
  323. var h = Env.Layout.ChartAreaBottom - Env.Layout.OscillatorPaneHeightTotal - Env.Layout.VolumePaneHeight;
  324. var point = this.PointToScreen(new Point(this.Location.X, this.Location.Y));
  325. Rectangle r = new Rectangle(point.X, point.Y, Env.Layout.ChartAreaWidth, h - _title.Height);
  326. Cursor.Clip = r;
  327. }
  328. //今引いている直線の再描画
  329. else if (_currentFreeLine!=null) {
  330. Invalidate(_currentFreeLine.GetInclusion(this.ClientRectangle), false);
  331. _currentFreeLine.Destination = p;
  332. }
  333. //左クリックしながら、マウスを動かした場合、コピー中と見なす。
  334. if (_diffX != 0 && _diffY != 0 && ev.Button == MouseButtons.Left && Win32.GetAsyncKeyState(System.Windows.Forms.Keys.ShiftKey) < 0 & 0x8000 != 0)
  335. {
  336. _currentFreeLine = new FreeLine(new Point(ev.X, ev.Y), new Point(ev.X - _diffX, ev.Y - _diffY));
  337. }
  338. //Controlキーを押しながら、マウスで左クリックしている時は、ピボット・コピー中と見なす。
  339. if (_diffX != 0 && _diffY != 0 && ev.Button == MouseButtons.Left && Win32.GetAsyncKeyState(System.Windows.Forms.Keys.ControlKey) < 0 & 0x8000 != 0)
  340. {
  341. int x, y = 0;
  342. if (_pivotX < _destX)//画面左から右へと引いたフリーライン
  343. {
  344. if ((_pivotX + _destX) / 2 > ev.X)//軸となる点は旧_dest
  345. {
  346. x = _destX;
  347. y = _destY;
  348. }
  349. else//軸となる点は旧_pivot
  350. {
  351. x = _pivotX;
  352. y = _pivotY;
  353. }
  354. }
  355. else//画面右から左へと引いたフリーライン
  356. {
  357. if ((_pivotX + _destX) / 2 > ev.X)//軸となる点は旧_pivot
  358. {
  359. x = _pivotX;
  360. y = _pivotY;
  361. }
  362. else//軸となる点は旧_dest
  363. {
  364. x = _destX;
  365. y = _destY;
  366. }
  367. }
  368. _currentFreeLine = new FreeLine(new Point(x, y), new Point(ev.X, ev.Y));
  369. }
  370. //接近した線があればそれをクリア
  371. bool near_line_found = false;
  372. foreach(FreeLine line in _drawing.FreeLines) {
  373. double d = line.GetDistance(p);
  374. FreeLine.LineDrawMode m = d<3? FreeLine.LineDrawMode.Hilight : FreeLine.LineDrawMode.Normal;
  375. if(line.DrawMode!=m) {
  376. line.DrawMode = m;
  377. Invalidate(line.GetInclusion(this.ClientRectangle), false);
  378. }
  379. if(!near_line_found) near_line_found = m==FreeLine.LineDrawMode.Hilight;
  380. }
  381. this.Cursor = near_line_found? Cursors.Hand : Cursors.Default;
  382. //☆Fibonacci
  383. near_line_found = false;
  384. foreach (Fibonacci line in _drawing.Fibonaccies)
  385. {
  386. double distance = 5;
  387. double d = Math.Abs(line.Pivot.Y - p.Y) < Math.Abs(line.Destination.Y - p.Y) ?
  388. line.Pivot.X < line.Destination.X ?
  389. line.Pivot.X <= p.X && p.X <= line.Destination.X ?
  390. Math.Abs(line.Pivot.Y - p.Y) : double.MaxValue :
  391. line.Destination.X <= p.X && p.X <= line.Pivot.X ?
  392. Math.Abs(line.Pivot.Y - p.Y) : double.MaxValue :
  393. line.Pivot.X < line.Destination.X ?
  394. line.Pivot.X <= p.X && p.X <= line.Destination.X ?
  395. Math.Abs(line.Destination.Y - p.Y) : double.MaxValue :
  396. line.Destination.X <= p.X && p.X <= line.Pivot.X ?
  397. Math.Abs(line.Destination.Y - p.Y) : double.MaxValue;
  398. Fibonacci.LineDrawMode m = d < distance ? Fibonacci.LineDrawMode.Hilight : Fibonacci.LineDrawMode.Normal;
  399. if (line.DrawMode != m)
  400. {
  401. line.DrawMode = m;
  402. Invalidate(line.GetInclusion(this.ClientRectangle), false);
  403. }
  404. if (!near_line_found) near_line_found = m == Fibonacci.LineDrawMode.Hilight;
  405. }
  406. this.Cursor = near_line_found ? Cursors.Hand : Cursors.Default;
  407. //☆Fibonacci 追加ここまで
  408. }
  409. private void OnMouseUp(object sender, MouseEventArgs args) {
  410. Cursor.Clip = Rectangle.Empty;//☆Fibonacci
  411. if(args.Button==MouseButtons.Right) {
  412. ContextMenu m = Env.Frame.CreateContextMenu();
  413. m.Show(this, new Point(args.X, args.Y));
  414. }
  415. else if(args.Button==MouseButtons.Left) {
  416. if(_currentFreeLine!=null) {
  417. if(_drawing.FreeLineCount==10) {
  418. Util.Warning(Env.Frame, "線は1銘柄につき10本までしか引けません");
  419. Invalidate();
  420. }
  421. else if(Env.FreeLines.Count==1000) {
  422. Util.Warning(Env.Frame, "線は全部で1000本までしか引けません");
  423. Invalidate();
  424. }
  425. else if(_currentFreeLine.PivotHasEnoughDistanceTo(_currentFreeLine.Destination)) {
  426. _drawing.FixFreeLine(_currentFreeLine);
  427. }
  428. _currentFreeLine = null;
  429. }
  430. if(_drawing.RemoveHighlitedFreeLines()) Invalidate(); //削除されたやつがあればInvalidate
  431. //☆Fibonacci
  432. if (_currentFibonacci != null)
  433. {
  434. if (_drawing.FibonacciesCount == 10)
  435. {
  436. Util.Warning(Env.Frame, "線は1銘柄につき10本までしか引けません");
  437. Invalidate();
  438. }
  439. else if (Env.Fibonacci.Count == 1000)
  440. {
  441. Util.Warning(Env.Frame, "線は全部で1000本までしか引けません");
  442. Invalidate();
  443. }
  444. else if (_currentFibonacci.PivotHasEnoughDistanceTo(_currentFibonacci.Destination))
  445. {
  446. //クリックして選んだ2点の内側の最高値と最安値を取得
  447. _currentFibonacci.SetHighPriceAndLowPrice(_brand.ReserveFarm(), _drawing.PriceTrans, _currentFibonacci.Pivot.X, args.X, FirstDateIndex);
  448. _drawing.FixFibonacci(_currentFibonacci);
  449. }
  450. _currentFibonacci = null;
  451. this.Refresh();
  452. }
  453. if (_drawing.RemoveHighlitedFibonacci()) Invalidate(); //削除されたやつがあればInvalidate
  454. }
  455. }
  456. protected override bool IsInputChar(char charCode) {
  457. return false;
  458. }
  459. private void AdjustScrollBar() {
  460. if(_brand==null || _brand.ReserveFarm().IsEmpty) {
  461. _scrollBar.Enabled = false;
  462. }
  463. else {
  464. Preference pref = Env.Preference;
  465. int total = GetTotalDataLength();
  466. int display = Env.Layout.DisplayColumnCount;
  467. if(display>=total) {
  468. _scrollBar.Enabled = false;
  469. _scrollBar.Value = 0;
  470. _drawing.FirstDateIndex = 0;
  471. }
  472. else {
  473. int v = _scrollBar.Value;
  474. _scrollBar.LargeChange = display;
  475. _scrollBar.Maximum = total-1;
  476. //Debug.WriteLine(String.Format("Adjusted disp={0} all={1} v={2}", display, all, v));
  477. if(v > _scrollBar.Maximum - display) _scrollBar.Value = _scrollBar.Maximum - display + 1;
  478. _scrollBar.Enabled = true;
  479. }
  480. }
  481. }
  482. private int GetTotalDataLength() {
  483. return _brand.ReserveFarm().TotalLength;
  484. }
  485. private void OnScrollBarValueChanged(object sender, EventArgs args) {
  486. if(this.DesignMode) return;
  487. int v = _scrollBar.Value;
  488. _drawing.FirstDateIndex = v;
  489. //Debug.WriteLine(String.Format("ValueChange max={0} lc={1} v={2}", _scrollBar.Maximum, _scrollBar.LargeChange, v));
  490. _drawing.ClearScale();
  491. Invalidate();
  492. }
  493. /*
  494. private void OnOscillatorGroupCheckedChanged(object sender, EventArgs args) {
  495. int i = _oscillatorGroupBoxes.IndexOf(sender);
  496. Debug.Assert(i!=-1);
  497. _drawing.OscillatorGroup = Env.CurrentIndicators.GetOscillatorGroupAt(i);
  498. Invalidate();
  499. }
  500. */
  501. //FreeLine関係
  502. private FreeLine _currentFreeLine;
  503. //☆Fibonacci
  504. private Fibonacci _currentFibonacci;
  505. protected override void OnMouseDown(MouseEventArgs e) {
  506. base.OnMouseDown (e);
  507. if (e.Button == MouseButtons.Left && (Control.ModifierKeys & Keys.Alt) == Keys.Alt)//☆Fibonacci 下記のif文の上に乗せる
  508. {
  509. _currentFibonacci = new Fibonacci(new Point(e.X, e.Y));
  510. }
  511. else if (e.Button == MouseButtons.Left)//☆Fibonacci if文をelse ifにする
  512. {
  513. if (_brand.ReserveFarm().IsEmpty) return;
  514. foreach (FreeLine line in _drawing.FreeLines)
  515. {
  516. if (line.DrawMode == FreeLine.LineDrawMode.Hilight && e.Button == MouseButtons.Left)
  517. {
  518. _diffX = line.Destination.X - line.Pivot.X;
  519. _diffY = line.Destination.Y - line.Pivot.Y;
  520. _destX = line.Destination.X;
  521. _destY = line.Destination.Y;
  522. _pivotX = line.Pivot.X;
  523. _pivotY = line.Pivot.Y;
  524. }
  525. }
  526. _currentFreeLine = new FreeLine(new Point(e.X, e.Y));
  527. }
  528. }
  529. protected override void OnDoubleClick(EventArgs e)
  530. {
  531. base.OnDoubleClick(e);
  532. var ev = (MouseEventArgs)e;
  533. _currentFreeLine = new FreeLine(new Point(0, ev.Y), new Point(ev.X, ev.Y));
  534. }
  535. public void ClearCurrentFreeLine() {
  536. if(_currentFreeLine!=null) {
  537. Invalidate(_currentFreeLine.GetInclusion(Env.Layout.ChartBodyRect), false);
  538. _currentFreeLine = null;
  539. }
  540. }
  541. //DOJIMA用半日足修正
  542. #if DOJIMA
  543. protected override void OnDoubleClick(EventArgs e) {
  544. base.OnDoubleClick (e);
  545. if(Env.CurrentIndicators.Format!=ChartFormat.HalfDaily) return;
  546. int index = _drawing.DateLine._lastDrawn;
  547. DailyDataFarm f = _brand.ReserveFarm() as DailyDataFarm;
  548. if(index<0 || index>=f.FilledLength) return;
  549. Dojima.ModifyHalfDayData dlg = new Dojima.ModifyHalfDayData();
  550. dlg.InitUI(f.GetByIndex(index), Dojima.DojimaUtil.HalfDailyDataFarmCache.Get(f), index);
  551. if(dlg.ShowDialog(Env.Frame)==DialogResult.OK) {
  552. Invalidate(true); //全画面再描画
  553. }
  554. }
  555. #endif
  556. }
  557. }
다운로드 Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text