12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the MIT license.
- // See the LICENSE file in the project root for more information.
- //
- // Purpose: Main windows forms chart control class.
- //
- using System;
- using System.Windows.Forms;
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design;
- using System.ComponentModel.Design.Serialization;
- using System.Diagnostics.CodeAnalysis;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Drawing.Imaging;
- using System.Globalization;
- using System.IO;
- using System.Reflection;
- using FastReport.DataVisualization.Charting.Borders3D;
- using FastReport.DataVisualization.Charting.ChartTypes;
- using FastReport.DataVisualization.Charting.Data;
- using FastReport.DataVisualization.Charting.Formulas;
- using FastReport.DataVisualization.Charting.Utilities;
- namespace FastReport.DataVisualization.Charting
- {
- #region Enumerations
- /// <summary>
- /// Specifies the format of the image
- /// </summary>
- public enum ChartImageFormat
- {
- /// <summary>
- /// Gets the Joint Photographic Experts Group (JPEG) image format.
- /// </summary>
- Jpeg,
- /// <summary>
- /// Gets the W3C Portable Network Graphics (PNG) image format.
- /// </summary>
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Png")]
- Png,
- /// <summary>
- /// Gets the bitmap image format (BMP).
- /// </summary>
- Bmp,
- /// <summary>
- /// Gets the Tag Image File Format (TIFF) image format.
- /// </summary>
- Tiff,
- /// <summary>
- /// Gets the Graphics Interchange Format (GIF) image format.
- /// </summary>
- Gif,
- /// <summary>
- /// Gets the Enhanced Meta File (Emf) image format.
- /// </summary>
- Emf,
- /// <summary>
- /// Enhanced Meta File (EmfDual) image format.
- /// </summary>
- EmfDual,
-
- /// <summary>
- /// Enhanced Meta File (Emf+) image format.
- /// </summary>
- EmfPlus,
- }
- #endregion
- /// <summary>
- /// Chart windows forms control
- /// </summary>
- [SRDescription("DescriptionAttributeChart_Chart")]
- #if DESIGNER
- [ToolboxBitmap(typeof(Chart), "ChartControl.ico")]
- [Designer(typeof(ChartWinDesigner))]
- [DesignerSerializer(typeof(ChartWinDesignerSerializer), typeof(CodeDomSerializer))]
- #endif
- [DisplayNameAttribute("Chart")]
- public class Chart : System.Windows.Forms.Control, ISupportInitialize, IDisposable
- {
- #region Control fields
- /// <summary>
- /// Determines whether or not to show debug markings in debug mode. For internal use.
- /// </summary>
- internal bool ShowDebugMarkings = false;
- // Chart services components
- private ChartTypeRegistry _chartTypeRegistry = null;
- private BorderTypeRegistry _borderTypeRegistry = null;
- private CustomPropertyRegistry _customAttributeRegistry = null;
- private DataManager _dataManager = null;
- internal ChartImage chartPicture = null;
- private ImageLoader _imageLoader = null;
- internal ServiceContainer serviceContainer = null;
- private ChartSerializer _chartSerializer = null;
- private PrintingManager _printingManager = null;
- // Selection class
- internal Selection selection = null;
- // Named images collection
- private NamedImagesCollection _namedImages = null;
-
- // Formula registry servise component
- private FormulaRegistry _formulaRegistry = null;
- // Indicates that control invalidation is temporary disabled
- internal bool disableInvalidates = false;
- // Indicates that chart is serializing the data
- internal bool serializing = false;
- // Detailed serialization status which allows not only to determine if serialization
- // is curently in process but also check if we are saving, loading or resetting the chart.
- internal SerializationStatus serializationStatus = SerializationStatus.None;
- // Bitmap used for double buffering chart painting
- internal Bitmap paintBufferBitmap = null;
- // Graphics of the double buffered bitmap
- internal IGraphics paintBufferBitmapGraphics = null;
- // Indicates that only chart area cursor/selection must be drawn during the next paint event
- internal bool paintTopLevelElementOnly = false;
- // Indicates that some chart properties where changed (used for painting)
- internal bool dirtyFlag = true;
- // Chart default cursor
- internal System.Windows.Forms.Cursor defaultCursor = Cursors.Default;
- // Keywords registry
- private KeywordsRegistry _keywordsRegistry = null;
- // Horizontal rendering resolution.
- static internal double renderingDpiX = 96.0;
- // Vertical rendering resolution.
- static internal double renderingDpiY = 96.0;
- #endregion
- #region Component Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- }
- #endregion
- #region Control constructors
- /// <summary>
- /// Chart control constructor.
- /// </summary>
- public Chart()
- {
- //*******************************************************
- //** Check control license
- //*******************************************************
- //*********************************************************
- //** Set control styles
- //*********************************************************
- this.SetStyle(ControlStyles.ResizeRedraw, true);
- //this.SetStyle(ControlStyles.Opaque, true);
- this.SetStyle(ControlStyles.UserPaint, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
- this.SetStyle(ControlStyles.Selectable, true);
- // NOTE: Fixes issue #4475
- this.SetStyle(ControlStyles.DoubleBuffer, true);
- // This is necessary to raise focus event on chart mouse click.
- this.SetStyle(ControlStyles.UserMouse, true);
- //*********************************************************
- //** Create services
- //*********************************************************
- serviceContainer = new ServiceContainer();
- _chartTypeRegistry = new ChartTypeRegistry();
- _borderTypeRegistry = new BorderTypeRegistry();
- _customAttributeRegistry = new CustomPropertyRegistry();
- _keywordsRegistry = new KeywordsRegistry();
- _dataManager = new DataManager(serviceContainer);
- _imageLoader = new ImageLoader(serviceContainer);
- chartPicture = new ChartImage(serviceContainer);
- _chartSerializer = new ChartSerializer(serviceContainer);
- _printingManager = new PrintingManager(serviceContainer);
- _formulaRegistry = new FormulaRegistry();
- // Add services to the service container
- serviceContainer.AddService(typeof(Chart), this); // Chart Control
- serviceContainer.AddService(_chartTypeRegistry.GetType(), _chartTypeRegistry);// Chart types registry
- serviceContainer.AddService(_borderTypeRegistry.GetType(), _borderTypeRegistry);// Border types registry
- serviceContainer.AddService(_customAttributeRegistry.GetType(), _customAttributeRegistry);// Custom attribute registry
- serviceContainer.AddService(_dataManager.GetType(), _dataManager); // Data Manager service
- serviceContainer.AddService(_imageLoader.GetType(), _imageLoader); // Image Loader service
- serviceContainer.AddService(chartPicture.GetType(), chartPicture); // Chart image service
- serviceContainer.AddService(_chartSerializer.GetType(), _chartSerializer); // Chart serializer service
- serviceContainer.AddService(_printingManager.GetType(), _printingManager); // Printing manager service
- serviceContainer.AddService(_formulaRegistry.GetType(), _formulaRegistry); // Formula modules service
- serviceContainer.AddService(_keywordsRegistry.GetType(), _keywordsRegistry); // Keywords registry
- // Initialize objects
- _dataManager.Initialize();
- // Register known chart types
- _chartTypeRegistry.Register( ChartTypeNames.Bar, typeof(BarChart));
- _chartTypeRegistry.Register( ChartTypeNames.Column, typeof(ColumnChart));
- _chartTypeRegistry.Register( ChartTypeNames.Point, typeof(PointChart));
- _chartTypeRegistry.Register( ChartTypeNames.Bubble, typeof(BubbleChart));
- _chartTypeRegistry.Register( ChartTypeNames.Line, typeof(LineChart));
- _chartTypeRegistry.Register( ChartTypeNames.Spline, typeof(SplineChart));
- _chartTypeRegistry.Register( ChartTypeNames.StepLine, typeof(StepLineChart));
- _chartTypeRegistry.Register( ChartTypeNames.Area, typeof(AreaChart));
- _chartTypeRegistry.Register( ChartTypeNames.SplineArea, typeof(SplineAreaChart));
- _chartTypeRegistry.Register( ChartTypeNames.StackedArea, typeof(StackedAreaChart));
- _chartTypeRegistry.Register( ChartTypeNames.Pie, typeof(PieChart));
- _chartTypeRegistry.Register( ChartTypeNames.Stock, typeof(StockChart));
- _chartTypeRegistry.Register( ChartTypeNames.Candlestick, typeof(CandleStickChart));
- _chartTypeRegistry.Register( ChartTypeNames.Doughnut, typeof(DoughnutChart));
- _chartTypeRegistry.Register( ChartTypeNames.StackedBar, typeof(StackedBarChart));
- _chartTypeRegistry.Register( ChartTypeNames.StackedColumn, typeof(StackedColumnChart));
- _chartTypeRegistry.Register( ChartTypeNames.OneHundredPercentStackedColumn, typeof(HundredPercentStackedColumnChart));
- _chartTypeRegistry.Register( ChartTypeNames.OneHundredPercentStackedBar, typeof(HundredPercentStackedBarChart));
- _chartTypeRegistry.Register( ChartTypeNames.OneHundredPercentStackedArea, typeof(HundredPercentStackedAreaChart));
- _chartTypeRegistry.Register(ChartTypeNames.Range, typeof(RangeChart));
- _chartTypeRegistry.Register(ChartTypeNames.SplineRange, typeof(SplineRangeChart));
- _chartTypeRegistry.Register(ChartTypeNames.RangeBar, typeof(RangeBarChart));
- _chartTypeRegistry.Register(ChartTypeNames.Radar, typeof(RadarChart));
- _chartTypeRegistry.Register(ChartTypeNames.RangeColumn, typeof(RangeColumnChart));
- _chartTypeRegistry.Register(ChartTypeNames.ErrorBar, typeof(ErrorBarChart));
- _chartTypeRegistry.Register(ChartTypeNames.BoxPlot, typeof(BoxPlotChart));
- _chartTypeRegistry.Register(ChartTypeNames.Renko, typeof(RenkoChart));
- _chartTypeRegistry.Register(ChartTypeNames.ThreeLineBreak, typeof(ThreeLineBreakChart));
- _chartTypeRegistry.Register(ChartTypeNames.Kagi, typeof(KagiChart));
- _chartTypeRegistry.Register(ChartTypeNames.PointAndFigure, typeof(PointAndFigureChart));
- _chartTypeRegistry.Register(ChartTypeNames.Polar, typeof(PolarChart));
- _chartTypeRegistry.Register(ChartTypeNames.FastLine, typeof(FastLineChart));
- _chartTypeRegistry.Register(ChartTypeNames.Funnel, typeof(FunnelChart));
- _chartTypeRegistry.Register(ChartTypeNames.Pyramid, typeof(PyramidChart));
- _chartTypeRegistry.Register(ChartTypeNames.FastPoint, typeof(FastPointChart));
- // Register known formula modules
- _formulaRegistry.Register(SR.FormulaNamePriceIndicators, typeof(PriceIndicators));
- _formulaRegistry.Register(SR.FormulaNameGeneralTechnicalIndicators,typeof(GeneralTechnicalIndicators));
- _formulaRegistry.Register(SR.FormulaNameTechnicalVolumeIndicators, typeof(VolumeIndicators));
- _formulaRegistry.Register(SR.FormulaNameOscillator, typeof(Oscillators));
- _formulaRegistry.Register(SR.FormulaNameGeneralFormulas, typeof(GeneralFormulas));
- _formulaRegistry.Register(SR.FormulaNameTimeSeriesAndForecasting, typeof(TimeSeriesAndForecasting));
- _formulaRegistry.Register(SR.FormulaNameStatisticalAnalysis, typeof(StatisticalAnalysis));
- // Register known 3D border types
- _borderTypeRegistry.Register("Emboss", typeof(EmbossBorder));
- _borderTypeRegistry.Register("Raised", typeof(RaisedBorder));
- _borderTypeRegistry.Register("Sunken", typeof(SunkenBorder));
- _borderTypeRegistry.Register("FrameThin1", typeof(FrameThin1Border));
- _borderTypeRegistry.Register("FrameThin2", typeof(FrameThin2Border));
- _borderTypeRegistry.Register("FrameThin3", typeof(FrameThin3Border));
- _borderTypeRegistry.Register("FrameThin4", typeof(FrameThin4Border));
- _borderTypeRegistry.Register("FrameThin5", typeof(FrameThin5Border));
- _borderTypeRegistry.Register("FrameThin6", typeof(FrameThin6Border));
- _borderTypeRegistry.Register("FrameTitle1", typeof(FrameTitle1Border));
- _borderTypeRegistry.Register("FrameTitle2", typeof(FrameTitle2Border));
- _borderTypeRegistry.Register("FrameTitle3", typeof(FrameTitle3Border));
- _borderTypeRegistry.Register("FrameTitle4", typeof(FrameTitle4Border));
- _borderTypeRegistry.Register("FrameTitle5", typeof(FrameTitle5Border));
- _borderTypeRegistry.Register("FrameTitle6", typeof(FrameTitle6Border));
- _borderTypeRegistry.Register("FrameTitle7", typeof(FrameTitle7Border));
- _borderTypeRegistry.Register("FrameTitle8", typeof(FrameTitle8Border));
- // Enable chart invalidating
- this.disableInvalidates = false;
-
- // Create selection object
- selection = new Selection(serviceContainer);
- // Create named images collection
- _namedImages = new NamedImagesCollection();
- // Hook up event handlers
- ChartAreas.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(Series.ChartAreaNameReferenceChanged);
- ChartAreas.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(Legends.ChartAreaNameReferenceChanged);
- ChartAreas.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(Titles.ChartAreaNameReferenceChanged);
- ChartAreas.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(Annotations.ChartAreaNameReferenceChanged);
- ChartAreas.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(ChartAreas.ChartAreaNameReferenceChanged);
- Legends.NameReferenceChanged += new EventHandler<NameReferenceChangedEventArgs>(Series.LegendNameReferenceChanged);
- }
- #endregion
- #region Control painting methods
- /// <summary>
- /// Paint chart control.
- /// </summary>
- /// <param name="e">Paint event arguments.</param>
- protected override void OnPaint(PaintEventArgs e)
- {
- //*******************************************************
- //** Check control license
- // Disable invalidates
- this.disableInvalidates = true;
- //*******************************************************
- //** If chart background is transparent - draw without
- //** double buffering.
- //*******************************************************
- if(this.IsBorderTransparent() ||
- !this.BackColor.IsEmpty &&
- (this.BackColor == Color.Transparent || this.BackColor.A != 255) )
- {
- /* Unmerged change from project 'Chart-Win (net5.0-windows7.0)'
- Before:
- StandardGraphicsRenderer gr = new StandardGraphicsRenderer(e.Graphics, false);
- After:
- GdiGraphics gr = new StandardGraphicsRenderer(e.Graphics, false);
- */
- /* Unmerged change from project 'Chart-Win (netcoreapp3.0)'
- Before:
- StandardGraphicsRenderer gr = new StandardGraphicsRenderer(e.Graphics, false);
- After:
- GdiGraphics gr = new StandardGraphicsRenderer(e.Graphics, false);
- */
- FastReport.GdiGraphics gr = new FastReport.GdiGraphics(e.Graphics, false);
- // Draw chart directly on the graphics
- try
- {
- if(this.paintTopLevelElementOnly)
- {
- chartPicture.Paint(gr, false);
- }
- chartPicture.Paint(gr, this.paintTopLevelElementOnly);
- }
- catch(Exception)
- {
- // Draw exception method
- DrawException(gr);
- // Rethrow exception if not in design-time mode
- if(!this.DesignMode)
- {
- throw;
- }
- }
-
- }
- else
- {
- //*******************************************************
- //** If nothing was changed in the chart and last image is stored in the buffer
- //** there is no need to repaint the chart.
- //*******************************************************
- if(this.dirtyFlag || paintBufferBitmap == null)
- {
- // Get scaling component from the drawing graphics
- float scaleX = e.Graphics.Transform.Elements[0];
- float scaleY = e.Graphics.Transform.Elements[3];
- // Create offscreen buffer bitmap
- if(paintBufferBitmap == null ||
- paintBufferBitmap.Width < scaleX * ClientRectangle.Width ||
- paintBufferBitmap.Height < scaleY * ClientRectangle.Height)
- {
- if(paintBufferBitmap != null)
- {
- paintBufferBitmap.Dispose();
- paintBufferBitmapGraphics.Dispose();
- }
- // Create offscreen bitmap taking in consideration graphics scaling
- paintBufferBitmap = new Bitmap((int)(ClientRectangle.Width * scaleX), (int)(ClientRectangle.Height * scaleY), e.Graphics);
- paintBufferBitmapGraphics = new FastReport.GdiGraphics(paintBufferBitmap);
- paintBufferBitmapGraphics.ScaleTransform(scaleX, scaleY);
- }
- //*******************************************************
- //** Draw chart in bitmap buffer
- //*******************************************************
- try
- {
- chartPicture.Paint(paintBufferBitmapGraphics, this.paintTopLevelElementOnly);
- }
- catch(Exception)
- {
- // Draw exception method
- DrawException(paintBufferBitmapGraphics);
- // Rethrow exception if not in design-time mode
- if(!this.DesignMode)
- {
- throw;
- }
- }
- }
- //*******************************************************
- //** Push bitmap buffer forward into the screen
- //*******************************************************
- // Set drawing scale 1:1. Only persist the transformation from current matrix
- System.Drawing.Drawing2D.Matrix drawingMatrix = new System.Drawing.Drawing2D.Matrix();
- System.Drawing.Drawing2D.Matrix oldMatrix = e.Graphics.Transform;
- drawingMatrix.Translate(oldMatrix.OffsetX, oldMatrix.OffsetY);
- e.Graphics.Transform = drawingMatrix;
- // Draw image
- e.Graphics.DrawImage(paintBufferBitmap, 0, 0);
- e.Graphics.Transform = oldMatrix;
- }
- // Clears control dirty flag
- this.dirtyFlag = false;
- this.disableInvalidates = false;
- // Call base class
- base.OnPaint(e);
- //*******************************************************
- //** Check if smart client data must be loaded
- //*******************************************************
- }
- /// <summary>
- /// Paints control background.
- /// </summary>
- /// <param name="pevent">Event arguments.</param>
- protected override void OnPaintBackground(PaintEventArgs pevent)
- {
- this.disableInvalidates = true;
- //*********************************************************
- //** Check if chart back ground has a transparent color
- //*********************************************************
- bool transpBack = false;
- if(chartPicture.BackColor.A != 255 && chartPicture.BackColor != Color.Empty)
- {
- transpBack = true;
- }
- else if(chartPicture.BackImageTransparentColor.A != 255 &&
- chartPicture.BackImageTransparentColor != Color.Empty &&
- !String.IsNullOrEmpty(chartPicture.BackImage))
- {
- transpBack = true;
- }
- //*********************************************************
- //** If chart or chart border page colr has transparent color
- //*********************************************************
- bool transpBorder = this.IsBorderTransparent();
- if( transpBorder || transpBack)
- {
- Color oldBackColor = chartPicture.BackColor;
- if(transpBorder)
- {
- chartPicture.BackColor = Color.Transparent;
- }
- // Call base class
- base.OnPaintBackground(pevent);
- chartPicture.BackColor = oldBackColor;
- }
- this.disableInvalidates = false;
- }
- /// <summary>
- /// When user changes system color, the Chart redraws itself.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnSystemColorsChanged(EventArgs e)
- {
- base.OnSystemColorsChanged(e);
- this.Invalidate();
- }
- /// <summary>
- /// Checks if border skins is enabled in the chart and it uses transparency in the page color
- /// </summary>
- /// <returns>True if transparency is used in the border.</returns>
- private bool IsBorderTransparent()
- {
- bool transpBorder = false;
- if(chartPicture.BorderSkin.SkinStyle != BorderSkinStyle.None)
- {
- if( chartPicture.BorderSkin.PageColor.A != 255 &&
- chartPicture.BorderSkin.PageColor != Color.Empty)
- {
- transpBorder = true;
- }
- if(chartPicture.BorderSkin.BackColor.A != 255 && chartPicture.BorderSkin.BackColor != Color.Empty)
- {
- transpBorder = true;
- }
- else if(chartPicture.BorderSkin.BackImageTransparentColor.A != 255 &&
- chartPicture.BorderSkin.BackImageTransparentColor != Color.Empty &&
- !String.IsNullOrEmpty(chartPicture.BorderSkin.BackImage))
- {
- transpBorder = true;
- }
- }
- return transpBorder;
- }
- /// <summary>
- /// Draws exception information at design-time.
- /// </summary>
- /// <param name="graphics">Chart graphics to use.</param>
- private void DrawException(IGraphics graphics)
- {
- // Fill background
- graphics.FillRectangle(Brushes.White, 0, 0, this.Width, this.Height);
-
- string addMessage = SR.ExceptionChartPreviewNotAvailable;
- // Get text rectangle
- RectangleF rect = new RectangleF(3, 3, this.Width-6, this.Height-6);
-
- // Draw exception text
- using (StringFormat format = new StringFormat())
- {
- format.Alignment = StringAlignment.Center;
- format.LineAlignment = StringAlignment.Center;
- using (Font font = new Font(FontCache.DefaultFamilyName, 8))
- {
- graphics.DrawString(addMessage, font, Brushes.Black, rect, format);
- }
- }
- }
- /// <summary>
- /// Forces the control to invalidate its client area and immediately redraw itself and any child controls.
- /// </summary>
- [
- EditorBrowsable(EditorBrowsableState.Never)
- ]
- public override void Refresh()
- {
- // Clear bitmap used to improve the performance of elements
- // like cursors and annotations
- // NOTE: Fixes issue #4157
- if(this.chartPicture.nonTopLevelChartBuffer != null)
- {
- this.chartPicture.nonTopLevelChartBuffer.Dispose();
- this.chartPicture.nonTopLevelChartBuffer = null;
- }
- this.dirtyFlag = true;
- #if ACCESSIBLE
- this.ResetAccessibilityObject();
- #endif
- base.Refresh();
- }
- /// <summary>
- /// Invalidates a specific region of the control and causes a paint message to be sent to the control.
- /// </summary>
- public new void Invalidate()
- {
- this.dirtyFlag = true;
- #if ACCESSIBLE
- this.ResetAccessibilityObject();
- #endif
- if (!this.disableInvalidates)
- {
- base.Invalidate(true);
- }
- // NOTE: Code below required for the Diagram integration. -AG
- if(!this.chartPicture.isSavingAsImage)
- {
- InvalidateEventArgs e = new InvalidateEventArgs(Rectangle.Empty);
- this.OnInvalidated(e);
- }
- }
- /// <summary>
- /// Invalidates a specific region of the control and causes a paint message to be sent to the control.
- /// </summary>
- public new void Invalidate(Rectangle rectangle)
- {
- this.dirtyFlag = true;
- #if ACCESSIBLE
- this.ResetAccessibilityObject();
- #endif
- if (!this.disableInvalidates)
- {
- base.Invalidate(rectangle);
-
- }
- // NOTE: Code below required for the Diagram integration. -AG
- if(!this.chartPicture.isSavingAsImage)
- {
- InvalidateEventArgs e = new InvalidateEventArgs(Rectangle.Empty);
- this.OnInvalidated(e);
- }
- }
- /// <summary>
- /// Updates chart cursor and range selection only.
- /// </summary>
- public void UpdateCursor()
- {
- // Set flag to redraw cursor/selection only
- this.paintTopLevelElementOnly = true;
- // Update chart cursor and range selection
- base.Update();
- // Clear flag to redraw cursor/selection only
- this.paintTopLevelElementOnly = false;
- }
- /// <summary>
- /// Updates chart annotations only.
- /// </summary>
- public void UpdateAnnotations()
- {
- // Set flag to redraw cursor/selection only
- this.paintTopLevelElementOnly = true;
- // Update chart cursor and range selection
- base.Update();
- // Clear flag to redraw cursor/selection only
- this.paintTopLevelElementOnly = false;
- }
-
- #endregion
- #region Control size and location properties/methods
- /// <summary>
- /// Returns default control size.
- /// </summary>
- protected override System.Drawing.Size DefaultSize
- {
- get
- {
- return new System.Drawing.Size(300, 300);
- }
- }
- /// <summary>
- /// Control location changed.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnLocationChanged(EventArgs e)
- {
- // If chart or chart border page color has transparent color
- if((chartPicture.BackColor.A != 255 && chartPicture.BackColor != Color.Empty) ||
- (chartPicture.BorderSkin.SkinStyle != BorderSkinStyle.None &&
- chartPicture.BorderSkin.PageColor.A != 255 &&
- chartPicture.BorderSkin.PageColor != Color.Empty))
- {
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- base.OnLocationChanged(e);
- }
- /// <summary>
- /// Control resized.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnResize(EventArgs e)
- {
- chartPicture.Width = this.Size.Width;
- chartPicture.Height = this.Size.Height;
- this.dirtyFlag = true;
- #if ACCESSIBLE
- this.ResetAccessibilityObject();
- #endif
- base.OnResize(e);
- }
- /// <summary>
- /// Fires RightToLeftChanged event.
- /// </summary>
- /// <param name="e">Event Arguments</param>
- protected override void OnRightToLeftChanged(EventArgs e)
- {
- base.OnRightToLeftChanged(e);
- this.Invalidate();
- }
-
- #endregion
- #region Chart image saving methods
- /// <summary>
- /// Saves chart image into the file.
- /// </summary>
- /// <param name="imageFileName">Image file name</param>
- /// <param name="format">Image format.</param>
- public void SaveImage(string imageFileName, ChartImageFormat format)
- {
- // Check arguments
- if (imageFileName == null)
- throw new ArgumentNullException("imageFileName");
- // Create file stream for the specified file name
- FileStream fileStream = new FileStream(imageFileName, FileMode.Create);
- // Save into stream
- try
- {
- SaveImage(fileStream, format);
- }
- finally
- {
- // Close file stream
- fileStream.Close();
- }
- }
- /// <summary>
- /// Saves chart image into the file.
- /// </summary>
- /// <param name="imageFileName">Image file name</param>
- /// <param name="format">Image format.</param>
- public void SaveImage(string imageFileName, ImageFormat format)
- {
- // Check arguments
- if (imageFileName == null)
- throw new ArgumentNullException("imageFileName");
- if (format == null)
- throw new ArgumentNullException("format");
- // Create file stream for the specified file name
- FileStream fileStream = new FileStream(imageFileName, FileMode.Create);
- // Save into stream
- try
- {
- SaveImage(fileStream, format);
- }
- finally
- {
- // Close file stream
- fileStream.Close();
- }
- }
- /// <summary>
- /// Saves chart image into the stream.
- /// </summary>
- /// <param name="imageStream">Image stream.</param>
- /// <param name="format">Image format.</param>
- public void SaveImage(Stream imageStream, ImageFormat format)
- {
- // Check arguments
- if (imageStream == null)
- throw new ArgumentNullException("imageStream");
- if (format == null)
- throw new ArgumentNullException("format");
- // Indicate that chart is saved into the image
- this.chartPicture.isSavingAsImage = true;
- if(format == ImageFormat.Emf || format == ImageFormat.Wmf)
- {
- this.chartPicture.SaveIntoMetafile(imageStream, EmfType.EmfOnly);
- }
- else
- {
- // Get chart image
- Image chartImage = this.chartPicture.GetImage();
- // Save image into the file
- chartImage.Save(imageStream, format);
- // Dispose image
- chartImage.Dispose();
- }
- // Reset flag
- this.chartPicture.isSavingAsImage = false;
- }
- /// <summary>
- /// Saves chart image into the stream.
- /// </summary>
- /// <param name="imageStream">Image stream.</param>
- /// <param name="format">Image format.</param>
- public void SaveImage( Stream imageStream, ChartImageFormat format )
- {
- // Check arguments
- if (imageStream == null)
- throw new ArgumentNullException("imageStream");
- // Indicate that chart is saved into the image
- this.chartPicture.isSavingAsImage = true;
- if( format == ChartImageFormat.Emf ||
- format == ChartImageFormat.EmfPlus ||
- format == ChartImageFormat.EmfDual)
- {
- EmfType emfType = EmfType.EmfOnly;
- if(format == ChartImageFormat.EmfDual)
- {
- emfType = EmfType.EmfPlusDual;
- }
- else if(format == ChartImageFormat.EmfPlus)
- {
- emfType = EmfType.EmfPlusOnly;
- }
- this.chartPicture.SaveIntoMetafile(imageStream, emfType);
- }
- else
- {
- // Get chart image
- Image chartImage = this.chartPicture.GetImage();
- ImageFormat standardImageFormat = ImageFormat.Png;
- switch( format )
- {
- case ChartImageFormat.Bmp:
- standardImageFormat = ImageFormat.Bmp;
- break;
- case ChartImageFormat.Gif:
- standardImageFormat = ImageFormat.Gif;
- break;
- case ChartImageFormat.Jpeg:
- standardImageFormat = ImageFormat.Jpeg;
- break;
- case ChartImageFormat.Png:
- standardImageFormat = ImageFormat.Png;
- break;
- case ChartImageFormat.Tiff:
- standardImageFormat = ImageFormat.Tiff;
- break;
- }
- // Save image into the file
- chartImage.Save(imageStream, standardImageFormat);
- // Dispose image
- chartImage.Dispose();
- }
- // Reset flag
- this.chartPicture.isSavingAsImage = false;
- }
- #endregion
- #region Control public properties
- // Avalonia: this allows to draw chart on render thread.
- public new RightToLeft RightToLeft { get; set; } = RightToLeft.No;
- public event EventHandler OnModifing;
- public void CallOnModifing(object sender)
- {
- OnModifing?.Invoke(sender, null);
- }
-
- /// <summary>
- /// Array of custom palette colors.
- /// </summary>
- /// <remarks>
- /// When this custom colors array is non-empty the <b>Palette</b> property is ignored.
- /// </remarks>
- [
- SRCategory("CategoryAttributeAppearance"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- SerializationVisibilityAttribute(SerializationVisibility.Attribute),
- SRDescription("DescriptionAttributeChart_PaletteCustomColors"),
- TypeConverter(typeof(ColorArrayConverter))
- ]
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public Color[] PaletteCustomColors
- {
- set
- {
- this._dataManager.PaletteCustomColors = value;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- get
- {
- return this._dataManager.PaletteCustomColors;
- }
- }
- /// <summary>
- /// Method resets custom colors array. Internal use only.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal void ResetPaletteCustomColors()
- {
- this.PaletteCustomColors = new Color[0];
- }
- /// <summary>
- /// Method resets custom colors array. Internal use only.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal bool ShouldSerializePaletteCustomColors()
- {
- if(this.PaletteCustomColors == null ||
- this.PaletteCustomColors.Length == 0)
- {
- return false;
- }
- return true;
- }
-
- /// <summary>
- /// Indicates that non-critical chart exceptions will be suppressed.
- /// </summary>
- [
- SRCategory("CategoryAttributeMisc"),
- DefaultValue(false),
- SRDescription("DescriptionAttributeSuppressExceptions"),
- ]
- public bool SuppressExceptions
- {
- set
- {
- this.chartPicture.SuppressExceptions = value;
- }
- get
- {
- return this.chartPicture.SuppressExceptions;
- }
- }
- /// <summary>
- /// "The data source used to populate series data. Series ValueMember properties must be also set."
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- Bindable(true),
- SRDescription("DescriptionAttributeDataSource"),
- DefaultValue(null),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- AttributeProvider(typeof(IListSource))
- ]
- public object DataSource
- {
- get
- {
- return chartPicture.DataSource;
- }
- set
- {
- chartPicture.DataSource = value;
- }
- }
- /// <summary>
- /// Chart named images collection.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- Bindable(false),
- SRDescription("DescriptionAttributeChart_Images"),
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- ]
- public NamedImagesCollection Images
- {
- get
- {
- return _namedImages;
- }
- }
- /// <summary>
- /// Chart printing object.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- Bindable(false),
- SRDescription("DescriptionAttributeChart_Printing"),
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public PrintingManager Printing
- {
- get
- {
- return _printingManager;
- }
- }
- /// <summary>
- /// Chart series collection.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- SRDescription("DescriptionAttributeChart_Series"),
- #if DESIGNER
- Editor(typeof(SeriesCollectionEditor), typeof(UITypeEditor)),
- #endif
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- ]
- public SeriesCollection Series
- {
- get
- {
- return _dataManager.Series;
- }
- }
- /// <summary>
- /// Chart legend collection.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- SRDescription("DescriptionAttributeLegends"),
- #if DESIGNER
- Editor(typeof(LegendCollectionEditor), typeof(UITypeEditor)),
- #endif
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- ]
- public LegendCollection Legends
- {
- get
- {
- return chartPicture.Legends;
- }
- }
- /// <summary>
- /// Chart title collection.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- SRDescription("DescriptionAttributeTitles"),
- #if DESIGNER
- Editor(typeof(ChartCollectionEditor), typeof(UITypeEditor)),
- #endif
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- ]
- public TitleCollection Titles
- {
- get
- {
- return chartPicture.Titles;
- }
- }
- /// <summary>
- /// Chart annotation collection.
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- SRDescription("DescriptionAttributeAnnotations3"),
- #if DESIGNER
- Editor(typeof(AnnotationCollectionEditor), typeof(UITypeEditor)),
- #endif
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- ]
- public AnnotationCollection Annotations
- {
- get
- {
- return chartPicture.Annotations;
- }
- }
- /// <summary>
- /// BackImage is not used. Use BackImage property instead.
- /// </summary>
- [
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public override Image BackgroundImage
- {
- get
- {
- return base.BackgroundImage;
- }
- set
- {
- base.BackgroundImage = value;
- }
- }
- /// <summary>
- /// Color palette to use
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributePalette"),
- DefaultValue(ChartColorPalette.BrightPastel),
- #if DESIGNER
- Editor(typeof(ColorPaletteEditor), typeof(UITypeEditor))
- #endif
- ]
- public ChartColorPalette Palette
- {
- get
- {
- return _dataManager.Palette;
- }
- set
- {
- _dataManager.Palette = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
-
- /// <summary>
- /// Specifies whether smoothing (antialiasing) is applied while drawing chart.
- /// </summary>
- [
- SRCategory("CategoryAttributeImage"),
- Bindable(true),
- DefaultValue(typeof(AntiAliasingStyles), "All"),
- SRDescription("DescriptionAttributeAntiAlias"),
- #if DESIGNER
- Editor(typeof(FlagsEnumUITypeEditor), typeof(UITypeEditor)),
- #endif
- ]
- public FastReport.DataVisualization.Charting.AntiAliasingStyles AntiAliasing
- {
- get
- {
- return chartPicture.AntiAliasing;
- }
- set
- {
- if(chartPicture.AntiAliasing != value)
- {
- chartPicture.AntiAliasing = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- }
- /// <summary>
- /// Specifies the quality of text antialiasing.
- /// </summary>
- [
- SRCategory("CategoryAttributeImage"),
- Bindable(true),
- DefaultValue(typeof(TextAntiAliasingQuality), "High"),
- SRDescription("DescriptionAttributeTextAntiAliasingQuality")
- ]
- public TextAntiAliasingQuality TextAntiAliasingQuality
- {
- get
- {
- return chartPicture.TextAntiAliasingQuality;
- }
- set
- {
- chartPicture.TextAntiAliasingQuality = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Specifies whether smoothing is applied while drawing shadows.
- /// </summary>
- [
- SRCategory("CategoryAttributeImage"),
- Bindable(true),
- DefaultValue(true),
- SRDescription("DescriptionAttributeChart_SoftShadows"),
- ]
- public bool IsSoftShadows
- {
- get
- {
- return chartPicture.IsSoftShadows;
- }
- set
- {
- chartPicture.IsSoftShadows = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Reference to chart area collection
- /// </summary>
- [
- SRCategory("CategoryAttributeChart"),
- Bindable(true),
- SRDescription("DescriptionAttributeChartAreas"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
- #if DESIGNER
- Editor(typeof(ChartCollectionEditor), typeof(UITypeEditor)),
- #endif
- ]
- public ChartAreaCollection ChartAreas
- {
- get
- {
- return chartPicture.ChartAreas;
- }
- }
- /// <summary>
- /// Back ground color for the Chart
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(typeof(Color), "White"),
- SRDescription("DescriptionAttributeBackColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public new Color BackColor
- {
- get
- {
- return chartPicture.BackColor;
- }
- set
- {
- if (chartPicture.BackColor != value)
- {
- chartPicture.BackColor = value;
- this.dirtyFlag = true;
- if (!this.disableInvalidates)
- {
- this.Invalidate();
- }
- // Call notification event
- this.OnBackColorChanged(EventArgs.Empty);
- }
- }
- }
- /// <summary>
- /// Fore color propery (not used)
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(false),
- Browsable(false),
- DefaultValue(typeof(Color), ""),
- SRDescription("DescriptionAttributeForeColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public new Color ForeColor
- {
- get
- {
- return Color.Empty;
- }
- set
- {
- }
- }
- /// <summary>
- /// Fore color propery (not used)
- /// </summary>
- [
- SRCategory("CategoryAttributeLayout"),
- Bindable(true),
- DefaultValue(typeof(System.Drawing.Size), "300, 300"),
- SRDescription("DescriptionAttributeChart_Size"),
- ]
- public new System.Drawing.Size Size
- {
- get
- {
- return base.Size;
- }
- set
- {
- chartPicture.InspectChartDimensions(value.Width, value.Height);
- base.Size = value;
- }
- }
-
- /// <summary>
- /// Series data manipulator
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- SRDescription("DescriptionAttributeDataManipulator"),
- Browsable(false),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public DataManipulator DataManipulator
- {
- get
- {
- return chartPicture.DataManipulator;
- }
- }
- /// <summary>
- /// Chart serializer object.
- /// </summary>
- [
- SRCategory("CategoryAttributeSerializer"),
- SRDescription("DescriptionAttributeChart_Serializer"),
- Browsable(false),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public ChartSerializer Serializer
- {
- get
- {
- return _chartSerializer;
- }
- }
- /// <summary>
- /// Title font
- /// </summary>
- [
- SRCategory("CategoryAttributeCharttitle"),
- Bindable(false),
- Browsable(false),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public new Font Font
- {
- get
- {
- return base.Font;
- }
- set
- {
- base.Font = value;
- }
- }
- /// <summary>
- /// Back Hatch style
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(ChartHatchStyle.None),
- SRDescription("DescriptionAttributeBackHatchStyle"),
- #if DESIGNER
- Editor(typeof(HatchStyleEditor), typeof(UITypeEditor))
- #endif
- ]
- public ChartHatchStyle BackHatchStyle
- {
- get
- {
- return chartPicture.BackHatchStyle;
- }
- set
- {
- chartPicture.BackHatchStyle = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Chart area background image
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(""),
- SRDescription("DescriptionAttributeBackImage"),
- NotifyParentPropertyAttribute(true),
- #if DESIGNER
- Editor(typeof(ImageValueEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string BackImage
- {
- get
- {
- return chartPicture.BackImage;
- }
- set
- {
- chartPicture.BackImage = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Chart area background image drawing mode.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(ChartImageWrapMode.Tile),
- NotifyParentPropertyAttribute(true),
- SRDescription("DescriptionAttributeImageWrapMode"),
- ]
- public ChartImageWrapMode BackImageWrapMode
- {
- get
- {
- return chartPicture.BackImageWrapMode;
- }
- set
- {
- chartPicture.BackImageWrapMode = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Background image transparent color.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(typeof(Color), ""),
- NotifyParentPropertyAttribute(true),
- SRDescription("DescriptionAttributeImageTransparentColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BackImageTransparentColor
- {
- get
- {
- return chartPicture.BackImageTransparentColor;
- }
- set
- {
- chartPicture.BackImageTransparentColor = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Background image alignment used by ClampUnscale drawing mode.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(ChartImageAlignmentStyle.TopLeft),
- NotifyParentPropertyAttribute(true),
- SRDescription("DescriptionAttributeBackImageAlign"),
- ]
- public ChartImageAlignmentStyle BackImageAlignment
- {
- get
- {
- return chartPicture.BackImageAlignment;
- }
- set
- {
- chartPicture.BackImageAlignment = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// A type for the background gradient
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(GradientStyle.None),
- SRDescription("DescriptionAttributeBackGradientStyle"),
- #if DESIGNER
- Editor(typeof(GradientEditor), typeof(UITypeEditor))
- #endif
- ]
- public GradientStyle BackGradientStyle
- {
- get
- {
- return chartPicture.BackGradientStyle;
- }
- set
- {
- chartPicture.BackGradientStyle = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// The second color which is used for a gradient
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(typeof(Color), ""),
- SRDescription("DescriptionAttributeBackSecondaryColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BackSecondaryColor
- {
- get
- {
- return chartPicture.BackSecondaryColor;
- }
- set
- {
- chartPicture.BackSecondaryColor = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Border color for the Chart
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(false),
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- DefaultValue(typeof(Color), "White"),
- SRDescription("DescriptionAttributeBorderColor"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BorderColor
- {
- get
- {
- return chartPicture.BorderColor;
- }
- set
- {
- chartPicture.BorderColor = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// The width of the border line
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(false),
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- DefaultValue(1),
- SRDescription("DescriptionAttributeChart_BorderlineWidth"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public int BorderWidth
- {
- get
- {
- return chartPicture.BorderWidth;
- }
- set
- {
- chartPicture.BorderWidth = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// The style of the border line
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(false),
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- DefaultValue(ChartDashStyle.NotSet),
- SRDescription("DescriptionAttributeBorderDashStyle"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public ChartDashStyle BorderDashStyle
- {
- get
- {
- return chartPicture.BorderDashStyle;
- }
- set
- {
- chartPicture.BorderDashStyle = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Border color for the Chart
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(typeof(Color), "White"),
- SRDescription("DescriptionAttributeBorderColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BorderlineColor
- {
- get
- {
- return chartPicture.BorderColor;
- }
- set
- {
- chartPicture.BorderColor = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// The width of the border line
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(1),
- SRDescription("DescriptionAttributeChart_BorderlineWidth"),
- ]
- public int BorderlineWidth
- {
- get
- {
- return chartPicture.BorderWidth;
- }
- set
- {
- chartPicture.BorderWidth = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// The style of the border line
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(ChartDashStyle.NotSet),
- SRDescription("DescriptionAttributeBorderDashStyle"),
- ]
- public ChartDashStyle BorderlineDashStyle
- {
- get
- {
- return chartPicture.BorderDashStyle;
- }
- set
- {
- chartPicture.BorderDashStyle = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Chart border skin style.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- DefaultValue(BorderSkinStyle.None),
- SRDescription("DescriptionAttributeBorderSkin"),
- NotifyParentPropertyAttribute(true),
- TypeConverterAttribute(typeof(LegendConverter)),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
- ]
- public BorderSkin BorderSkin
- {
- get
- {
- return chartPicture.BorderSkin;
- }
- set
- {
- chartPicture.BorderSkin = value;
- this.dirtyFlag = true;
- if(!this.disableInvalidates)
- {
- this.Invalidate();
- }
- }
- }
- /// <summary>
- /// Build number of the control
- /// </summary>
- [
- SRDescription("DescriptionAttributeChart_BuildNumber"),
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- DefaultValue("")
- ]
- public string BuildNumber
- {
- get
- {
- // Get build number from the assembly
- string buildNumber = String.Empty;
- Assembly assembly = Assembly.GetExecutingAssembly();
- if(assembly != null)
- {
- buildNumber = assembly.FullName.ToUpper(CultureInfo.InvariantCulture);
- int versionIndex = buildNumber.IndexOf("VERSION=", StringComparison.Ordinal);
- if(versionIndex >= 0)
- {
- buildNumber = buildNumber.Substring(versionIndex + 8);
- }
- versionIndex = buildNumber.IndexOf(",", StringComparison.Ordinal);
- if(versionIndex >= 0)
- {
- buildNumber = buildNumber.Substring(0, versionIndex);
- }
- }
- return buildNumber;
- }
- }
- /// <summary>
- /// Vertical resolution of the chart renderer.
- /// </summary>
- /// <remarks>
- /// This property is for the internal use only.
- /// </remarks>
- [
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- SRCategory("CategoryAttributeMisc"),
- DefaultValue(96.0),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public double RenderingDpiY
- {
- set
- {
- Chart.renderingDpiY = value;
- }
- get
- {
- return Chart.renderingDpiY;
- }
- }
- /// <summary>
- /// Horizontal resolution of the chart renderer.
- /// </summary>
- /// <remarks>
- /// This property is for the internal use only.
- /// </remarks>
- [
- Browsable(false),
- EditorBrowsable(EditorBrowsableState.Never),
- SRCategory("CategoryAttributeMisc"),
- DefaultValue(96.0),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public double RenderingDpiX
- {
- set
- {
- Chart.renderingDpiX = value;
- }
- get
- {
- return Chart.renderingDpiX;
- }
- }
- #endregion
- #region Control public methods
- /// <summary>
- /// Loads chart appearance template from file.
- /// </summary>
- /// <param name="name">Template file name to load from.</param>
- public void LoadTemplate(string name)
- {
- chartPicture.LoadTemplate(name);
- }
- /// <summary>
- /// Loads chart appearance template from stream.
- /// </summary>
- /// <param name="stream">Template stream to load from.</param>
- public void LoadTemplate(Stream stream)
- {
- chartPicture.LoadTemplate(stream);
- }
- /// <summary>
- /// Applies palette colors to series or data points.
- /// </summary>
- public void ApplyPaletteColors()
- {
- // Apply palette colors to series
- this._dataManager.ApplyPaletteColors();
- // Apply palette colors to data Points in series
- foreach(Series series in this.Series)
- {
- // Check if palette colors should be aplied to the points
- bool applyToPoints = false;
- if(series.Palette != ChartColorPalette.None)
- {
- applyToPoints = true;
- }
- else
- {
- IChartType chartType = this._chartTypeRegistry.GetChartType(series.ChartType);
- applyToPoints = chartType.ApplyPaletteColorsToPoints;
- }
- // Apply palette colors to the points
- if(applyToPoints)
- {
- series.ApplyPaletteColors();
- }
- }
- }
- /// <summary>
- /// Checks if control is in design mode.
- /// </summary>
- /// <returns>True if control is in design mode.</returns>
- internal bool IsDesignMode()
- {
- return this.DesignMode;
- }
- /// <summary>
- /// Reset auto calculated chart properties values to "Auto".
- /// </summary>
- public void ResetAutoValues()
- {
- // Reset auto calculated series properties values
- foreach(Series series in this.Series)
- {
- series.ResetAutoValues();
- }
- // Reset auto calculated axis properties values
- foreach(ChartArea chartArea in this.ChartAreas)
- {
- chartArea.ResetAutoValues();
- }
- }
- /// <summary>
- /// This method performs the hit test and returns a HitTestResult objects.
- /// </summary>
- /// <param name="x">X coordinate</param>
- /// <param name="y">Y coordinate</param>
- /// <returns>Hit test result object</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public HitTestResult HitTest( int x, int y )
- {
- return selection.HitTest( x, y );
- }
- /// <summary>
- /// This method performs the hit test and returns a HitTestResult object.
- /// </summary>
- /// <param name="x">X coordinate</param>
- /// <param name="y">Y coordinate</param>
- /// <param name="ignoreTransparent">Indicates that transparent elements should be ignored.</param>
- /// <returns>Hit test result object</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public HitTestResult HitTest( int x, int y, bool ignoreTransparent )
- {
- return selection.HitTest( x, y, ignoreTransparent );
- }
- /// <summary>
- /// This method performs the hit test and returns a HitTestResult object.
- /// </summary>
- /// <param name="x">X coordinate</param>
- /// <param name="y">Y coordinate</param>
- /// <param name="requestedElement">Only this chart element will be hit tested.</param>
- /// <returns>Hit test result object</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public HitTestResult HitTest( int x, int y, ChartElementType requestedElement )
- {
- return selection.HitTest( x, y, requestedElement);
- }
- /// <summary>
- /// Call this method to determine the chart element,
- /// if any, that is located at a point defined by the given X and Y
- /// coordinates.
- /// <seealso cref="HitTestResult"/></summary>
- /// <param name="x">The X coordinate for the point in question.
- /// Often obtained from a parameter in an event
- /// (e.g. the X parameter value in the MouseDown event).</param>
- /// <param name="y">The Y coordinate for the point in question.
- /// Often obtained from a parameter in an event
- /// (e.g. the Y parameter value in the MouseDown event).</param>
- /// <param name="ignoreTransparent">Indicates that transparent
- /// elements should be ignored.</param>
- /// <param name="requestedElement">
- /// An array of type which specify the types
- /// to test for, on order to filter the result. If omitted checking for
- /// elementTypes will be ignored and all kind of elementTypes will be
- /// valid.
- /// </param>
- /// <returns>
- /// A array of <see cref="HitTestResult"/> objects,
- /// which provides information concerning the chart element
- /// (if any) that is at the specified location. Result contains at least
- /// one element, which could be ChartElementType.Nothing.
- /// The objects in the result are sorted in from top to bottom of
- /// different layers of control. </returns>
- /// <remarks>Call this method to determine the gauge element
- /// (if any) that is located at a specified point. Often this method is used in
- /// some mouse-related event (e.g. MouseDown)
- /// to determine what gauge element the end-user clicked on.
- /// The X and Y mouse coordinates obtained from the
- /// event parameters are then used for the X and Y parameter
- /// values of this method call. The returned
- /// <see cref="HitTestResult"/> object's properties
- /// can then be used to determine what chart element was clicked on,
- /// and also provides a reference to the actual object selected (if
- /// any).</remarks>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public HitTestResult[] HitTest(int x, int y, bool ignoreTransparent, params ChartElementType[] requestedElement)
- {
- return this.selection.HitTest(x, y, ignoreTransparent, requestedElement);
- }
- /// <summary>
- /// Gets the chart element outline.
- /// </summary>
- /// <param name="element">The chart object.</param>
- /// <param name="elementType">Type of the element.</param>
- /// <returns> A <see cref="ChartElementOutline"/> object which contains
- /// 1) An array of points in absolute coordinates which can be used as outline markers arround this chart element.
- /// 2) A GraphicsPath for drawing aouline around this chart emenent.
- /// </returns>
- /// <remarks>
- /// If the <paramref name="element"/> is not part of the chart or <paramref name="elementType"/> cannot be combined
- /// with <paramref name="element"/> then the result will contain empty array of marker points.
- /// The marker points are sorted clockwize.
- /// </remarks>
- public ChartElementOutline GetChartElementOutline(object element, ChartElementType elementType)
- {
- return this.selection.GetChartElementOutline(element, elementType);
- }
- #endregion
- #region Control protected methods
- protected override void OnGotFocus(EventArgs e)
- {
- base.OnGotFocus(e);
- using (Graphics g = Graphics.FromHwndInternal(Handle))
- {
- ControlPaint.DrawFocusRectangle(g, new Rectangle(1, 1, Size.Width - 2, Size.Height - 2));
- }
- }
- protected override void OnLostFocus(EventArgs e)
- {
- base.OnLostFocus(e);
- using (Graphics g = Graphics.FromHwndInternal(Handle))
- {
- using (Brush b = new SolidBrush(BackColor))
- {
- Rectangle topBorder = new Rectangle(1, 1, Size.Width - 2, 1);
- g.FillRectangle(b, topBorder);
- Rectangle rightBorder = new Rectangle(Size.Width - 2, 1, 1, Size.Height - 2);
- g.FillRectangle(b, rightBorder);
- Rectangle bottomBorder = new Rectangle(1, Size.Height - 2, Size.Width - 2, 1);
- g.FillRectangle(b, bottomBorder);
- Rectangle leftBorder = new Rectangle(1, 1, 1, Size.Height - 2);
- g.FillRectangle(b, leftBorder);
- }
- }
- }
- #endregion
- #region ISupportInitialize implementation
- /// <summary>
- /// Signals the object that initialization is starting.
- /// </summary>
- public void BeginInit()
- {
- // Disable control invalidation
- disableInvalidates = true;
- }
-
- /// <summary>
- /// Signals the object that initialization is complete.
- /// </summary>
- public void EndInit()
- {
- // Enable control invalidation
- disableInvalidates = false;
- // If control is durty - invalidate it
- if(this.dirtyFlag)
- {
- base.Invalidate();
- }
- }
- #endregion
- #region Control mouse events
- /// <summary>
- /// Raises the <see cref="E:System.Windows.Forms.Control.CursorChanged"/> event.
- /// </summary>
- /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
- protected override void OnCursorChanged(EventArgs e)
- {
- this.defaultCursor = this.Cursor;
- base.OnCursorChanged(e);
- }
- /// <summary>
- /// Mouse button pressed in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnMouseDown(MouseEventArgs e)
- {
- OnChartMouseDown(e);
- }
- /// <summary>
- /// Mouse button pressed in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- internal void OnChartMouseDown(MouseEventArgs e)
- {
- bool handled = false;
- if(!handled)
- {
- // Notify annotation object collection about the mouse down event
- this.Annotations.OnMouseDown(e, ref handled);
- }
- // Loop through all areas and notify required object about the event
- if(!handled)
- {
- foreach(ChartArea area in this.ChartAreas)
- {
- // No cursor or scroll bar support in 3D
- if(!area.Area3DStyle.Enable3D &&
- !area.chartAreaIsCurcular
- && area.Visible)
- {
- foreach(Axis axis in area.Axes)
- {
- // Notify axis scroll bar
- axis.ScrollBar.ScrollBar_MouseDown(this, e);
- }
- // Notify area X and Y cursors
- area.CursorX.Cursor_MouseDown(this, e);
- area.CursorY.Cursor_MouseDown(this, e);
- }
- }
- }
- // Call the base class
- base.OnMouseDown(e);
- }
- /// <summary>
- /// Mouse button up in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnMouseUp(MouseEventArgs e)
- {
- OnChartMouseUp(e);
- }
- /// <summary>
- /// Mouse button up in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- internal void OnChartMouseUp(MouseEventArgs e)
- {
- // Loop through all areas and notify required object about the event
- foreach(ChartArea area in this.ChartAreas)
- {
- // No cursor or scroll bar support in 3D
- if(!area.Area3DStyle.Enable3D &&
- !area.chartAreaIsCurcular
- && area.Visible)
- {
- foreach(Axis axis in area.Axes)
- {
- // Notify axis scroll bar
- axis.ScrollBar.ScrollBar_MouseUp(this, e);
- }
- // Notify area X and Y cursors
- area.CursorX.Cursor_MouseUp(this, e);
- area.CursorY.Cursor_MouseUp(this, e);
- }
- }
- // Notify annotation object collection about the mouse down event
- this.Annotations.OnMouseUp(e);
- // Call the base class
- base.OnMouseUp(e);
- }
- /// <summary>
- /// Mouse moved in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected override void OnMouseMove(MouseEventArgs e)
- {
- OnChartMouseMove(e);
- }
- /// <summary>
- /// Mouse moved in the control.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- internal void OnChartMouseMove(MouseEventArgs e)
- {
- // Flag which indicates if event was already isHandled
- bool handled = false;
- // Loop through all areas and notify required object about the event
- foreach(ChartArea area in this.ChartAreas)
- {
- // No cursor or scroll bar support in 3D
- if(!area.Area3DStyle.Enable3D &&
- !area.chartAreaIsCurcular
- && area.Visible)
- {
- foreach(Axis axis in area.Axes)
- {
- // Notify axis scroll bar
- axis.ScrollBar.ScrollBar_MouseMove(e, ref handled);
- }
- // Notify area X and Y cursors
- area.CursorX.Cursor_MouseMove(e, ref handled);
- area.CursorY.Cursor_MouseMove(e, ref handled);
- }
- }
- // Notify Selection object for tool tips processing
- if(!handled)
- {
- this.selection.Selection_MouseMove(this, e);
- }
- // Notify annotation object collection about the mouse down event
- if(!handled)
- {
- this.Annotations.OnMouseMove(e);
- }
- // Call the base class
- base.OnMouseMove(e);
- }
- /// <summary>
- /// Mouse was double clicked on the control.
- /// </summary>
- /// <param name="e">Event arguments</param>
- protected override void OnDoubleClick(EventArgs e)
- {
- // Notify annotation object collection about the mouse down event
- this.Annotations.OnDoubleClick();
- // Call the base class
- base.OnDoubleClick(e);
- }
- #endregion
- #region Chart get tool tip text events
- /// <summary>
- /// Called before showing the tooltip to get the tooltip text.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_GetToolTipText"),
- SRCategory("CategoryAttributeToolTips")]
- public event EventHandler<ToolTipEventArgs> GetToolTipText;
- /// <summary>
- /// Checks if GetToolTipEvent is used
- /// </summary>
- /// <returns>True if event is used</returns>
- internal bool IsToolTipEventUsed()
- {
- if(GetToolTipText != null)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Cursor event arguments.</param>
- internal void OnGetToolTipText(ToolTipEventArgs arguments)
- {
- if(GetToolTipText != null)
- {
- GetToolTipText(this, arguments);
- }
- }
- #endregion
- #region Chart area cursor and selection events
-
- /// <summary>
- /// Called when cursor position is about to change.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_CursorPositionChanging"),
- SRCategory("CategoryAttributeCursor")]
- public event EventHandler<CursorEventArgs> CursorPositionChanging;
- /// <summary>
- /// Called when cursor position is changed.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_CursorPositionChanged"),
- SRCategory("CategoryAttributeCursor")]
- public event EventHandler<CursorEventArgs> CursorPositionChanged;
- /// <summary>
- /// Called when selection start/end position is about to change.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_SelectionRangeChanging"),
- SRCategory("CategoryAttributeCursor")]
- public event EventHandler<CursorEventArgs> SelectionRangeChanging;
- /// <summary>
- /// Called when selection start/end position is changed.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_SelectionRangeChanged"),
- SRCategory("CategoryAttributeCursor")]
- public event EventHandler<CursorEventArgs> SelectionRangeChanged;
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Cursor event arguments.</param>
- internal void OnCursorPositionChanging(CursorEventArgs arguments)
- {
- if(CursorPositionChanging != null)
- {
- CursorPositionChanging(this, arguments);
- }
- }
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Cursor event arguments.</param>
- internal void OnCursorPositionChanged(CursorEventArgs arguments)
- {
- if(CursorPositionChanged != null)
- {
- CursorPositionChanged(this, arguments);
- }
- }
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Cursor event arguments.</param>
- internal void OnSelectionRangeChanging(CursorEventArgs arguments)
- {
- if(SelectionRangeChanging != null)
- {
- SelectionRangeChanging(this, arguments);
- }
- }
-
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Cursor event arguments.</param>
- internal void OnSelectionRangeChanged(CursorEventArgs arguments)
- {
- if(SelectionRangeChanged != null)
- {
- SelectionRangeChanged(this, arguments);
- }
- }
- #endregion
- #region Axis data scaleView position/size changing events
- /// <summary>
- /// Called when axis scaleView position/size is about to change.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_AxisViewChanging"),
- SRCategory("CategoryAttributeAxisView")]
- public event EventHandler<ViewEventArgs> AxisViewChanging;
- /// <summary>
- /// Called when axis scaleView position/size is changed.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_AxisViewChanged"),
- SRCategory("CategoryAttributeAxisView")]
- public event EventHandler<ViewEventArgs> AxisViewChanged;
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Axis scaleView event arguments.</param>
- internal void OnAxisViewChanging(ViewEventArgs arguments)
- {
- if(AxisViewChanging != null)
- {
- AxisViewChanging(this, arguments);
- }
- }
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Axis scaleView event arguments.</param>
- internal void OnAxisViewChanged(ViewEventArgs arguments)
- {
- if(AxisViewChanged != null)
- {
- AxisViewChanged(this, arguments);
- }
- }
- #endregion
- #region Axis scroll bar events
- /// <summary>
- /// Called when axis scroll bar is used by user.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_AxisScrollBarClicked"),
- SRCategory("CategoryAttributeAxisView")]
- public event EventHandler<ScrollBarEventArgs> AxisScrollBarClicked;
- /// <summary>
- /// Calls event delegate.
- /// </summary>
- /// <param name="arguments">Axis scroll bar event arguments.</param>
- internal void OnAxisScrollBarClicked(ScrollBarEventArgs arguments)
- {
- if(AxisScrollBarClicked != null)
- {
- AxisScrollBarClicked(this, arguments);
- }
- }
- #endregion
- #region Painting events
- /// <summary>
- /// Called when chart element is painted.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_PostPaint"),
- SRCategory("CategoryAttributeAppearance")]
- public event EventHandler<ChartPaintEventArgs> PostPaint;
- /// <summary>
- /// Called when chart element back ground is painted.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_PrePaint"),
- SRCategory("CategoryAttributeAppearance")]
- public event EventHandler<ChartPaintEventArgs> PrePaint;
- /// <summary>
- /// Fires when chart element backround must be drawn.
- /// This event is fired for elements like: ChartPicture, ChartArea and Legend
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected virtual void OnPrePaint(ChartPaintEventArgs e)
- {
- if(PrePaint != null)
- {
- PrePaint(this, e);
- }
- }
- /// <summary>
- /// Fires when chart element backround must be drawn.
- /// This event is fired for elements like: ChartPicture, ChartArea and Legend
- /// </summary>
- /// <param name="e">Event arguments.</param>
- internal void CallOnPrePaint(ChartPaintEventArgs e)
- {
- this.OnPrePaint(e);
- }
- /// <summary>
- /// Fires when chart element must be drawn.
- /// This event is fired for elements like: ChartPicture, ChartArea and Legend
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected virtual void OnPostPaint(ChartPaintEventArgs e)
- {
- if(PostPaint != null)
- {
- PostPaint(this, e);
- }
- }
- /// <summary>
- /// Fires when chart element must be drawn.
- /// This event is fired for elements like: ChartPicture, ChartArea and Legend
- /// </summary>
- /// <param name="e">Event arguments.</param>
- internal void CallOnPostPaint(ChartPaintEventArgs e)
- {
- this.OnPostPaint(e);
- }
-
- #endregion
- #region Customize event
- /// <summary>
- /// Fires just before the chart image is drawn. Use this event to customize the chart picture.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_Customize")
- ]
- public event EventHandler Customize;
- /// <summary>
- /// Fires when all chart data is prepared to be customized before drawing.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChart_OnCustomize")
- ]
- protected virtual void OnCustomize()
- {
- if(Customize != null)
- {
- Customize(this, EventArgs.Empty);
- }
- }
- /// <summary>
- /// Fires when all chart data is prepared to be customized before drawing.
- /// </summary>
- internal void CallOnCustomize()
- {
- this.OnCustomize();
- }
- /// <summary>
- /// Use this event to customize chart legend.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_CustomizeLegend")
- ]
- public event EventHandler<CustomizeLegendEventArgs> CustomizeLegend;
- /// <summary>
- /// Fires when all chart data is prepared to be customized before drawing.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChart_OnCustomizeLegend")
- ]
- protected virtual void OnCustomizeLegend(LegendItemsCollection legendItems, string legendName)
- {
- if (CustomizeLegend != null)
- {
- CustomizeLegend(this, new CustomizeLegendEventArgs(legendItems, legendName));
- }
- }
- /// <summary>
- /// Fires when all chart data is prepared to be customized before drawing.
- /// </summary>
- internal void CallOnCustomizeLegend(LegendItemsCollection legendItems, string legendName)
- {
- this.OnCustomizeLegend(legendItems, legendName);
- }
- #endregion
- #region Annotation events
- /// <summary>
- /// Fires when annotation text was changed.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_AnnotationTextChanged"),
- SRCategory("CategoryAttributeAnnotation")
- ]
- public event EventHandler AnnotationTextChanged;
- /// <summary>
- /// Fires when annotation text is changed.
- /// </summary>
- /// <param name="annotation">Annotation which text was changed.</param>
- internal void OnAnnotationTextChanged(Annotation annotation)
- {
- if(AnnotationTextChanged != null)
- {
- AnnotationTextChanged(annotation, EventArgs.Empty);
- }
- }
- /// <summary>
- /// Fires when selected annotation changes.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_AnnotationSelectionChanged"),
- SRCategory("CategoryAttributeAnnotation")
- ]
- public event EventHandler AnnotationSelectionChanged;
- /// <summary>
- /// Fires when annotation position was changed.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_AnnotationPositionChanged"),
- SRCategory("CategoryAttributeAnnotation")
- ]
- public event EventHandler AnnotationPositionChanged;
- /// <summary>
- /// Fires when annotation position is changing.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_AnnotationPositionChanging"),
- SRCategory("CategoryAttributeAnnotation")
- ]
- public event EventHandler<AnnotationPositionChangingEventArgs> AnnotationPositionChanging;
- /// <summary>
- /// Fires when annotation is placed by the user on the chart.
- /// </summary>
- [
- SRDescription("DescriptionAttributeChartEvent_AnnotationPlaced"),
- SRCategory("CategoryAttributeAnnotation")
- ]
- public event EventHandler AnnotationPlaced;
- /// <summary>
- /// Fires when annotation is placed by the user on the chart.
- /// </summary>
- /// <param name="annotation">Annotation which was placed.</param>
- internal void OnAnnotationPlaced(Annotation annotation)
- {
- if(AnnotationPlaced != null)
- {
- AnnotationPlaced(annotation, EventArgs.Empty);
-
- }
- }
-
- /// <summary>
- /// Fires when selected annotation changes.
- /// </summary>
- /// <param name="annotation">Annotation which have it's selection changed.</param>
- internal void OnAnnotationSelectionChanged(Annotation annotation)
- {
- if(AnnotationSelectionChanged != null)
- {
- AnnotationSelectionChanged(annotation, EventArgs.Empty);
- }
- }
- /// <summary>
- /// Fires when annotation position was changed.
- /// </summary>
- /// <param name="annotation">Annotation which have it's position changed.</param>
- internal void OnAnnotationPositionChanged(Annotation annotation)
- {
- if(AnnotationPositionChanged != null)
- {
- AnnotationPositionChanged(annotation, EventArgs.Empty);
- }
- }
- /// <summary>
- /// Fires when annotation position is changing.
- /// </summary>
- /// <param name="args">Event arguments.</param>
- /// <returns>True if event was processed.</returns>
- internal bool OnAnnotationPositionChanging(ref AnnotationPositionChangingEventArgs args)
- {
- if(AnnotationPositionChanging != null)
- {
- AnnotationPositionChanging(args.Annotation, args);
- return true;
- }
- return false;
- }
- #endregion
- #region Control DataBind method
-
- /// <summary>
- /// Data binds control to the selected data source.
- /// </summary>
- public void DataBind()
- {
- this.chartPicture.DataBind();
- }
- /// <summary>
- /// Aligns data points using their axis labels.
- /// </summary>
- public void AlignDataPointsByAxisLabel()
- {
- this.chartPicture.AlignDataPointsByAxisLabel(false, PointSortOrder.Ascending);
- }
- /// <summary>
- /// Aligns data points using their axis labels.
- /// </summary>
- /// <param name="series">Comma separated list of series that should be aligned by axis label.</param>
- public void AlignDataPointsByAxisLabel(string series)
- {
- //Check arguments
- if (series == null)
- throw new ArgumentNullException("series");
- // Create list of series
- ArrayList seriesList = new ArrayList();
- string[] seriesNames = series.Split(',');
- foreach(string name in seriesNames)
- {
- seriesList.Add(this.Series[name.Trim()]);
- }
- // Align series
- this.chartPicture.AlignDataPointsByAxisLabel(seriesList, false, PointSortOrder.Ascending);
- }
- /// <summary>
- /// Aligns data points using their axis labels.
- /// </summary>
- /// <param name="series">Comma separated list of series that should be aligned by axis label.</param>
- /// <param name="sortingOrder">Points sorting order by axis labels.</param>
- public void AlignDataPointsByAxisLabel(string series, PointSortOrder sortingOrder)
- {
- //Check arguments
- if (series == null)
- throw new ArgumentNullException("series");
-
- // Create list of series
- ArrayList seriesList = new ArrayList();
- string[] seriesNames = series.Split(',');
- foreach(string name in seriesNames)
- {
- seriesList.Add(this.Series[name.Trim()]);
- }
- // Align series
- this.chartPicture.AlignDataPointsByAxisLabel(seriesList, true, sortingOrder);
- }
- /// <summary>
- /// Aligns data points using their axis labels.
- /// </summary>
- /// <param name="sortingOrder">Points sorting order by axis labels.</param>
- public void AlignDataPointsByAxisLabel(PointSortOrder sortingOrder)
- {
- this.chartPicture.AlignDataPointsByAxisLabel(true, sortingOrder);
- }
- /// <summary>
- /// Automatically creates and binds series to specified data table.
- /// Each column of the table becomes a Y value in a separate series.
- /// Series X value field may also be provided.
- /// </summary>
- /// <param name="dataSource">Data source.</param>
- /// <param name="xField">Name of the field for series X values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X is a cartesian coordinate and well understood")]
- public void DataBindTable(
- IEnumerable dataSource,
- string xField)
- {
- this.chartPicture.DataBindTable(
- dataSource,
- xField);
- }
- /// <summary>
- /// Automatically creates and binds series to specified data table.
- /// Each column of the table becomes a Y value in a separate series.
- /// </summary>
- /// <param name="dataSource">Data source.</param>
- public void DataBindTable(IEnumerable dataSource)
- {
- this.chartPicture.DataBindTable(
- dataSource,
- String.Empty);
- }
- /// <summary>
- /// Data bind chart to the table. Series will be automatically added to the chart depending ont
- /// yhe number of unique values in the seriesGroupByField column of the data source.
- /// Data source can be the Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="dataSource">Data source.</param>
- /// <param name="seriesGroupByField">Name of the field used to group data into series.</param>
- /// <param name="xField">Name of the field for X values.</param>
- /// <param name="yFields">Comma separated name(s) of the field(s) for Y value(s).</param>
- /// <param name="otherFields">Other point properties binding rule in format: PointProperty=Field[{Format}] [,PointProperty=Field[{Format}]]. For example: "Tooltip=Price{C1},Url=WebSiteName".</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void DataBindCrossTable(
- IEnumerable dataSource,
- string seriesGroupByField,
- string xField,
- string yFields,
- string otherFields)
- {
- this.chartPicture.DataBindCrossTab(
- dataSource,
- seriesGroupByField,
- xField,
- yFields,
- otherFields,
- false,
- PointSortOrder.Ascending);
- }
- /// <summary>
- /// Data bind chart to the table. Series will be automatically added to the chart depending ont
- /// yhe number of unique values in the seriesGroupByField column of the data source.
- /// Data source can be the Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="dataSource">Data source.</param>
- /// <param name="seriesGroupByField">Name of the field used to group data into series.</param>
- /// <param name="xField">Name of the field for X values.</param>
- /// <param name="yFields">Comma separated name(s) of the field(s) for Y value(s).</param>
- /// <param name="otherFields">Other point properties binding rule in format: PointProperty=Field[{Format}] [,PointProperty=Field[{Format}]]. For example: "Tooltip=Price{C1},Url=WebSiteName".</param>
- /// <param name="sortingOrder">Series will be sorted by group field values in specified order.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void DataBindCrossTable(
- IEnumerable dataSource,
- string seriesGroupByField,
- string xField,
- string yFields,
- string otherFields,
- PointSortOrder sortingOrder)
- {
- this.chartPicture.DataBindCrossTab(
- dataSource,
- seriesGroupByField,
- xField,
- yFields,
- otherFields,
- true,
- sortingOrder);
- }
- #endregion
- #region Special Extension Methods and Properties
- /// <summary>
- /// Gets the requested chart service.
- /// </summary>
- /// <param name="serviceType">AxisName of requested service.</param>
- /// <returns>Instance of the service or null if it can't be found.</returns>
- public new object GetService(Type serviceType)
- {
- // Check arguments
- if (serviceType == null)
- throw new ArgumentNullException("serviceType");
- object service = null;
- if(serviceContainer != null)
- {
- service = serviceContainer.GetService(serviceType);
- }
- if(service == null)
- {
- base.GetService(serviceType);
- }
- return service;
- }
- /// <summary>
- /// Called when a numeric value has to be converted to a string.
- /// </summary>
- [SRDescription("DescriptionAttributeChartEvent_PrePaint")]
- public event EventHandler<FormatNumberEventArgs> FormatNumber;
- /// <summary>
- /// Utility method for firing the FormatNumber event. Allows it to be
- /// handled via OnFormatNumber as is the usual pattern as well as via
- /// CallOnFormatNumber.
- /// </summary>
- /// <param name="caller">Event caller. Can be ChartPicture, ChartArea or Legend objects.</param>
- /// <param name="e">Event arguemtns</param>
- private void OnFormatNumber(object caller, FormatNumberEventArgs e)
- {
- if (FormatNumber != null)
- {
- FormatNumber(caller, e);
- }
- }
- /// <summary>
- /// Called when a numeric value has to be converted to a string.
- /// </summary>
- /// <param name="e">Event arguments.</param>
- protected virtual void OnFormatNumber(FormatNumberEventArgs e)
- {
- OnFormatNumber(this, e);
- }
- /// <summary>
- /// Called when a numeric value has to be converted to a string.
- /// </summary>
- /// <param name="caller">Event caller. Can be ChartPicture, ChartArea or Legend objects.</param>
- /// <param name="e">Event arguments.</param>
- internal void CallOnFormatNumber(object caller, FormatNumberEventArgs e)
- {
- this.OnFormatNumber(caller, e);
- }
- #endregion
- #region Accessibility
- #if ACCESSIBLE
- // Current chart accessibility object
- private ChartAccessibleObject _chartAccessibleObject = null;
- /// <summary>
- /// Overridden to return the custom AccessibleObject for the entire chart.
- /// </summary>
- /// <returns>Chart accessibility object.</returns>
- protected override AccessibleObject CreateAccessibilityInstance()
- {
- if (this._chartAccessibleObject == null)
- {
- this._chartAccessibleObject = new ChartAccessibleObject(this);
- }
- return this._chartAccessibleObject;
- }
- /// <summary>
- /// Reset accessibility object children.
- /// </summary>
- private void ResetAccessibilityObject()
- {
- if (this._chartAccessibleObject != null)
- {
- this._chartAccessibleObject.ResetChildren();
- }
- }
- #endif
- #endregion // Accessibility
- #region IDisposable override
- /// <summary>
- /// Disposing control resourses
- /// </summary>
- protected override void Dispose(bool disposing)
- {
- // call first because font cache
- base.Dispose(disposing);
- if (disposing)
- {
- // Dispose managed objects here
- if (_imageLoader != null)
- {
- _imageLoader.Dispose();
- _imageLoader = null;
- }
- if (_namedImages != null)
- {
- _namedImages.Dispose();
- _namedImages = null;
- }
- if (_chartTypeRegistry != null)
- {
- _chartTypeRegistry.Dispose();
- _chartTypeRegistry = null;
- }
- if (serviceContainer != null)
- {
- serviceContainer.RemoveService(typeof(Chart));
- serviceContainer.Dispose();
- serviceContainer = null;
- }
- // Dispose selection manager
- if (selection != null)
- {
- selection.Dispose();
- selection = null;
- }
- // Dispose print manager
- if (_printingManager != null)
- {
- _printingManager.Dispose();
- _printingManager = null;
- }
- // Dispoase buffer
- if (paintBufferBitmap != null)
- {
- paintBufferBitmap.Dispose();
- paintBufferBitmap = null;
- }
- if (paintBufferBitmapGraphics != null)
- {
- paintBufferBitmapGraphics.Dispose();
- paintBufferBitmapGraphics = null;
- }
- }
-
- base.Dispose(disposing);
- //The chart picture and datamanager will be the last to be disposed
- if (disposing)
- {
- if (_dataManager != null)
- {
- _dataManager.Dispose();
- _dataManager = null;
- }
- if (chartPicture != null)
- {
- chartPicture.Dispose();
- chartPicture = null;
- }
- }
- }
- #endregion
- }
- #region Customize event delegate
- /// <summary>
- /// Chart legend customize events arguments
- /// </summary>
- public class CustomizeLegendEventArgs : EventArgs
- {
- private LegendItemsCollection _legendItems = null;
- private string _legendName = "";
- /// <summary>
- /// Default construvtor is not accessible
- /// </summary>
- private CustomizeLegendEventArgs()
- {
- }
- /// <summary>
- /// Customize legend event arguments constructor
- /// </summary>
- /// <param name="legendItems">Legend items collection.</param>
- public CustomizeLegendEventArgs(LegendItemsCollection legendItems)
- {
- this._legendItems = legendItems;
- }
- /// <summary>
- /// Customize legend event arguments constructor
- /// </summary>
- /// <param name="legendItems">Legend items collection.</param>
- /// <param name="legendName">Legend name.</param>
- public CustomizeLegendEventArgs(LegendItemsCollection legendItems, string legendName)
- {
- this._legendItems = legendItems;
- this._legendName = legendName;
- }
- /// <summary>
- /// Legend name.
- /// </summary>
- public string LegendName
- {
- get
- {
- return _legendName;
- }
- }
- /// <summary>
- /// Legend items collection.
- /// </summary>
- public LegendItemsCollection LegendItems
- {
- get
- {
- return _legendItems;
- }
- }
- }
- #endregion
- }
|