| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646 |
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using MuchInfo.Chart.Data.EnumTypes;
- using MuchInfo.Chart.Infrastructure.Helpers;
- using MuchInfo.Chart.WPF.Controls.ValueScaling;
- using MuchInfo.Chart.WPF.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Windows.Shapes;
- namespace MuchInfo.Chart.WPF.Primitives
- {
- public class ValueScaleDisplay : Canvas
- {
- #region Fields
- //private const int c_TimeSpaning = 3; //设置分时图显示网络是图表字体的多少倍,控制网格数量
- private const int c_TimeSpaningGridCount = 8; //设置显示分时图显示图表风格数量
- protected ValueScaleDisplay.ValueScaleMode mArithScaleMode;
- protected Color mBorderColor;
- protected List<float> mDivisors;
- protected bool mDrawGridLines;
- protected ValueScaleDisplay.ValueScaleMode mExpScaleMode;
- private Brush _upBrush = Brushes.Red;
- /// <summary>
- /// 设置涨时的图表的颜色
- /// </summary>
- public Brush UpBrush
- {
- get { return _upBrush; }
- set { _upBrush = value; }
- }
- private Brush _downBrush = Brushes.SeaGreen;
- /// <summary>
- /// 设置下跌里图表的颜色
- /// </summary>
- public Brush DownBrush
- {
- get { return _downBrush; }
- set { _downBrush = value; }
- }
- private Brush _lastBrush = Brushes.White;
- public Brush LastBrush
- {
- get { return _lastBrush; }
- set { _lastBrush = value; }
- }
- /// <summary>
- /// 小数位数
- /// </summary>
- protected int mFormatSigDigits;
- protected int mLineOpacity;
- protected DoubleCollection mLineStyle;
- protected ValueScaleDisplay.ValueScaleMode mLogScaleMode;
- protected Color mPercentColor;
- protected bool mShowScaleControls;
- protected bool mTextAlignLeft;
- protected ValueScaleDisplay.LRPlacement mTextPos;
- protected float _curNet;
- protected float _curPercent;
- protected float _divisor;
- protected float _fixedPercent;
- protected int _lineCount;
- private bool _allowAbbreviate;
- private ValueScaleBufferAdjuster _bottomAdjuster;
- private Chart _chart;
- private ChartPane _chartPane;
- private bool _flag2;
- private bool _flag3;
- private Color _lineColor;
- private Rect _rect;
- private ScaleLayer _scalelayer;
- private ValueScaleBufferAdjuster _topAdjuster;
- /// <summary>
- /// Y轴面板
- /// </summary>
- private Canvas _yCanvas;
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> _yList;
- private float _yValue;
- #endregion Fields
- #region Constructors
- public ValueScaleDisplay(IValueScaler valueScaler)
- {
- base.SizeChanged -= (new SizeChangedEventHandler(this.ValueScaleDisplay_SizeChanged));
- base.SizeChanged += (new SizeChangedEventHandler(this.ValueScaleDisplay_SizeChanged));
- this._scalelayer = null;
- this._lineCount = 5;
- this._divisor = 1f;
- this._fixedPercent = 1f;
- this.mFormatSigDigits = 2;
- this.mArithScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
- this.mLogScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
- this.mExpScaleMode = ValueScaleDisplay.ValueScaleMode.Auto;
- this.mTextPos = ValueScaleDisplay.LRPlacement.Right;
- this._lineColor = Colors.LightGray;
- this.mBorderColor = Colors.LightGray;
- this.mPercentColor = Colors.Red;
- this.mDrawGridLines = true;
- this.mTextAlignLeft = true;
- this.mShowScaleControls = false;
- this.mLineStyle = new DoubleCollection();
- this.mLineOpacity = 10;
- this.mDivisors = new List<float>();
- this._flag2 = false;
- this._yValue = 0f;
- this._flag3 = false;
- this._allowAbbreviate = false;
- this.InitializeDivisors();
- this._topAdjuster = new ValueScaleBufferAdjuster();
- this._bottomAdjuster = new ValueScaleBufferAdjuster();
- this._yCanvas = new Canvas();
- this.Children.Add(this._yCanvas);
- this.CurrentValueScaler = valueScaler;
- }
- #endregion Constructors
- #region Enumerations
- public enum LRPlacement
- {
- Right,
- Left,
- None
- }
- public enum ValueScaleMode
- {
- Auto,
- Manual,
- LineCount,
- MaxLines,
- AutoPercent
- }
- public enum ValueScalePaintMode
- {
- AutoScale,
- AutoDivisor,
- AutoPercentScale,
- Divisor,
- FixedPercent,
- LineCount,
- }
- #endregion Enumerations
- #region Properties
- #region Public Properties
- public Color BorderColor
- {
- get
- {
- return this.mBorderColor;
- }
- set
- {
- this.mBorderColor = value;
- this.RefreshChart();
- }
- }
- public float Divisor
- {
- get
- {
- return this._divisor;
- }
- set
- {
- bool flag = this._divisor != value;
- if (flag)
- {
- this._divisor = value;
- this.RefreshChart();
- }
- }
- }
- public bool DrawGridLines
- {
- get
- {
- return this.mDrawGridLines;
- }
- set
- {
- this.mDrawGridLines = value;
- this.RefreshChart();
- }
- }
- public float FixedPercent
- {
- get
- {
- return this._fixedPercent;
- }
- set
- {
- bool flag = this._fixedPercent != value;
- if (flag)
- {
- this._fixedPercent = value;
- this.RefreshChart();
- }
- }
- }
- /// <summary>
- /// 小数位数
- /// </summary>
- public int FormatSignificantDigits
- {
- get
- {
- return this.mFormatSigDigits;
- }
- set
- {
- this.mFormatSigDigits = value;
- }
- }
- public DoubleCollection GridLineStyle
- {
- get
- {
- return this.mLineStyle;
- }
- set
- {
- this.mLineStyle = value;
- this.RefreshChart();
- }
- }
- public Color LineColor
- {
- get
- {
- return this._lineColor;
- }
- set
- {
- this._lineColor = value;
- this.RefreshChart();
- }
- }
- public int LineCount
- {
- get
- {
- return this._lineCount;
- }
- set
- {
- bool flag = this._lineCount != value;
- if (flag)
- {
- this._lineCount = value;
- this.RefreshChart();
- }
- }
- }
- public Color PercentColor
- {
- get
- {
- return this.mPercentColor;
- }
- set
- {
- this.mPercentColor = value;
- this.RefreshChart();
- }
- }
- public ScaleLayer ScaleLayer
- {
- get
- {
- return this._scalelayer;
- }
- set
- {
- this._scalelayer = value;
- }
- }
- public ValueScaleDisplay.ValueScaleMode ScaleMode
- {
- get
- {
- bool flag = CurrentValueScaler is ValueScalerArithmetic;
- ValueScaleDisplay.ValueScaleMode result;
- if (flag)
- {
- result = this.mArithScaleMode;
- }
- else
- {
- result = ValueScaleDisplay.ValueScaleMode.Auto;
- }
- return result;
- }
- set
- {
- bool flag = CurrentValueScaler is ValueScalerArithmetic;
- if (flag)
- {
- this.mArithScaleMode = value;
- }
- this.RefreshChart();
- }
- }
- public bool ShowScaleControls
- {
- get
- {
- return this.mShowScaleControls;
- }
- set
- {
- this.mShowScaleControls = value;
- this.RefreshChart();
- }
- }
- public bool TextAlignLeft
- {
- get
- {
- return this.mTextAlignLeft;
- }
- set
- {
- this.mTextAlignLeft = value;
- this.RefreshChart();
- }
- }
- public ValueScaleDisplay.LRPlacement ValueOrientation
- {
- get
- {
- return this.mTextPos;
- }
- set
- {
- this.mTextPos = value;
- this.RefreshChart();
- }
- }
- #endregion Public Properties
- #region Internal Properties
- internal IValueScaler CurrentValueScaler
- {
- get;
- set;
- }
- #endregion Internal Properties
- #region Private Properties
- private ValueScaleDisplay.ValueScalePaintMode TextMode
- {
- get
- {
- bool flag = CurrentValueScaler is ValueScalerArithmetic;
- var result = new ValueScalePaintMode();
- if (flag)
- {
- switch (this.mArithScaleMode)
- {
- case ValueScaleDisplay.ValueScaleMode.Auto:
- result = ValueScaleDisplay.ValueScalePaintMode.AutoDivisor;
- break;
- case ValueScaleDisplay.ValueScaleMode.Manual:
- result = ValueScaleDisplay.ValueScalePaintMode.Divisor;
- break;
- case ValueScaleDisplay.ValueScaleMode.LineCount:
- result = ValueScaleDisplay.ValueScalePaintMode.LineCount;
- break;
- case ValueScaleDisplay.ValueScaleMode.MaxLines:
- result = ValueScaleDisplay.ValueScalePaintMode.AutoScale;
- break;
- }
- }
- return result;
- }
- }
- #endregion Private Properties
- #endregion Properties
- #region Methods
- #region Internal Methods
- internal void BuildYList(ChartPane aPane, Rect theRect)
- {
- this._chartPane = aPane;
- bool flag = aPane == null;
- if (!flag)
- {
- var aRect = new Rect(theRect.X, theRect.Y + aPane.GetActualHeight(), theRect.Width, theRect.Height);
- this._rect = theRect;
- flag = this.CurrentValueScaler.Spread().Equals(0f);
- if (flag)
- {
- this._yCanvas.Children.Clear();
- }
- else
- {
- Color color = Colors.White;
- flag = (this._scalelayer != null && this._scalelayer.AllPlots.Count > 0);
- if (flag)
- {
- color = this._scalelayer.AllPlots[0].GetPlotColor();
- }
- this._allowAbbreviate = true;
- // if (aPane.IsPriceHistory) this._allowAbbreviate = false;
- if (aPane.IsPriceHistory) this._allowAbbreviate = false;
- var height = (float)this.ActualHeight;
- var list = new List<UIElement>();
- var list2 = this._yList ?? this.GetYList(height, CurrentValueScaler, aPane.IsTimeSpaning);
- var fontFamily = new FontFamily("Verdana");
- var foreground = new SolidColorBrush(color);
- if (list2 != null && list2.Any())
- {
- if (!aPane.IsTimeSpaning)
- {
- foreach (var current in list2)
- {
- if (!current.Value.Equals(float.NaN))
- {
- float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
- var textBlock = new TextBlock
- {
- Text = current.Text,
- FontSize = ((double)this.FontSize()),
- FontFamily = (fontFamily),
- Foreground = (foreground),
- //Width = this.FontSize()*current.Text.Length*0.7
- //固定长度,否则绘图区大小写会变动
- Width = this.FontSize() * 7 * 0.7
- };
- //根据字符长度计算控件宽度
- textBlock.SetValue(Canvas.LeftProperty, 3.0);
- textBlock.SetValue(Canvas.TopProperty, (double)num - (double)this.FontSize() * 0.6);
- list.Add(textBlock);
- }
- }
- }
- else //设置分时图刻度颜色
- {
- foreach (var current in list2)
- {
- if (!current.Value.Equals(float.NaN))
- {
- float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
- var textBlock = new TextBlock
- {
- Text = current.Text,
- FontSize = ((double)this.FontSize()),
- FontFamily = (fontFamily),
- Width = TreeHelper.GetTextWidth(fontFamily, this.FontSize(), current.Text) //this.FontSize()*current.Text.Length*0.7
- };
- float valueNum = CurrentValueScaler.ValueFromPercent(current.Value);
- if (CurrentValueScaler.GetPercentBaseline() > valueNum) //设置红涨绿跌
- {
- textBlock.Foreground = this.DownBrush;
- }
- else if (CurrentValueScaler.GetPercentBaseline() < valueNum)
- {
- textBlock.Foreground = this.UpBrush;
- }
- else
- {
- textBlock.Foreground = LastBrush;
- }
- //根据字符长度计算控件宽度
- textBlock.SetValue(Canvas.LeftProperty, 3.0);
- textBlock.SetValue(Canvas.TopProperty, (double)num - (double)this.FontSize() * 0.6);
- list.Add(textBlock);
- }
- }
- }
- }
- this._flag3 = false;
- var flag2 = (this._scalelayer != null && this._scalelayer.AllPlots.Count > 0);
- //不添加默认数据显示
- //if (flag2)
- //{
- // PlotBase plotBase = this._scalelayer.AllPlots()[0];
- // flag2 = (plotBase is LinePlot);
- // if (flag2)
- // {
- // var linePlot = (LinePlot)plotBase;
- // flag2 = (linePlot.GetDataSet() != null && linePlot.GetDataSet().DataPoints != null && linePlot.GetDataSet().DataPoints.Count > 0);
- // if (flag2)
- // {
- // float num2 = linePlot.GetDataSet().DataPoints[linePlot.GetDataSet().DataPoints.Count - 1].Value;
- // float valY = CurrentValueScaler.ScaledY(num2, aRect);
- // //超出范围不添加
- // if (valY > 0 && valY < aRect.Height) list.Add(this.BuildDisplayBorder(valY, num2));
- // }
- // }
- //}
- this._flag3 = this.IsPChangeFromBeginning();
- if (_flag2)
- {
- float txtVal = CurrentValueScaler.ValueFromPercentDisplay((float)((aRect.Bottom - (double)this._yValue) / aRect.Height));
- list.Add(this.BuildDisplayBorder(this._yValue, txtVal));
- }
- this._yCanvas.Children.Clear();
- if (list.Any())
- {
- foreach (var current in list)
- {
- this._yCanvas.Children.Add(current);
- }
- }
- //计算rightcontrol 宽度
- double width = 0;
- if (_yCanvas.Children != null && _yCanvas.Children.Count > 0)
- {
- var textBlocks = _yCanvas.Children.OfType<TextBlock>().Where(z => !z.Width.Equals(0));
- var enumerable = textBlocks as IList<TextBlock> ?? textBlocks.ToList();
- if (enumerable.Any())
- {
- width = enumerable.Max(z => z.Width);
- }
- }
- this.Width = Math.Max(width, 50);
- bool flag3 = true;
- flag2 = (CurrentValueScaler is ValueScalerArithmetic);
- if (flag2)
- {
- flag = (((ValueScalerArithmetic)CurrentValueScaler).BoundingMethod ==
- ValueScalerArithmetic.enumScaleBounding.eCentered);
- if (flag)
- {
- flag3 = false;
- }
- }
- else
- {
- flag3 = false;
- }
- flag2 = flag3;// && this.chartContainer.ShowMarginGrabs);
- if (flag2)
- {
- var valueScalerArithmetic = (ValueScalerArithmetic)CurrentValueScaler;
- this._topAdjuster.SetValues(this._chart, this._scalelayer.GetLeftValueScaleDisplay(), this._scalelayer.GetRightValueScaleDisplay(), true);
- var num8 = (double)(1f - valueScalerArithmetic.MaxAddPercent / 100f);
- this._topAdjuster.SetValue(Canvas.TopProperty, (double)valueScalerArithmetic.YFromPercent((float)num8, theRect));
- this._bottomAdjuster.SetValues(this._chart, this._scalelayer.GetLeftValueScaleDisplay(), this._scalelayer.GetRightValueScaleDisplay(), false);
- num8 = (double)(valueScalerArithmetic.MinAddPercent / 100f);
- var num9 = (double)valueScalerArithmetic.YFromPercent((float)num8, theRect);
- flag2 = (num9 + 4.0 > theRect.Bottom);
- if (flag2)
- {
- num9 = theRect.Bottom - 4.0;
- }
- this._bottomAdjuster.SetValue(Canvas.TopProperty, num9);
- this._topAdjuster.Visibility = Visibility.Visible;
- this._bottomAdjuster.Visibility = Visibility.Visible;
- }
- else
- {
- this._topAdjuster.Visibility = Visibility.Collapsed;
- this._bottomAdjuster.Visibility = Visibility.Collapsed;
- }
- }
- }
- }
- internal void BuildYList(float aY)
- {
- this._flag2 = true;
- this._yValue = aY;
- try
- {
- this.BuildYList(this._chartPane, this._rect);
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- }
- internal void BuildYList()
- {
- this._flag2 = false;
- try
- {
- this.BuildYList(this._chartPane, this._rect);
- }
- catch (Exception expr_3F)
- {
- ProjectData.SetProjectError(expr_3F);
- ProjectData.ClearProjectError();
- }
- }
- internal double FontSize()
- {
- bool flag = this._chart != null;
- double result;
- if (flag)
- {
- result = this._chart.ChartFontSize;
- }
- else
- {
- result = 12f;
- }
- return result;
- }
- internal ValueScaleBufferAdjuster GetBottomAdjuster()
- {
- return this._bottomAdjuster;
- }
- internal ValueScaleBufferAdjuster GetTopAdjuster()
- {
- return this._topAdjuster;
- }
- internal double GetValuePercent(double aY)
- {
- bool flag = this._chartPane != null;
- double result;
- if (flag)
- {
- Rect rect = new Rect(this._rect.X, this._rect.Y + this._chartPane.GetActualHeight(), this._rect.Width, this._rect.Height);
- flag = (rect.Height != 0.0);
- if (flag)
- {
- result = 1.0 - (aY - rect.Top) / rect.Height;
- return result;
- }
- }
- result = 0.0;
- return result;
- }
- internal List<FrameworkElement> GetValueScaleDisplay(Chart theChart, IDateScaler dateScale,
- Rect aRect, List<ValueScaleDisplay.ValueScaleDisplay_Y> ylist, bool drawGridLines, bool isTimeSpaning)
- {
- var list = new List<FrameworkElement>();
- this._chart = theChart;
- var path = new Path { IsHitTestVisible = (false) };
- list.Add(path);
- this._flag3 = this.IsPChangeFromBeginning();
- bool flag = CurrentValueScaler.Spread().Equals(0);
- List<FrameworkElement> result;
- if (flag)
- {
- result = list;
- }
- else
- {
- path.UseLayoutRounding = true;
- var geometryGroup = new GeometryGroup();
- if (theChart.CycleType == CycleType.TimeSharing)
- {
- path.Stroke = theChart.TimeSharingGridBrush.Clone();
- path.Stroke.Opacity = theChart.GridOpacity;
- }
- else
- {
- var solidColorBrush = new SolidColorBrush { Color = this._lineColor, Opacity = theChart.GridOpacity };
- path.Stroke = solidColorBrush;
- path.StrokeThickness = 1.0;
- }
- var list2 = ylist == null ? this.GetYList((float)aRect.Height, CurrentValueScaler, isTimeSpaning) : UpdateYList(ylist);
- this._yList = list2;
- if (list2 != null && list2.Any())
- {
- foreach (var current in list2)
- {
- if (!current.Value.Equals(float.NaN))
- {
- float num = CurrentValueScaler.YFromPercent(current.Value, aRect);
- num = (float)((double)checked((int)Math.Round((double)num)) + 0.5);
- if (this.mDrawGridLines && drawGridLines)
- {
- var lineGeometry = new LineGeometry
- {
- StartPoint = new Point(aRect.Left, (double)num),
- EndPoint = new Point(aRect.Width, (double)num)
- };
- geometryGroup.Children.Add(lineGeometry);
- }
- }
- }
- }
- if (this._flag3 && this.mDrawGridLines)
- {
- //显示百分比,画基准线
- var line = new Line
- {
- IsHitTestVisible = (false),
- Stroke = new SolidColorBrush
- {
- Color =Colors.Blue,
- Opacity = (theChart.GridOpacity * 1.5)
- },
- StrokeThickness = (3.0),
- X1 = (aRect.Left),
- X2 = (aRect.Right)
- };
- if (isTimeSpaning)
- {
- line.Stroke = theChart.TimeSharingGridBrush.Clone();
- line.Stroke.Opacity = (theChart.GridOpacity * 1.5);
- }
- float num = CurrentValueScaler.ScaledY(((ValueScalerArithmetic)CurrentValueScaler).GetPercentBaseline(), aRect);
- var y = Math.Round(num) + 0.5;
- line.Y1 = y;
- line.Y2 = y;
- list.Add(line);
- }
- path.Data = (geometryGroup);
- result = list;
- }
- return result;
- }
- internal List<ValueScaleDisplay.ValueScaleDisplay_Y> GetYList(float height, IValueScaler ValScale, bool isTimeSpaning)
- {
- if (this._chart == null || this._chart.DataSet == null || this._chart.DataSet.DataPoints == null ||
- !this._chart.DataSet.DataPoints.Any()) return null;
- bool flag = true;
- List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
- if (isTimeSpaning) //分时图显示网络线数量
- {
- result = GetTimeSpaningScaleValues(height, ValScale);
- return result;
- }
- if (flag)
- {
- switch (this.TextMode)
- {
- case ValueScaleDisplay.ValueScalePaintMode.AutoScale:
- result = this.GetAAutoScaleValues(height, ValScale);
- break;
- case ValueScaleDisplay.ValueScalePaintMode.AutoDivisor:
- result = this.GetAutoDivisorValues(height, ValScale);
- break;
- case ValueScaleDisplay.ValueScalePaintMode.AutoPercentScale:
- result = this.GetAutoPercentScaleValues(height, ValScale);
- break;
- case ValueScaleDisplay.ValueScalePaintMode.Divisor:
- result = this.GetDivisorValues(height, ValScale);
- break;
- case ValueScaleDisplay.ValueScalePaintMode.FixedPercent:
- result = this.GetFixedPercentValues(height, ValScale);
- break;
- case ValueScaleDisplay.ValueScalePaintMode.LineCount:
- result = this.GetLineCountValues(height, ValScale);
- break;
- default:
- result = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- break;
- }
- }
- else
- {
- List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = 0.01f;
- valueScaleDisplay_.SetText(ValScale.ValueFromPercentDisplay(0f), this);
- list.Add(valueScaleDisplay_);
- result = list;
- }
- return result;
- }
- #endregion Internal Methods
- #region Private Methods
- private Border BuildDisplayBorder(float valY, float txtVal)
- {
- var border = new Border
- {
- BorderThickness = new Thickness(1.0),
- CornerRadius = new CornerRadius(3.0),
- Padding = new Thickness(1.0, 0.0, 1.0, 1.0),
- BorderBrush = new SolidColorBrush(Colors.White),
- Background = new SolidColorBrush(Colors.Black)
- };
- border.SetValue(Canvas.LeftProperty, 3.0);
- border.SetValue(Canvas.TopProperty, (double)valY - (double)this.FontSize() * 0.6);
- var textBlock = new TextBlock
- {
- Text = this.ConvertToString(txtVal),
- FontSize = (double)this.FontSize(),
- FontFamily = new FontFamily("Verdana"),
- Foreground = new SolidColorBrush(Colors.White),
- };
- if (_chart.IsDarkBackground)
- {
- textBlock.Foreground = (new SolidColorBrush(Colors.White));
- border.BorderBrush = (new SolidColorBrush(Colors.White));
- border.Background = (new SolidColorBrush(Colors.Black));
- }
- else
- {
- textBlock.Foreground = (new SolidColorBrush(Colors.Black));
- border.BorderBrush = (new SolidColorBrush(Colors.Black));
- border.Background = (new SolidColorBrush(Colors.White));
- }
- border.Child = textBlock;
- return border;
- }
- /// <summary>
- /// 把数值转换为指点格式字符串(加% 或者转换成保留2位的小数)
- /// </summary>
- /// <param name="aVal"></param>
- /// <returns></returns>
- private string ConvertToString(float aVal)
- {
- if (_flag3)
- {
- return Strings.Format(aVal, "0.00") + "%";
- }
- else
- {
- return Conversions.ToString(TextFormatting.FormatNumber(aVal, this.mFormatSigDigits, this._allowAbbreviate));
- }
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetTimeSpaningScaleValues(float height, IValueScaler valScale)
- {
- var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- try
- {
- int num;
- checked
- {
- // num = (int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * c_TimeSpaning));
- // num = num % 2 == 0 ? num : num - 1; // 取偶数
- num = c_TimeSpaningGridCount;
- int num2 = 0;
- while (true)
- {
- if (num2 > num)
- {
- break;
- }
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = (float)((double)num2 / (double)num);
- valueScaleDisplay_.SetText(valScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
- list.Add(valueScaleDisplay_);
- num2++;
- }
- }
- this._curNet = valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f);
- this._curPercent = (valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f)) / valScale.ValueFromPercentDisplay(0f);
- }
- catch (Exception expr_10D)
- {
- ProjectData.SetProjectError(expr_10D);
- ProjectData.ClearProjectError();
- }
- return list;
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAAutoScaleValues(float height, IValueScaler valScale)
- {
- var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- try
- {
- int num;
- checked
- {
- num = (int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * 1.1));
- int num2 = 0;
- while (true)
- {
- if (num2 > num)
- {
- break;
- }
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = (float)((double)num2 / (double)num);
- valueScaleDisplay_.SetText(valScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
- list.Add(valueScaleDisplay_);
- num2++;
- }
- }
- this._curNet = valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f);
- this._curPercent = (valScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - valScale.ValueFromPercentDisplay(0f)) / valScale.ValueFromPercentDisplay(0f);
- }
- catch (Exception expr_10D)
- {
- ProjectData.SetProjectError(expr_10D);
- ProjectData.ClearProjectError();
- }
- return list;
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAutoDivisorValues(float height, IValueScaler ValScale)
- {
- var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
- try
- {
- float num = ValScale.ValueFromPercentDisplay(1f);
- float num2 = ValScale.ValueFromPercentDisplay(0f);
- bool flag = ValScale.Inverse;
- if (flag)
- {
- num = ValScale.ValueFromPercentDisplay(0f);
- num2 = ValScale.ValueFromPercentDisplay(1f);
- }
- flag = (float.IsInfinity(num) || float.IsNaN(num));
- if (flag)
- {
- result = list;
- return result;
- }
- int num3 = 0;
- int num4 = 0;
- int num6 = 0;
- bool flag2 = false;
- float num8 = 0f;
- checked
- {
- num3 = (int)Math.Round((double)unchecked(this.GetFontSizeLength() + 4f));
- num4 = -1;
- int num5 = this.mDivisors.Count - 1;
- num6 = 0;
- while (true)
- {
- if (num6 > num5)
- {
- goto IL_1A8;
- }
- unchecked
- {
- float aVal = num - this.mDivisors[num6];
- flag = ValScale.Inverse;
- if (flag)
- {
- flag2 = (Math.Abs(0f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num3);
- if (flag2)
- {
- break;
- }
- }
- else
- {
- flag2 = (Math.Abs(1f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num3);
- if (flag2)
- {
- goto Block_10;
- }
- }
- }
- num6++;
- }
- num8 = this.mDivisors[num6];
- }
- flag2 = ((double)Math.Abs(1f - ValScale.PercentFromValueDisplay(num2 + num8)) > 0.25);
- if (flag2)
- {
- num4 = num6;
- goto IL_12A;
- }
- goto IL_12A;
- Block_10:
- num8 = this.mDivisors[num6];
- flag2 = ((double)Math.Abs(0f - ValScale.PercentFromValueDisplay(num2 + num8)) > 0.25);
- if (flag2)
- {
- num4 = num6;
- }
- IL_1A8:
- flag2 = (num8 == 0f);
- if (flag2)
- {
- num8 = 10000f;
- }
- int num9 = 0;
- num = (float)checked((int)Math.Round((double)(num / num8)));
- num += 1f;
- num *= num8;
- while (true)
- {
- float num10 = ValScale.PercentFromValueDisplay(num);
- flag2 = (num10 <= 1f & num10 >= 0f);
- if (flag2)
- {
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = num10;
- valueScaleDisplay_.SetText(num, this);
- list.Add(valueScaleDisplay_);
- }
- flag2 = (num4 > 0 && (double)(Math.Abs(ValScale.PercentFromValueDisplay(num - num8) - ValScale.PercentFromValueDisplay(num)) * height) >= 1.5 * (double)num3);
- if (flag2)
- {
- while (num4 > 0 && Math.Abs(ValScale.PercentFromValueDisplay(num - this.mDivisors[checked(num4 - 1)]) - ValScale.PercentFromValueDisplay(num)) * height >= (float)num3)
- {
- checked
- {
- num4--;
- num8 = this.mDivisors[num4];
- }
- }
- }
- num -= num8;
- checked
- {
- num9++;
- if (!ValScale.Inverse && num10 >= 0f)
- {
- goto IL_2F2;
- }
- if (ValScale.Inverse && num10 <= 100f)
- {
- goto IL_2F2;
- }
- goto IL_2FB;
- IL_2FF:
- bool arg_2FF_0;
- if (!arg_2FF_0)
- {
- break;
- }
- continue;
- IL_2FB:
- arg_2FF_0 = false;
- goto IL_2FF;
- IL_2F2:
- if (num9 >= 1000)
- {
- goto IL_2FB;
- }
- arg_2FF_0 = true;
- goto IL_2FF;
- }
- }
- this._curNet = num8;
- goto IL_356;
- IL_12A:
- goto IL_1A8;
- }
- catch (Exception expr_346)
- {
- ProjectData.SetProjectError(expr_346);
- ProjectData.ClearProjectError();
- }
- IL_356:
- result = list;
- return result;
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetAutoPercentScaleValues(float height, IValueScaler ValScale)
- {
- List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
- try
- {
- int num = 0;
- float num2 = ValScale.ValueFromPercentDisplay(1f);
- float num3 = ValScale.ValueFromPercentDisplay(0f);
- bool flag = ValScale.Inverse;
- if (flag)
- {
- num2 = ValScale.ValueFromPercentDisplay(0f);
- num3 = ValScale.ValueFromPercentDisplay(1f);
- }
- flag = (float.IsInfinity(num2) || float.IsNaN(num2));
- if (flag)
- {
- result = list;
- return result;
- }
- flag = (float.IsInfinity(num3) || float.IsNaN(num3));
- if (flag)
- {
- result = list;
- return result;
- }
- int num4 = checked((int)Math.Round((double)height / unchecked((double)this.GetFontSizeLength() * 1.1)));
- this._curPercent = (num2 - num3) / (float)num4;
- this._curPercent = (num3 + this._curPercent) / num3;
- this._curPercent -= 1f;
- checked
- {
- int num5 = (int)Math.Round((double)unchecked(this.GetFontSizeLength() + 4f));
- int arg_11A_0 = 0;
- int num6 = this.mDivisors.Count - 1;
- int num7 = arg_11A_0;
- float num9;
- bool flag2;
- while (true)
- {
- int arg_1BD_0 = num7;
- int num8 = num6;
- if (arg_1BD_0 > num8)
- {
- goto IL_1C2;
- }
- num9 = this.mDivisors[num7];
- unchecked
- {
- float aVal = num2 * (1f / (1f + num9));
- flag = ValScale.Inverse;
- if (flag)
- {
- flag2 = (Math.Abs(0f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num5);
- if (flag2)
- {
- break;
- }
- }
- else
- {
- flag2 = (Math.Abs(1f - ValScale.PercentFromValueDisplay(aVal)) * height >= (float)num5);
- if (flag2)
- {
- goto Block_12;
- }
- }
- }
- num7++;
- }
- this._curPercent = num9;
- goto IL_1C2;
- Block_12:
- this._curPercent = num9;
- IL_1C2:
- flag2 = (this._curPercent < 0f);
- if (flag2)
- {
- result = list;
- return result;
- }
- flag2 = ValScale.Inverse;
- if (flag2)
- {
- num2 = num3;
- }
- float num10;
- do
- {
- num10 = ValScale.PercentFromValueDisplay(num2);
- flag2 = (num10 <= 1f & num10 >= 0f);
- if (flag2)
- {
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = num10;
- valueScaleDisplay_.SetText(num2, this);
- list.Add(valueScaleDisplay_);
- }
- flag2 = ValScale.Inverse;
- unchecked
- {
- if (flag2)
- {
- num2 *= 1f + this._curPercent;
- }
- else
- {
- num2 /= 1f + this._curPercent;
- }
- }
- num++;
- }
- while (num10 >= 0f && num < 1000);
- }
- }
- catch (Exception expr_2CA)
- {
- ProjectData.SetProjectError(expr_2CA);
- ProjectData.ClearProjectError();
- }
- result = list;
- return result;
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetDivisorValues(float height, IValueScaler ValScale)
- {
- var list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- List<ValueScaleDisplay.ValueScaleDisplay_Y> result;
- try
- {
- int num = 0;
- float num2 = ValScale.ValueFromPercentDisplay(1f);
- bool flag = ValScale.Inverse;
- if (flag)
- {
- num2 = ValScale.ValueFromPercentDisplay(0f);
- }
- flag = (float.IsInfinity(num2) || float.IsNaN(num2));
- if (flag)
- {
- result = list;
- return result;
- }
- flag = (this._divisor == 0f);
- if (flag)
- {
- result = list;
- return result;
- }
- num2 = (float)checked((int)Math.Round((double)(num2 / this._divisor)));
- num2 += 1f;
- num2 *= this._divisor;
- while (true)
- {
- float num3 = ValScale.PercentFromValueDisplay(num2);
- flag = (num3 <= 1f & num3 >= 0f);
- if (flag)
- {
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = num3;
- valueScaleDisplay_.SetText(num2, this);
- list.Add(valueScaleDisplay_);
- }
- num2 -= this._divisor;
- checked
- {
- num++;
- if (!ValScale.Inverse && num3 >= 0f)
- {
- goto IL_129;
- }
- if (ValScale.Inverse && num3 <= 100f)
- {
- goto IL_129;
- }
- goto IL_131;
- IL_135:
- bool arg_135_0;
- if (!arg_135_0)
- {
- break;
- }
- continue;
- IL_131:
- arg_135_0 = false;
- goto IL_135;
- IL_129:
- if (num >= 1000)
- {
- goto IL_131;
- }
- arg_135_0 = true;
- goto IL_135;
- }
- }
- this._curNet = this._divisor;
- }
- catch (Exception expr_180)
- {
- ProjectData.SetProjectError(expr_180);
- ProjectData.ClearProjectError();
- }
- result = list;
- return result;
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetFixedPercentValues(float height, IValueScaler ValScale)
- {
- List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- try
- {
- int num = 0;
- float num2 = ValScale.ValueFromPercentDisplay(1f);
- bool flag = ValScale.Inverse;
- if (flag)
- {
- num2 = ValScale.ValueFromPercentDisplay(0f);
- }
- this._curPercent = this._fixedPercent / 100f;
- while (true)
- {
- float num3 = ValScale.PercentFromValueDisplay(num2);
- flag = (num3 <= 1f & num3 >= 0f);
- if (flag)
- {
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = num3;
- valueScaleDisplay_.SetText(num2, this);
- list.Add(valueScaleDisplay_);
- }
- num2 /= 1f + this._fixedPercent / 100f;
- checked
- {
- num++;
- if (!ValScale.Inverse && num3 >= 0f)
- {
- goto IL_E1;
- }
- if (ValScale.Inverse && num3 <= 100f)
- {
- goto IL_E1;
- }
- goto IL_E9;
- IL_ED:
- bool arg_ED_0;
- if (!arg_ED_0)
- {
- break;
- }
- continue;
- IL_E9:
- arg_ED_0 = false;
- goto IL_ED;
- IL_E1:
- if (num >= 1000)
- {
- goto IL_E9;
- }
- arg_ED_0 = true;
- goto IL_ED;
- }
- }
- }
- catch (Exception expr_12C)
- {
- ProjectData.SetProjectError(expr_12C);
- ProjectData.ClearProjectError();
- }
- return list;
- }
- private float GetFontSizeLength()
- {
- return (float)((double)this.FontSize() * 1.1);
- }
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> GetLineCountValues(float height, IValueScaler ValScale)
- {
- List<ValueScaleDisplay.ValueScaleDisplay_Y> list = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- try
- {
- int num;
- checked
- {
- num = this.LineCount - 1;
- int arg_EB_0 = 0;
- int num2 = num;
- int num3 = arg_EB_0;
- while (true)
- {
- int arg_6E_0 = num3;
- int num4 = num2;
- if (arg_6E_0 > num4)
- {
- break;
- }
- ValueScaleDisplay.ValueScaleDisplay_Y valueScaleDisplay_ = new ValueScaleDisplay.ValueScaleDisplay_Y();
- valueScaleDisplay_.Value = (float)((double)num3 / (double)num);
- valueScaleDisplay_.SetText(ValScale.ValueFromPercentDisplay(valueScaleDisplay_.Value), this);
- list.Add(valueScaleDisplay_);
- num3++;
- }
- }
- this._curNet = ValScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - ValScale.ValueFromPercentDisplay(0f);
- this._curPercent = (ValScale.ValueFromPercentDisplay((float)(1.0 / (double)num)) - ValScale.ValueFromPercentDisplay(0f)) / ValScale.ValueFromPercentDisplay(0f);
- }
- catch (Exception expr_FB)
- {
- ProjectData.SetProjectError(expr_FB);
- ProjectData.ClearProjectError();
- }
- return list;
- }
- private void InitializeDivisors()
- {
- this.mDivisors.Add(1E-05f);
- this.mDivisors.Add(5E-05f);
- this.mDivisors.Add(0.0001f);
- this.mDivisors.Add(0.0005f);
- this.mDivisors.Add(0.001f);
- this.mDivisors.Add(0.005f);
- this.mDivisors.Add(0.01f);
- this.mDivisors.Add(0.02f);
- this.mDivisors.Add(0.03f);
- this.mDivisors.Add(0.04f);
- this.mDivisors.Add(0.05f);
- this.mDivisors.Add(0.1f);
- this.mDivisors.Add(0.25f);
- this.mDivisors.Add(0.3f);
- this.mDivisors.Add(0.4f);
- this.mDivisors.Add(0.5f);
- this.mDivisors.Add(0.6f);
- this.mDivisors.Add(0.7f);
- this.mDivisors.Add(0.8f);
- this.mDivisors.Add(0.9f);
- this.mDivisors.Add(1f);
- this.mDivisors.Add(1.5f);
- this.mDivisors.Add(2f);
- this.mDivisors.Add(2.5f);
- this.mDivisors.Add(3f);
- this.mDivisors.Add(4f);
- this.mDivisors.Add(5f);
- this.mDivisors.Add(6f);
- this.mDivisors.Add(7f);
- this.mDivisors.Add(8f);
- this.mDivisors.Add(9f);
- this.mDivisors.Add(10f);
- this.mDivisors.Add(20f);
- this.mDivisors.Add(25f);
- this.mDivisors.Add(50f);
- this.mDivisors.Add(100f);
- this.mDivisors.Add(250f);
- this.mDivisors.Add(500f);
- this.mDivisors.Add(1000f);
- this.mDivisors.Add(2500f);
- this.mDivisors.Add(5000f);
- this.mDivisors.Add(10000f);
- this.mDivisors.Add(25000f);
- this.mDivisors.Add(50000f);
- this.mDivisors.Add(100000f);
- this.mDivisors.Add(250000f);
- this.mDivisors.Add(500000f);
- this.mDivisors.Add(1000000f);
- this.mDivisors.Add(2500000f);
- this.mDivisors.Add(5000000f);
- this.mDivisors.Add(1E+07f);
- this.mDivisors.Add(2.5E+07f);
- this.mDivisors.Add(5E+07f);
- this.mDivisors.Add(1E+08f);
- this.mDivisors.Add(2.5E+08f);
- this.mDivisors.Add(5E+08f);
- this.mDivisors.Add(1E+09f);
- this.mDivisors.Add(2.5E+09f);
- this.mDivisors.Add(5E+09f);
- this.mDivisors.Add(1E+10f);
- this.mDivisors.Add(2.5E+10f);
- this.mDivisors.Add(5E+10f);
- this.mDivisors.Add(1E+11f);
- this.mDivisors.Add(2.5E+11f);
- this.mDivisors.Add(5E+11f);
- this.mDivisors.Add(1E+12f);
- this.mDivisors.Add(2.5E+12f);
- this.mDivisors.Add(5E+12f);
- this.mDivisors.Add(1E+13f);
- this.mDivisors.Add(2.5E+13f);
- this.mDivisors.Add(5E+13f);
- }
- private bool IsPChangeFromBeginning()
- {
- var valueScaler = this.CurrentValueScaler;
- if (valueScaler == null) return false;
- return (valueScaler is ValueScalerArithmetic && ((ValueScalerArithmetic)valueScaler).IsPChangeFromBeginning() && ((ValueScalerArithmetic)valueScaler).ShowScaleAsPercent);
- }
- private void RefreshChart()
- {
- if (this._chart == null) return;
- this._chart.Refresh();
- }
- /// <summary>
- /// Shows the percent scale.
- /// </summary>
- /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
- private bool ShowPercentScale()
- {
- var scale = CurrentValueScaler as ValueScalerArithmetic;
- if (scale == null) return false;
- return scale.ShowScaleAsPercent;
- }
- /// <summary>
- /// Updates the Y list.
- /// </summary>
- /// <param name="ylist">The ylist.</param>
- /// <returns>List{ValueScaleDisplay.ValueScaleDisplay_Y}.</returns>
- private List<ValueScaleDisplay.ValueScaleDisplay_Y> UpdateYList(List<ValueScaleDisplay.ValueScaleDisplay_Y> ylist)
- {
- //更新y轴数据,只针对左边显示数据,右边显示百分比。
- try
- {
- if (!this.CurrentValueScaler.ShowScaleAsPercent) return ylist;
- var result = new List<ValueScaleDisplay.ValueScaleDisplay_Y>();
- var baseline = CurrentValueScaler.GetPercentBaseline();
- foreach (var y in ylist)
- {
- var val = float.Parse(y.Text);
- result.Add(new ValueScaleDisplay_Y()
- {
- Text = ConvertToString(((val - baseline) / baseline) * 100),
- Value = y.Value
- });
- }
- return result;
- }
- catch
- {
- return ylist;
- }
- }
- private void ValueScaleDisplay_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- this._yCanvas.Width = (this.ActualWidth);
- this._yCanvas.Height = (this.ActualHeight);
- }
- #endregion Private Methods
- #endregion Methods
- #region Nested Types
- /// <summary>
- /// 存储Y轴坐标值
- /// </summary>
- internal class ValueScaleDisplay_Y
- {
- #region Constructors
- public ValueScaleDisplay_Y()
- {
- }
- #endregion Constructors
- #region Properties
- #region Public Properties
- /// <summary>
- /// 处理后的Y轴数值文本
- /// </summary>
- public string Text
- {
- get;
- set;
- }
- /// <summary>
- /// Y轴坐标值
- /// </summary>
- public float Value
- {
- get;
- set;
- }
- #endregion Public Properties
- #endregion Properties
- #region Methods
- #region Internal Methods
- internal void SetText(float aVal, ValueScaleDisplay aValScaleDisp)
- {
- this.Text = aValScaleDisp.ConvertToString(aVal);
- }
- #endregion Internal Methods
- #endregion Methods
- }
- #endregion Nested Types
- }
- }
|