ValueScaleDisplay.cs 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  1. using Microsoft.VisualBasic;
  2. using Microsoft.VisualBasic.CompilerServices;
  3. using MuchInfo.Chart.Data.EnumTypes;
  4. using MuchInfo.Chart.Infrastructure.Helpers;
  5. using MuchInfo.Chart.WPF.Controls.ValueScaling;
  6. using MuchInfo.Chart.WPF.Helpers;
  7. using MuchInfo.Chart.WPF.Primitives.Interfaces;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Media;
  14. using System.Windows.Shapes;
  15. namespace MuchInfo.Chart.WPF.Primitives
  16. {
  17. public class ValueScaleDisplay : Canvas
  18. {
  19. #region Fields
  20. //private const int c_TimeSpaning = 3; //设置分时图显示网络是图表字体的多少倍,控制网格数量
  21. private const int c_TimeSpaningGridCount = 8; //设置显示分时图显示图表风格数量
  22. protected ValueScaleDisplay.ValueScaleMode mArithScaleMode;
  23. protected Color mBorderColor;
  24. protected List<float> mDivisors;
  25. protected bool mDrawGridLines;
  26. protected ValueScaleDisplay.ValueScaleMode mExpScaleMode;
  27. private Brush _upBrush = Brushes.Red;
  28. /// <summary>
  29. /// 设置涨时的图表的颜色
  30. /// </summary>
  31. public Brush UpBrush
  32. {
  33. get { return _upBrush; }
  34. set { _upBrush = value; }
  35. }
  36. private Brush _downBrush = Brushes.SeaGreen;
  37. /// <summary>
  38. /// 设置下跌里图表的颜色
  39. /// </summary>
  40. public Brush DownBrush
  41. {
  42. get { return _downBrush; }
  43. set { _downBrush = value; }
  44. }
  45. private Brush _lastBrush = Brushes.White;
  46. public Brush LastBrush
  47. {
  48. get { return _lastBrush; }
  49. set { _lastBrush = value; }
  50. }
  51. /// <summary>
  52. /// 小数位数
  53. /// </summary>
  54. protected int mFormatSigDigits;
  55. protected int mLineOpacity;
  56. protected DoubleCollection mLineStyle;
  57. protected ValueScaleDisplay.ValueScaleMode mLogScaleMode;
  58. protected Color mPercentColor;
  59. protected bool mShowScaleControls;
  60. protected bool mTextAlignLeft;
  61. protected ValueScaleDisplay.LRPlacement mTextPos;
  62. protected float _curNet;
  63. protected float _curPercent;
  64. protected float _divisor;
  65. protected float _fixedPercent;
  66. protected int _lineCount;
  67. private bool _allowAbbreviate;
  68. private ValueScaleBufferAdjuster _bottomAdjuster;
  69. private Chart _chart;
  70. private ChartPane _chartPane;
  71. private bool _flag2;
  72. private bool _flag3;
  73. private Color _lineColor;
  74. private Rect _rect;
  75. private ScaleLayer _scalelayer;
  76. private ValueScaleBufferAdjuster _topAdjuster;
  77. /// <summary>
  78. /// Y轴面板
  79. /// </summary>
  80. private Canvas _yCanvas;
  81. private List<ValueScaleDisplay.ValueScaleDisplay_Y> _yList;
  82. private float _yValue;
  83. #endregion Fields
  84. #region Constructors
  85. public ValueScaleDisplay(IValueScaler valueScaler)
  86. {
  87. base.SizeChanged -= (new SizeChangedEventHandler(this.ValueScaleDisplay_SizeChanged));
  88. base.SizeChanged += (new SizeChangedEventHandler(this.ValueScaleDisplay_SizeChanged));
  89. this._scalelayer = null;
  90. this._lineCount = 5;
  91. this._divisor = 1f;
  92. this._fixedPercent = 1f;
  93. this.mFormatSigDigits = 2;
  94. this.mArithScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
  95. this.mLogScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
  96. this.mExpScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
  97. this.mTextPos = ValueScaleDisplay.LRPlacement.Right;
  98. this._lineColor = Colors.LightGray;
  99. this.mBorderColor = Colors.LightGray;
  100. this.mPercentColor = Colors.Red;
  101. this.mDrawGridLines = true;
  102. this.mTextAlignLeft = true;
  103. this.mShowScaleControls = false;
  104. this.mLineStyle = new DoubleCollection();
  105. this.mLineOpacity = 10;
  106. this.mDivisors = new List<float>();
  107. this._flag2 = false;
  108. this._yValue = 0f;
  109. this._flag3 = false;
  110. this._allowAbbreviate = false;
  111. this.InitializeDivisors();
  112. this._topAdjuster = new ValueScaleBufferAdjuster();
  113. this._bottomAdjuster = new ValueScaleBufferAdjuster();
  114. this._yCanvas = new Canvas();
  115. this.Children.Add(this._yCanvas);
  116. this.CurrentValueScaler = valueScaler;
  117. }
  118. #endregion Constructors
  119. #region Enumerations
  120. public enum LRPlacement
  121. {
  122. Right,
  123. Left,
  124. None
  125. }
  126. public enum ValueScaleMode
  127. {
  128. Auto,
  129. Manual,
  130. LineCount,
  131. MaxLines,
  132. AutoPercent
  133. }
  134. public enum ValueScalePaintMode
  135. {
  136. AutoScale,
  137. AutoDivisor,
  138. AutoPercentScale,
  139. Divisor,
  140. FixedPercent,
  141. LineCount,
  142. }
  143. #endregion Enumerations
  144. #region Properties
  145. #region Public Properties
  146. public Color BorderColor
  147. {
  148. get
  149. {
  150. return this.mBorderColor;
  151. }
  152. set
  153. {
  154. this.mBorderColor = value;
  155. this.RefreshChart();
  156. }
  157. }
  158. public float Divisor
  159. {
  160. get
  161. {
  162. return this._divisor;
  163. }
  164. set
  165. {
  166. bool flag = this._divisor != value;
  167. if (flag)
  168. {
  169. this._divisor = value;
  170. this.RefreshChart();
  171. }
  172. }
  173. }
  174. public bool DrawGridLines
  175. {
  176. get
  177. {
  178. return this.mDrawGridLines;
  179. }
  180. set
  181. {
  182. this.mDrawGridLines = value;
  183. this.RefreshChart();
  184. }
  185. }
  186. public float FixedPercent
  187. {
  188. get
  189. {
  190. return this._fixedPercent;
  191. }
  192. set
  193. {
  194. bool flag = this._fixedPercent != value;
  195. if (flag)
  196. {
  197. this._fixedPercent = value;
  198. this.RefreshChart();
  199. }
  200. }
  201. }
  202. /// <summary>
  203. /// 小数位数
  204. /// </summary>
  205. public int FormatSignificantDigits
  206. {
  207. get
  208. {
  209. return this.mFormatSigDigits;
  210. }
  211. set
  212. {
  213. this.mFormatSigDigits = value;
  214. }
  215. }
  216. public DoubleCollection GridLineStyle
  217. {
  218. get
  219. {
  220. return this.mLineStyle;
  221. }
  222. set
  223. {
  224. this.mLineStyle = value;
  225. this.RefreshChart();
  226. }
  227. }
  228. public Color LineColor
  229. {
  230. get
  231. {
  232. return this._lineColor;
  233. }
  234. set
  235. {
  236. this._lineColor = value;
  237. this.RefreshChart();
  238. }
  239. }
  240. public int LineCount
  241. {
  242. get
  243. {
  244. return this._lineCount;
  245. }
  246. set
  247. {
  248. bool flag = this._lineCount != value;
  249. if (flag)
  250. {
  251. this._lineCount = value;
  252. this.RefreshChart();
  253. }
  254. }
  255. }
  256. public Color PercentColor
  257. {
  258. get
  259. {
  260. return this.mPercentColor;
  261. }
  262. set
  263. {
  264. this.mPercentColor = value;
  265. this.RefreshChart();
  266. }
  267. }
  268. public ScaleLayer ScaleLayer
  269. {
  270. get
  271. {
  272. return this._scalelayer;
  273. }
  274. set
  275. {
  276. this._scalelayer = value;
  277. }
  278. }
  279. public ValueScaleDisplay.ValueScaleMode ScaleMode
  280. {
  281. get
  282. {
  283. bool flag = CurrentValueScaler is ValueScalerArithmetic;
  284. ValueScaleDisplay.ValueScaleMode result;
  285. if (flag)
  286. {
  287. result = this.mArithScaleMode;
  288. }
  289. else
  290. {
  291. result = ValueScaleDisplay.ValueScaleMode.Auto;
  292. }
  293. return result;
  294. }
  295. set
  296. {
  297. bool flag = CurrentValueScaler is ValueScalerArithmetic;
  298. if (flag)
  299. {
  300. this.mArithScaleMode = value;
  301. }
  302. this.RefreshChart();
  303. }
  304. }
  305. public bool ShowScaleControls
  306. {
  307. get
  308. {
  309. return this.mShowScaleControls;
  310. }
  311. set
  312. {
  313. this.mShowScaleControls = value;
  314. this.RefreshChart();
  315. }
  316. }
  317. public bool TextAlignLeft
  318. {
  319. get
  320. {
  321. return this.mTextAlignLeft;
  322. }
  323. set
  324. {
  325. this.mTextAlignLeft = value;
  326. this.RefreshChart();
  327. }
  328. }
  329. public ValueScaleDisplay.LRPlacement ValueOrientation
  330. {
  331. get
  332. {
  333. return this.mTextPos;
  334. }
  335. set
  336. {
  337. this.mTextPos = value;
  338. this.RefreshChart();
  339. }
  340. }
  341. #endregion Public Properties
  342. #region Internal Properties
  343. internal IValueScaler CurrentValueScaler
  344. {
  345. get;
  346. set;
  347. }
  348. #endregion Internal Properties
  349. #region Private Properties
  350. private ValueScaleDisplay.ValueScalePaintMode TextMode
  351. {
  352. get
  353. {
  354. bool flag = CurrentValueScaler is ValueScalerArithmetic;
  355. var result = new ValueScalePaintMode();
  356. if (flag)
  357. {
  358. switch (this.mArithScaleMode)
  359. {
  360. case ValueScaleDisplay.ValueScaleMode.Auto:
  361. result = ValueScaleDisplay.ValueScalePaintMode.AutoDivisor;
  362. break;
  363. case ValueScaleDisplay.ValueScaleMode.Manual:
  364. result = ValueScaleDisplay.ValueScalePaintMode.Divisor;
  365. break;
  366. case ValueScaleDisplay.ValueScaleMode.LineCount:
  367. result = ValueScaleDisplay.ValueScalePaintMode.LineCount;
  368. break;
  369. case ValueScaleDisplay.ValueScaleMode.MaxLines:
  370. result = ValueScaleDisplay.ValueScalePaintMode.AutoScale;
  371. break;
  372. }
  373. }
  374. return result;
  375. }
  376. }
  377. #endregion Private Properties
  378. #endregion Properties
  379. #region Methods
  380. #region Internal Methods
  381. internal void BuildYList(ChartPane aPane, Rect theRect)
  382. {
  383. this._chartPane = aPane;
  384. bool flag = aPane == null;
  385. if (!flag)
  386. {
  387. var aRect = new Rect(theRect.X, theRect.Y + aPane.GetActualHeight(), theRect.Width, theRect.Height);
  388. this._rect = theRect;
  389. flag = this.CurrentValueScaler.Spread().Equals(0f);
  390. if (flag)
  391. {
  392. this._yCanvas.Children.Clear();
  393. }
  394. else
  395. {
  396. Color color = Colors.White;
  397. flag = (this._scalelayer != null && this._scalelayer.AllPlots.Count > 0);
  398. if (flag)
  399. {
  400. color = this._scalelayer.AllPlots[0].GetPlotColor();
  401. }
  402. this._allowAbbreviate = true;
  403. // if (aPane.IsPriceHistory) this._allowAbbreviate = false;
  404. if (aPane.IsPriceHistory) this._allowAbbreviate = false;
  405. var height = (float)this.ActualHeight;
  406. var list = new List<UIElement>();
  407. var list2 = this._yList ?? this.GetYList(height, CurrentValueScaler, aPane.IsTimeSpaning);
  408. var fontFamily = new FontFamily("Verdana");
  409. var foreground = new SolidColorBrush(color);
  410. if (list2 != null && list2.Any())
  411. {
  412. if (!aPane.IsTimeSpaning)
  413. {
  414. foreach (var current in list2)
  415. {
  416. if (!current.Value.Equals(float.NaN))
  417. {
  418. float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
  419. var textBlock = new TextBlock
  420. {
  421. Text = current.Text,
  422. FontSize = ((double)this.FontSize()),
  423. FontFamily = (fontFamily),
  424. Foreground = (foreground),
  425. //Width = this.FontSize()*current.Text.Length*0.7
  426. //固定长度,否则绘图区大小写会变动
  427. Width = this.FontSize() * 7 * 0.7
  428. };
  429. //根据字符长度计算控件宽度
  430. textBlock.SetValue(Canvas.LeftProperty, 3.0);
  431. textBlock.SetValue(Canvas.TopProperty, (double)num - (double)this.FontSize() * 0.6);
  432. list.Add(textBlock);
  433. }
  434. }
  435. }
  436. else //设置分时图刻度颜色
  437. {
  438. foreach (var current in list2)
  439. {
  440. if (!current.Value.Equals(float.NaN))
  441. {
  442. float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
  443. var textBlock = new TextBlock
  444. {
  445. Text = current.Text,
  446. FontSize = ((double)this.FontSize()),
  447. FontFamily = (fontFamily),
  448. Width = TreeHelper.GetTextWidth(fontFamily, this.FontSize(), current.Text) //this.FontSize()*current.Text.Length*0.7
  449. };
  450. float valueNum = CurrentValueScaler.ValueFromPercent(current.Value);
  451. if (CurrentValueScaler.GetPercentBaseline() > valueNum) //设置红涨绿跌
  452. {
  453. textBlock.Foreground = this.DownBrush;
  454. }
  455. else if (CurrentValueScaler.GetPercentBaseline() < valueNum)
  456. {
  457. textBlock.Foreground = this.UpBrush;
  458. }
  459. else
  460. {
  461. textBlock.Foreground = LastBrush;
  462. }
  463. //根据字符长度计算控件宽度
  464. textBlock.SetValue(Canvas.LeftProperty, 3.0);
  465. textBlock.SetValue(Canvas.TopProperty, (double)num - (double)this.FontSize() * 0.6);
  466. list.Add(textBlock);
  467. }
  468. }
  469. }
  470. }
  471. this._flag3 = false;
  472. var flag2 = (this._scalelayer != null && this._scalelayer.AllPlots.Count > 0);
  473. //不添加默认数据显示
  474. //if (flag2)
  475. //{
  476. // PlotBase plotBase = this._scalelayer.AllPlots()[0];
  477. // flag2 = (plotBase is LinePlot);
  478. // if (flag2)
  479. // {
  480. // var linePlot = (LinePlot)plotBase;
  481. // flag2 = (linePlot.GetDataSet() != null && linePlot.GetDataSet().DataPoints != null && linePlot.GetDataSet().DataPoints.Count > 0);
  482. // if (flag2)
  483. // {
  484. // float num2 = linePlot.GetDataSet().DataPoints[linePlot.GetDataSet().DataPoints.Count - 1].Value;
  485. // float valY = CurrentValueScaler.ScaledY(num2, aRect);
  486. // //超出范围不添加
  487. // if (valY > 0 && valY < aRect.Height) list.Add(this.BuildDisplayBorder(valY, num2));
  488. // }
  489. // }
  490. //}
  491. this._flag3 = this.IsPChangeFromBeginning();
  492. if (_flag2)
  493. {
  494. float txtVal = CurrentValueScaler.ValueFromPercentDisplay((float)((aRect.Bottom - (double)this._yValue) / aRect.Height));
  495. list.Add(this.BuildDisplayBorder(this._yValue, txtVal));
  496. }
  497. this._yCanvas.Children.Clear();
  498. if (list.Any())
  499. {
  500. foreach (var current in list)
  501. {
  502. this._yCanvas.Children.Add(current);
  503. }
  504. }
  505. //计算rightcontrol 宽度
  506. double width = 0;
  507. if (_yCanvas.Children != null && _yCanvas.Children.Count > 0)
  508. {
  509. var textBlocks = _yCanvas.Children.OfType<TextBlock>().Where(z => !z.Width.Equals(0));
  510. var enumerable = textBlocks as IList<TextBlock> ?? textBlocks.ToList();
  511. if (enumerable.Any())
  512. {
  513. width = enumerable.Max(z => z.Width);
  514. }
  515. }
  516. this.Width = Math.Max(width, 50);
  517. bool flag3 = true;
  518. flag2 = (CurrentValueScaler is ValueScalerArithmetic);
  519. if (flag2)
  520. {
  521. flag = (((ValueScalerArithmetic)CurrentValueScaler).BoundingMethod ==
  522. ValueScalerArithmetic.enumScaleBounding.eCentered);
  523. if (flag)
  524. {
  525. flag3 = false;
  526. }
  527. }
  528. else
  529. {
  530. flag3 = false;
  531. }
  532. flag2 = flag3;// && this.chartContainer.ShowMarginGrabs);
  533. if (flag2)
  534. {
  535. var valueScalerArithmetic = (ValueScalerArithmetic)CurrentValueScaler;
  536. this._topAdjuster.SetValues(this._chart, this._scalelayer.GetLeftValueScaleDisplay(), this._scalelayer.GetRightValueScaleDisplay(), true);
  537. var num8 = (double)(1f - valueScalerArithmetic.MaxAddPercent / 100f);
  538. this._topAdjuster.SetValue(Canvas.TopProperty, (double)valueScalerArithmetic.YFromPercent((float)num8, theRect));
  539. this._bottomAdjuster.SetValues(this._chart, this._scalelayer.GetLeftValueScaleDisplay(), this._scalelayer.GetRightValueScaleDisplay(), false);
  540. num8 = (double)(valueScalerArithmetic.MinAddPercent / 100f);
  541. var num9 = (double)valueScalerArithmetic.YFromPercent((float)num8, theRect);
  542. flag2 = (num9 + 4.0 > theRect.Bottom);
  543. if (flag2)
  544. {
  545. num9 = theRect.Bottom - 4.0;
  546. }
  547. this._bottomAdjuster.SetValue(Canvas.TopProperty, num9);
  548. this._topAdjuster.Visibility = Visibility.Visible;
  549. this._bottomAdjuster.Visibility = Visibility.Visible;
  550. }
  551. else
  552. {
  553. this._topAdjuster.Visibility = Visibility.Collapsed;
  554. this._bottomAdjuster.Visibility = Visibility.Collapsed;
  555. }
  556. }
  557. }
  558. }
  559. internal void BuildYList(float aY)
  560. {
  561. this._flag2 = true;
  562. this._yValue = aY;
  563. try
  564. {
  565. this.BuildYList(this._chartPane, this._rect);
  566. }
  567. catch (Exception ex)
  568. {
  569. ProjectData.SetProjectError(ex);
  570. ProjectData.ClearProjectError();
  571. }
  572. }
  573. internal void BuildYList()
  574. {
  575. this._flag2 = false;
  576. try
  577. {
  578. this.BuildYList(this._chartPane, this._rect);
  579. }
  580. catch (Exception expr_3F)
  581. {
  582. ProjectData.SetProjectError(expr_3F);
  583. ProjectData.ClearProjectError();
  584. }
  585. }
  586. internal double FontSize()
  587. {
  588. bool flag = this._chart != null;
  589. double result;
  590. if (flag)
  591. {
  592. result = this._chart.ChartFontSize;
  593. }
  594. else
  595. {
  596. result = 12f;
  597. }
  598. return result;
  599. }
  600. internal ValueScaleBufferAdjuster GetBottomAdjuster()
  601. {
  602. return this._bottomAdjuster;
  603. }
  604. internal ValueScaleBufferAdjuster GetTopAdjuster()
  605. {
  606. return this._topAdjuster;
  607. }
  608. internal double GetValuePercent(double aY)
  609. {
  610. bool flag = this._chartPane != null;
  611. double result;
  612. if (flag)
  613. {
  614. Rect rect = new Rect(this._rect.X, this._rect.Y + this._chartPane.GetActualHeight(), this._rect.Width, this._rect.Height);
  615. flag = (rect.Height != 0.0);
  616. if (flag)
  617. {
  618. result = 1.0 - (aY - rect.Top) / rect.Height;
  619. return result;
  620. }
  621. }
  622. result = 0.0;
  623. return result;
  624. }
  625. internal List<FrameworkElement> GetValueScaleDisplay(Chart theChart, IDateScaler dateScale,
  626. Rect aRect, List<ValueScaleDisplay.ValueScaleDisplay_Y> ylist, bool drawGridLines, bool isTimeSpaning)
  627. {
  628. var list = new List<FrameworkElement>();
  629. this._chart = theChart;
  630. var path = new Path { IsHitTestVisible = (false) };
  631. list.Add(path);
  632. this._flag3 = this.IsPChangeFromBeginning();
  633. bool flag = CurrentValueScaler.Spread().Equals(0);
  634. List<FrameworkElement> result;
  635. if (flag)
  636. {
  637. result = list;
  638. }
  639. else
  640. {
  641. path.UseLayoutRounding = true;
  642. var geometryGroup = new GeometryGroup();
  643. if (theChart.CycleType == CycleType.TimeSharing)
  644. {
  645. path.Stroke = theChart.TimeSharingGridBrush.Clone();
  646. path.Stroke.Opacity = theChart.GridOpacity;
  647. }
  648. else
  649. {
  650. var solidColorBrush = new SolidColorBrush { Color = this._lineColor, Opacity = theChart.GridOpacity };
  651. path.Stroke = solidColorBrush;
  652. path.StrokeThickness = 1.0;
  653. }
  654. var list2 = ylist == null ? this.GetYList((float)aRect.Height, CurrentValueScaler, isTimeSpaning) : UpdateYList(ylist);
  655. this._yList = list2;
  656. if (list2 != null && list2.Any())
  657. {
  658. foreach (var current in list2)
  659. {
  660. if (!current.Value.Equals(float.NaN))
  661. {
  662. float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
  663. num = (float)((double)checked((int)Math.Round((double)num)) + 0.5);
  664. if (this.mDrawGridLines && drawGridLines)
  665. {
  666. var lineGeometry = new LineGeometry
  667. {
  668. StartPoint = new Point(aRect.Left, (double)num),
  669. EndPoint = new Point(aRect.Width, (double)num)
  670. };
  671. geometryGroup.Children.Add(lineGeometry);
  672. }
  673. }
  674. }
  675. }
  676. if (this._flag3 && this.mDrawGridLines)
  677. {
  678. //显示百分比,画基准线
  679. var line = new Line
  680. {
  681. IsHitTestVisible = (false),
  682. Stroke = new SolidColorBrush
  683. {
  684. Color =Colors.Blue,
  685. Opacity = (theChart.GridOpacity * 1.5)
  686. },
  687. StrokeThickness = (3.0),
  688. X1 = (aRect.Left),
  689. X2 = (aRect.Right)
  690. };
  691. if (isTimeSpaning)
  692. {
  693. line.Stroke = theChart.TimeSharingGridBrush.Clone();
  694. line.Stroke.Opacity = (theChart.GridOpacity * 1.5);
  695. }
  696. float num = CurrentValueScaler.ScaledY(((ValueScalerArithmetic)CurrentValueScaler).GetPercentBaseline(), aRect);
  697. var y = Math.Round(num) + 0.5;
  698. line.Y1 = y;
  699. line.Y2 = y;
  700. list.Add(line);
  701. }
  702. path.Data = (geometryGroup);
  703. result = list;
  704. }
  705. return result;
  706. }
  707. internal List<ValueScaleDisplay.ValueScaleDisplay_Y> GetYList(float height, IValueScaler ValScale, bool isTimeSpaning)
  708. {
  709. if (this._chart == null || this._chart.DataSet == null || this._chart.DataSet.DataPoints == null ||
  710. !this._chart.DataSet.DataPoints.Any()) return null;
  711. bool flag = true;
  712. List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
  713. if (isTimeSpaning) //分时图显示网络线数量
  714. {
  715. result = GetTimeSpaningScaleValues(height, ValScale);
  716. return result;
  717. }
  718. if (flag)
  719. {
  720. switch (this.TextMode)
  721. {
  722. case ValueScaleDisplay.ValueScalePaintMode.AutoScale:
  723. result = this.GetAAutoScaleValues(height, ValScale);
  724. break;
  725. case ValueScaleDisplay.ValueScalePaintMode.AutoDivisor:
  726. result = this.GetAutoDivisorValues(height, ValScale);
  727. break;
  728. case ValueScaleDisplay.ValueScalePaintMode.AutoPercentScale:
  729. result = this.GetAutoPercentScaleValues(height, ValScale);
  730. break;
  731. case ValueScaleDisplay.ValueScalePaintMode.Divisor:
  732. result = this.GetDivisorValues(height, ValScale);
  733. break;
  734. case ValueScaleDisplay.ValueScalePaintMode.FixedPercent:
  735. result = this.GetFixedPercentValues(height, ValScale);
  736. break;
  737. case ValueScaleDisplay.ValueScalePaintMode.LineCount:
  738. result = this.GetLineCountValues(height, ValScale);
  739. break;
  740. default:
  741. result = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  742. break;
  743. }
  744. }
  745. else
  746. {
  747. List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  748. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  749. valueScaleDisplay_.Value = 0.01f;
  750. valueScaleDisplay_.SetText(ValScale.ValueFromPercentDisplay(0f), this);
  751. list.Add(valueScaleDisplay_);
  752. result = list;
  753. }
  754. return result;
  755. }
  756. #endregion Internal Methods
  757. #region Private Methods
  758. private Border BuildDisplayBorder(float valY, float txtVal)
  759. {
  760. var border = new Border
  761. {
  762. BorderThickness = new Thickness(1.0),
  763. CornerRadius = new CornerRadius(3.0),
  764. Padding = new Thickness(1.0, 0.0, 1.0, 1.0),
  765. BorderBrush = new SolidColorBrush(Colors.White),
  766. Background = new SolidColorBrush(Colors.Black)
  767. };
  768. border.SetValue(Canvas.LeftProperty, 3.0);
  769. border.SetValue(Canvas.TopProperty, (double)valY - (double)this.FontSize() * 0.6);
  770. var textBlock = new TextBlock
  771. {
  772. Text = this.ConvertToString(txtVal),
  773. FontSize = (double)this.FontSize(),
  774. FontFamily = new FontFamily("Verdana"),
  775. Foreground = new SolidColorBrush(Colors.White),
  776. };
  777. if (_chart.IsDarkBackground)
  778. {
  779. textBlock.Foreground = (new SolidColorBrush(Colors.White));
  780. border.BorderBrush = (new SolidColorBrush(Colors.White));
  781. border.Background = (new SolidColorBrush(Colors.Black));
  782. }
  783. else
  784. {
  785. textBlock.Foreground = (new SolidColorBrush(Colors.Black));
  786. border.BorderBrush = (new SolidColorBrush(Colors.Black));
  787. border.Background = (new SolidColorBrush(Colors.White));
  788. }
  789. border.Child = textBlock;
  790. return border;
  791. }
  792. /// <summary>
  793. /// 把数值转换为指点格式字符串(加% 或者转换成保留2位的小数)
  794. /// </summary>
  795. /// <param name="aVal"></param>
  796. /// <returns></returns>
  797. private string ConvertToString(float aVal)
  798. {
  799. if (_flag3)
  800. {
  801. return Strings.Format(aVal, "0.00") + "%";
  802. }
  803. else
  804. {
  805. return Conversions.ToString(TextFormatting.FormatNumber(aVal, this.mFormatSigDigits, this._allowAbbreviate));
  806. }
  807. }
  808. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetTimeSpaningScaleValues(float height, IValueScaler valScale)
  809. {
  810. var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  811. try
  812. {
  813. int num;
  814. checked
  815. {
  816. // num = (int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * c_TimeSpaning));
  817. // num = num % 2 == 0 ? num : num - 1; // 取偶数
  818. num = c_TimeSpaningGridCount;
  819. int num2 = 0;
  820. while (true)
  821. {
  822. if (num2 > num)
  823. {
  824. break;
  825. }
  826. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  827. valueScaleDisplay_.Value = (float)((double)num2 / (double)num);
  828. valueScaleDisplay_.SetText(valScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
  829. list.Add(valueScaleDisplay_);
  830. num2++;
  831. }
  832. }
  833. this._curNet = valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f);
  834. this._curPercent = (valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f)) / valScale.ValueFromPercentDisplay(0f);
  835. }
  836. catch (Exception expr_10D)
  837. {
  838. ProjectData.SetProjectError(expr_10D);
  839. ProjectData.ClearProjectError();
  840. }
  841. return list;
  842. }
  843. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAAutoScaleValues(float height, IValueScaler valScale)
  844. {
  845. var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  846. try
  847. {
  848. int num;
  849. checked
  850. {
  851. num = (int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * 1.1));
  852. int num2 = 0;
  853. while (true)
  854. {
  855. if (num2 > num)
  856. {
  857. break;
  858. }
  859. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  860. valueScaleDisplay_.Value = (float)((double)num2 / (double)num);
  861. valueScaleDisplay_.SetText(valScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
  862. list.Add(valueScaleDisplay_);
  863. num2++;
  864. }
  865. }
  866. this._curNet = valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f);
  867. this._curPercent = (valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f)) / valScale.ValueFromPercentDisplay(0f);
  868. }
  869. catch (Exception expr_10D)
  870. {
  871. ProjectData.SetProjectError(expr_10D);
  872. ProjectData.ClearProjectError();
  873. }
  874. return list;
  875. }
  876. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAutoDivisorValues(float height, IValueScaler ValScale)
  877. {
  878. var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  879. List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
  880. try
  881. {
  882. float num = ValScale.ValueFromPercentDisplay(1f);
  883. float num2 = ValScale.ValueFromPercentDisplay(0f);
  884. bool flag = ValScale.Inverse;
  885. if (flag)
  886. {
  887. num = ValScale.ValueFromPercentDisplay(0f);
  888. num2 = ValScale.ValueFromPercentDisplay(1f);
  889. }
  890. flag = (float.IsInfinity(num) || float.IsNaN(num));
  891. if (flag)
  892. {
  893. result = list;
  894. return result;
  895. }
  896. int num3 = 0;
  897. int num4 = 0;
  898. int num6 = 0;
  899. bool flag2 = false;
  900. float num8 = 0f;
  901. checked
  902. {
  903. num3 = (int)Math.Round((double)unchecked(this.GetFontSizeLength() + 4f));
  904. num4 = -1;
  905. int num5 = this.mDivisors.Count - 1;
  906. num6 = 0;
  907. while (true)
  908. {
  909. if (num6 > num5)
  910. {
  911. goto IL_1A8;
  912. }
  913. unchecked
  914. {
  915. float aVal = num - this.mDivisors[num6];
  916. flag = ValScale.Inverse;
  917. if (flag)
  918. {
  919. flag2 = (Math.Abs(0f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num3);
  920. if (flag2)
  921. {
  922. break;
  923. }
  924. }
  925. else
  926. {
  927. flag2 = (Math.Abs(1f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num3);
  928. if (flag2)
  929. {
  930. goto Block_10;
  931. }
  932. }
  933. }
  934. num6++;
  935. }
  936. num8 = this.mDivisors[num6];
  937. }
  938. flag2 = ((double)Math.Abs(1f - ValScale.PercentFromValueDisplay(num2 + num8)) > 0.25);
  939. if (flag2)
  940. {
  941. num4 = num6;
  942. goto IL_12A;
  943. }
  944. goto IL_12A;
  945. Block_10:
  946. num8 = this.mDivisors[num6];
  947. flag2 = ((double)Math.Abs(0f - ValScale.PercentFromValueDisplay(num2 + num8)) > 0.25);
  948. if (flag2)
  949. {
  950. num4 = num6;
  951. }
  952. IL_1A8:
  953. flag2 = (num8 == 0f);
  954. if (flag2)
  955. {
  956. num8 = 10000f;
  957. }
  958. int num9 = 0;
  959. num = (float)checked((int)Math.Round((double)(num / num8)));
  960. num += 1f;
  961. num *= num8;
  962. while (true)
  963. {
  964. float num10 = ValScale.PercentFromValueDisplay(num);
  965. flag2 = (num10 <= 1f & num10 >= 0f);
  966. if (flag2)
  967. {
  968. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  969. valueScaleDisplay_.Value = num10;
  970. valueScaleDisplay_.SetText(num, this);
  971. list.Add(valueScaleDisplay_);
  972. }
  973. flag2 = (num4 > 0 && (double)(Math.Abs(ValScale.PercentFromValueDisplay(num - num8) - ValScale.PercentFromValueDisplay(num)) * height) >= 1.5 * (double)num3);
  974. if (flag2)
  975. {
  976. while (num4 > 0 && Math.Abs(ValScale.PercentFromValueDisplay(num - this.mDivisors[checked(num4 - 1)]) - ValScale.PercentFromValueDisplay(num)) * height >= (float)num3)
  977. {
  978. checked
  979. {
  980. num4--;
  981. num8 = this.mDivisors[num4];
  982. }
  983. }
  984. }
  985. num -= num8;
  986. checked
  987. {
  988. num9++;
  989. if (!ValScale.Inverse && num10 >= 0f)
  990. {
  991. goto IL_2F2;
  992. }
  993. if (ValScale.Inverse && num10 <= 100f)
  994. {
  995. goto IL_2F2;
  996. }
  997. goto IL_2FB;
  998. IL_2FF:
  999. bool arg_2FF_0;
  1000. if (!arg_2FF_0)
  1001. {
  1002. break;
  1003. }
  1004. continue;
  1005. IL_2FB:
  1006. arg_2FF_0 = false;
  1007. goto IL_2FF;
  1008. IL_2F2:
  1009. if (num9 >= 1000)
  1010. {
  1011. goto IL_2FB;
  1012. }
  1013. arg_2FF_0 = true;
  1014. goto IL_2FF;
  1015. }
  1016. }
  1017. this._curNet = num8;
  1018. goto IL_356;
  1019. IL_12A:
  1020. goto IL_1A8;
  1021. }
  1022. catch (Exception expr_346)
  1023. {
  1024. ProjectData.SetProjectError(expr_346);
  1025. ProjectData.ClearProjectError();
  1026. }
  1027. IL_356:
  1028. result = list;
  1029. return result;
  1030. }
  1031. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAutoPercentScaleValues(float height, IValueScaler ValScale)
  1032. {
  1033. List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  1034. List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
  1035. try
  1036. {
  1037. int num = 0;
  1038. float num2 = ValScale.ValueFromPercentDisplay(1f);
  1039. float num3 = ValScale.ValueFromPercentDisplay(0f);
  1040. bool flag = ValScale.Inverse;
  1041. if (flag)
  1042. {
  1043. num2 = ValScale.ValueFromPercentDisplay(0f);
  1044. num3 = ValScale.ValueFromPercentDisplay(1f);
  1045. }
  1046. flag = (float.IsInfinity(num2) || float.IsNaN(num2));
  1047. if (flag)
  1048. {
  1049. result = list;
  1050. return result;
  1051. }
  1052. flag = (float.IsInfinity(num3) || float.IsNaN(num3));
  1053. if (flag)
  1054. {
  1055. result = list;
  1056. return result;
  1057. }
  1058. int num4 = checked((int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * 1.1)));
  1059. this._curPercent = (num2 - num3) / (float)num4;
  1060. this._curPercent = (num3 + this._curPercent) / num3;
  1061. this._curPercent -= 1f;
  1062. checked
  1063. {
  1064. int num5 = (int)Math.Round((double)unchecked(this.GetFontSizeLength() + 4f));
  1065. int arg_11A_0 = 0;
  1066. int num6 = this.mDivisors.Count - 1;
  1067. int num7 = arg_11A_0;
  1068. float num9;
  1069. bool flag2;
  1070. while (true)
  1071. {
  1072. int arg_1BD_0 = num7;
  1073. int num8 = num6;
  1074. if (arg_1BD_0 > num8)
  1075. {
  1076. goto IL_1C2;
  1077. }
  1078. num9 = this.mDivisors[num7];
  1079. unchecked
  1080. {
  1081. float aVal = num2 * (1f / (1f + num9));
  1082. flag = ValScale.Inverse;
  1083. if (flag)
  1084. {
  1085. flag2 = (Math.Abs(0f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num5);
  1086. if (flag2)
  1087. {
  1088. break;
  1089. }
  1090. }
  1091. else
  1092. {
  1093. flag2 = (Math.Abs(1f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num5);
  1094. if (flag2)
  1095. {
  1096. goto Block_12;
  1097. }
  1098. }
  1099. }
  1100. num7++;
  1101. }
  1102. this._curPercent = num9;
  1103. goto IL_1C2;
  1104. Block_12:
  1105. this._curPercent = num9;
  1106. IL_1C2:
  1107. flag2 = (this._curPercent < 0f);
  1108. if (flag2)
  1109. {
  1110. result = list;
  1111. return result;
  1112. }
  1113. flag2 = ValScale.Inverse;
  1114. if (flag2)
  1115. {
  1116. num2 = num3;
  1117. }
  1118. float num10;
  1119. do
  1120. {
  1121. num10 = ValScale.PercentFromValueDisplay(num2);
  1122. flag2 = (num10 <= 1f & num10 >= 0f);
  1123. if (flag2)
  1124. {
  1125. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  1126. valueScaleDisplay_.Value = num10;
  1127. valueScaleDisplay_.SetText(num2, this);
  1128. list.Add(valueScaleDisplay_);
  1129. }
  1130. flag2 = ValScale.Inverse;
  1131. unchecked
  1132. {
  1133. if (flag2)
  1134. {
  1135. num2 *= 1f + this._curPercent;
  1136. }
  1137. else
  1138. {
  1139. num2 /= 1f + this._curPercent;
  1140. }
  1141. }
  1142. num++;
  1143. }
  1144. while (num10 >= 0f && num < 1000);
  1145. }
  1146. }
  1147. catch (Exception expr_2CA)
  1148. {
  1149. ProjectData.SetProjectError(expr_2CA);
  1150. ProjectData.ClearProjectError();
  1151. }
  1152. result = list;
  1153. return result;
  1154. }
  1155. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetDivisorValues(float height, IValueScaler ValScale)
  1156. {
  1157. var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  1158. List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
  1159. try
  1160. {
  1161. int num = 0;
  1162. float num2 = ValScale.ValueFromPercentDisplay(1f);
  1163. bool flag = ValScale.Inverse;
  1164. if (flag)
  1165. {
  1166. num2 = ValScale.ValueFromPercentDisplay(0f);
  1167. }
  1168. flag = (float.IsInfinity(num2) || float.IsNaN(num2));
  1169. if (flag)
  1170. {
  1171. result = list;
  1172. return result;
  1173. }
  1174. flag = (this._divisor == 0f);
  1175. if (flag)
  1176. {
  1177. result = list;
  1178. return result;
  1179. }
  1180. num2 = (float)checked((int)Math.Round((double)(num2 / this._divisor)));
  1181. num2 += 1f;
  1182. num2 *= this._divisor;
  1183. while (true)
  1184. {
  1185. float num3 = ValScale.PercentFromValueDisplay(num2);
  1186. flag = (num3 <= 1f & num3 >= 0f);
  1187. if (flag)
  1188. {
  1189. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  1190. valueScaleDisplay_.Value = num3;
  1191. valueScaleDisplay_.SetText(num2, this);
  1192. list.Add(valueScaleDisplay_);
  1193. }
  1194. num2 -= this._divisor;
  1195. checked
  1196. {
  1197. num++;
  1198. if (!ValScale.Inverse && num3 >= 0f)
  1199. {
  1200. goto IL_129;
  1201. }
  1202. if (ValScale.Inverse && num3 <= 100f)
  1203. {
  1204. goto IL_129;
  1205. }
  1206. goto IL_131;
  1207. IL_135:
  1208. bool arg_135_0;
  1209. if (!arg_135_0)
  1210. {
  1211. break;
  1212. }
  1213. continue;
  1214. IL_131:
  1215. arg_135_0 = false;
  1216. goto IL_135;
  1217. IL_129:
  1218. if (num >= 1000)
  1219. {
  1220. goto IL_131;
  1221. }
  1222. arg_135_0 = true;
  1223. goto IL_135;
  1224. }
  1225. }
  1226. this._curNet = this._divisor;
  1227. }
  1228. catch (Exception expr_180)
  1229. {
  1230. ProjectData.SetProjectError(expr_180);
  1231. ProjectData.ClearProjectError();
  1232. }
  1233. result = list;
  1234. return result;
  1235. }
  1236. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetFixedPercentValues(float height, IValueScaler ValScale)
  1237. {
  1238. List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  1239. try
  1240. {
  1241. int num = 0;
  1242. float num2 = ValScale.ValueFromPercentDisplay(1f);
  1243. bool flag = ValScale.Inverse;
  1244. if (flag)
  1245. {
  1246. num2 = ValScale.ValueFromPercentDisplay(0f);
  1247. }
  1248. this._curPercent = this._fixedPercent / 100f;
  1249. while (true)
  1250. {
  1251. float num3 = ValScale.PercentFromValueDisplay(num2);
  1252. flag = (num3 <= 1f & num3 >= 0f);
  1253. if (flag)
  1254. {
  1255. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  1256. valueScaleDisplay_.Value = num3;
  1257. valueScaleDisplay_.SetText(num2, this);
  1258. list.Add(valueScaleDisplay_);
  1259. }
  1260. num2 /= 1f + this._fixedPercent / 100f;
  1261. checked
  1262. {
  1263. num++;
  1264. if (!ValScale.Inverse && num3 >= 0f)
  1265. {
  1266. goto IL_E1;
  1267. }
  1268. if (ValScale.Inverse && num3 <= 100f)
  1269. {
  1270. goto IL_E1;
  1271. }
  1272. goto IL_E9;
  1273. IL_ED:
  1274. bool arg_ED_0;
  1275. if (!arg_ED_0)
  1276. {
  1277. break;
  1278. }
  1279. continue;
  1280. IL_E9:
  1281. arg_ED_0 = false;
  1282. goto IL_ED;
  1283. IL_E1:
  1284. if (num >= 1000)
  1285. {
  1286. goto IL_E9;
  1287. }
  1288. arg_ED_0 = true;
  1289. goto IL_ED;
  1290. }
  1291. }
  1292. }
  1293. catch (Exception expr_12C)
  1294. {
  1295. ProjectData.SetProjectError(expr_12C);
  1296. ProjectData.ClearProjectError();
  1297. }
  1298. return list;
  1299. }
  1300. private float GetFontSizeLength()
  1301. {
  1302. return (float)((double)this.FontSize() * 1.1);
  1303. }
  1304. private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetLineCountValues(float height, IValueScaler ValScale)
  1305. {
  1306. List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  1307. try
  1308. {
  1309. int num;
  1310. checked
  1311. {
  1312. num = this.LineCount - 1;
  1313. int arg_EB_0 = 0;
  1314. int num2 = num;
  1315. int num3 = arg_EB_0;
  1316. while (true)
  1317. {
  1318. int arg_6E_0 = num3;
  1319. int num4 = num2;
  1320. if (arg_6E_0 > num4)
  1321. {
  1322. break;
  1323. }
  1324. ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
  1325. valueScaleDisplay_.Value = (float)((double)num3 / (double)num);
  1326. valueScaleDisplay_.SetText(ValScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
  1327. list.Add(valueScaleDisplay_);
  1328. num3++;
  1329. }
  1330. }
  1331. this._curNet = ValScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - ValScale.ValueFromPercentDisplay(0f);
  1332. this._curPercent = (ValScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - ValScale.ValueFromPercentDisplay(0f)) / ValScale.ValueFromPercentDisplay(0f);
  1333. }
  1334. catch (Exception expr_FB)
  1335. {
  1336. ProjectData.SetProjectError(expr_FB);
  1337. ProjectData.ClearProjectError();
  1338. }
  1339. return list;
  1340. }
  1341. private void InitializeDivisors()
  1342. {
  1343. this.mDivisors.Add(1E-05f);
  1344. this.mDivisors.Add(5E-05f);
  1345. this.mDivisors.Add(0.0001f);
  1346. this.mDivisors.Add(0.0005f);
  1347. this.mDivisors.Add(0.001f);
  1348. this.mDivisors.Add(0.005f);
  1349. this.mDivisors.Add(0.01f);
  1350. this.mDivisors.Add(0.02f);
  1351. this.mDivisors.Add(0.03f);
  1352. this.mDivisors.Add(0.04f);
  1353. this.mDivisors.Add(0.05f);
  1354. this.mDivisors.Add(0.1f);
  1355. this.mDivisors.Add(0.25f);
  1356. this.mDivisors.Add(0.3f);
  1357. this.mDivisors.Add(0.4f);
  1358. this.mDivisors.Add(0.5f);
  1359. this.mDivisors.Add(0.6f);
  1360. this.mDivisors.Add(0.7f);
  1361. this.mDivisors.Add(0.8f);
  1362. this.mDivisors.Add(0.9f);
  1363. this.mDivisors.Add(1f);
  1364. this.mDivisors.Add(1.5f);
  1365. this.mDivisors.Add(2f);
  1366. this.mDivisors.Add(2.5f);
  1367. this.mDivisors.Add(3f);
  1368. this.mDivisors.Add(4f);
  1369. this.mDivisors.Add(5f);
  1370. this.mDivisors.Add(6f);
  1371. this.mDivisors.Add(7f);
  1372. this.mDivisors.Add(8f);
  1373. this.mDivisors.Add(9f);
  1374. this.mDivisors.Add(10f);
  1375. this.mDivisors.Add(20f);
  1376. this.mDivisors.Add(25f);
  1377. this.mDivisors.Add(50f);
  1378. this.mDivisors.Add(100f);
  1379. this.mDivisors.Add(250f);
  1380. this.mDivisors.Add(500f);
  1381. this.mDivisors.Add(1000f);
  1382. this.mDivisors.Add(2500f);
  1383. this.mDivisors.Add(5000f);
  1384. this.mDivisors.Add(10000f);
  1385. this.mDivisors.Add(25000f);
  1386. this.mDivisors.Add(50000f);
  1387. this.mDivisors.Add(100000f);
  1388. this.mDivisors.Add(250000f);
  1389. this.mDivisors.Add(500000f);
  1390. this.mDivisors.Add(1000000f);
  1391. this.mDivisors.Add(2500000f);
  1392. this.mDivisors.Add(5000000f);
  1393. this.mDivisors.Add(1E+07f);
  1394. this.mDivisors.Add(2.5E+07f);
  1395. this.mDivisors.Add(5E+07f);
  1396. this.mDivisors.Add(1E+08f);
  1397. this.mDivisors.Add(2.5E+08f);
  1398. this.mDivisors.Add(5E+08f);
  1399. this.mDivisors.Add(1E+09f);
  1400. this.mDivisors.Add(2.5E+09f);
  1401. this.mDivisors.Add(5E+09f);
  1402. this.mDivisors.Add(1E+10f);
  1403. this.mDivisors.Add(2.5E+10f);
  1404. this.mDivisors.Add(5E+10f);
  1405. this.mDivisors.Add(1E+11f);
  1406. this.mDivisors.Add(2.5E+11f);
  1407. this.mDivisors.Add(5E+11f);
  1408. this.mDivisors.Add(1E+12f);
  1409. this.mDivisors.Add(2.5E+12f);
  1410. this.mDivisors.Add(5E+12f);
  1411. this.mDivisors.Add(1E+13f);
  1412. this.mDivisors.Add(2.5E+13f);
  1413. this.mDivisors.Add(5E+13f);
  1414. }
  1415. private bool IsPChangeFromBeginning()
  1416. {
  1417. var valueScaler = this.CurrentValueScaler;
  1418. if (valueScaler == null) return false;
  1419. return (valueScaler is ValueScalerArithmetic && ((ValueScalerArithmetic)valueScaler).IsPChangeFromBeginning() && ((ValueScalerArithmetic)valueScaler).ShowScaleAsPercent);
  1420. }
  1421. private void RefreshChart()
  1422. {
  1423. if (this._chart == null) return;
  1424. this._chart.Refresh();
  1425. }
  1426. /// <summary>
  1427. /// Shows the percent scale.
  1428. /// </summary>
  1429. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
  1430. private bool ShowPercentScale()
  1431. {
  1432. var scale = CurrentValueScaler as ValueScalerArithmetic;
  1433. if (scale == null) return false;
  1434. return scale.ShowScaleAsPercent;
  1435. }
  1436. /// <summary>
  1437. /// Updates the Y list.
  1438. /// </summary>
  1439. /// <param name="ylist">The ylist.</param>
  1440. /// <returns>List{ValueScaleDisplay.ValueScaleDisplay_Y}.</returns>
  1441. private List<ValueScaleDisplay.ValueScaleDisplay_Y> UpdateYList(List<ValueScaleDisplay.ValueScaleDisplay_Y> ylist)
  1442. {
  1443. //更新y轴数据,只针对左边显示数据,右边显示百分比。
  1444. try
  1445. {
  1446. if (!this.CurrentValueScaler.ShowScaleAsPercent) return ylist;
  1447. var result = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
  1448. var baseline = CurrentValueScaler.GetPercentBaseline();
  1449. foreach (var y in ylist)
  1450. {
  1451. var val = float.Parse(y.Text);
  1452. result.Add(new ValueScaleDisplay_Y()
  1453. {
  1454. Text = ConvertToString(((val - baseline) / baseline) * 100),
  1455. Value = y.Value
  1456. });
  1457. }
  1458. return result;
  1459. }
  1460. catch
  1461. {
  1462. return ylist;
  1463. }
  1464. }
  1465. private void ValueScaleDisplay_SizeChanged(object sender, SizeChangedEventArgs e)
  1466. {
  1467. this._yCanvas.Width = (this.ActualWidth);
  1468. this._yCanvas.Height = (this.ActualHeight);
  1469. }
  1470. #endregion Private Methods
  1471. #endregion Methods
  1472. #region Nested Types
  1473. /// <summary>
  1474. /// 存储Y轴坐标值
  1475. /// </summary>
  1476. internal class ValueScaleDisplay_Y
  1477. {
  1478. #region Constructors
  1479. public ValueScaleDisplay_Y()
  1480. {
  1481. }
  1482. #endregion Constructors
  1483. #region Properties
  1484. #region Public Properties
  1485. /// <summary>
  1486. /// 处理后的Y轴数值文本
  1487. /// </summary>
  1488. public string Text
  1489. {
  1490. get;
  1491. set;
  1492. }
  1493. /// <summary>
  1494. /// Y轴坐标值
  1495. /// </summary>
  1496. public float Value
  1497. {
  1498. get;
  1499. set;
  1500. }
  1501. #endregion Public Properties
  1502. #endregion Properties
  1503. #region Methods
  1504. #region Internal Methods
  1505. internal void SetText(float aVal, ValueScaleDisplay aValScaleDisp)
  1506. {
  1507. this.Text = aValScaleDisp.ConvertToString(aVal);
  1508. }
  1509. #endregion Internal Methods
  1510. #endregion Methods
  1511. }
  1512. #endregion Nested Types
  1513. }
  1514. }