LinePlot.cs 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918
  1. using MuchInfo.Chart.Data.EnumTypes;
  2. using MuchInfo.Chart.Data.Interfaces;
  3. using MuchInfo.Chart.Data.Models;
  4. using MuchInfo.Chart.Infrastructure.Data;
  5. using MuchInfo.Chart.Infrastructure.EventArgs;
  6. using MuchInfo.Chart.Infrastructure.Helpers;
  7. using MuchInfo.Chart.Infrastructure.Utilities;
  8. using MuchInfo.Chart.Utilities.Enums;
  9. using MuchInfo.Chart.WPF.Helpers;
  10. using MuchInfo.Chart.WPF.Primitives.Interfaces;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Windows;
  15. using System.Windows.Controls;
  16. using System.Windows.Media;
  17. using System.Windows.Shapes;
  18. namespace MuchInfo.Chart.WPF.Primitives
  19. {
  20. #region Delegates
  21. public delegate void PlotStyleChangedEventHandler();
  22. #endregion Delegates
  23. public class LinePlot : PlotBase
  24. {
  25. #region Fields
  26. protected Color mAreaFillColorDarkBG;
  27. protected Color mAreaFillColorLightBG;
  28. protected double mAreaFillOpacity;
  29. protected Color mPlotColorDarkBG;
  30. protected Color mPlotColorLightBG;
  31. protected Color mPlotNegColorDarkBG;
  32. protected Color mPlotNegColorLightBG;
  33. private readonly Color c_YestodayColor;
  34. private readonly Color c_TodayOpenColor;
  35. protected OutputDataWrapper mOutputData;
  36. //protected bool mPlotNegValsDiffColor;
  37. private DashStyleType _dashStyleType;
  38. private DoubleCollection _doubleCollection;
  39. private bool _isDark;
  40. private static Random _random = new Random(18000); // 没设置颜色时使用随机颜色,
  41. private double _lineThickness;
  42. #endregion Fields
  43. #region Constructors
  44. public LinePlot()
  45. {
  46. c_YestodayColor = Colors.Gold;
  47. c_TodayOpenColor = Colors.Chocolate;
  48. this.mPlotColorDarkBG = Colors.Cyan;
  49. this.mPlotColorLightBG = ColorHelper.DarkBlue;
  50. this.mPlotNegColorDarkBG = Colors.Red;
  51. this.mPlotNegColorLightBG = ColorHelper.DarkRed;
  52. //this.mPlotNegValsDiffColor = false;
  53. this._isDark = true;
  54. // this.mPlotType = LinePlotType.OHLC;
  55. this._dashStyleType = DashStyleType.Solid;
  56. this._lineThickness = 1.2;
  57. this.mAreaFillColorDarkBG = Colors.Gray;
  58. this.mAreaFillColorLightBG = ColorHelper.Gray;
  59. this.mAreaFillOpacity = 0.5;
  60. }
  61. public LinePlot(IndicatorModel indeicator, Chart chart)
  62. : base(indeicator, chart)
  63. {
  64. var OutputData = new OutputDataWrapper()
  65. {
  66. mDat = new ChartDataSet(indeicator.CalculateDataPoints),
  67. };
  68. this.mOutputData = OutputData;
  69. c_YestodayColor = Colors.Gold;
  70. c_TodayOpenColor = Colors.Chocolate;
  71. this.mPlotColorDarkBG = Colors.Cyan;
  72. this.mPlotColorLightBG = ColorHelper.DarkBlue;
  73. this.mPlotNegColorDarkBG = Colors.Red;
  74. this.mPlotNegColorLightBG = ColorHelper.DarkRed;
  75. this._isDark = true;
  76. this._dashStyleType = DashStyleType.Solid;
  77. this._lineThickness = 1.2;
  78. this.mAreaFillColorDarkBG = Colors.Gray;
  79. this.mAreaFillColorLightBG = ColorHelper.Gray;
  80. this.mAreaFillOpacity = 0.5;
  81. this.Calculate();
  82. InitAsNew();
  83. }
  84. #endregion Constructors
  85. #region Events
  86. public event PlotStyleChangedEventHandler PlotStyleChanged;
  87. #endregion Events
  88. #region Properties
  89. #region Public Properties
  90. public DashStyleType DashStyle
  91. {
  92. get
  93. {
  94. return this._dashStyleType;
  95. }
  96. set
  97. {
  98. this._dashStyleType = value;
  99. switch (this._dashStyleType)
  100. {
  101. case DashStyleType.Solid:
  102. this._doubleCollection = null;
  103. break;
  104. case DashStyleType.Dashed:
  105. this._doubleCollection = new DoubleCollection { 10.0, 5.0 };
  106. break;
  107. case DashStyleType.Dotted:
  108. this._doubleCollection = new DoubleCollection { 3.0, 3.0 };
  109. break;
  110. case DashStyleType.LongDashes:
  111. this._doubleCollection = new DoubleCollection { 25.0, 10.0 };
  112. break;
  113. }
  114. }
  115. }
  116. //public bool PlotNegValsDiffColor
  117. //{
  118. // get
  119. // {
  120. // return this.mPlotNegValsDiffColor;
  121. // }
  122. // set
  123. // {
  124. // bool flag = value != this.mPlotNegValsDiffColor;
  125. // if (flag)
  126. // {
  127. // this.mPlotNegValsDiffColor = value;
  128. // flag = (this.mChart != null);
  129. // if (flag)
  130. // {
  131. // this.mChart.Refresh();
  132. // }
  133. // }
  134. // }
  135. //}
  136. #endregion Public Properties
  137. #endregion Properties
  138. #region Methods
  139. #region Public Methods
  140. #region 获取公式中各个图的颜色
  141. #endregion
  142. //public override void FromXML(XElement node)
  143. //{
  144. // Color? color = default(Color?);
  145. // bool flag = node.Attribute("PlotColor") != null;
  146. // if (flag)
  147. // {
  148. // this.mPlotColorDarkBG = ColorHelper.ColorFromString(node.Attribute("PlotColor").Value);
  149. // }
  150. // flag = (node.Attribute("PlotColorL") != null);
  151. // if (flag)
  152. // {
  153. // color = ColorHelper.ColorFromString(node.Attribute("PlotColorL").Value);
  154. // }
  155. // flag = (node.Attribute("PlotNegValsDiffColor") != null);
  156. // if (flag)
  157. // {
  158. // this.mPlotNegValsDiffColor = bool.Parse(node.Attribute("PlotNegValsDiffColor").Value);
  159. // }
  160. // flag = (node.Attribute("NegPlotColor") != null);
  161. // if (flag)
  162. // {
  163. // this.mPlotNegColorDarkBG = ColorHelper.ColorFromString(node.Attribute("NegPlotColor").Value);
  164. // }
  165. // flag = (node.Attribute("NegPlotColorL") != null);
  166. // if (flag)
  167. // {
  168. // this.mPlotNegColorLightBG = ColorHelper.ColorFromString(node.Attribute("NegPlotColorL").Value);
  169. // }
  170. // flag = (node.Attribute("AreaColor") != null);
  171. // if (flag)
  172. // {
  173. // this.mAreaFillColorDarkBG = ColorHelper.ColorFromString(node.Attribute("AreaColor").Value);
  174. // }
  175. // flag = (node.Attribute("AreaColorL") != null);
  176. // if (flag)
  177. // {
  178. // this.mAreaFillColorLightBG = ColorHelper.ColorFromString(node.Attribute("AreaColorL").Value);
  179. // }
  180. // flag = (node.Attribute("Thickness") != null);
  181. // if (flag)
  182. // {
  183. // this.LinePlot_1593 = XmlHelper.ParseDouble(node.Attribute("Thickness").Value);
  184. // }
  185. // flag = (node.Attribute("DashPattern") != null);
  186. // if (flag)
  187. // {
  188. // string value = node.Attribute("DashPattern").Value;
  189. // string text = value;
  190. // flag = (Operators.CompareString(text, DashStyleType.Solid.ToString(), false) == 0);
  191. // if (flag)
  192. // {
  193. // this.DashStyle = DashStyleType.Solid;
  194. // }
  195. // else
  196. // {
  197. // flag = (Operators.CompareString(text, DashStyleType.Dashed.ToString(), false) == 0);
  198. // if (flag)
  199. // {
  200. // this.DashStyle = DashStyleType.Dashed;
  201. // }
  202. // else
  203. // {
  204. // flag = (Operators.CompareString(text, DashStyleType.Dotted.ToString(), false) == 0);
  205. // if (flag)
  206. // {
  207. // this.DashStyle = DashStyleType.Dotted;
  208. // }
  209. // else
  210. // {
  211. // flag = (Operators.CompareString(text, DashStyleType.LongDashes.ToString(), false) == 0);
  212. // if (flag)
  213. // {
  214. // this.DashStyle = DashStyleType.LongDashes;
  215. // }
  216. // }
  217. // }
  218. // }
  219. // }
  220. // flag = (node.Attribute("PlotStyle") != null);
  221. // if (flag)
  222. // {
  223. // string value2 = node.Attribute("PlotStyle").Value;
  224. // string text2 = value2.ToLower();
  225. // flag = (Operators.CompareString(text2, "eline", false) == 0);
  226. // if (flag)
  227. // {
  228. // this.mPlotStyle = LinePlotType.Line;
  229. // }
  230. // else
  231. // {
  232. // flag = (Operators.CompareString(text2, "ehlc", false) == 0);
  233. // if (flag)
  234. // {
  235. // this.mPlotStyle = LinePlotType.HLC;
  236. // }
  237. // else
  238. // {
  239. // flag = (Operators.CompareString(text2, "eohlc", false) == 0);
  240. // if (flag)
  241. // {
  242. // this.mPlotStyle = LinePlotType.OHLC;
  243. // }
  244. // else
  245. // {
  246. // flag = (Operators.CompareString(text2, "ecandle", false) == 0);
  247. // if (flag)
  248. // {
  249. // this.mPlotStyle = LinePlotType.Candle;
  250. // }
  251. // else
  252. // {
  253. // flag = (Operators.CompareString(text2, "ebar", false) == 0);
  254. // if (flag)
  255. // {
  256. // this.mPlotStyle = LinePlotType.Bar;
  257. // }
  258. // else
  259. // {
  260. // flag = (Operators.CompareString(text2, "edot", false) == 0);
  261. // if (flag)
  262. // {
  263. // this.mPlotStyle = LinePlotType.Dot;
  264. // }
  265. // else
  266. // {
  267. // flag = (Operators.CompareString(text2, "earea", false) == 0);
  268. // if (flag)
  269. // {
  270. // this.mPlotStyle = LinePlotType.Area;
  271. // }
  272. // else
  273. // {
  274. // flag = (Operators.CompareString(text2, "eheikenashi", false) == 0);
  275. // if (flag)
  276. // {
  277. // this.mPlotStyle = LinePlotType.HeikenAshi;
  278. // }
  279. // }
  280. // }
  281. // }
  282. // }
  283. // }
  284. // }
  285. // }
  286. // }
  287. // flag = (node.Attribute("OutputDataGUID") != null);
  288. // if (flag)
  289. // {
  290. // OutputDataWrapper arg_501_0 = this.mOutputData;
  291. // Guid value3 = new Guid(node.Attribute("OutputDataGUID").Value);
  292. // arg_501_0.DataGUID = value3;
  293. // }
  294. // flag = (node.Attribute("SourceID") != null);
  295. // if (flag)
  296. // {
  297. // this.mPendingSourceUID = (string)node.Attribute("SourceID");
  298. // }
  299. // try
  300. // {
  301. // IEnumerator<XElement> enumerator = node.Elements().GetEnumerator();
  302. // while (enumerator.MoveNext())
  303. // {
  304. // XElement current = enumerator.Current;
  305. // flag = !(current.Name == "PLOTADDITIONS");
  306. // if (flag)
  307. // {
  308. // var iXMLSavable = XmlTypeCreator.MakeElement(current);
  309. // flag = (iXMLSavable != null && iXMLSavable is ILineCalc);
  310. // if (flag)
  311. // {
  312. // this.mCalculation = (ILineCalc)iXMLSavable;
  313. // }
  314. // }
  315. // }
  316. // }
  317. // finally
  318. // {
  319. // //IEnumerator<XElement> enumerator;
  320. // //flag = (enumerator != null);
  321. // //if (flag)
  322. // //{
  323. // // enumerator.Dispose();
  324. // //}
  325. // }
  326. // flag = !color.HasValue;
  327. // if (flag)
  328. // {
  329. // bool flag2 = this.mCalculation != null;
  330. // if (flag2)
  331. // {
  332. // this.mPlotColorLightBG = this.mCalculation.DefaultColorForLightBG();
  333. // }
  334. // }
  335. // else
  336. // {
  337. // this.mPlotColorLightBG = color.Value;
  338. // }
  339. // base.ReadFromXML(node);
  340. //}
  341. //public override string GetXMLForDefault()
  342. //{
  343. // List<object> list = new List<object>();
  344. // list.Add("SAVEDEF");
  345. // return this.ToXML(list).ToString();
  346. //}
  347. public override void InitAsNew()
  348. {
  349. //this.mPlotType = ((ILineCalculation)this.PlotCalculation).DefaultPlotType;
  350. //this.mPlotColorDarkBG = this.PlotCalculation.DefaultColorForDarkBG();
  351. //this.mPlotColorLightBG = this.PlotCalculation.DefaultColorForLightBG();
  352. }
  353. public override void ReInstanceSources()
  354. {
  355. this.mOutputData.DataGUID = Guid.NewGuid();
  356. }
  357. public override void SourceDataChange(object change)
  358. {
  359. bool flag = change is DataChangedArgs;
  360. if (flag)
  361. {
  362. var dChange = (DataChangedArgs)change;
  363. //flag = this.mOutputData != null && this.mOutputData.DataPoints != null && this.mOutputData.DataPoints.Any();
  364. //if (flag)
  365. //{
  366. // flag = mOutputData.IsIncludeOHLCDataPoint(dChange);
  367. // if (flag)
  368. // {
  369. // return;
  370. // }
  371. //}
  372. }
  373. //调用公司计算
  374. this.Calculate();
  375. }
  376. #endregion Public Methods
  377. #region Internal Methods
  378. internal override List<FrameworkElement> BuildPlot(Chart owner, ScaleLayer aScale, IDateScaler dateScale,
  379. IValueScaler ValScale, Rect aRect)
  380. {
  381. //bool flag = this._isDark != owner.IsDarkBackground;
  382. //if (flag)
  383. //{
  384. // this._isDark = owner.IsDarkBackground;
  385. // //flag = (this.PlotCalculation != null && this.PlotCalculation is IBackGroundAwareCalculation);
  386. // if (flag)
  387. // {
  388. // }
  389. //}
  390. this.mChart = owner;
  391. this.mScale = aScale;
  392. bool flag = false; // (this.mCalculation != null && this.mCalculation is ISelfPlottingLineCalc);
  393. var result = new List<FrameworkElement>();
  394. //创建指标图形
  395. if (this.Indicator == null) return result;
  396. DashStyle = Indicator.DashStyleType;
  397. var painter = new PlotPainter(aRect, this._doubleCollection, Indicator.LineWidth);
  398. var eLinePlotType = Indicator.LinePlotType;
  399. switch (eLinePlotType)
  400. {
  401. case LinePlotType.Line:
  402. this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator);
  403. break;
  404. case LinePlotType.HLC:
  405. flag = this.HasOHLC();
  406. if (flag)
  407. {
  408. this.BuildHLCPoints(painter, dateScale, ValScale, aRect, Indicator);
  409. }
  410. else
  411. {
  412. this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator);
  413. }
  414. break;
  415. case LinePlotType.OHLC:
  416. flag = this.HasOHLC();
  417. if (flag)
  418. {
  419. this.BuildOHLCPoints(painter, dateScale, ValScale, aRect, Indicator);
  420. }
  421. else
  422. {
  423. this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator);
  424. }
  425. break;
  426. case LinePlotType.Candlestick:
  427. flag = this.HasOHLC();
  428. if (flag)
  429. {
  430. this.BuildCandlestickPoints(painter, dateScale, ValScale, aRect, Indicator);
  431. }
  432. else
  433. {
  434. this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator);
  435. }
  436. break;
  437. case LinePlotType.Bar:
  438. this.BuildBarPoints(painter, dateScale, ValScale, aRect, Indicator);
  439. break;
  440. case LinePlotType.Dot:
  441. this.BuildDotPoints(painter, dateScale, ValScale, aRect, Indicator, true);
  442. break;
  443. case LinePlotType.CIRCLEDOT:
  444. this.BuildDotPoints(painter, dateScale, ValScale, aRect, Indicator, false);
  445. break;
  446. case LinePlotType.CROSSDOT:
  447. this.BuildCROSSDOTPoints(painter, dateScale, ValScale, aRect, Indicator);
  448. break;
  449. case LinePlotType.Area:
  450. this.BuildAreaLine(painter, dateScale, ValScale, aRect, Indicator);
  451. this.BuildAreaPolyLine(painter, dateScale, ValScale, aRect, Indicator);
  452. break;
  453. case LinePlotType.FillRGN:
  454. result.AddRange(this.BuildArea(dateScale, ValScale, aRect, Indicator));
  455. break;
  456. //case LinePlotType.HeikenAshi:
  457. // flag = this.LinePlot_4886();
  458. // if (flag)
  459. // {
  460. // this.LinePlot_4892(painter, dateScale, ValScale, aRect,indicatorModel);
  461. // }
  462. // else
  463. // {
  464. // this.LinePlot_4891(painter, dateScale, ValScale, aRect,indicatorModel);
  465. // }
  466. // break;
  467. }
  468. #region 暂时不使用
  469. //flag = (this.Indicator.ParentFormula.IsMain && this.mChart != null &&
  470. // this.mChart.CurrentTimeFrame.TotalDays < 1.0 && (this.Indicator.IsShowYestodayLines));
  471. //if (flag)
  472. //{
  473. // this.BuildYesterdaysCloseLine(painter, dateScale, ValScale, aRect, this.Indicator);
  474. //}
  475. //flag = (this.Indicator.ParentFormula.IsMain && this.mChart != null && this.mChart.CurrentTimeFrame.TotalDays < 1.0 );
  476. //if (flag)
  477. //{
  478. // this.BuildTodaysOpenLine(painter, dateScale, ValScale, aRect, this.Indicator);
  479. //}
  480. #endregion
  481. result.AddRange(painter.GetGraph());
  482. try
  483. {
  484. List<FrameworkElement>.Enumerator enumerator3 = result.GetEnumerator();
  485. while (enumerator3.MoveNext())
  486. {
  487. FrameworkElement current3 = enumerator3.Current;
  488. current3.IsHitTestVisible = (false);
  489. }
  490. }
  491. finally
  492. {
  493. //List<FrameworkElement>.Enumerator enumerator3;
  494. //enumerator3.Dispose();
  495. }
  496. return result;
  497. }
  498. /// <summary>
  499. /// Calculates this instance.
  500. /// </summary>
  501. internal override void Calculate()
  502. {
  503. // bool flag = this.PlotCalculation is IBackGroundAwareCalculation;
  504. // if (flag)
  505. // {
  506. // ((IBackGroundAwareCalculation)this.PlotCalculation).SetCurrentBackground(this._isDark);
  507. // }
  508. // //flag = (this.mCalculation != null && this.mCalculation is PriceHistoryCalculation);
  509. // //if (flag)
  510. // //{
  511. // // ((PriceHistoryCalculation)this.mCalculation).isHeikenAshi = (this.mPlotType == LinePlotType.HeikenAshi);
  512. // //}
  513. // ////线状图设为一单色
  514. // //var cal = this.mCalculation as PriceHistoryCalculation;
  515. // //if (cal != null && this.mChart != null)
  516. // //{
  517. // // cal.ColorMode = this.mChart.LinePlotType == LinePlotType.Line || this.mChart.LinePlotType == LinePlotType.Area ?
  518. // // PriceColorType.OneColor : PriceColorType.CloseUpDown;
  519. // //}
  520. // this.mOutputData.OnDataSetDataChanged(((ILineCalculation)this.PlotCalculation).Calculate(this.mSource, this.CurrentPlotColor()));
  521. }
  522. internal override Color GetColor()
  523. {
  524. return this.CurrentPlotColor();
  525. }
  526. /// <summary>
  527. /// 检测画图面板中的图例,并返回它们在aDate日期下的数据面板
  528. /// </summary>
  529. /// <param name="aDate"></param>
  530. /// <param name="isDarkBackground"></param>
  531. /// <param name="isForex"></param>
  532. /// <returns></returns>
  533. internal override List<ControlPair> GetControlPairs(DateTime aDate, bool isDarkBackground, bool isForex)
  534. {
  535. var digits = isForex ? 4 : 2;
  536. var list = GetControlPairs(aDate, isDarkBackground, digits);
  537. return list;
  538. }
  539. /// <summary>
  540. /// Gets the control pairs.
  541. /// </summary>
  542. /// <param name="aDate">A date.</param>
  543. /// <param name="isDarkBackground">if set to <c>true</c> [is dark background].</param>
  544. /// <param name="digits">The digits.</param>
  545. /// <returns>List{ControlPair}.</returns>
  546. internal override List<ControlPair> GetControlPairs(DateTime aDate, bool isDarkBackground, int digits)
  547. {
  548. var list = new List<ControlPair>();
  549. checked
  550. {
  551. bool flag2 = this.Indicator.ParentFormula.IsMain;
  552. #region 显示当前的主图数据到面板中
  553. if (flag2)
  554. {
  555. if (this.OutputSource == null || this.OutputSource.CalculateDataPoints == null) return list;
  556. var datapoint = this.OutputSource.CalculateDataPoints.FirstOrDefault((point) => DateTime.Compare(point.Date, aDate) == 0);
  557. if (datapoint == null) return list;
  558. var iOHLCDataPoint = (IBarDataPoint)datapoint;
  559. list.Add(
  560. this.BuildQuoteControlPair(
  561. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Open),
  562. iOHLCDataPoint.Open, isDarkBackground, digits, false));
  563. list.Add(
  564. this.BuildQuoteControlPair(
  565. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_High),
  566. iOHLCDataPoint.High, isDarkBackground, digits, false));
  567. list.Add(
  568. this.BuildQuoteControlPair(
  569. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Low), iOHLCDataPoint.Low,
  570. isDarkBackground, digits, false));
  571. list.Add(
  572. this.BuildQuoteControlPair(
  573. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Close),
  574. iOHLCDataPoint.Close, isDarkBackground, digits, false));
  575. var increase = GetIncrease(iOHLCDataPoint);
  576. list.Add(
  577. this.BuildQuoteControlPair(
  578. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Increase),
  579. increase.ToString("P2"), isDarkBackground));
  580. var increaseValue = GetIncreaseValue(iOHLCDataPoint);
  581. list.Add(this.BuildQuoteControlPair(LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_AmountChanges),
  582. increaseValue, isDarkBackground, 2, true));
  583. list.Add(
  584. this.BuildQuoteControlPair(
  585. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_Turnover),
  586. iOHLCDataPoint.Turnover, isDarkBackground, 2, true));
  587. //期货才有持仓量
  588. if (this.mChart != null && this.mChart.CurrentGoods != null &&
  589. mChart.CurrentGoods.GoodsType == GoodsType.Futures)
  590. {
  591. list.Add(
  592. this.BuildQuoteControlPair(
  593. LanguageManager.FindResource(LanguageConst.Indicator_QuoteBoard_HoldVolume),
  594. iOHLCDataPoint.HoldVolume, isDarkBackground, 2, true));
  595. }
  596. }
  597. #endregion
  598. else
  599. {
  600. if (this.Indicator.LinePlotType != LinePlotType.FillRGN && this.Indicator.LinePlotType != LinePlotType.Area)
  601. {
  602. list.AddRange(this.GetPointControlPairs(aDate, digits, true));
  603. }
  604. }
  605. }
  606. return list;
  607. }
  608. /// <summary>
  609. /// Gets the increase.
  610. /// </summary>
  611. /// <param name="dataPoint">The data point.</param>
  612. /// <returns>System.Single.</returns>
  613. private float GetIncrease(IBarDataPoint dataPoint)
  614. {
  615. if (mChart == null || mChart.DataSet == null || mChart.DataSet.DataPoints == null || dataPoint == null) return 0;
  616. var dataPoints = mChart.DataSet.DataPoints;
  617. var item = dataPoints.FirstOrDefault(z => z.Date == dataPoint.Date);
  618. if (item == null) return 0;
  619. var index = dataPoints.IndexOf(item);
  620. if (index == 0)
  621. {
  622. return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open) / dataPoint.Open;
  623. }
  624. else
  625. {
  626. var last = dataPoints[index - 1] as IOHLCDataPoint;
  627. if (last == null || last.Close == 0) return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open) / dataPoint.Open;
  628. return last.Close.Equals(0) ? 0f : (dataPoint.Close - last.Close) / last.Close;
  629. }
  630. return 0;
  631. }
  632. /// <summary>
  633. /// Gets the increase.
  634. /// </summary>
  635. /// <param name="dataPoint">The data point.</param>
  636. /// <returns>System.Single.</returns>
  637. private float GetIncreaseValue(IBarDataPoint dataPoint)
  638. {
  639. if (mChart == null || mChart.DataSet == null || mChart.DataSet.DataPoints == null || dataPoint == null) return 0;
  640. var dataPoints = mChart.DataSet.DataPoints;
  641. var item = dataPoints.FirstOrDefault(z => z.Date == dataPoint.Date);
  642. if (item == null) return 0;
  643. var index = dataPoints.IndexOf(item);
  644. if (index == 0)
  645. {
  646. return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open);
  647. }
  648. else
  649. {
  650. var last = dataPoints[index - 1] as IOHLCDataPoint;
  651. if (last == null || last.Close == 0) return dataPoint.Open.Equals(0) ? 0f : (dataPoint.Close - dataPoint.Open);
  652. return last.Close.Equals(0) ? 0f : (dataPoint.Close - last.Close);
  653. }
  654. return 0;
  655. }
  656. /// <summary>
  657. /// 应用公式计算的值
  658. /// </summary>
  659. /// <returns></returns>
  660. //internal ILineDataSet GetDataSet()
  661. //{
  662. // // return this.mOutputData;
  663. // return this.OutputSource;
  664. //}
  665. internal ILineDataSetWithUid LinePlot_4866()
  666. {
  667. return this.mOutputData;
  668. }
  669. /// <summary>
  670. /// 应用公司计算的值
  671. /// </summary>
  672. /// <returns></returns>
  673. internal IndicatorModel GetDataSet()
  674. {
  675. // return this.mOutputData;
  676. return this.OutputSource;
  677. }
  678. /// <summary>
  679. /// Gets the color of the plot.
  680. /// </summary>
  681. /// <returns>Color.</returns>
  682. internal override Color GetPlotColor()
  683. {
  684. if (this.Indicator != null) return this.Indicator.UpBrush;
  685. return Colors.White;
  686. }
  687. internal override void ShowPlotEdit(FrameworkElement relativeTo)
  688. {
  689. bool flag = this.mChart == null;
  690. if (!flag)
  691. {
  692. //LinePlotEditor linePlotEditor = new LinePlotEditor(this, this.mChart);
  693. //linePlotEditor.Show(relativeTo);
  694. }
  695. }
  696. #endregion Internal Methods
  697. #region Protected Methods
  698. internal Color CurrentPlotColor()
  699. {
  700. return _isDark ? this.mPlotColorDarkBG : this.mPlotColorLightBG;
  701. }
  702. /// <summary>
  703. /// 04月08日
  704. /// </summary>
  705. protected override void DeleteData()
  706. {
  707. //bool flag = this.mOutputData != null;
  708. //if (flag)
  709. //{
  710. // this.mOutputData.OnDelete();
  711. // //this.mOutputData.OnDataSetDataChanged();
  712. //}
  713. }
  714. /// <summary>
  715. /// 添加其他指标数据到面板
  716. /// </summary>
  717. private List<ControlPair> GetPointControlPairs(DateTime aDate, bool isForex, bool allowAbbreviate)
  718. {
  719. var digits = isForex ? 4 : 2;
  720. return GetPointControlPairs(aDate, digits, allowAbbreviate);
  721. }
  722. /// <summary>
  723. /// 添加其他指标数据到面板
  724. /// </summary>
  725. /// <param name="aDate">A date.</param>
  726. /// <param name="digits">The digits.</param>
  727. /// <param name="allowAbbreviate">if set to <c>true</c> [allow abbreviate].</param>
  728. /// <returns>List{ControlPair}.</returns>
  729. private List<ControlPair> GetPointControlPairs(DateTime aDate, int digits, bool allowAbbreviate)
  730. {
  731. var pairList = new List<ControlPair>();
  732. if (this.Indicator == null || this.Indicator.CalculateDataPoints == null) return pairList;
  733. ILineDataPoint dataPoint = null;
  734. if (this.mChart != null && this.mChart.CycleType == CycleType.TimeSharing)
  735. {
  736. dataPoint = this.Indicator.CalculateDataPoints.FirstOrDefault(z => z.Date.Date == aDate.Date && z.Date.Hour == aDate.Hour && z.Date.Minute == aDate.Minute);
  737. }
  738. else
  739. {
  740. dataPoint = this.Indicator.CalculateDataPoints.FirstOrDefault(
  741. (point) => DateTime.Compare(point.Date, aDate) == 0);
  742. }
  743. if (dataPoint == null) return pairList;
  744. if (float.IsNaN(dataPoint.Value)) return pairList;
  745. var leftTextBlock = new TextBlock
  746. {
  747. Text = this.Indicator.LineName,
  748. Foreground = new SolidColorBrush(Indicator.UpBrush),
  749. Padding = new Thickness(10.0, 0.0, 10.0, 0.0),
  750. };
  751. var rightTextBlock = new TextBlock
  752. {
  753. Text = TextFormatting.FormatNumber(dataPoint.Value, digits, allowAbbreviate),
  754. Foreground = leftTextBlock.Foreground,
  755. HorizontalAlignment = HorizontalAlignment.Right,
  756. Padding = new Thickness(5.0, 0.0, 0.0, 0.0)
  757. };
  758. pairList.Add(new ControlPair
  759. {
  760. ControlLeft = leftTextBlock,
  761. ControlRight = rightTextBlock
  762. });
  763. return pairList;
  764. }
  765. protected ControlPair GetPointerPair(string desc, Color descColor, float aVal, bool indent, bool isForex, bool allowAbbreviate)
  766. {
  767. var digits = isForex ? 4 : 2;
  768. return GetPointerPair(desc, descColor, aVal, indent, digits, allowAbbreviate);
  769. }
  770. protected ControlPair GetPointerPair(string desc, Color descColor, float aVal, bool indent, int digits, bool allowAbbreviate)
  771. {
  772. var foreground = new SolidColorBrush(descColor);
  773. var textBlock = new TextBlock
  774. {
  775. Text = desc,
  776. Foreground = (foreground),
  777. Margin = indent ? new Thickness(15.0, 3.0, 0.0, 0.0) : new Thickness(0.0, 3.0, 0.0, 0.0)
  778. };
  779. var textBlock2 = new TextBlock
  780. {
  781. Text = TextFormatting.FormatNumber(aVal, digits, allowAbbreviate),
  782. Foreground = (foreground),
  783. HorizontalAlignment = HorizontalAlignment.Right,
  784. Margin = new Thickness(5.0, 3.0, 0.0, 0.0)
  785. };
  786. return new ControlPair
  787. {
  788. ControlLeft = textBlock,
  789. ControlRight = textBlock2
  790. };
  791. }
  792. #endregion Protected Methods
  793. #region Private Methods
  794. private void BuildAreaLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  795. {
  796. var list = indicatorModel.CalculateDataPoints;
  797. var upbrush = indicatorModel.UpBrush;
  798. bool flag = list != null;
  799. checked
  800. {
  801. if (flag)
  802. {
  803. bool flag2 = this.NotHasColoredDataPoint();
  804. if (flag2)
  805. {
  806. int num = dateScale.FirstVisibleIndexFromData(list);
  807. num--;
  808. num = Math.Max(0, num);
  809. int upper = list.Count;
  810. for (int i = num; i < upper; i++)
  811. {
  812. if (dateScale.DateVisible(list[i].Date))
  813. {
  814. float x = dateScale.XforDate(list[i].Date);
  815. if (!float.IsNaN(list[i].Value))
  816. {
  817. var point = new Point((double)x, (double)valScale.ScaledY(list[i].Value, aRect));
  818. painter.AddPoint(point, upbrush);
  819. }
  820. }
  821. }
  822. }
  823. else
  824. {
  825. int num = dateScale.FirstVisibleIndexFromData(list);
  826. //线从第2个点开始,第1个点忽略.
  827. num = Math.Max(1, num);
  828. var upper = list.Count;
  829. for (int i = num; i < upper; i++)
  830. {
  831. var start = list[i - 1];
  832. var end = list[i];
  833. flag2 = (dateScale.DateVisible(start.Date) || dateScale.DateVisible(end.Date));
  834. if (flag2)
  835. {
  836. float startX = dateScale.XforDate(start.Date);
  837. float endX = dateScale.XforDate(end.Date);
  838. if (!float.IsNaN(startX) && float.IsNaN(endX))
  839. {
  840. var lineGeometry = new LineGeometry()
  841. {
  842. StartPoint =
  843. new Point((double)startX, (double)valScale.ScaledY(start.Value, aRect)),
  844. EndPoint = new Point((double)endX, (double)valScale.ScaledY(end.Value, aRect))
  845. };
  846. painter.AddLine(lineGeometry, upbrush);
  847. }
  848. }
  849. }
  850. }
  851. }
  852. }
  853. }
  854. private void BuildAreaPolyLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect,
  855. IndicatorModel indicatorModel)
  856. {
  857. var list = indicatorModel.CalculateDataPoints;
  858. bool flag = list != null;
  859. checked
  860. {
  861. if (flag)
  862. {
  863. int num = dateScale.FirstVisibleIndexFromData(list);
  864. flag = (num < 0);
  865. if (flag)
  866. {
  867. num = 0;
  868. }
  869. int num2 = (int)Math.Round(unchecked(this.mAreaFillOpacity * 255.0));
  870. flag = (num2 < 0);
  871. if (flag)
  872. {
  873. num2 = 0;
  874. }
  875. flag = (num2 > 255);
  876. if (flag)
  877. {
  878. num2 = 255;
  879. }
  880. var solidBrush = indicatorModel.AreaBrush;
  881. Color aColor = Colors.Transparent;
  882. if (!ColorHelper.IsEmptyColor(solidBrush))
  883. {
  884. aColor = Color.FromArgb((byte)num2, solidBrush.R, solidBrush.G, solidBrush.B);
  885. }
  886. var pathGeometry = new PathGeometry();
  887. var pathFigure = new PathFigure();
  888. pathGeometry.Figures.Add(pathFigure);
  889. var arg_FC_0 = pathFigure;
  890. Point point = new Point(aRect.Left, (double)valScale.ScaledY(0f, aRect));
  891. arg_FC_0.StartPoint = (point);
  892. var polyLineSegment = new PolyLineSegment();
  893. pathFigure.Segments.Add(polyLineSegment);
  894. int arg_124_0 = num;
  895. int num3 = list.Count - 1;
  896. int num4 = arg_124_0;
  897. float num6 = 0f;
  898. while (true)
  899. {
  900. int arg_194_0 = num4;
  901. int num5 = num3;
  902. if (arg_194_0 > num5)
  903. {
  904. break;
  905. }
  906. flag = dateScale.DateVisible(list[num4].Date);
  907. if (flag)
  908. {
  909. num6 = dateScale.XforDate(list[num4].Date);
  910. var arg_17E_0 = polyLineSegment.Points;
  911. point = new Point((double)num6, (double)valScale.ScaledY(list[num4].Value, aRect));
  912. arg_17E_0.Add(point);
  913. }
  914. num4++;
  915. }
  916. var arg_1B7_0 = polyLineSegment.Points;
  917. point = new Point((double)num6, (double)valScale.ScaledY(0f, aRect));
  918. arg_1B7_0.Add(point);
  919. var arg_1E3_0 = polyLineSegment.Points;
  920. point = new Point(aRect.Left, (double)valScale.ScaledY(0f, aRect));
  921. arg_1E3_0.Add(point);
  922. painter.AddShape(pathGeometry, aColor);
  923. }
  924. }
  925. }
  926. private void BuildBarPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale, Rect aRect, IndicatorModel indicatorModel)
  927. {
  928. var list = indicatorModel.CalculateDataPoints;
  929. var width = (float)checked((int)Math.Round((double)dateScale.DistanceBetweenDates()) - 4);
  930. bool flag = width > 10f;
  931. if (flag)
  932. {
  933. width -= 4f;
  934. }
  935. checked
  936. {
  937. var num2 = (int)Math.Round((double)(width / 2f));
  938. flag = (list != null);
  939. if (flag)
  940. {
  941. int startIndex = dateScale.FirstVisibleIndexFromData(list);
  942. int endIndex = list.Count;
  943. for (int i = startIndex; i < endIndex; i++)
  944. {
  945. flag = dateScale.DateVisible(list[i].Date);
  946. if (flag)
  947. {
  948. Color aColor = Colors.White;
  949. if (indicatorModel.VolBar)
  950. {
  951. aColor = this.GetPointColor(list[i]);
  952. }
  953. else
  954. {
  955. var upColorBrush = indicatorModel.UpBrush;
  956. if (!ColorHelper.IsEmptyColor(upColorBrush))
  957. {
  958. aColor = upColorBrush;
  959. }
  960. else
  961. {
  962. indicatorModel.UpBrush = (Colors.White);
  963. }
  964. }
  965. flag = (indicatorModel.PlotNegValsDiffColor && list[i].Value < 0f);
  966. if (flag)
  967. {
  968. var solidColorBrush = indicatorModel.DownBrush;
  969. if (!ColorHelper.IsEmptyColor(solidColorBrush))
  970. {
  971. aColor = solidColorBrush;
  972. }
  973. }
  974. var num7 = (float)((int)Math.Round((double)dateScale.XforDate(list[i].Date)));
  975. flag = (width > 1f);
  976. unchecked
  977. {
  978. if (flag)
  979. {
  980. var rectangleGeometry = new RectangleGeometry();
  981. Rect rect = default(Rect);
  982. double num8 = (double)ValScale.ScaledY(list[i].Value, aRect) - 0.5;
  983. double num9 = (double)ValScale.ScaledY(0f, aRect) - 0.5;
  984. flag = (num8 > num9);
  985. if (flag)
  986. {
  987. double num10 = num8;
  988. num8 = num9;
  989. num9 = num10;
  990. }
  991. rect.X = ((double)(num7 - (float)num2) + 0.5);
  992. rect.Y = (num8);
  993. rect.Width = ((double)width);
  994. rect.Height = (Math.Max(-0.5, num9 - rect.Top));
  995. rectangleGeometry.Rect = (rect);
  996. Painter.AddShape(rectangleGeometry, aColor);
  997. }
  998. else
  999. {
  1000. var lineGeometry = new LineGeometry
  1001. {
  1002. StartPoint = new Point((double)num7 + 0.5, (double)ValScale.ScaledY(list[i].Value, aRect)),
  1003. EndPoint = new Point((double)num7 + 0.5, (double)ValScale.ScaledY(0f, aRect))
  1004. };
  1005. Painter.AddLine(lineGeometry, aColor);
  1006. }
  1007. }
  1008. }
  1009. }
  1010. }
  1011. }
  1012. }
  1013. private void BuildCandlestickPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1014. {
  1015. var list = indicatorModel.CalculateDataPoints;
  1016. if (list == null || !list.Any()) return;
  1017. var num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates())));
  1018. #region 未知作用
  1019. bool upFilled = true;
  1020. bool downFilled = true;
  1021. var fillModel = PriceColorType.BarUpDown;
  1022. //var price = this.PlotCalculation as PriceHistoryCalculation;
  1023. //if (price != null)
  1024. //{
  1025. // upFilled = price.UpFilled;
  1026. // downFilled = price.DownFilled;
  1027. // fillModel = price.FillMode;
  1028. //}
  1029. #endregion
  1030. var start = dateScale.FirstVisibleIndexFromData(list);
  1031. var length = list.Count;
  1032. for (var i = start; i < length; i++)
  1033. {
  1034. var current = list[i];
  1035. var visible = dateScale.DateVisible(current.Date);
  1036. if (!visible) continue;
  1037. var ohlcDataPoint = current as IOHLCDataPoint;
  1038. if (ohlcDataPoint == null) continue;
  1039. var dateX = (float)((int)Math.Round((double)dateScale.XforDate(ohlcDataPoint.Date)));
  1040. var color = this.GetPointColor(ohlcDataPoint);
  1041. var isFill = false;
  1042. var isRising = false;
  1043. var isDeclining = false;
  1044. if (ohlcDataPoint.Close > ohlcDataPoint.Open)
  1045. {
  1046. isRising = true;
  1047. isFill = upFilled;
  1048. }
  1049. else if (ohlcDataPoint.Close < ohlcDataPoint.Open)
  1050. {
  1051. isDeclining = true;
  1052. isFill = downFilled;
  1053. }
  1054. if (i > 0 && fillModel == PriceColorType.CloseUpDown)
  1055. {
  1056. if (ohlcDataPoint.Close > ohlcDataPoint.Value)
  1057. {
  1058. isFill = upFilled;
  1059. }
  1060. else if (ohlcDataPoint.Close < ohlcDataPoint.Value)
  1061. {
  1062. isFill = downFilled;
  1063. }
  1064. }
  1065. var rect = new Rect();
  1066. if (!isRising && !isDeclining)
  1067. {
  1068. //相等画直线
  1069. rect = new Rect(dateX - num + 0.5, 0.5 + valScale.ScaledY(ohlcDataPoint.Open, aRect), 2f * num, 0);
  1070. painter.AddLine(new LineGeometry
  1071. {
  1072. StartPoint = new Point(rect.X - 0.5, rect.Y),
  1073. EndPoint = new Point(rect.Right + 0.5, rect.Y)
  1074. }, color);
  1075. }
  1076. else if (isRising)
  1077. {
  1078. rect = new Rect(dateX - num + 0.5, 0.5 + (double)valScale.ScaledY(ohlcDataPoint.Close, aRect), 2f * num, 0);
  1079. rect.Height = (0.5 + (double)valScale.ScaledY(ohlcDataPoint.Open, aRect) - rect.Top);
  1080. var rectangleGeometry = new RectangleGeometry { Rect = rect };
  1081. if (isFill)
  1082. {
  1083. painter.AddShape(rectangleGeometry, color);
  1084. }
  1085. else
  1086. {
  1087. painter.AddLine(rectangleGeometry, color);
  1088. }
  1089. }
  1090. else
  1091. {
  1092. rect = new Rect(dateX - num + 0.5, 0.5 + (double)valScale.ScaledY(ohlcDataPoint.Open, aRect), 2f * num, 0);
  1093. rect.Height = (0.5 + (double)valScale.ScaledY(ohlcDataPoint.Close, aRect) - rect.Top);
  1094. var rectangleGeometry = new RectangleGeometry { Rect = (rect) };
  1095. if (isFill)
  1096. {
  1097. painter.AddShape(rectangleGeometry, color);
  1098. }
  1099. else
  1100. {
  1101. painter.AddLine(rectangleGeometry, color);
  1102. }
  1103. }
  1104. painter.AddLine(new LineGeometry
  1105. {
  1106. StartPoint = new Point(dateX + 0.5, (double)valScale.ScaledY(ohlcDataPoint.High, aRect)),
  1107. EndPoint = new Point((double)dateX + 0.5, rect.Top)
  1108. }, color);
  1109. painter.AddLine(new LineGeometry
  1110. {
  1111. StartPoint = new Point(dateX + 0.5, (double)valScale.ScaledY(ohlcDataPoint.Low, aRect)),
  1112. EndPoint = new Point(dateX + 0.5, rect.Bottom)
  1113. }, color);
  1114. }
  1115. }
  1116. private void BuildDotPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale,
  1117. Rect aRect, IndicatorModel indicatorModel, bool IsfillPoint)
  1118. {
  1119. var list = indicatorModel.CalculateDataPoints;
  1120. checked
  1121. {
  1122. float num = (float)((int)Math.Round(unchecked(0.35 * (double)dateScale.DistanceBetweenDates())));
  1123. bool flag = num <= 1f;
  1124. if (flag)
  1125. {
  1126. num = 1.01f;
  1127. }
  1128. flag = ((double)num > 3.5);
  1129. if (flag)
  1130. {
  1131. num = 3.5f;
  1132. }
  1133. flag = (list != null);
  1134. if (flag)
  1135. {
  1136. int num2 = dateScale.FirstVisibleIndexFromData(list);
  1137. int arg_90_0 = num2;
  1138. int num3 = list.Count - 1;
  1139. int num4 = arg_90_0;
  1140. while (true)
  1141. {
  1142. int arg_1EA_0 = num4;
  1143. int num5 = num3;
  1144. if (arg_1EA_0 > num5)
  1145. {
  1146. break;
  1147. }
  1148. flag = dateScale.DateVisible(list[num4].Date);
  1149. if (flag)
  1150. {
  1151. // Color aColor = this.GetPointColor(list[num4]);
  1152. Color aColor = Colors.White; // this.GetPointColor(list[num4]);
  1153. var upColorBrush = indicatorModel.UpBrush;
  1154. if (!ColorHelper.IsEmptyColor(upColorBrush))
  1155. {
  1156. aColor = upColorBrush;
  1157. }
  1158. else
  1159. {
  1160. indicatorModel.UpBrush = (Colors.White);
  1161. }
  1162. var scalefloat = dateScale.XforDate(list[num4].Date);
  1163. if (float.IsNaN(scalefloat))
  1164. {
  1165. float num6 = (float)((int)Math.Round((double)scalefloat));
  1166. flag = (num > 1f);
  1167. unchecked
  1168. {
  1169. if (flag)
  1170. {
  1171. EllipseGeometry ellipseGeometry = new EllipseGeometry();
  1172. double num7 = (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5;
  1173. EllipseGeometry arg_123_0 = ellipseGeometry;
  1174. Point point = new Point((double)num6, num7);
  1175. arg_123_0.Center = (point);
  1176. ellipseGeometry.RadiusX = ((double)num);
  1177. ellipseGeometry.RadiusY = ((double)num);
  1178. Painter.AddShape(ellipseGeometry, aColor, IsfillPoint);
  1179. }
  1180. else
  1181. {
  1182. LineGeometry lineGeometry = new LineGeometry();
  1183. Painter.AddLine(lineGeometry, aColor);
  1184. LineGeometry arg_198_0 = lineGeometry;
  1185. Point point = new Point((double)num6 + 0.5,
  1186. (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5);
  1187. arg_198_0.StartPoint = (point);
  1188. LineGeometry arg_1D6_0 = lineGeometry;
  1189. point = new Point((double)num6 + 0.5,
  1190. (double)ValScale.ScaledY(list[num4].Value, aRect) + 0.5);
  1191. arg_1D6_0.EndPoint = (point);
  1192. }
  1193. }
  1194. }
  1195. }
  1196. num4++;
  1197. }
  1198. }
  1199. }
  1200. }
  1201. private void BuildCROSSDOTPoints(PlotPainter Painter, IDateScaler dateScale, IValueScaler ValScale,
  1202. Rect aRect, IndicatorModel indicatorModel)
  1203. {
  1204. var list = indicatorModel.CalculateDataPoints;
  1205. checked
  1206. {
  1207. float num = (float)((int)Math.Round(unchecked(0.35 * (double)dateScale.DistanceBetweenDates())));
  1208. bool flag = num <= 1f;
  1209. if (flag)
  1210. {
  1211. num = 1.01f;
  1212. }
  1213. flag = ((double)num > 3.5);
  1214. if (flag)
  1215. {
  1216. num = 3.5f;
  1217. }
  1218. flag = (list != null);
  1219. if (flag)
  1220. {
  1221. int num2 = dateScale.FirstVisibleIndexFromData(list);
  1222. int arg_90_0 = num2;
  1223. int num3 = list.Count - 1;
  1224. int num4 = arg_90_0;
  1225. while (true)
  1226. {
  1227. int arg_1EA_0 = num4;
  1228. int num5 = num3;
  1229. if (arg_1EA_0 > num5)
  1230. {
  1231. break;
  1232. }
  1233. flag = dateScale.DateVisible(list[num4].Date);
  1234. if (flag)
  1235. {
  1236. Color aColor = Colors.White; // this.GetPointColor(list[num4]);
  1237. var upColorBrush = (indicatorModel.UpBrush);
  1238. if (!ColorHelper.IsEmptyColor(upColorBrush))
  1239. {
  1240. aColor = upColorBrush;
  1241. }
  1242. else
  1243. {
  1244. indicatorModel.UpBrush = (Colors.White);
  1245. }
  1246. var scalefloat = dateScale.XforDate(list[num4].Date);
  1247. if (float.IsNaN(scalefloat))
  1248. {
  1249. float num6 = (float)((int)Math.Round(scalefloat));
  1250. flag = (num > 1f);
  1251. unchecked
  1252. {
  1253. if (flag)
  1254. {
  1255. PathGeometry pathGeometry = new PathGeometry();
  1256. double num7 = (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5;
  1257. LineGeometry line1 = new LineGeometry(new Point(num6 - num, num7 - num),
  1258. new Point(num6 + num, num7 + num));
  1259. LineGeometry line2 = new LineGeometry(new Point(num6 - num, num7 + num),
  1260. new Point(num6 + num, num7 - num));
  1261. pathGeometry.AddGeometry(line1);
  1262. pathGeometry.AddGeometry(line2);
  1263. Painter.AddShape(pathGeometry, aColor);
  1264. }
  1265. else
  1266. {
  1267. LineGeometry lineGeometry = new LineGeometry();
  1268. Painter.AddLine(lineGeometry, aColor);
  1269. LineGeometry arg_198_0 = lineGeometry;
  1270. Point point = new Point((double)num6 + 0.5,
  1271. (double)ValScale.ScaledY(list[num4].Value, aRect) - 0.5);
  1272. arg_198_0.StartPoint = (point);
  1273. LineGeometry arg_1D6_0 = lineGeometry;
  1274. point = new Point((double)num6 + 0.5,
  1275. (double)ValScale.ScaledY(list[num4].Value, aRect) + 0.5);
  1276. arg_1D6_0.EndPoint = (point);
  1277. }
  1278. }
  1279. }
  1280. }
  1281. num4++;
  1282. }
  1283. }
  1284. }
  1285. }
  1286. private void BuildHLCPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1287. {
  1288. var list = indicatorModel.CalculateDataPoints;
  1289. checked
  1290. {
  1291. float num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates())));
  1292. bool flag = list != null;
  1293. if (flag)
  1294. {
  1295. int num2 = dateScale.FirstVisibleIndexFromData(list);
  1296. int arg_60_0 = num2;
  1297. int num3 = list.Count - 1;
  1298. int num4 = arg_60_0;
  1299. while (true)
  1300. {
  1301. int arg_1B5_0 = num4;
  1302. int num5 = num3;
  1303. if (arg_1B5_0 > num5)
  1304. {
  1305. break;
  1306. }
  1307. flag = dateScale.DateVisible(list[num4].Date);
  1308. if (flag)
  1309. {
  1310. Color aColor = this.GetPointColor(list[num4]);
  1311. float num6 = (float)((int)Math.Round((double)dateScale.XforDate(list[num4].Date)));
  1312. IOHLCDataPoint iOHLCDataPoint = (IOHLCDataPoint)list[num4];
  1313. LineGeometry lineGeometry = new LineGeometry();
  1314. painter.AddLine(lineGeometry, aColor);
  1315. LineGeometry arg_F5_0 = lineGeometry;
  1316. unchecked
  1317. {
  1318. Point point = new Point((double)num6 + 0.5, (double)valScale.ScaledY(iOHLCDataPoint.High, aRect));
  1319. arg_F5_0.StartPoint = (point);
  1320. LineGeometry arg_12A_0 = lineGeometry;
  1321. point = new Point((double)num6 + 0.5, (double)(1f + valScale.ScaledY(iOHLCDataPoint.Low, aRect)));
  1322. arg_12A_0.EndPoint = (point);
  1323. lineGeometry = new LineGeometry();
  1324. painter.AddLine(lineGeometry, aColor);
  1325. LineGeometry arg_173_0 = lineGeometry;
  1326. point = new Point((double)(num6 + num + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect));
  1327. arg_173_0.StartPoint = (point);
  1328. LineGeometry arg_1A2_0 = lineGeometry;
  1329. point = new Point((double)num6, 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect));
  1330. arg_1A2_0.EndPoint = (point);
  1331. }
  1332. }
  1333. num4++;
  1334. }
  1335. }
  1336. }
  1337. }
  1338. private void BuildOHLCPoints(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1339. {
  1340. var list = indicatorModel.CalculateDataPoints;
  1341. checked
  1342. {
  1343. float num = (float)((int)Math.Round(unchecked(0.3 * (double)dateScale.DistanceBetweenDates())));
  1344. bool flag = list != null;
  1345. if (flag)
  1346. {
  1347. int num2 = dateScale.FirstVisibleIndexFromData(list);
  1348. int num3 = list.Count - 1;
  1349. while (true)
  1350. {
  1351. if (num2 > num3)
  1352. {
  1353. break;
  1354. }
  1355. flag = dateScale.DateVisible(list[num2].Date);
  1356. if (flag)
  1357. {
  1358. Color aColor = this.GetPointColor(list[num2]);
  1359. float num6 = (float)((int)Math.Round((double)dateScale.XforDate(list[num2].Date)));
  1360. var iOHLCDataPoint = (IOHLCDataPoint)list[num2];
  1361. var lineGeometry = new LineGeometry();
  1362. painter.AddLine(lineGeometry, this.GetPointColor(list[num2]));
  1363. unchecked
  1364. {
  1365. Point point =
  1366. lineGeometry.StartPoint = new Point((double)num6 + 0.5, (double)valScale.ScaledY(iOHLCDataPoint.High, aRect));
  1367. lineGeometry.EndPoint = new Point((double)num6 + 0.5, (double)(1f + valScale.ScaledY(iOHLCDataPoint.Low, aRect)));
  1368. lineGeometry = new LineGeometry();
  1369. painter.AddLine(lineGeometry, aColor);
  1370. lineGeometry.StartPoint = new Point((double)(num6 - num), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Open, aRect));
  1371. lineGeometry.EndPoint = new Point((double)(num6 + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Open, aRect));
  1372. lineGeometry = new LineGeometry();
  1373. painter.AddLine(lineGeometry, aColor);
  1374. lineGeometry.StartPoint = new Point((double)(num6 + num + 1f), 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect));
  1375. lineGeometry.EndPoint = new Point((double)num6, 0.5 + (double)valScale.ScaledY(iOHLCDataPoint.Close, aRect));
  1376. }
  1377. }
  1378. num2++;
  1379. }
  1380. }
  1381. }
  1382. }
  1383. /// <summary>
  1384. /// 返回光标处的弹出菜单元素
  1385. /// </summary>
  1386. /// <param name="desc">The desc.</param>
  1387. /// <param name="aVal">A value.</param>
  1388. /// <param name="isDarkBackground">if set to <c>true</c> [is dark background].</param>
  1389. /// <param name="digits">The digits.</param>
  1390. /// <param name="allowAbbreviate">if set to <c>true</c> [allow abbreviate].</param>
  1391. /// <returns>ControlPair.</returns>
  1392. private ControlPair BuildQuoteControlPair(string desc, float aVal, bool isDarkBackground, int digits, bool allowAbbreviate)
  1393. {
  1394. var foreground = isDarkBackground ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
  1395. var leftTextBlock = new TextBlock
  1396. {
  1397. Text = desc,
  1398. Foreground = foreground,
  1399. Padding = new Thickness(10.0, 0.0, 10.0, 0.0),
  1400. };
  1401. var rightTextBlock = new TextBlock
  1402. {
  1403. Text = TextFormatting.FormatNumber(aVal, digits, allowAbbreviate),
  1404. Foreground = foreground,
  1405. HorizontalAlignment = HorizontalAlignment.Right,
  1406. Padding = new Thickness(5.0, 0.0, 0.0, 0.0)
  1407. };
  1408. return new ControlPair
  1409. {
  1410. ControlLeft = leftTextBlock,
  1411. ControlRight = rightTextBlock
  1412. };
  1413. }
  1414. /// <summary>
  1415. /// Builds the quote control pair.
  1416. /// </summary>
  1417. /// <param name="desc">The desc.</param>
  1418. /// <param name="valueString">The value string.</param>
  1419. /// <param name="isDarkBackground">if set to <c>true</c> [is dark background].</param>
  1420. /// <returns>ControlPair.</returns>
  1421. private ControlPair BuildQuoteControlPair(string desc, string valueString, bool isDarkBackground)
  1422. {
  1423. var foreground = isDarkBackground ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
  1424. var leftTextBlock = new TextBlock
  1425. {
  1426. Text = desc,
  1427. Foreground = foreground,
  1428. Padding = new Thickness(10.0, 0.0, 10.0, 0.0),
  1429. };
  1430. var rightTextBlock = new TextBlock
  1431. {
  1432. Text = valueString,
  1433. Foreground = foreground,
  1434. HorizontalAlignment = HorizontalAlignment.Right,
  1435. Padding = new Thickness(5.0, 0.0, 0.0, 0.0)
  1436. };
  1437. return new ControlPair
  1438. {
  1439. ControlLeft = leftTextBlock,
  1440. ControlRight = rightTextBlock
  1441. };
  1442. }
  1443. /// <summary>
  1444. /// 创建区域图
  1445. /// </summary>
  1446. /// <param name="dateScale"></param>
  1447. /// <param name="valScale"></param>
  1448. /// <param name="aRect"></param>
  1449. /// <returns></returns>
  1450. private List<FrameworkElement> BuildArea(IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1451. {
  1452. var list = new List<FrameworkElement>();
  1453. var path = new Path();
  1454. var rectangleGeometry = new RectangleGeometry();
  1455. rectangleGeometry.Rect = (aRect);
  1456. path.Clip = (rectangleGeometry);
  1457. path.UseLayoutRounding = (true);
  1458. var solidColorBrush = new SolidColorBrush((this.Indicator.AreaBrush));
  1459. solidColorBrush.Opacity = ((double)this.Indicator.Alpha / 256);
  1460. path.StrokeThickness = indicatorModel.LineWidth < 1 ? 1 : indicatorModel.LineWidth;
  1461. path.Fill = (solidColorBrush);
  1462. var pathGeometry = new PathGeometry();
  1463. path.Data = (pathGeometry);
  1464. var pathFigure = new PathFigure();
  1465. pathGeometry.Figures.Add(pathFigure);
  1466. var list2 = indicatorModel.SubData[indicatorModel.FillRNGKey] as List<ILineDataPoint>;
  1467. var doubleCond = indicatorModel.SubData[indicatorModel.CondKey] as double[];
  1468. bool flag = false;
  1469. bool flag2 = list2 != null && doubleCond != null;
  1470. checked
  1471. {
  1472. bool flag3;
  1473. if (flag2)
  1474. {
  1475. int num = list2.Count - 1;
  1476. int num2 = 0;
  1477. while (true)
  1478. {
  1479. int arg_1BF_0 = num2;
  1480. int num3 = num;
  1481. if (arg_1BF_0 > num3)
  1482. {
  1483. break;
  1484. }
  1485. bool arg_125_0 = (dateScale.DateVisible(list2[num2].Date)
  1486. || (num2 < list2.Count - 1 && dateScale.DateVisible(list2[num2 + 1].Date))) ||
  1487. (num2 > 0 && dateScale.DateVisible(list2[num2 - 1].Date));
  1488. flag3 = arg_125_0 && Convert.ToBoolean(doubleCond[num2]);
  1489. if (flag3)
  1490. {
  1491. float num4 = valScale.ScaledY(list2[num2].Value, aRect);
  1492. float num5 = dateScale.XforDate(list2[num2].Date);
  1493. flag3 = !flag;
  1494. if (flag3)
  1495. {
  1496. var arg_175_0 = pathFigure;
  1497. Point startPoint = new Point((double)num5, (double)num4);
  1498. arg_175_0.StartPoint = (startPoint);
  1499. flag = true;
  1500. }
  1501. else
  1502. {
  1503. var lineSegment = new LineSegment();
  1504. var arg_19A_0 = lineSegment;
  1505. Point startPoint = new Point((double)num5, (double)num4);
  1506. arg_19A_0.Point = (startPoint);
  1507. pathFigure.Segments.Add(lineSegment);
  1508. }
  1509. }
  1510. num2++;
  1511. }
  1512. }
  1513. list2 = this.Indicator.CalculateDataPoints;
  1514. flag3 = (list2 != null) && doubleCond != null; ;
  1515. if (flag3)
  1516. {
  1517. int num6 = list2.Count - 1;
  1518. while (true)
  1519. {
  1520. int arg_2E3_0 = num6;
  1521. int num3 = 0;
  1522. if (arg_2E3_0 < num3)
  1523. {
  1524. break;
  1525. }
  1526. bool arg_24A_0 = (dateScale.DateVisible(list2[num6].Date)
  1527. || (num6 < list2.Count - 1 && dateScale.DateVisible(list2[num6 + 1].Date))) ||
  1528. (num6 > 0 && dateScale.DateVisible(list2[num6 - 1].Date));
  1529. flag2 = arg_24A_0 && Convert.ToBoolean(doubleCond[num6]); ;
  1530. if (flag2)
  1531. {
  1532. float num7 = valScale.ScaledY(list2[num6].Value, aRect);
  1533. float num8 = dateScale.XforDate(list2[num6].Date);
  1534. flag3 = !flag;
  1535. if (flag3)
  1536. {
  1537. PathFigure arg_29A_0 = pathFigure;
  1538. Point startPoint = new Point((double)num8, (double)num7);
  1539. arg_29A_0.StartPoint = (startPoint);
  1540. flag = true;
  1541. }
  1542. else
  1543. {
  1544. LineSegment lineSegment = new LineSegment();
  1545. LineSegment arg_2BF_0 = lineSegment;
  1546. Point startPoint = new Point((double)num8, (double)num7);
  1547. arg_2BF_0.Point = (startPoint);
  1548. pathFigure.Segments.Add(lineSegment);
  1549. }
  1550. }
  1551. num6 += -1;
  1552. }
  1553. }
  1554. flag3 = flag;
  1555. if (flag3)
  1556. {
  1557. LineSegment lineSegment = new LineSegment();
  1558. LineSegment arg_322_0 = lineSegment;
  1559. Point startPoint = pathFigure.StartPoint;
  1560. Point point = new Point(startPoint.X, pathFigure.StartPoint.Y);
  1561. arg_322_0.Point = (point);
  1562. pathFigure.Segments.Add(lineSegment);
  1563. }
  1564. list.Add(path);
  1565. return list;
  1566. }
  1567. }
  1568. #region 暂时未用到
  1569. private void BuildTodaysOpenLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1570. {
  1571. var list = indicatorModel.CalculateDataPoints;
  1572. bool flag = list != null && list.Count > 1;
  1573. checked
  1574. {
  1575. if (flag)
  1576. {
  1577. DateTime aDate = list[list.Count - 1].Date;
  1578. int num = list.Count - 1;
  1579. while (true)
  1580. {
  1581. if (num < 0)
  1582. {
  1583. return;
  1584. }
  1585. flag = (DateTime.Compare(list[num].Date.Date, aDate.Date) < 0);
  1586. if (flag)
  1587. {
  1588. break;
  1589. }
  1590. num += -1;
  1591. }
  1592. bool flag2 = num < list.Count - 1;
  1593. if (flag2)
  1594. {
  1595. float num3 = dateScale.XforDate(list[num + 1].Date);
  1596. float num4 = dateScale.XforDate(aDate);
  1597. var lineGeometry = new LineGeometry();
  1598. float aVal = list[num + 1].Value;
  1599. flag2 = (list[num + 1] is IOHLCDataPoint);
  1600. if (flag2)
  1601. {
  1602. aVal = ((IOHLCDataPoint)list[num + 1]).Open;
  1603. }
  1604. painter.AddLine(lineGeometry, c_TodayOpenColor);
  1605. unchecked
  1606. {
  1607. lineGeometry.StartPoint = new Point((double)num4, 0.5 + (double)valScale.ScaledY(aVal, aRect));
  1608. lineGeometry.EndPoint = new Point((double)num3, 0.5 + (double)valScale.ScaledY(aVal, aRect));
  1609. }
  1610. }
  1611. }
  1612. }
  1613. }
  1614. private void BuildYesterdaysCloseLine(PlotPainter painter, IDateScaler dateScale, IValueScaler valScale, Rect aRect, IndicatorModel indicatorModel)
  1615. {
  1616. var list = indicatorModel.CalculateDataPoints;
  1617. bool flag = list != null && list.Count > 1;
  1618. if (flag)
  1619. {
  1620. int num;
  1621. float num3;
  1622. float num4;
  1623. LineGeometry lineGeometry;
  1624. LineGeometry arg_F7_0;
  1625. checked
  1626. {
  1627. DateTime aDate = list[list.Count - 1].Date;
  1628. num = list.Count - 1;
  1629. while (true)
  1630. {
  1631. int arg_13F_0 = num;
  1632. int num2 = 0;
  1633. if (arg_13F_0 < num2)
  1634. {
  1635. return;
  1636. }
  1637. flag = (DateTime.Compare(list[num].Date.Date, aDate.Date) < 0);
  1638. if (flag)
  1639. {
  1640. break;
  1641. }
  1642. num += -1;
  1643. }
  1644. num3 = dateScale.XforDate(list[num].Date);
  1645. num4 = dateScale.XforDate(aDate);
  1646. lineGeometry = new LineGeometry();
  1647. painter.AddLine(lineGeometry, c_YestodayColor);
  1648. arg_F7_0 = lineGeometry;
  1649. }
  1650. Point point = new Point((double)num4, 0.5 + (double)valScale.ScaledY(list[num].Value, aRect));
  1651. arg_F7_0.StartPoint = (point);
  1652. LineGeometry arg_12A_0 = lineGeometry;
  1653. point = new Point((double)num3, 0.5 + (double)valScale.ScaledY(list[num].Value, aRect));
  1654. arg_12A_0.EndPoint = (point);
  1655. }
  1656. }
  1657. #endregion
  1658. private Color GetPointColor(ILineDataPoint aPoint)
  1659. {
  1660. bool flag = aPoint is IColoredDataPoint;
  1661. Color result;
  1662. if (flag)
  1663. {
  1664. result = ((IColoredDataPoint)aPoint).Color;
  1665. }
  1666. else
  1667. {
  1668. result = this.CurrentPlotColor();
  1669. }
  1670. return result;
  1671. }
  1672. private bool HasOHLC()
  1673. {
  1674. //bool flag = this.mOutputData == null || this.mOutputData.DataPoints == null;
  1675. //checked
  1676. //{
  1677. // if (!flag)
  1678. // {
  1679. // var list = this.mOutputData.DataPoints;
  1680. // int num = list.Count - 1;
  1681. // int num2 = 0;
  1682. // while (true)
  1683. // {
  1684. // int num3 = num;
  1685. // if (num2 > num3)
  1686. // {
  1687. // return false;
  1688. // }
  1689. // flag = (list[num2] is IOHLCDataPoint);
  1690. // if (flag)
  1691. // {
  1692. // break;
  1693. // }
  1694. // num2++;
  1695. // }
  1696. // return true;
  1697. // }
  1698. // return false;
  1699. //}
  1700. return true;
  1701. }
  1702. private bool NotHasColoredDataPoint()
  1703. {
  1704. //if (this.mOutputData == null || this.mOutputData.DataPoints == null) return true;
  1705. //return !this.mOutputData.DataPoints.OfType<IColoredDataPoint>().Any();
  1706. return true;
  1707. }
  1708. private void OnPlotStyleChanged()
  1709. {
  1710. if (PlotStyleChanged != null)
  1711. {
  1712. PlotStyleChanged();
  1713. }
  1714. }
  1715. #endregion Private Methods
  1716. #endregion Methods
  1717. #region Other
  1718. //public override XElement ToXML(List<object> args)
  1719. //{
  1720. // XElement xElement = new XElement(this.RootName());
  1721. // xElement.Add(new XAttribute("PlotColor", this.mPlotColorDarkBG.ToString()));
  1722. // xElement.Add(new XAttribute("PlotColorL", this.mPlotColorLightBG.ToString()));
  1723. // bool flag = this.mPlotNegValsDiffColor;
  1724. // if (flag)
  1725. // {
  1726. // xElement.Add(new XAttribute("PlotNegValsDiffColor", true.ToString()));
  1727. // }
  1728. // xElement.Add(new XAttribute("NegPlotColor", this.mPlotNegColorDarkBG.ToString()));
  1729. // xElement.Add(new XAttribute("NegPlotColorL", this.mPlotNegColorLightBG.ToString()));
  1730. // xElement.Add(new XAttribute("AreaColor", this.mAreaFillColorDarkBG.ToString()));
  1731. // xElement.Add(new XAttribute("AreaColorL", this.mAreaFillColorLightBG.ToString()));
  1732. // xElement.Add(new XAttribute("PlotStyle", this.mPlotStyle.ToString()));
  1733. // xElement.Add(new XAttribute("Thickness", this.LinePlot_1593.ToString()));
  1734. // xElement.Add(new XAttribute("DashPattern", this.LinePlot_1591.ToString()));
  1735. // xElement.Add(new XAttribute("OutputDataGUID", this.mOutputData.DataGUID.ToString()));
  1736. // flag = (this.mSource != null && (args == null || !args.Contains("NOSAVEINDSOURCE")));
  1737. // if (flag)
  1738. // {
  1739. // xElement.Add(new XAttribute("SourceID", this.mSource.UID()));
  1740. // }
  1741. // xElement.Add(this.mCalculation.ToXML(args));
  1742. // base.AddToXML(xElement, args);
  1743. // return xElement;
  1744. //}
  1745. #endregion Other
  1746. }
  1747. }