| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821 |
- using Microsoft.VisualBasic.CompilerServices;
- using MuchInfo.Chart.Data.Interfaces;
- using MuchInfo.Chart.Data.Models;
- using MuchInfo.Chart.Infrastructure.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Windows;
- using System.Xml.Linq;
- namespace MuchInfo.Chart.WPF.Primitives
- {
- public class ValueScalerArithmetic : IValueScaler
- {
- #region Fields
- private const float c_HightPrecent = 0.2f; //显示分时图最大的百分比
- private Dictionary<string, string> _dictionary;
- private float _diffInverse;
- private bool _flag;
- private float _high;
- private bool _inverse;
- private float _logDiffInverse;
- private float _logMax;
- private float _logMin;
- private float _low;
- private float _max;
- private float _maxValue;
- private float _min;
- private float _minValue;
- private float _percentBaseline;
- private bool _percentScale;
- private ValueScalerArithmetic.enumScaleMethod _scaleMode;
- private ValueScalerArithmetic.enumScaleMethod _scaleMode2;
- #endregion Fields
- #region Constructors
- public ValueScalerArithmetic(bool showPercentScale)
- {
- _high = 0f;
- _low = 0f;
- _maxValue = 0f;
- _minValue = 0f;
- _flag = false;
- _inverse = false;
- _dictionary = new Dictionary<string, string>();
- _scaleMode = ValueScalerArithmetic.enumScaleMethod.eArithmetic;
- _scaleMode2 = ValueScalerArithmetic.enumScaleMethod.eArithmetic;
- //右边显示百分比
- _percentScale = showPercentScale;//true;
- }
- #endregion Constructors
- #region Enumerations
- public enum enumCenteredHeight
- {
- eAuto,
- eManual
- }
- public enum enumCenteredValueMode
- {
- eMedian,
- eManual
- }
- public enum enumMaxMinValueMode
- {
- eMaxMin,
- eManual
- }
- public enum enumScaleBounding
- {
- eMaxMin,
- eCentered
- }
- public enum enumScaleMethod
- {
- eArithmetic,
- eLog,
- ePChangeFromBeginning,
- }
- public enum enumScaleMode
- {
- AutoScale,
- Manual,
- CenteredAuto,
- CenteredManual,
- AutoMinimum,
- AutoMaximum
- }
- #endregion Enumerations
- #region Events
- public event ScalePropertiesChangedEventHandler ScalePropertiesChanged;
- #endregion Events
- #region Properties
- #region Public Properties
- /// <summary>
- /// Gets or sets the bounding method.
- /// </summary>
- public ValueScalerArithmetic.enumScaleBounding BoundingMethod
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "BoundMethod");
- bool flag = property == null;
- ValueScalerArithmetic.enumScaleBounding result;
- if (flag)
- {
- result = ValueScalerArithmetic.enumScaleBounding.eMaxMin;
- }
- else
- {
- ValueScalerArithmetic.enumScaleBounding enumScaleBounding = (ValueScalerArithmetic.enumScaleBounding)Conversions.ToInteger(property);
- result = enumScaleBounding;
- }
- return result;
- }
- set
- {
- string arg_5E_1 = GetScaleModeString() + "BoundMethod";
- int num = (int)value;
- SetProperty(arg_5E_1, num.ToString());
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the center mode.
- /// </summary>
- public ValueScalerArithmetic.enumCenteredValueMode CenterMode
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "CenterMode");
- bool flag = property == null;
- ValueScalerArithmetic.enumCenteredValueMode result;
- if (flag)
- {
- result = ValueScalerArithmetic.enumCenteredValueMode.eMedian;
- }
- else
- {
- ValueScalerArithmetic.enumCenteredValueMode enumCenteredValueMode = (ValueScalerArithmetic.enumCenteredValueMode)Conversions.ToInteger(property);
- result = enumCenteredValueMode;
- }
- return result;
- }
- set
- {
- string arg_5E_1 = GetScaleModeString() + "CenterMode";
- int num = (int)value;
- SetProperty(arg_5E_1, num.ToString());
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the height mode.
- /// </summary>
- public ValueScalerArithmetic.enumCenteredHeight HeightMode
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "HeightMode");
- bool flag = property == null;
- ValueScalerArithmetic.enumCenteredHeight result;
- if (flag)
- {
- result = ValueScalerArithmetic.enumCenteredHeight.eAuto;
- }
- else
- {
- ValueScalerArithmetic.enumCenteredHeight enumCenteredHeight = (ValueScalerArithmetic.enumCenteredHeight)Conversions.ToInteger(property);
- result = enumCenteredHeight;
- }
- return result;
- }
- set
- {
- string arg_5E_1 = GetScaleModeString() + "HeightMode";
- int num = (int)value;
- SetProperty(arg_5E_1, num.ToString());
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets a value indicating whether this <see cref="ValueScalerArithmetic"/> is inverse.
- /// </summary>
- public bool Inverse
- {
- get
- {
- return _inverse;
- }
- set
- {
- _inverse = value;
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the manual center.
- /// </summary>
- public float ManualCenter
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "ManualCenter");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 50f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- SetProperty(GetScaleModeString() + "ManualCenter", value.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the height of the manual.
- /// </summary>
- public float ManualHeight
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "ManualHeight");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 50f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- SetProperty(GetScaleModeString() + "ManualHeight", value.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the manual max.
- /// </summary>
- public float ManualMax
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "ManualMax");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 100f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- SetProperty(GetScaleModeString() + "ManualMax", value.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the manual min.
- /// </summary>
- public float ManualMin
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "ManualMin");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 0f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- SetProperty(GetScaleModeString() + "ManualMin", value.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the max add percent.
- /// </summary>
- public float MaxAddPercent
- {
- get
- {
- string property = GetProperty("eArithmeticMaxAddPercent");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 2f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- float num = value;
- bool flag = num + MinAddPercent > 97f;
- if (flag)
- {
- num = 97f - MinAddPercent;
- }
- else
- {
- flag = (num < 0f);
- if (flag)
- {
- num = 0f;
- }
- }
- SetProperty("eArithmeticMaxAddPercent", num.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the max mode.
- /// </summary>
- public ValueScalerArithmetic.enumMaxMinValueMode MaxMode
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "MaxMode");
- bool flag = property == null;
- ValueScalerArithmetic.enumMaxMinValueMode result;
- if (flag)
- {
- result = ValueScalerArithmetic.enumMaxMinValueMode.eMaxMin;
- }
- else
- {
- ValueScalerArithmetic.enumScaleBounding enumScaleBounding = (ValueScalerArithmetic.enumScaleBounding)Conversions.ToInteger(property);
- flag = (enumScaleBounding == (ValueScalerArithmetic.enumScaleBounding)2);
- if (flag)
- {
- enumScaleBounding = ValueScalerArithmetic.enumScaleBounding.eMaxMin;
- }
- result = (ValueScalerArithmetic.enumMaxMinValueMode)enumScaleBounding;
- }
- return result;
- }
- set
- {
- string arg_5E_1 = GetScaleModeString() + "MaxMode";
- int num = (int)value;
- SetProperty(arg_5E_1, num.ToString());
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the min add percent.
- /// </summary>
- public float MinAddPercent
- {
- get
- {
- string property = GetProperty("eArithmeticMinAddPercent");
- bool flag = property == null;
- float result;
- if (flag)
- {
- result = 2f;
- }
- else
- {
- result = ConvertHelper.ParseSingle(property);
- }
- return result;
- }
- set
- {
- float num = value;
- if (num + MaxAddPercent > 97f)
- {
- num = 97f - MaxAddPercent;
- }
- else
- {
- if (num < 0f)
- {
- num = 0f;
- }
- }
- SetProperty("eArithmeticMinAddPercent", num.ToString(CultureInfo.InvariantCulture.NumberFormat));
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the min mode.
- /// </summary>
- public ValueScalerArithmetic.enumMaxMinValueMode MinMode
- {
- get
- {
- string property = GetProperty(GetScaleModeString() + "MinMode");
- bool flag = property == null;
- ValueScalerArithmetic.enumMaxMinValueMode result;
- if (flag)
- {
- result = ValueScalerArithmetic.enumMaxMinValueMode.eMaxMin;
- }
- else
- {
- ValueScalerArithmetic.enumScaleBounding enumScaleBounding = (ValueScalerArithmetic.enumScaleBounding)Conversions.ToInteger(property);
- flag = (enumScaleBounding == (ValueScalerArithmetic.enumScaleBounding)2);
- if (flag)
- {
- enumScaleBounding = ValueScalerArithmetic.enumScaleBounding.eMaxMin;
- }
- result = (ValueScalerArithmetic.enumMaxMinValueMode)enumScaleBounding;
- }
- return result;
- }
- set
- {
- string arg_5E_1 = GetScaleModeString() + "MinMode";
- int num = (int)value;
- SetProperty(arg_5E_1, num.ToString());
- OnScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Gets or sets the scale mode.
- /// </summary>
- public ValueScalerArithmetic.enumScaleMethod ScaleMode
- {
- get
- {
- return _scaleMode;
- }
- set
- {
- bool flag = _scaleMode != value;
- if (flag)
- {
- _scaleMode = value;
- OnScalePropertiesChanged();
- }
- }
- }
- /// <summary>
- /// Gets or sets a value indicating whether [show scale as percent].
- /// </summary>
- public bool ShowScaleAsPercent
- {
- get
- {
- return _percentScale;
- }
- set
- {
- bool flag = _percentScale != value;
- if (flag)
- {
- _percentScale = value;
- // OnScalePropertiesChanged(); //只有更新图表时刷新时使用,可以不重新刷新
- }
- }
- }
- #endregion Public Properties
- #endregion Properties
- #region Methods
- #region Public Methods
- /// <summary>
- /// Calculates the scale.
- /// </summary>
- /// <param name="plots">The plots.</param>
- /// <param name="scaler">The scaler.</param>
- public void CalculateScale(List<PlotBase> plots, IDateScaler scaler, bool isTimeSpaning)
- {
- _flag = false;
- _high = 0f;
- _low = 0f;
- _maxValue = 0f;
- _minValue = 0f;
- bool flag = HasPriceHistory(plots, scaler, isTimeSpaning);
- if (flag)
- {
- _scaleMode2 = ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning;
- }
- else
- {
- _scaleMode2 = _scaleMode;
- }
- bool flag2 = ScaleOnlyPrice(plots);
- try
- {
- List<PlotBase>.Enumerator enumerator = plots.GetEnumerator();
- while (enumerator.MoveNext())
- {
- PlotBase current = enumerator.Current;
- flag = (current is ComparisonPlot);
- if (flag)
- {
- var dat = ((LinePlot)current).GetDataSet();
- flag = ((ComparisonPlot)current).IsActive;
- if (flag)
- {
- UpdateMaxAndMin(dat, scaler);
- }
- }
- else
- {
- flag = (current.Indicator != null && current.Indicator.ParentFormula.IsMain && isTimeSpaning);
- if (flag)
- {
- var dat = ((LinePlot)current).GetDataSet();
- UpdateHighAndLow(dat, scaler, true);
- }
- else
- {
- var dat = ((LinePlot)current).GetDataSet();
- UpdateHighAndLow(dat, scaler, false);
- }
- }
- }
- }
- finally
- {
- //List<PlotBase>.Enumerator enumerator;
- //enumerator.Dispose();
- }
- flag = (_high == _low);
- if (flag)
- {
- _high = (float)((double)_high + 0.1);
- flag = ((double)_low - 0.1 > 1.0);
- if (flag)
- {
- _low = (float)((double)_low - 0.1);
- }
- }
- try
- {
- switch (_scaleMode2)
- {
- case ValueScalerArithmetic.enumScaleMethod.eArithmetic:
- //if (cycleType == CycleType.TimeSharing)
- //{
- // var maxAbs = Math.Max(Math.Abs(_high - _percentBaseline), Math.Abs(_low - _percentBaseline));
- // _high = maxAbs + _percentBaseline;
- // _low = _percentBaseline - maxAbs;
- //}
- SetMinMaxArithmetic();
- break;
- case ValueScalerArithmetic.enumScaleMethod.eLog:
- SetMinMaxLog();
- break;
- case ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning:
- if (isTimeSpaning)
- {
- var maxAbs = Math.Max(Math.Abs(_high - _percentBaseline), Math.Abs(_low - _percentBaseline));
- _high =(maxAbs *1.1f)/ _percentBaseline; // c_HightPrecent; //上限加10%
- _low = -_high;
- //SetMinMaxComparison();
- SetMinMaxTimeSpaning();
- }
- else
- {
- _high = (_high - _percentBaseline) / _percentBaseline;
- _low = (_low - _percentBaseline) / _percentBaseline;
- _high = Math.Max(_high, _maxValue);
- _low = Math.Min(_low, _minValue);
- SetMinMaxComparison();
- }
- break;
- }
- }
- catch (Exception expr_347)
- {
- ProjectData.SetProjectError(expr_347);
- ProjectData.ClearProjectError();
- }
- }
- /// <summary>
- /// Froms the XML.
- /// </summary>
- /// <param name="node">The node.</param>
- public void FromXML(XElement node)
- {
- bool flag = node.Attribute("Inverse") != null;
- if (flag)
- {
- _inverse = bool.Parse(node.Attribute("Inverse").Value);
- }
- flag = (node.Attribute("ComparisonScaleAsPercent") != null);
- if (flag)
- {
- _percentScale = bool.Parse(node.Attribute("ComparisonScaleAsPercent").Value);
- }
- flag = (node.Attribute("ScaleMode") != null);
- if (flag)
- {
- string value = node.Attribute("ScaleMode").Value;
- string text = value.ToLower();
- flag = (Operators.CompareString(text, "earithmetic", false) == 0);
- if (flag)
- {
- _scaleMode = ValueScalerArithmetic.enumScaleMethod.eArithmetic;
- }
- else
- {
- flag = (Operators.CompareString(text, "elog", false) == 0);
- if (flag)
- {
- _scaleMode = ValueScalerArithmetic.enumScaleMethod.eLog;
- }
- }
- }
- _dictionary.Clear();
- try
- {
- IEnumerator<XElement> enumerator = node.Elements().GetEnumerator();
- while (enumerator.MoveNext())
- {
- XElement current = enumerator.Current;
- flag = (current.Name == "Arg");
- if (flag)
- {
- bool flag2 = current.Attribute("Name") != null && current.Attribute("Val") != null;
- if (flag2)
- {
- _dictionary[current.Attribute("Name").Value] = current.Attribute("Val").Value;
- }
- }
- }
- }
- finally
- {
- //IEnumerator<XElement> enumerator;
- //bool flag2 = enumerator != null;
- //if (flag2)
- //{
- // enumerator.Dispose();
- //}
- }
- }
- /// <summary>
- /// Gets the max value.
- /// </summary>
- /// <returns>System.Single.</returns>
- public float GetMaxValue()
- {
- if (_scaleMode2 == ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning)
- {
- var value = (_max + 1) * _percentBaseline;
- return value;
- }
- return _max;
- }
- /// <summary>
- /// Gets the min value.
- /// </summary>
- /// <returns>System.Single.</returns>
- public float GetMinValue()
- {
- if (_scaleMode2 == ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning)
- {
- var value = (_min + 1) * _percentBaseline;
- return value;
- }
- return _min;
- }
- /// <summary>
- /// Gets the percent baseline.
- /// </summary>
- /// <returns>System.Single.</returns>
- public float GetPercentBaseline()
- {
- return _percentBaseline;
- }
- /// <summary>
- /// Percents from value.
- /// </summary>
- /// <param name="aVal">A val.</param>
- /// <returns>System.Single.</returns>
- public float PercentFromValue(float aVal)
- {
- float result = 0f;
- switch (_scaleMode2)
- {
- case ValueScalerArithmetic.enumScaleMethod.eArithmetic:
- result = PercentFromValueArithmetic(aVal);
- break;
- case ValueScalerArithmetic.enumScaleMethod.eLog:
- result = PercentFromValueLog(aVal);
- break;
- case ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning:
- result = PercentFromValueComparison(aVal);
- break;
- }
- return result;
- }
- /// <summary>
- /// Percents from value arithmetic.
- /// </summary>
- /// <param name="aValue">A value.</param>
- /// <returns>System.Single.</returns>
- public float PercentFromValueArithmetic(float aValue)
- {
- bool flag = float.IsInfinity(aValue) || float.IsNaN(aValue);
- float result = 0f;
- if (flag)
- {
- result = 0f;
- }
- else
- {
- flag = (_min != _max);
- if (flag)
- {
- bool flag2 = _inverse;
- float num;
- if (flag2)
- {
- num = 1f - (aValue - _min) * _diffInverse;
- }
- else
- {
- num = (aValue - _min) * _diffInverse;
- }
- flag2 = (num > 500000f);
- if (flag2)
- {
- num = 500000f;
- }
- else
- {
- flag2 = (num < -500000f);
- if (flag2)
- {
- num = -500000f;
- }
- }
- result = num;
- }
- }
- return result;
- }
- /// <summary>
- /// Percents from value comparison.
- /// </summary>
- /// <param name="inValue">The in value.</param>
- /// <returns>System.Single.</returns>
- public float PercentFromValueComparison(float inValue)
- {
- float num = (inValue - _percentBaseline) / _percentBaseline;
- bool flag = float.IsInfinity(num) || float.IsNaN(num);
- float result = 0f;
- if (flag)
- {
- result = 0f;
- }
- else
- {
- flag = (_min != _max);
- if (flag)
- {
- bool flag2 = _inverse;
- float num2;
- if (flag2)
- {
- num2 = 1f - (num - _min) * _diffInverse;
- }
- else
- {
- num2 = (num - _min) * _diffInverse;
- }
- flag2 = (num2 > 500000f);
- if (flag2)
- {
- num2 = 500000f;
- }
- else
- {
- flag2 = (num2 < -500000f);
- if (flag2)
- {
- num2 = -500000f;
- }
- }
- result = num2;
- }
- }
- return result;
- }
- /// <summary>
- /// Percents from value display.
- /// </summary>
- /// <param name="aVal">A val.</param>
- /// <returns>System.Single.</returns>
- public float PercentFromValueDisplay(float aVal)
- {
- bool flag = _scaleMode2 == ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning && _percentScale;
- float result;
- if (flag)
- {
- result = PercentFromValueArithmetic(aVal / 100f);
- }
- else
- {
- result = PercentFromValue(aVal);
- }
- return result;
- }
- /// <summary>
- /// Percents from value log.
- /// </summary>
- /// <param name="aValue">A value.</param>
- /// <returns>System.Single.</returns>
- public float PercentFromValueLog(float aValue)
- {
- bool flag = aValue <= 0f;
- float result = 0f;
- if (flag)
- {
- result = -500000f;
- }
- else
- {
- float num = (float)Math.Log10((double)aValue);
- flag = (_logMin != _logMax);
- if (flag)
- {
- bool flag2 = _inverse;
- float num2;
- if (flag2)
- {
- num2 = 1f - (num - _logMin) * _logDiffInverse;
- }
- else
- {
- num2 = (num - _logMin) * _logDiffInverse;
- }
- flag2 = (num2 > 500000f);
- if (flag2)
- {
- num2 = 500000f;
- }
- else
- {
- flag2 = (num2 < -500000f);
- if (flag2)
- {
- num2 = -500000f;
- }
- }
- result = num2;
- }
- }
- return result;
- }
- /// <summary>
- /// Roots the name.
- /// </summary>
- /// <returns>System.String.</returns>
- public string RootName()
- {
- return "VALSCALER";
- }
- /// <summary>
- /// Scaleds the Y.
- /// </summary>
- /// <param name="aVal">A val.</param>
- /// <param name="aRect">A rect.</param>
- /// <returns>System.Single.</returns>
- public float ScaledY(float aVal, Rect aRect)
- {
- bool flag = _high.Equals(_low);
- float result;
- if (flag)
- {
- result = (float)aRect.Bottom;
- }
- else
- {
- float num = (float)(aRect.Height - 1.0);
- flag = (num <= 0f);
- if (flag)
- {
- num = 1E-05f;
- }
- result = (float)checked((int)Math.Round(unchecked(aRect.Top + (double)((1f - PercentFromValue(aVal)) * num))));
- }
- return result;
- }
- public float Spread()
- {
- return _high - _low;
- }
- /// <summary>
- /// To the XML.
- /// </summary>
- /// <param name="args">The args.</param>
- /// <returns>XElement.</returns>
- public XElement ToXML(List<object> args)
- {
- XElement xElement = new XElement(RootName());
- xElement.Add(new XAttribute("Inverse", _inverse.ToString()));
- xElement.Add(new XAttribute("ScaleMode", _scaleMode.ToString()));
- xElement.Add(new XAttribute("ComparisonScaleAsPercent", _percentScale.ToString()));
- try
- {
- Dictionary<string, string>.KeyCollection.Enumerator enumerator = _dictionary.Keys.GetEnumerator();
- while (enumerator.MoveNext())
- {
- string current = enumerator.Current;
- XElement xElement2 = new XElement("Arg");
- xElement2.Add(new XAttribute("Name", current));
- xElement2.Add(new XAttribute("Val", _dictionary[current]));
- xElement.Add(xElement2);
- }
- }
- finally
- {
- //Dictionary<string, string>.KeyCollection.Enumerator enumerator;
- //enumerator.Dispose();
- }
- return xElement;
- }
- /// <summary>
- /// Values from percent.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromPercent(float aPercent)
- {
- float result = 0f;
- switch (_scaleMode2)
- {
- case ValueScalerArithmetic.enumScaleMethod.eArithmetic:
- result = ValueFromPercentArithmetic(aPercent);
- break;
- case ValueScalerArithmetic.enumScaleMethod.eLog:
- result = ValueFromPercentLog(aPercent);
- break;
- case ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning:
- result = ValueFromPercentComparison(aPercent);
- break;
- }
- return result;
- }
- /// <summary>
- /// Values from percent arithmetic.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromPercentArithmetic(float aPercent)
- {
- bool flag = aPercent == 0f;
- float result = 0f;
- if (flag)
- {
- bool flag2 = _inverse;
- if (flag2)
- {
- result = _max;
- }
- else
- {
- result = _min;
- }
- }
- else
- {
- bool flag2 = _inverse;
- if (flag2)
- {
- result = (_max - _min) * (1f - aPercent) + _min;
- }
- else
- {
- result = (_max - _min) * aPercent + _min;
- }
- }
- return result;
- }
- /// <summary>
- /// Values from percent comparison.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromPercentComparison(float aPercent)
- {
- bool flag = aPercent == 0f;
- float num;
- if (flag)
- {
- bool flag2 = _inverse;
- if (flag2)
- {
- num = _max;
- }
- else
- {
- num = _min;
- }
- }
- else
- {
- bool flag2 = _inverse;
- if (flag2)
- {
- num = (_max - _min) * (1f - aPercent) + _min;
- }
- else
- {
- num = (_max - _min) * aPercent + _min;
- }
- }
- return _percentBaseline + _percentBaseline * num;
- }
- /// <summary>
- /// 分时图中的刻度线
- /// </summary>
- /// <param name="aPercent">百分比</param>
- /// <returns></returns>
- public float ValueFromTimeSpaningPercent(float aPercent)
- {
- return _percentBaseline + _percentBaseline * aPercent;
- }
- /// <summary>
- /// Values from percent display.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromPercentDisplay(float aPercent)
- {
- bool flag = _scaleMode2 == ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning
- && _percentScale;
- float result;
- if (flag)
- {
- result = ValueFromPercentArithmetic(aPercent) * 100f;
- }
- else
- {
- result = ValueFromPercent(aPercent);
- }
- return result;
- }
- /// <summary>
- /// Values from percent log.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromPercentLog(float aPercent)
- {
- float result = 0f;
- try
- {
- bool flag = _inverse;
- if (flag)
- {
- result = (float)Math.Pow(10.0, (double)((_logMax - _logMin) * (1f - aPercent) + _logMin));
- }
- else
- {
- result = (float)Math.Pow(10.0, (double)((_logMax - _logMin) * aPercent + _logMin));
- }
- }
- catch (Exception expr_8E)
- {
- ProjectData.SetProjectError(expr_8E);
- ProjectData.ClearProjectError();
- }
- return result;
- }
- /// <summary>
- /// Values from Y.
- /// </summary>
- /// <param name="aY">A Y.</param>
- /// <param name="aRect">A rect.</param>
- /// <returns>System.Single.</returns>
- public float ValueFromY(float aY, Rect aRect)
- {
- float aPercent = (float)(((double)aY - aRect.Bottom) / (aRect.Top - aRect.Bottom));
- return ValueFromPercent(aPercent);
- }
- /// <summary>
- /// Ys from percent.
- /// </summary>
- /// <param name="aPercent">A percent.</param>
- /// <param name="aRect">A rect.</param>
- /// <returns>System.Single.</returns>
- public float YFromPercent(float aPercent, Rect aRect)
- {
- float num = (float)(aRect.Height - 1.0);
- bool flag = num <= 0f;
- if (flag)
- {
- num = 1E-05f;
- }
- return (float)checked((int)Math.Round(unchecked(aRect.Top + (double)((1f - aPercent) * num))));
- }
- #endregion Public Methods
- #region Internal Methods
- /// <summary>
- /// Determines whether [is P change from beginning].
- /// </summary>
- /// <returns><c>true</c> if [is P change from beginning]; otherwise, <c>false</c>.</returns>
- internal bool IsPChangeFromBeginning()
- {
- return _scaleMode2 == ValueScalerArithmetic.enumScaleMethod.ePChangeFromBeginning;
- }
- #endregion Internal Methods
- #region Protected Methods
- /// <summary>
- /// Gets the property.
- /// </summary>
- /// <param name="aName">A name.</param>
- /// <returns>System.String.</returns>
- protected string GetProperty(string aName)
- {
- string result = null;
- bool flag = _dictionary.ContainsKey(aName);
- if (flag)
- {
- result = _dictionary[aName];
- }
- return result;
- }
- /// <summary>
- /// Sets the min max arithmetic.
- /// </summary>
- protected void SetMinMaxArithmetic()
- {
- bool flag;
- switch (BoundingMethod)
- {
- case enumScaleBounding.eMaxMin:
- switch (MaxMode)
- {
- case enumMaxMinValueMode.eMaxMin:
- _max = _high;
- break;
- case enumMaxMinValueMode.eManual:
- _max = ManualMax;
- break;
- }
- switch (MinMode)
- {
- case enumMaxMinValueMode.eMaxMin:
- _min = _low;
- break;
- case enumMaxMinValueMode.eManual:
- _min = ManualMin;
- break;
- }
- flag = (MaxAddPercent > 0f || MinAddPercent > 0f);
- if (flag)
- {
- double num = (double)(MaxAddPercent / 100f);
- double num2 = (double)(MinAddPercent / 100f);
- double num3 = 1.0 - (num + num2);
- double num4 = (double)(_max - _min);
- flag = (num3 > 0.0);
- if (flag)
- {
- _max = (float)((double)_max + num4 * (num / num3));
- _min = (float)((double)_min - num4 * (num2 / num3));
- }
- }
- break;
- case enumScaleBounding.eCentered:
- {
- _max = _high;
- _min = _low;
- float num5 = ManualCenter;
- flag = (CenterMode == enumCenteredValueMode.eMedian);
- if (flag)
- {
- num5 = _max / 2f + _min / 2f;
- }
- switch (HeightMode)
- {
- case enumCenteredHeight.eAuto:
- {
- float num6 = Math.Max(Math.Abs(_max - num5), Math.Abs(num5 - _min));
- _max = num5 + num6;
- _min = num5 - num6;
- break;
- }
- case enumCenteredHeight.eManual:
- _max = num5 + ManualHeight / 2f;
- _min = num5 - ManualHeight / 2f;
- break;
- }
- break;
- }
- }
- bool arg_24E_0;
- if (!float.IsNaN(_min) && !float.IsInfinity(_min))
- {
- if (!float.IsNaN(_min))
- {
- if (!float.IsInfinity(_min))
- {
- arg_24E_0 = false;
- goto IL_24E;
- }
- }
- }
- //IL_24D:
- arg_24E_0 = true;
- //goto IL_24E;
- //goto IL_24D;
- IL_24E:
- flag = arg_24E_0;
- if (flag)
- {
- _min = 0f;
- _max = 0f;
- }
- flag = (_max != _min);
- if (flag)
- {
- _diffInverse = 1f / (_max - _min);
- }
- else
- {
- _diffInverse = 0f;
- }
- }
- /// <summary>
- /// Sets the min max comparison.
- /// </summary>
- protected void SetMinMaxComparison()
- {
- _max = _high;
- _min = _low;
- bool flag = MaxAddPercent > 0f || MinAddPercent > 0f;
- if (flag)
- {
- double num = (double)(MaxAddPercent / 100f);
- double num2 = (double)(MinAddPercent / 100f);
- double num3 = 1.0 - (num + num2);
- double num4 = (double)(_max - _min);
- flag = (num3 > 0.0);
- if (flag)
- {
- _max = (float)((double)_max + num4 * (num / num3));
- _min = (float)((double)_min - num4 * (num2 / num3));
- }
- }
- float num5 = _max - _min;
- _max += num5 * 3f / 100f;
- _min -= num5 * 3f / 100f;
- bool arg_14F_0;
- if (!float.IsNaN(_min) && !float.IsInfinity(_min))
- {
- if (!float.IsNaN(_min))
- {
- if (!float.IsInfinity(_min))
- {
- arg_14F_0 = false;
- goto IL_14F;
- }
- }
- }
- arg_14F_0 = true;
- IL_14F:
- flag = arg_14F_0;
- if (flag)
- {
- _min = 0f;
- _max = 0f;
- }
- flag = (_max != _min);
- if (flag)
- {
- _diffInverse = 1f / (_max - _min);
- }
- else
- {
- _diffInverse = 0f;
- }
- }
- /// <summary>
- /// 设置分时图最大最小值
- /// </summary>
- private void SetMinMaxTimeSpaning()
- {
- _max = _high;
- _min = _low;
- bool flag = MaxAddPercent > 0f || MinAddPercent > 0f;
- //if (flag)
- //{
- // double num = (double)(MaxAddPercent / 100f);
- // double num2 = (double)(MinAddPercent / 100f);
- // double num3 = 1.0 - (num + num2);
- // double num4 = (double)(_max - _min);
- // flag = (num3 > 0.0);
- // if (flag)
- // {
- // _max = (float)((double)_max + num4 * (num / num3));
- // _min = (float)((double)_min - num4 * (num2 / num3));
- // }
- //}
- //float num5 = _max - _min;
- //_max += num5 * 3f / 100f;
- //_min -= num5 * 3f / 100f;
- bool arg_14F_0;
- if (!float.IsNaN(_min) && !float.IsInfinity(_min))
- {
- if (!float.IsNaN(_min))
- {
- if (!float.IsInfinity(_min))
- {
- arg_14F_0 = false;
- goto IL_14F;
- }
- }
- }
- arg_14F_0 = true;
- IL_14F:
- flag = arg_14F_0;
- if (flag)
- {
- _min = 0f;
- _max = 0f;
- }
- flag = (_max != _min);
- if (flag)
- {
- _diffInverse = 1f / (_max - _min);
- }
- else
- {
- _diffInverse = 0f;
- }
- }
- /// <summary>
- /// Sets the min max log.
- /// </summary>
- protected void SetMinMaxLog()
- {
- bool flag = _high <= 0f;
- float num;
- if (flag)
- {
- num = (float)Math.Log10(0.01);
- }
- else
- {
- num = (float)Math.Log10((double)_high);
- }
- flag = (_low <= 0f);
- float num2;
- if (flag)
- {
- num2 = (float)Math.Log10(0.01);
- }
- else
- {
- num2 = (float)Math.Log10((double)_low);
- }
- switch (BoundingMethod)
- {
- case ValueScalerArithmetic.enumScaleBounding.eMaxMin:
- switch (MaxMode)
- {
- case ValueScalerArithmetic.enumMaxMinValueMode.eMaxMin:
- _max = num;
- break;
- case ValueScalerArithmetic.enumMaxMinValueMode.eManual:
- flag = (ManualMax <= 0f);
- if (flag)
- {
- _max = (float)Math.Log10(0.01);
- }
- else
- {
- _max = (float)Math.Log10((double)ManualMax);
- }
- break;
- }
- switch (MinMode)
- {
- case ValueScalerArithmetic.enumMaxMinValueMode.eMaxMin:
- _min = num2;
- break;
- case ValueScalerArithmetic.enumMaxMinValueMode.eManual:
- flag = (ManualMin <= 0f);
- if (flag)
- {
- _min = (float)Math.Log10(0.01);
- }
- else
- {
- _min = (float)Math.Log10((double)ManualMin);
- }
- break;
- }
- flag = (MaxAddPercent > 0f || MinAddPercent > 0f);
- if (flag)
- {
- double num3 = (double)(MaxAddPercent / 100f);
- double num4 = (double)(MinAddPercent / 100f);
- double num5 = 1.0 - (num3 + num4);
- double num6 = (double)(_max - _min);
- flag = (num5 > 0.0);
- if (flag)
- {
- _max = (float)((double)_max + num6 * (num3 / num5));
- _min = (float)((double)_min - num6 * (num4 / num5));
- }
- }
- break;
- case ValueScalerArithmetic.enumScaleBounding.eCentered:
- {
- flag = (ManualCenter <= 0f);
- float num7;
- if (flag)
- {
- num7 = (float)Math.Log10(0.01);
- }
- else
- {
- num7 = (float)Math.Log10((double)ManualCenter);
- }
- _max = num;
- _min = num2;
- flag = (CenterMode == ValueScalerArithmetic.enumCenteredValueMode.eMedian);
- if (flag)
- {
- num7 = _max / 2f + _min / 2f;
- }
- switch (HeightMode)
- {
- case ValueScalerArithmetic.enumCenteredHeight.eAuto:
- {
- float num8 = Math.Max(Math.Abs(_max - num7), Math.Abs(num7 - _min));
- _max = num7 + num8;
- _min = num7 - num8;
- break;
- }
- case ValueScalerArithmetic.enumCenteredHeight.eManual:
- {
- flag = (ManualHeight <= 0f);
- float num9;
- if (flag)
- {
- num9 = (float)Math.Log10(0.01);
- }
- else
- {
- num9 = (float)Math.Log10((double)ManualHeight);
- }
- float num10 = (float)((double)ManualHeight / Math.Pow(10.0, (double)num7));
- float num11 = (float)(((double)(-1f * num10) + Math.Sqrt(Math.Pow((double)num10, 2.0) + 4.0)) / 2.0);
- float num12 = (float)((double)ManualHeight / Math.Pow(10.0, (double)num7));
- num9 = (float)(-1.0 * (Math.Log10((double)num12) / 2.0));
- num9 = (float)Math.Log10((double)num11);
- _max = num7 - num9;
- _min = num7 + num9;
- break;
- }
- }
- break;
- }
- }
- _logMax = _max;
- _logMin = _min;
- flag = (_logMax != _logMin);
- if (flag)
- {
- _logDiffInverse = 1f / (_logMax - _logMin);
- }
- else
- {
- _logDiffInverse = 0f;
- }
- }
- /// <summary>
- /// Sets the property.
- /// </summary>
- /// <param name="aName">A name.</param>
- /// <param name="newVal">The new val.</param>
- protected void SetProperty(string aName, string newVal)
- {
- _dictionary[aName] = newVal;
- }
- #endregion Protected Methods
- #region Private Methods
- /// <summary>
- /// Gets the scale mode string.
- /// </summary>
- /// <returns>System.String.</returns>
- private string GetScaleModeString()
- {
- return _scaleMode.ToString();
- }
- /// <summary>
- /// Determines whether [has price history] [the specified plots].
- /// </summary>
- /// <param name="plots">The plots.</param>
- /// <param name="scaler">The scaler.</param>
- /// <param name="isTimeSpaning">if set to <c>true</c> [is time spaning].</param>
- /// <returns><c>true</c> if [has price history] [the specified plots]; otherwise, <c>false</c>.</returns>
- private bool HasPriceHistory(List<PlotBase> plots, IDateScaler scaler, bool isTimeSpaning)
- {
- if (plots == null || !plots.Any()) return false;
- foreach (var plot in plots)
- {
- if (plot == null || plot.Indicator == null || plot.Indicator.ParentFormula == null) continue;
- bool flag = plot.Indicator.ParentFormula.IsMain || isTimeSpaning;
- if (flag)
- {
- UpdatePercentBaseline((LinePlot)plot, scaler);
- return true;
- }
- }
- return false;
- }
- /// <summary>
- /// Called when [scale properties changed].
- /// </summary>
- private void OnScalePropertiesChanged()
- {
- if (ScalePropertiesChanged != null)
- {
- ScalePropertiesChanged();
- }
- }
- /// <summary>
- /// Scales the only price.
- /// </summary>
- /// <param name="plots">The plots.</param>
- /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
- private bool ScaleOnlyPrice(List<PlotBase> plots)
- {
- if (plots == null || !plots.Any()) return false;
- return true;
- //return (from current in plots
- // let flag = current.Calculation() is PriceHistoryCalculation
- // where flag
- // select ((PriceHistoryCalculation)current.Calculation()).ScaleOnlyPrice).Any(scaleOnlyPrice => scaleOnlyPrice);
- }
- /// <summary>
- /// Updates the high and low.
- /// </summary>
- /// <param name="dat">The dat.</param>
- /// <param name="scaler">The scaler.</param>
- /// <param name="allowOhlc">if set to <c>true</c> [allow OHLC].</param>
- private void UpdateHighAndLow(IndicatorModel dat, IDateScaler scaler, bool allowOhlc)
- {
- if (dat == null || dat.CalculateDataPoints == null || !dat.CalculateDataPoints.Any()) return;
- foreach (var current in dat.CalculateDataPoints)
- {
- var visible = scaler.DateVisible(current.Date);
- if (!visible) continue;
- if (allowOhlc && (current is IOHLCDataPoint))
- {
- var iohlcDataPoint = (IOHLCDataPoint)current;
- if (_flag)
- {
- if (!float.IsNaN(iohlcDataPoint.High)) _high = Math.Max(_high, iohlcDataPoint.High);
- if (!float.IsNaN(iohlcDataPoint.Low)) _low = Math.Min(_low, iohlcDataPoint.Low);
- }
- else
- {
- _low = iohlcDataPoint.Low;
- _high = iohlcDataPoint.High;
- _flag = true;
- }
- }
- else
- {
- float value = current.Value;
- if (float.IsNaN(value)) continue;
- if (_flag)
- {
- _high = Math.Max(_high, value);
- _low = Math.Min(_low, value);
- }
- else
- {
- _low = value;
- _high = value;
- _flag = true;
- }
- }
- }
- }
- /// <summary>
- /// Updates the max and min.
- /// </summary>
- /// <param name="dat">The dat.</param>
- /// <param name="scaler">The scaler.</param>
- private void UpdateMaxAndMin(IndicatorModel dat, IDateScaler scaler)
- {
- bool flag = false;
- float num = 0f;
- bool flag2 = dat != null && dat.CalculateDataPoints != null;
- checked
- {
- if (flag2)
- {
- var list = dat.CalculateDataPoints;
- int num2 = list.Count - 1;
- int num3 = 0;
- while (true)
- {
- int num4 = num2;
- if (num3 > num4)
- {
- break;
- }
- flag2 = scaler.DateVisible(list[num3].Date);
- if (flag2)
- {
- bool flag3 = !flag;
- if (flag3)
- {
- num = list[num3].Value;
- flag = true;
- }
- float num5 = unchecked(list[num3].Value - num) / num;
- _maxValue = Math.Max(_maxValue, num5);
- _minValue = Math.Min(_minValue, num5);
- }
- num3++;
- }
- }
- }
- }
- /// <summary>
- /// Updates the percent baseline.
- /// </summary>
- /// <param name="aPlot">A plot.</param>
- /// <param name="scaler">The scaler.</param>
- private void UpdatePercentBaseline(LinePlot aPlot, IDateScaler scaler)
- {
- if (IsTimeSpaning)
- {
- _percentBaseline = TimeSpaningLast;
- }
- else
- {
- _percentBaseline = 0f;
- var lineDataSet = aPlot.GetDataSet();
- if (lineDataSet == null || lineDataSet.CalculateDataPoints == null ||
- !lineDataSet.CalculateDataPoints.Any()) return;
- //var firstIndex = scaler.FirstVisibleIndexFromData(lineDataSet.CalculateDataPoints);
- //var first = lineDataSet.CalculateDataPoints[firstIndex];
- //if (first == null) return;
- //var dataPoint = first as IOHLCDataPoint;
- //_percentBaseline = dataPoint == null ? first.Value : dataPoint.Close;
- //使用最后一点做现价线
- var endIndex = scaler.LastVisibleIndexFromData(lineDataSet.CalculateDataPoints);
- var end = lineDataSet.CalculateDataPoints[endIndex];
- if (end == null) return;
- var dataPoint = end as IOHLCDataPoint;
- _percentBaseline = dataPoint == null ? end.Value : dataPoint.Close;
- }
- }
- #endregion Private Methods
- #endregion Methods
- public bool IsTimeSpaning
- {
- get;
- set;
- }
- public float TimeSpaningLast
- {
- get;
- set;
- }
- }
- }
|