1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244 |
- // 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: Classes related to the Data Points:
- // DataPointCollection - data points collection class
- // DataPoint - data point properties and methods
- // DataPointCustomProperties - data point & series properties
- // DataPointComparer - used for sorting data points in series
- //
- using System;
- using System.Windows.Forms;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Common;
- using System.Diagnostics.CodeAnalysis;
- using System.Drawing;
- using System.Drawing.Design;
- using System.Globalization;
- using System.Text;
- using FastReport.DataVisualization.Charting.Utilities;
- using FastReport.Design.DataVisualization.Charting;
- namespace FastReport.DataVisualization.Charting
- {
- #region CustomProperties enumeration
- /// <summary>
- /// Enumeration of common properties names.
- /// </summary>
- internal enum CommonCustomProperties
- {
- PointName,
- Label,
- AxisLabel,
- LabelFormat,
- IsValueShownAsLabel,
- Color,
- BorderColor,
- BorderDashStyle,
- BorderWidth,
- BackImage,
- BackImageWrapMode,
- BackImageAlignment,
- BackImageTransparentColor,
- BackGradientStyle,
- BackSecondaryColor,
- BackHatchStyle,
- Font,
- LabelForeColor,
- LabelAngle,
- MarkerStyle,
- MarkerSize,
- MarkerImage,
- MarkerImageTransparentColor,
- MarkerColor,
- MarkerBorderColor,
- MarkerBorderWidth,
- MapAreaAttributes,
- PostBackValue,
- MapAreaType,
- LegendMapAreaType,
- LabelMapAreaType,
- Url,
- ToolTip,
- Tag,
- LegendUrl,
- LegendToolTip,
- LegendText,
- LegendMapAreaAttributes,
- LegendPostBackValue,
- IsVisibleInLegend,
- LabelUrl,
- LabelToolTip,
- LabelMapAreaAttributes,
- LabelPostBackValue,
- LabelBorderColor,
- LabelBorderDashStyle,
- LabelBorderWidth,
- LabelBackColor,
- };
- #endregion
- /// <summary>
- /// Data points comparer class
- /// </summary>
- [
- SRDescription("DescriptionAttributeDataPointComparer_DataPointComparer")
- ]
- public class DataPointComparer : IComparer<DataPoint>
- {
- #region Fields
- // Sorting order
- private PointSortOrder _sortingOrder = PointSortOrder.Ascending;
- // Sorting value index
- private int _sortingValueIndex = 1;
- #endregion
- #region Constructors
- /// <summary>
- /// Private default constructor.
- /// </summary>
- private DataPointComparer()
- {
- }
- /// <summary>
- /// Data points comparer class constructor.
- /// </summary>
- /// <param name="series">Data series.</param>
- /// <param name="sortOrder">Sorting order.</param>
- /// <param name="sortBy">Value used for sorting ("X", "Y or Y1", "Y2", ...).</param>
- public DataPointComparer(Series series, PointSortOrder sortOrder, string sortBy)
- {
- // Check if sorting value is valid
- sortBy = sortBy.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
- if(String.Compare(sortBy, "X", StringComparison.Ordinal) == 0)
- {
- _sortingValueIndex = -1;
- }
- else if (String.Compare(sortBy, "Y", StringComparison.Ordinal) == 0)
- {
- _sortingValueIndex = 0;
- }
- else if (String.Compare(sortBy, "AXISLABEL", StringComparison.Ordinal) == 0)
- {
- _sortingValueIndex = -2;
- }
- else if(sortBy.Length == 2 &&
- sortBy.StartsWith("Y", StringComparison.Ordinal) &&
- Char.IsDigit(sortBy[1]))
- {
- _sortingValueIndex = Int32.Parse(sortBy.Substring(1), System.Globalization.CultureInfo.InvariantCulture) - 1;
- }
- else
- {
- throw(new ArgumentException( SR.ExceptionDataPointConverterInvalidSorting, "sortBy"));
- }
- // Check if data series support as many Y values as required
- if(_sortingValueIndex > 0 && _sortingValueIndex >= series.YValuesPerPoint)
- {
- throw(new ArgumentException( SR.ExceptionDataPointConverterUnavailableSorting(sortBy, series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture) ), "sortBy"));
- }
- this._sortingOrder = sortOrder;
- }
- #endregion
- #region Comparing method
- /// <summary>
- /// Compares two data points.
- /// </summary>
- /// <param name="x">First data point.</param>
- /// <param name="y">Second data point.</param>
- /// <returns>If the two values are equal, it returns zero. If point 1 is greater than point 2,
- /// it returns a positive integer; otherwise, it returns a negative integer.
- /// </returns>
- public int Compare(DataPoint x, DataPoint y)
- {
- int result = -1;
- // Compare X value
- if(_sortingValueIndex == -1)
- {
- result = x.XValue.CompareTo(y.XValue);
- }
- // Compare Axis Label value
- else if(_sortingValueIndex == -2)
- {
- result = string.Compare(x.AxisLabel, y.AxisLabel, StringComparison.CurrentCulture);
- }
- // Compare one of the Y value(s)
- else
- {
- result = x.YValues[_sortingValueIndex].CompareTo(y.YValues[_sortingValueIndex]);
- }
- // Invert result depending on the sorting order
- if(this._sortingOrder == PointSortOrder.Descending)
- {
- result = -result;
- }
- return result;
- }
- #endregion
- }
- /// <summary>
- /// A collection of data points.
- /// </summary>
- [
- SRDescription("DescriptionAttributeDataPointCollection_DataPointCollection"),
- ]
- public class DataPointCollection : ChartElementCollection<DataPoint>
- {
- #region Fields
- // Reference to the sereies of data points
- internal Series series = null;
- #endregion
- #region Constructors and Initialization
- /// <summary>
- /// Data Point Collection object constructor.
- /// </summary>
- /// <param name="series">Series object, which the Data Point Collection belongs to.</param>
- internal DataPointCollection(Series series) : base(series)
- {
- this.series = series;
- }
- /// <summary>
- /// Initialize data point series and name.
- /// </summary>
- /// <param name="dataPoint">Reference to the data point object to initialize.</param>
- internal void DataPointInit(ref DataPoint dataPoint)
- {
- DataPointInit(this.series, ref dataPoint);
- }
- /// <summary>
- /// Initialize data point series and name.
- /// </summary>
- /// <param name="series">Series the data point belongs to.</param>
- /// <param name="dataPoint">Reference to the data point object to initialize.</param>
- internal static void DataPointInit(Series series, ref DataPoint dataPoint)
- {
- dataPoint.series = series;
- if(dataPoint.AxisLabel.Length > 0 && series != null)
- {
- series.noLabelsInPoints = false;
- }
- // Set flag that tooltips flags should be recalculated
- if(dataPoint.ToolTip.Length > 0 &&
- dataPoint.LegendToolTip.Length > 0 &&
- dataPoint.LabelToolTip.Length > 0 &&
- series != null && series.Chart != null && series.Chart.selection != null)
- {
- series.Chart.selection.enabledChecked = false;
- }
- }
- #endregion
- #region Data point binding, adding and inserting methods
- /// <summary>
- /// Adds the new DataPoint to a collection and sets its Y values.
- /// </summary>
- /// <param name="y">The y.</param>
- /// <returns></returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public DataPoint Add(params double[] y)
- {
- DataPoint point = new DataPoint(0, y);
- this.Add(point);
- return point;
- }
- /// <summary>
- /// Parse the input parameter with other point attribute binding rule
- /// in format: PointProperty=Field[{Format}] [,PointProperty=Field[{Format}]].
- /// For example: "Tooltip=Price{C1},Url=WebSiteName".
- /// </summary>
- /// <param name="otherFields">Other fields parameter.</param>
- /// <param name="otherAttributeNames">Returns array of attribute names.</param>
- /// <param name="otherFieldNames">Returns array of field names.</param>
- /// <param name="otherValueFormat">Returns array of format strings.</param>
- internal static void ParsePointFieldsParameter(
- string otherFields,
- ref string[] otherAttributeNames,
- ref string[] otherFieldNames,
- ref string[] otherValueFormat)
- {
- if(otherFields != null && otherFields.Length > 0)
- {
- // Split string by comma
- otherAttributeNames = otherFields.Replace(",,", "\n").Split(',');
- otherFieldNames = new string[otherAttributeNames.Length];
- otherValueFormat = new string[otherAttributeNames.Length];
- // Loop through all strings
- for(int index = 0; index < otherAttributeNames.Length; index++)
- {
- // Split string by equal sign
- int equalSignIndex = otherAttributeNames[index].IndexOf('=');
- if(equalSignIndex > 0)
- {
- otherFieldNames[index] = otherAttributeNames[index].Substring(equalSignIndex + 1);
- otherAttributeNames[index] = otherAttributeNames[index].Substring(0, equalSignIndex);
- }
- else
- {
- throw (new ArgumentException(SR.ExceptionParameterFormatInvalid, "otherFields"));
- }
- // Check if format string was specified
- int bracketIndex = otherFieldNames[index].IndexOf('{');
- if(bracketIndex > 0 && otherFieldNames[index][otherFieldNames[index].Length - 1] == '}')
- {
- otherValueFormat[index] = otherFieldNames[index].Substring(bracketIndex + 1);
- otherValueFormat[index] = otherValueFormat[index].Trim('{', '}');
- otherFieldNames[index] = otherFieldNames[index].Substring(0, bracketIndex);
- }
- // Trim and replace new line character
- otherAttributeNames[index] = otherAttributeNames[index].Trim().Replace("\n", ",");
- otherFieldNames[index] = otherFieldNames[index].Trim().Replace("\n", ",");
- if ( otherValueFormat[index] != null )
- otherValueFormat[index] = otherValueFormat[index].Trim().Replace("\n", ",");
- }
- }
- }
- /// <summary>
- /// Data bind X, Y and other values (like Tooltip, LabelStyle,...) of the data points to 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="xField">Name of the field for X values.</param>
- /// <param name="yFields">Comma separated names of the fields for Y values.</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 DataBind(IEnumerable dataSource, string xField, string yFields, string otherFields)
- {
- // Check arguments
- if (dataSource == null)
- throw new ArgumentNullException("dataSource", SR.ExceptionDataPointInsertionNoDataSource);
- if (dataSource is string)
- throw (new ArgumentException(SR.ExceptionDataBindSeriesToString, "dataSource"));
- if (yFields == null)
- throw new ArgumentNullException("yFields");
- // Convert comma separated Y values field names string to array of names
- string[] yFieldNames = yFields.Replace(",,", "\n").Split(',');
- for(int index = 0; index < yFieldNames.Length; index++)
- {
- yFieldNames[index] = yFieldNames[index].Replace("\n", ",");
- }
- if (yFieldNames.GetLength(0) > series.YValuesPerPoint)
- throw (new ArgumentOutOfRangeException("yFields", SR.ExceptionDataPointYValuesCountMismatch(series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture))));
- // Convert other fields/properties names to two arrays of names
- string[] otherAttributeNames = null;
- string[] otherFieldNames = null;
- string[] otherValueFormat = null;
- ParsePointFieldsParameter(
- otherFields,
- ref otherAttributeNames,
- ref otherFieldNames,
- ref otherValueFormat);
- // Remove all existing data points
- this.Clear();
- // Get and reset enumerator
- IEnumerator enumerator = GetDataSourceEnumerator(dataSource);
- if (enumerator.GetType() != typeof(System.Data.Common.DbEnumerator))
- {
- try
- {
- enumerator.Reset();
- }
- // Some enumerators may not support Resetting
- catch (InvalidOperationException)
- {
- }
- catch (NotImplementedException)
- {
- }
- catch (NotSupportedException)
- {
- }
- }
- // Add data points
- bool valueExsist = true;
- object[] yValuesObj = new object[yFieldNames.Length];
- object xValueObj = null;
- bool autoDetectType = true;
- this.SuspendUpdates();
- try
- {
- do
- {
- // Move to the next objects in the enumerations
- if (valueExsist)
- {
- valueExsist = enumerator.MoveNext();
- }
- // Auto detect valu(s) type
- if (autoDetectType)
- {
- autoDetectType = false;
- AutoDetectValuesType(this.series, enumerator, xField, enumerator, yFieldNames[0]);
- }
- // Create and initialize data point
- if (valueExsist)
- {
- DataPoint newDataPoint = new DataPoint(series);
- bool emptyValues = false;
- // Set X to the value provided
- if (xField.Length > 0)
- {
- xValueObj = ConvertEnumerationItem(enumerator.Current, xField);
- if (IsEmptyValue(xValueObj))
- {
- emptyValues = true;
- xValueObj = 0.0;
- }
- }
- // Set Y values
- if (yFieldNames.Length == 0)
- {
- yValuesObj[0] = ConvertEnumerationItem(enumerator.Current, null);
- if (IsEmptyValue(yValuesObj[0]))
- {
- emptyValues = true;
- yValuesObj[0] = 0.0;
- }
- }
- else
- {
- for (int i = 0; i < yFieldNames.Length; i++)
- {
- yValuesObj[i] = ConvertEnumerationItem(enumerator.Current, yFieldNames[i]);
- if (IsEmptyValue(yValuesObj[i]))
- {
- emptyValues = true;
- yValuesObj[i] = 0.0;
- }
- }
- }
- // Set other values
- if (otherAttributeNames != null &&
- otherAttributeNames.Length > 0)
- {
- for (int i = 0; i < otherFieldNames.Length; i++)
- {
- // Get object by field name
- object obj = ConvertEnumerationItem(enumerator.Current, otherFieldNames[i]);
- if (!IsEmptyValue(obj))
- {
- newDataPoint.SetPointCustomProperty(
- obj,
- otherAttributeNames[i],
- otherValueFormat[i]);
- }
- }
- }
- // IsEmpty value was detected
- if (emptyValues)
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- newDataPoint.IsEmpty = true;
- this.Add(newDataPoint);
- }
- else
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- this.Add(newDataPoint);
- }
- }
- } while (valueExsist);
- }
- finally
- {
- this.ResumeUpdates();
- }
- }
- /// <summary>
- /// Data bind Y values of the data points to the data source.
- /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="yValue">One or more enumerable objects with Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "Y is a cartesian coordinate and well understood")]
- public void DataBindY(params IEnumerable[] yValue)
- {
- DataBindXY(null, yValue);
- }
- /// <summary>
- /// Data bind X and Y values of the data points to the data source.
- /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="xValue">Enumerable objects with X values.</param>
- /// <param name="yValues">One or more enumerable objects with Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void DataBindXY(IEnumerable xValue, params IEnumerable[] yValues)
- {
- // Y value must be provided
- if (yValues == null ||
- yValues.Length==1 && yValues[0]==null)
- throw new ArgumentNullException("yValues");
- if (yValues.GetLength(0) == 0)
- throw new ArgumentException(SR.ExceptionDataPointBindingYValueNotSpecified, "yValues");
- // Double check that a string object is not provided for data binding
- for(int i = 0; i < yValues.Length; i++)
- {
- if(yValues[i] is string)
- {
- throw (new ArgumentException(SR.ExceptionDataBindYValuesToString, "yValues"));
- }
- }
- // Check if number of Y values do not out of range
- if(yValues.GetLength(0) > series.YValuesPerPoint)
- {
- throw(new ArgumentOutOfRangeException("yValues", SR.ExceptionDataPointYValuesBindingCountMismatch( series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture) ) ) );
- }
- // Remove all existing data points
- this.Clear();
- // Reset X, Y enumerators
- IEnumerator xEnumerator = null;
- IEnumerator[] yEnumerator = new IEnumerator[yValues.GetLength(0)];
- if(xValue != null)
- {
- // Double check that a string object is not provided for data binding
- if(xValue is string)
- {
- throw (new ArgumentException(SR.ExceptionDataBindXValuesToString, "xValue"));
- }
-
- // Get and reset Y values enumerators
- xEnumerator = GetDataSourceEnumerator(xValue);
- if(xEnumerator.GetType() != typeof(System.Data.Common.DbEnumerator))
- {
- xEnumerator.Reset();
- }
- }
- for(int i = 0; i < yValues.Length; i++)
- {
- // Get and reset Y values enumerators
- yEnumerator[i] = GetDataSourceEnumerator(yValues[i]);
- if(yEnumerator[i].GetType() != typeof(System.Data.Common.DbEnumerator))
- {
- yEnumerator[i].Reset();
- }
- }
- // Add data points
- bool xValueExsist = false;
- bool yValueExsist = true;
- object[] yValuesObj = new object[series.YValuesPerPoint];
- object xValueObj = null;
- bool autoDetectType = true;
- SuspendUpdates();
- try
- {
- do
- {
- // Move to the next objects in the enumerations
- yValueExsist = true;
- for (int i = 0; i < yValues.Length; i++)
- {
- if (yValueExsist)
- {
- yValueExsist = yEnumerator[i].MoveNext();
- }
- }
- if (xValue != null)
- {
- xValueExsist = xEnumerator.MoveNext();
- if (yValueExsist && !xValueExsist)
- {
- throw (new ArgumentOutOfRangeException("xValue", SR.ExceptionDataPointInsertionXValuesQtyIsLessYValues));
- }
- }
- // Auto detect value(s) type
- if (autoDetectType)
- {
- autoDetectType = false;
- AutoDetectValuesType(this.series, xEnumerator, null, yEnumerator[0], null);
- }
- // Create and initialize data point
- if (xValueExsist || yValueExsist)
- {
- DataPoint newDataPoint = new DataPoint(series);
- bool emptyValues = false;
- // Set X to the value provided
- if (xValueExsist)
- {
- xValueObj = ConvertEnumerationItem(xEnumerator.Current, null);
- if (xValueObj is System.DBNull || xValueObj == null)
- {
- emptyValues = true;
- xValueObj = 0.0;
- }
- }
- // Set Y values
- for (int i = 0; i < yValues.Length; i++)
- {
- yValuesObj[i] = ConvertEnumerationItem(yEnumerator[i].Current, null);
- if (yValuesObj[i] is System.DBNull || yValuesObj[i] == null)
- {
- emptyValues = true;
- yValuesObj[i] = 0.0;
- }
- }
- // IsEmpty value was detected
- if (emptyValues)
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- newDataPoint.IsEmpty = true;
- this.Add(newDataPoint);
- }
- else
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- this.Add(newDataPoint);
- }
- }
- } while (xValueExsist || yValueExsist);
- }
- finally
- {
- this.ResumeUpdates();
- }
- }
- /// <summary>
- /// Data bind Y values of the data points to the data source.
- /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="yValue">Enumerable objects with Y values.</param>
- /// <param name="yFields">Name of the fields for Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void DataBindY(IEnumerable yValue, string yFields)
- {
- DataBindXY(null, null, yValue, yFields);
- }
- /// <summary>
- /// Data bind X and Y values of the data points to the data source.
- /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
- /// </summary>
- /// <param name="xValue">Enumerable object with X values.</param>
- /// <param name="xField">Name of the field for X values.</param>
- /// <param name="yValue">Enumerable objects with Y values.</param>
- /// <param name="yFields">Comma separated names of the fields for Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void DataBindXY(IEnumerable xValue, string xField, IEnumerable yValue, string yFields)
- {
- // Check arguments
- if (xValue is string)
- throw new ArgumentException(SR.ExceptionDataBindXValuesToString, "xValue");
- if (yValue == null)
- throw new ArgumentNullException("yValue", SR.ExceptionDataPointInsertionYValueNotSpecified);
- if (yValue is string)
- throw new ArgumentException(SR.ExceptionDataBindYValuesToString, "yValue");
- if (yFields == null)
- throw new ArgumentOutOfRangeException("yFields", SR.ExceptionDataPointYValuesCountMismatch(series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture)));
- // Convert comma separated field names string to array of names
- string[] yFieldNames = yFields.Replace(",,", "\n").Split(',');;
- for(int index = 0; index < yFieldNames.Length; index++)
- {
- yFieldNames[index] = yFieldNames[index].Replace("\n", ",");
- }
- if (yFieldNames.GetLength(0) > series.YValuesPerPoint)
- throw new ArgumentOutOfRangeException("yFields", SR.ExceptionDataPointYValuesCountMismatch(series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture)));
-
- // Remove all existing data points
- this.Clear();
- // Reset X, Y enumerators
- IEnumerator xEnumerator = null;
- IEnumerator yEnumerator = GetDataSourceEnumerator(yValue);
-
- if(yEnumerator.GetType() != typeof(System.Data.Common.DbEnumerator))
- {
- yEnumerator.Reset();
- }
- if(xValue != null)
- {
- if(xValue != yValue)
- {
- xEnumerator = GetDataSourceEnumerator(xValue);
- if(xEnumerator.GetType() != typeof(System.Data.Common.DbEnumerator))
- {
- xEnumerator.Reset();
- }
- }
- else
- {
- xEnumerator = yEnumerator;
- }
- }
- // Add data points
- bool xValueExsist = false;
- bool yValueExsist = true;
- object[] yValuesObj = new object[yFieldNames.Length];
- object xValueObj = null;
- bool autoDetectType = true;
- this.SuspendUpdates();
- try
- {
- do
- {
- // Move to the next objects in the enumerations
- if (yValueExsist)
- {
- yValueExsist = yEnumerator.MoveNext();
- }
- if (xValue != null)
- {
- if (xValue != yValue)
- {
- xValueExsist = xEnumerator.MoveNext();
- if (yValueExsist && !xValueExsist)
- {
- throw (new ArgumentOutOfRangeException("xValue", SR.ExceptionDataPointInsertionXValuesQtyIsLessYValues));
- }
- }
- else
- {
- xValueExsist = yValueExsist;
- }
- }
- // Auto detect valu(s) type
- if (autoDetectType)
- {
- autoDetectType = false;
- AutoDetectValuesType(this.series, xEnumerator, xField, yEnumerator, yFieldNames[0]);
- }
- // Create and initialize data point
- if (xValueExsist || yValueExsist)
- {
- DataPoint newDataPoint = new DataPoint(series);
- bool emptyValues = false;
- // Set X to the value provided or use sequence numbers starting with 1
- if (xValueExsist)
- {
- xValueObj = ConvertEnumerationItem(xEnumerator.Current, xField);
- if (IsEmptyValue(xValueObj))
- {
- emptyValues = true;
- xValueObj = 0.0;
- }
- }
- if (yFieldNames.Length == 0)
- {
- yValuesObj[0] = ConvertEnumerationItem(yEnumerator.Current, null);
- if (IsEmptyValue(yValuesObj[0]))
- {
- emptyValues = true;
- yValuesObj[0] = 0.0;
- }
- }
- else
- {
- for (int i = 0; i < yFieldNames.Length; i++)
- {
- yValuesObj[i] = ConvertEnumerationItem(yEnumerator.Current, yFieldNames[i]);
- if (IsEmptyValue(yValuesObj[i]))
- {
- emptyValues = true;
- yValuesObj[i] = 0.0;
- }
- }
- }
- // IsEmpty value was detected
- if (emptyValues)
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- newDataPoint.IsEmpty = true;
- this.Add(newDataPoint);
- }
- else
- {
- if (xValueObj != null)
- {
- newDataPoint.SetValueXY(xValueObj, yValuesObj);
- }
- else
- {
- newDataPoint.SetValueXY(0, yValuesObj);
- }
- DataPointInit(ref newDataPoint);
- this.Add(newDataPoint);
- }
- }
- } while (xValueExsist || yValueExsist);
- }
- finally
- {
- this.ResumeUpdates();
- }
- }
- /// <summary>
- /// Returns true if objet represents an empty value.
- /// </summary>
- /// <param name="val">Value to test.</param>
- /// <returns>True if empty.</returns>
- internal static bool IsEmptyValue(object val)
- {
- if(val is System.DBNull || val == null)
- {
- return true;
- }
- if(val is double && double.IsNaN((double)val))
- {
- return true;
- }
- if(val is Single && Single.IsNaN((Single)val))
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// Adds one data point with one Y value.
- /// </summary>
- /// <param name="yValue">Y value of the data point.</param>
- /// <returns>Index of newly added data point.</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "Y is a cartesian coordinate and well understood")]
- public int AddY(double yValue)
- {
- // Create new point object
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueY(yValue);
- DataPointInit(ref newDataPoint);
- Add(newDataPoint);
- return Count - 1;
- }
- /// <summary>
- /// Adds one data point with one or more Y values.
- /// </summary>
- /// <param name="yValue">List of Y values of the data point.</param>
- /// <returns>Index of newly added data point.</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "Y is a cartesian coordinate and well understood")]
- public int AddY(params object[] yValue)
- {
- //Check arguments
- if (yValue == null ||
- yValue.Length==1 && yValue[0]==null)
- throw new ArgumentNullException("yValue");
- // Auto detect DateTime values type
- if(this.series.YValueType == ChartValueType.Auto &&
- yValue.Length > 0 &&
- yValue[0] != null)
- {
- if (yValue[0] is DateTime)
- {
- this.series.YValueType = ChartValueType.DateTime;
- this.series.autoYValueType = true;
- }
- else if (yValue[0] is DateTimeOffset)
- {
- this.series.YValueType = ChartValueType.DateTimeOffset;
- this.series.autoYValueType = true;
- }
- }
- // Create new point object
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueY(yValue);
- DataPointInit(ref newDataPoint);
- Add(newDataPoint);
- return Count - 1;
- }
- /// <summary>
- /// Adds one data point with X value and one Y value.
- /// </summary>
- /// <param name="yValue">Y value of the data point.</param>
- /// <param name="xValue">X value of the data point.</param>
- /// <returns>Index of newly added data poit.</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public int AddXY(double xValue, double yValue)
- {
- // Create new point object
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueXY(xValue, yValue);
- DataPointInit(ref newDataPoint);
- Add(newDataPoint);
- return Count - 1;
- }
- /// <summary>
- /// Adds one data point with X value and one or more Y values.
- /// </summary>
- /// <param name="yValue">List of Y values of the data point.</param>
- /// <param name="xValue">X value of the data point.</param>
- /// <returns>Index of newly added data poit.</returns>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public int AddXY(object xValue, params object[] yValue)
- {
- // Auto detect DateTime and String values type
- if(this.series.XValueType == ChartValueType.Auto)
- {
- if(xValue is DateTime)
- {
- this.series.XValueType = ChartValueType.DateTime;
- }
- if(xValue is DateTimeOffset)
- {
- this.series.XValueType = ChartValueType.DateTimeOffset;
- }
- if(xValue is string)
- {
- this.series.XValueType = ChartValueType.String;
- }
-
- this.series.autoXValueType = true;
- }
- if(this.series.YValueType == ChartValueType.Auto &&
- yValue.Length > 0 &&
- yValue[0] != null)
- {
- if (yValue[0] is DateTime)
- {
- this.series.YValueType = ChartValueType.DateTime;
- this.series.autoYValueType = true;
- }
- else if (yValue[0] is DateTimeOffset)
- {
- this.series.YValueType = ChartValueType.DateTimeOffset;
- this.series.autoYValueType = true;
- }
- }
- // Create new point object
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueXY(xValue, yValue);
- DataPointInit(ref newDataPoint);
- Add(newDataPoint);
- return Count - 1;
- }
- /// <summary>
- /// Insert one data point with X value and one or more Y values.
- /// </summary>
- /// <param name="index">Index after which to insert the data point.</param>
- /// <param name="xValue">X value of the data point.</param>
- /// <param name="yValue">List of Y values of the data point.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void InsertXY(int index, object xValue, params object[] yValue)
- {
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueXY(xValue, yValue);
- DataPointInit(ref newDataPoint);
- this.Insert(index, newDataPoint);
- }
- /// <summary>
- /// Insert one data point with one or more Y values.
- /// </summary>
- /// <param name="index">Index after which to insert the data point.</param>
- /// <param name="yValue">List of Y values of the data point.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "Y is a cartesian coordinate and well understood")]
- public void InsertY(int index, params object[] yValue)
- {
- DataPoint newDataPoint = new DataPoint(series);
- newDataPoint.SetValueY(yValue);
- DataPointInit(ref newDataPoint);
- this.Insert(index, newDataPoint);
- }
- /// <summary>
- /// Get data source enumerator object helper function.
- /// </summary>
- /// <param name="dataSource">Data source.</param>
- /// <returns>Returns data source enumerator.</returns>
- internal static IEnumerator GetDataSourceEnumerator(IEnumerable dataSource)
- {
- DataView dataView = dataSource as DataView;
- if(dataView != null)
- {
- return dataView.GetEnumerator();
- }
- DataSet dataSet = dataSource as DataSet;
- if(dataSet != null)
- {
- if(dataSet.Tables.Count > 0)
- {
- return dataSet.Tables[0].Rows.GetEnumerator();
- }
- }
- return dataSource.GetEnumerator();
- }
- /// <summary>
- /// Convert enumeration item object from DataRow and DataRowView
- /// to the actual value of specified column in row
- /// </summary>
- /// <param name="item">Enumeration item.</param>
- /// <param name="fieldName">Converted item.</param>
- /// <returns></returns>
- internal static object ConvertEnumerationItem(object item, string fieldName)
- {
- object result = item;
- // If original object is DataRow
- DataRow dataRow = item as DataRow;
- if(dataRow != null)
- {
- if(fieldName != null && fieldName.Length > 0)
- {
- // Check if specified column exist
- bool failed = true;
- if (dataRow.Table.Columns.Contains(fieldName))
- {
- result = dataRow[fieldName];
- failed = false;
- }
- else
- {
- // Try to treat field name as column index number
- int columnIndex;
- failed = !int.TryParse(fieldName, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (!failed && columnIndex < dataRow.Table.Columns.Count && columnIndex >= 0)
- {
- result = dataRow[columnIndex];
- }
- }
- if(failed)
- {
- throw(new ArgumentException( SR.ExceptionColumnNameNotFound( fieldName) ) );
- }
- }
- else
- {
- // Get first column value if name not specified
- result = dataRow[0];
- }
- }
- // If original object is DataRowView
- DataRowView dataRowView = item as DataRowView;
- if(dataRowView != null)
- {
- if(fieldName != null && fieldName.Length > 0)
- {
- // Check if specified column exist
- bool failed = true;
- if (dataRowView.DataView.Table.Columns.Contains(fieldName))
- {
- result = dataRowView[fieldName];
- failed = false;
- }
- else
- {
- // Try to treat field name as column index number
- int columnIndex;
- failed = !int.TryParse(fieldName, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (!failed && columnIndex < dataRowView.DataView.Table.Columns.Count && columnIndex >= 0)
- {
- result = dataRowView[columnIndex];
- }
- }
- if(failed)
- {
- throw(new ArgumentException( SR.ExceptionColumnNameNotFound(fieldName)));
- }
- }
- else
- {
- // Get first column value if name not specified
- result = dataRowView[0];
- }
- }
- // If original object is DbDataRecord
- DbDataRecord dbDataRecord = item as DbDataRecord;
- if(dbDataRecord != null)
- {
- if(fieldName != null && fieldName.Length > 0)
- {
- // Check if specified column exist
- bool failed = true;
- if(!Char.IsNumber(fieldName, 0))
- {
- try
- {
- result = dbDataRecord[fieldName];
- failed = false;
- }
- catch (IndexOutOfRangeException)
- {
- failed = true;
- }
- }
- if(failed)
- {
- // Try to treat field name as column index number
- try
- {
- int columnIndex;
- bool parseSucceed = int.TryParse(fieldName, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (parseSucceed)
- {
- result = dbDataRecord[columnIndex];
- failed = false;
- }
- else
- {
- failed = true;
- }
- }
- catch (IndexOutOfRangeException)
- {
- failed = true;
- }
- }
- if(failed)
- {
- throw(new ArgumentException( SR.ExceptionColumnNameNotFound(fieldName)));
- }
- }
- else
- {
- // Get first column value if name not specified
- result = dbDataRecord[0];
- }
- }
- else
- {
- if (fieldName != null && fieldName.Length > 0)
- {
- PropertyDescriptor descriptor = TypeDescriptor.GetProperties(item).Find(fieldName, true);
- if (descriptor != null)
- {
- result = descriptor.GetValue(item);
- return result ?? null;
- }
- }
- }
- return result;
- }
- /// <summary>
- /// Auto detects the X and Y(s) values type
- /// </summary>
- /// <param name="series">Series the values type is detected for.</param>
- /// <param name="xEnumerator">X values enumerator.</param>
- /// <param name="xField">X value field.</param>
- /// <param name="yEnumerator">Y values enumerator.</param>
- /// <param name="yField">Y value field.</param>
- internal static void AutoDetectValuesType(
- Series series,
- IEnumerator xEnumerator,
- string xField,
- IEnumerator yEnumerator,
- string yField)
- {
- if(series.XValueType == ChartValueType.Auto)
- {
- series.XValueType = GetValueType(xEnumerator, xField);
- if(series.XValueType != ChartValueType.Auto)
- {
- series.autoXValueType = true;
- }
- }
- if(series.YValueType == ChartValueType.Auto)
- {
- series.YValueType = GetValueType(yEnumerator, yField);
- if(series.YValueType != ChartValueType.Auto)
- {
- series.autoYValueType = true;
- }
- }
- }
- /// <summary>
- /// Return value type.
- /// </summary>
- /// <param name="enumerator">Values enumerator.</param>
- /// <param name="field">Value field.</param>
- private static ChartValueType GetValueType(IEnumerator enumerator, string field)
- {
- ChartValueType type = ChartValueType.Auto;
- Type columnDataType = null;
- // Check parameters
- if(enumerator == null)
- {
- return type;
- }
- // Check if current enumeration element is available
- try
- {
- if(enumerator.Current == null)
- {
- return type;
- }
- }
- catch(InvalidOperationException)
- {
- return type;
- }
- // If original object is DataRow
- if(enumerator.Current is DataRow)
- {
- if(field != null && field.Length > 0)
- {
- // Check if specified column exist
- bool failed = true;
- if(((DataRow)enumerator.Current).Table.Columns.Contains(field))
- {
- columnDataType = ((DataRow)enumerator.Current).Table.Columns[field].DataType;
- failed = false;
- }
- // Try to treat field as column number
- if (failed)
- {
- int columnIndex;
- bool parseSucceed = int.TryParse(field, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (parseSucceed)
- {
- columnDataType = ((DataRow)enumerator.Current).Table.Columns[columnIndex].DataType;
- failed = false;
- }
- else
- {
- failed = true;
- }
- }
- if(failed)
- {
- throw(new ArgumentException( SR.ExceptionColumnNameNotFound(field)));
- }
-
- }
- else if(((DataRow)enumerator.Current).Table.Columns.Count > 0)
- {
- columnDataType = ((DataRow)enumerator.Current).Table.Columns[0].DataType;
- }
- }
- // If original object is DataRowView
- else if(enumerator.Current is DataRowView)
- {
- if(field != null && field.Length > 0)
- {
- // Check if specified column exist
- bool failed = true;
- if(((DataRowView)enumerator.Current).DataView.Table.Columns.Contains(field))
- {
- columnDataType = ((DataRowView)enumerator.Current).DataView.Table.Columns[field].DataType;
- failed = false;
- }
- // Try to treat field as column number
- if (failed)
- {
- int columnIndex;
- bool parseSucceed = int.TryParse(field, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (parseSucceed)
- {
- columnDataType = ((DataRowView)enumerator.Current).DataView.Table.Columns[columnIndex].DataType;
- failed = false;
- }
- else
- {
- failed = true;
- }
- }
- if(failed)
- {
- throw(new ArgumentException(SR.ExceptionColumnNameNotFound(field)));
- }
-
- }
- else if(((DataRowView)enumerator.Current).DataView.Table.Columns.Count > 0)
- {
- columnDataType = ((DataRowView)enumerator.Current).DataView.Table.Columns[0].DataType;
- }
- }
-
- // If original object is DbDataRecord
- else if(enumerator.Current is DbDataRecord)
- {
- if(field != null && field.Length > 0)
- {
- bool failed = true;
- int columnIndex = 0;
- if(!Char.IsNumber(field, 0))
- {
- columnIndex = ((DbDataRecord)enumerator.Current).GetOrdinal(field);
- columnDataType = ((DbDataRecord)enumerator.Current).GetFieldType(columnIndex);
- failed = false;
- }
- // Try to treat field as column number
- if (failed)
- {
- failed = !int.TryParse(field, NumberStyles.Any, CultureInfo.InvariantCulture, out columnIndex);
- if (!failed)
- {
- columnDataType = ((DbDataRecord)enumerator.Current).GetFieldType(columnIndex);
- }
- }
- if(failed)
- {
- throw(new ArgumentException(SR.ExceptionColumnNameNotFound(field)));
- }
-
- }
- else if(((DbDataRecord)enumerator.Current).FieldCount > 0)
- {
- columnDataType = ((DbDataRecord)enumerator.Current).GetFieldType(0);
- }
- }
- // Try detecting simple data types
- else
- {
- if (field != null && field.Length > 0)
- {
- PropertyDescriptor descriptor = TypeDescriptor.GetProperties(enumerator.Current).Find(field, true);
- if (descriptor != null)
- {
- columnDataType = descriptor.PropertyType;
- }
- }
- if ( columnDataType == null )
- {
- columnDataType = enumerator.Current.GetType();
- }
- }
- // Use data type
- if(columnDataType != null)
- {
- if(columnDataType == typeof(DateTime))
- type = ChartValueType.DateTime;
- else if (columnDataType == typeof(DateTimeOffset))
- type = ChartValueType.DateTimeOffset;
- else if (columnDataType == typeof(TimeSpan))
- type = ChartValueType.Time;
- else if (columnDataType == typeof(Double))
- type = ChartValueType.Double;
- else if (columnDataType == typeof(Int32))
- type = ChartValueType.Int32;
- else if(columnDataType == typeof(Int64))
- type = ChartValueType.Int64;
- else if(columnDataType == typeof(Single))
- type = ChartValueType.Single;
- else if(columnDataType == typeof(String))
- type = ChartValueType.String;
- else if(columnDataType == typeof(UInt32))
- type = ChartValueType.UInt32;
- else if(columnDataType == typeof(UInt64))
- type = ChartValueType.UInt64;
- }
- return type;
- }
- #endregion
- #region DataPoint finding functions
- /// <summary>
- /// Find all the points that equal to the specified value starting from the specified index.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <param name="startIndex">Index of the point to start looking from.</param>
- /// <returns>Enumerator of datapoints.</returns>
- public IEnumerable<DataPoint> FindAllByValue(double valueToFind, string useValue, int startIndex)
- {
- // Loop through all points from specified index
- for (int i = startIndex; i < this.Count; i++)
- {
- DataPoint point = this[i];
- if (point.GetValueByName(useValue) == valueToFind)
- {
- yield return point;
- }
- }
- }
- /// <summary>
- /// Find all the points that equal to the specified value.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <returns>Enumerator of datapoints.</returns>
- public IEnumerable<DataPoint> FindAllByValue(double valueToFind, string useValue)
- {
- // Loop through all points from specified index
- for (int i = 0; i < this.Count; i++)
- {
- DataPoint point = this[i];
- if (point.GetValueByName(useValue) == valueToFind)
- {
- yield return point;
- }
- }
- }
- /// <summary>
- /// Find all the points that equal to the specified value.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <returns>Enumerator of datapoints.</returns>
- public IEnumerable<DataPoint> FindAllByValue(double valueToFind)
- {
- return FindAllByValue(valueToFind, "Y");
- }
- /// <summary>
- /// Find the first point that equals to the specified value starting from the specified index.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <param name="startIndex">Index of the point to start looking from.</param>
- /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
- public DataPoint FindByValue(double valueToFind, string useValue, int startIndex)
- {
- //Check arguments
- if (useValue == null)
- throw new ArgumentNullException("useValue");
- if (startIndex < 0 || startIndex >= this.Count)
- throw new ArgumentOutOfRangeException("startIndex");
- // Loop through all points from specified index
- for (int i = startIndex; i < this.Count; i++)
- {
- DataPoint point = this[i];
- if (point.GetValueByName(useValue) == valueToFind)
- {
- return point;
- }
- }
- // Nothing was found
- return null;
- }
- /// <summary>
- /// Find the first point that equals to the specified value.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
- public DataPoint FindByValue(double valueToFind, string useValue)
- {
- return FindByValue(valueToFind, useValue, 0);
- }
- /// <summary>
- /// Find the first point that equals to the specified value.
- /// </summary>
- /// <param name="valueToFind">Point value to find.</param>
- /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
- public DataPoint FindByValue(double valueToFind)
- {
- return FindByValue(valueToFind, "Y");
- }
- /// <summary>
- /// Find point with the maximum value starting from specified index.
- /// </summary>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <param name="startIndex">Index of the point to start looking from.</param>
- /// <returns>Datapoint with the maximum value.</returns>
- public DataPoint FindMaxByValue(string useValue, int startIndex)
- {
- //Check arguments
- if (useValue == null)
- throw new ArgumentNullException("useValue");
- if (startIndex < 0 || startIndex >= this.Count)
- throw new ArgumentOutOfRangeException("startIndex");
- bool isYValue = useValue.StartsWith("Y", StringComparison.OrdinalIgnoreCase);
- double maxValue = double.MinValue;
- DataPoint maxPoint = null;
- for (int i = startIndex; i < this.Count; i++)
- {
- DataPoint point = this[i];
- // Skip empty points when searching for the Y values
- if (point.IsEmpty && isYValue)
- continue;
- double pointValue = point.GetValueByName(useValue);
- if (maxValue < pointValue)
- {
- maxValue = pointValue;
- maxPoint = point;
- }
- }
- return maxPoint;
- }
- /// <summary>
- /// Find point with the maximum value.
- /// </summary>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <returns>Datapoint with the maximum value.</returns>
- public DataPoint FindMaxByValue(string useValue)
- {
- return FindMaxByValue(useValue, 0);
- }
- /// <summary>
- /// Find data point with the maximum value.
- /// </summary>
- /// <returns>Datapoint with the maximum value.</returns>
- public DataPoint FindMaxByValue()
- {
- return FindMaxByValue("Y");
- }
- /// <summary>
- /// Find point with the Min value starting from specified index.
- /// </summary>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <param name="startIndex">Index of the point to start looking from.</param>
- /// <returns>Datapoint with the Min value.</returns>
- public DataPoint FindMinByValue(string useValue, int startIndex)
- {
- if (useValue == null)
- throw new ArgumentNullException("useValue");
- if (startIndex < 0 || startIndex >= this.Count)
- throw new ArgumentOutOfRangeException("startIndex");
- bool isYValue = useValue.StartsWith("Y", StringComparison.OrdinalIgnoreCase);
- double minValue = double.MaxValue;
- DataPoint minPoint = null;
- for (int i = startIndex; i < this.Count; i++)
- {
- DataPoint point = this[i];
- // Skip empty points when searching for the Y values
- if (point.IsEmpty && isYValue)
- continue;
- double pointValue = point.GetValueByName(useValue);
- if (minValue > pointValue)
- {
- minValue = pointValue;
- minPoint = point;
- }
- }
- return minPoint;
- }
- /// <summary>
- /// Find point with the Min value.
- /// </summary>
- /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
- /// <returns>Datapoint with the Min value.</returns>
- public DataPoint FindMinByValue(string useValue)
- {
- return FindMinByValue(useValue, 0);
- }
- /// <summary>
- /// Find point with the Min value
- /// </summary>
- /// <returns>Datapoint with the Min value.</returns>
- public DataPoint FindMinByValue()
- {
- return FindMinByValue("Y");
- }
- #endregion
-
- #region Collection<T> overrides
- /// <summary>
- /// Initializes the specified item.
- /// </summary>
- /// <param name="item">The item.</param>
- internal override void Initialize(DataPoint item)
- {
- DataPointInit(ref item);
- base.Initialize(item);
- }
- /// <summary>
- /// Removes all elements from the <see cref="T:System.Collections.ObjectModel.Collection`1"/>.
- /// </summary>
- protected override void ClearItems()
- {
- // Refresh Minimum and Maximum from data
- // after recalc and set data
- if (Common != null && Common.ChartPicture != null)
- {
- Common.ChartPicture.ResetMinMaxFromData();
- }
- base.ClearItems();
- }
- #endregion
- }
- /// <summary>
- /// Stores values and properties of a DataPoint of a Series.
- /// </summary>
- [
- SRDescription("DescriptionAttributeDataPoint_DataPoint"),
- DefaultProperty("YValues"),
- TypeConverter(typeof(DataPointConverter))
- ]
- public class DataPoint : DataPointCustomProperties
- {
- #region Fields
- // Point X value
- private double _xValue;
- // Point Y values
- private double[] _yValue = new double[1];
- // Pre calculated (during painting) relative position of data point
- internal PointF positionRel = PointF.Empty;
- // VSTS:199794 - Accessibility needs the last rendered label content to be exposed.
- // The current label content evaluation is scattered over different chart types and cannot be isolated without risk of regression.
- // This variable will cache the label content taken just before drawing.
- internal string _lastLabelText = String.Empty;
- #endregion
- #region Constructors
- /// <summary>
- /// DataPoint object constructor.
- /// </summary>
- public DataPoint() : base(null, true)
- {
- _yValue = new double[1];
- }
- /// <summary>
- /// DataPoint object constructor.
- /// </summary>
- /// <param name="series">series object, which the DataPoint belongs to.</param>
- public DataPoint(Series series) : base(series, true)
- {
- // Create Y value(s) array
- _yValue = new double[series.YValuesPerPoint];
- _xValue = 0;
- }
- /// <summary>
- /// DataPoint object constructor.
- /// </summary>
- /// <param name="xValue">X value.</param>
- /// <param name="yValue">Y value.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public DataPoint(double xValue, double yValue)
- : base(null, true)
- {
- // Set Y value
- this._yValue = new double[1];
- this._yValue[0] = yValue;
- // Set X value
- this._xValue = xValue;
- }
- /// <summary>
- /// DataPoint object constructor.
- /// </summary>
- /// <param name="xValue">X value.</param>
- /// <param name="yValues">Array of Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public DataPoint(double xValue, double[] yValues)
- : base(null, true)
- {
- // Set Y value
- this._yValue = yValues;
- // Set X value
- this._xValue = xValue;
- }
- /// <summary>
- /// DataPoint object constructor.
- /// </summary>
- /// <remarks>
- /// This method is only used during the Windows Forms serialization of the chart.
- /// </remarks>
- /// <param name="xValue">X value.</param>
- /// <param name="yValues">String of comma separated Y values.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DataPoint(double xValue, string yValues)
- : base(null, true)
- {
- string[] values = yValues.Split(',');
- // Create Y value(s) array
- _yValue = new double[values.Length];
- for (int index = 0; index < values.Length; index++)
- {
- _yValue[index] = CommonElements.ParseDouble(values[index], true);
- }
- // Set X value
- this._xValue = xValue;
- }
- #endregion
- #region Data point methods
- /// <summary>
- /// Sets the specified data point attribute to the specified value.
- /// </summary>
- /// <param name="obj">Attribute value.</param>
- /// <param name="propertyName">Attribute name.</param>
- /// <param name="format">Value format.</param>
- internal void SetPointCustomProperty(
- object obj,
- string propertyName,
- string format)
- {
- // Convert value to string
- string stringValue = obj as string;
- if(stringValue == null)
- {
- double doubleObj = double.NaN;
- ChartValueType valueType = ChartValueType.Auto;
- if(obj is DateTime)
- {
- doubleObj = ((DateTime)obj).ToOADate();
- valueType = ChartValueType.Date;
- }
- else
- {
- doubleObj = this.ConvertValue(obj);
- }
- // Try converting to string
- if( !double.IsNaN(doubleObj) )
- {
- try
- {
- stringValue = ValueConverter.FormatValue(
- this.Chart,
- this,
- this.Tag,
- doubleObj,
- format,
- valueType,
- ChartElementType.DataPoint);
- }
- catch(FormatException)
- {
- // Use basic string converter
- stringValue = obj.ToString();
- }
- }
- else
- {
- // Use basic string converter
- stringValue = obj.ToString();
- }
- }
-
- // Assign data point attribute by name
- if(stringValue.Length > 0)
- {
- if(String.Compare(propertyName, "AxisLabel", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.AxisLabel = stringValue;
- }
- else if (String.Compare(propertyName, "Tooltip", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.ToolTip = stringValue;
- }
- else if (String.Compare(propertyName, "Label", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.Label = stringValue;
- }
- else if (String.Compare(propertyName, "LegendTooltip", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.LegendToolTip = stringValue;
- }
- else if (String.Compare(propertyName, "LegendText", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.LegendText = stringValue;
- }
- else if (String.Compare(propertyName, "LabelToolTip", StringComparison.OrdinalIgnoreCase) == 0)
- {
- this.LabelToolTip = stringValue;
- }
- else
- {
- this[propertyName] = stringValue;
- }
- }
- }
- /// <summary>
- /// Converts object to double.
- /// </summary>
- /// <param name="value">Object to convert.</param>
- /// <returns>Double value.</returns>
- private double ConvertValue(object value)
- {
- if(value == null)
- {
- return 0;
- }
- if(value is Double)
- {
- return (double)value;
- }
- else if(value is Single)
- {
- return (double)((float)value);
- }
- else if(value is Decimal)
- {
- return (double)((Decimal)value);
- }
- else if(value is Int32)
- {
- return (double)((Int32)value);
- }
- else if(value is UInt32)
- {
- return (double)((UInt32)value);
- }
- else if(value is Int64)
- {
- return (double)((Int64)value);
- }
- else if(value is UInt64)
- {
- return (double)((UInt64)value);
- }
- else if(value is Byte)
- {
- return (double)((Byte)value);
- }
- else if(value is SByte)
- {
- return (double)((SByte)value);
- }
- else if(value is Boolean)
- {
- return ((Boolean)value) ? 1.0 : 0.0;
- }
- else
- {
- string stringValue = "";
- stringValue = value.ToString();
- return CommonElements.ParseDouble(stringValue);
- }
- }
- /// <summary>
- /// Set X value and one or more Y values of the data point.
- /// </summary>
- /// <param name="xValue">X value of the data point.</param>
- /// <param name="yValue">List of Y values of the data point.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "X and Y are cartesian coordinates and well understood")]
- public void SetValueXY(object xValue, params object[] yValue)
- {
- // Check arguments
- if (xValue == null)
- throw new ArgumentNullException("xValue");
- // Set Y value first
- SetValueY(yValue);
- // Check if parameters type matches with series type
- Type paramType = xValue.GetType();
- if(base.series != null)
- {
- base.series.CheckSupportedTypes(paramType);
- }
- // Save value in the array
- if(paramType == typeof(String))
- {
- AxisLabel = (string)xValue;
- }
- else if(paramType == typeof(DateTime))
- {
- this._xValue = ((DateTime)xValue).ToOADate();
- }
- else
- {
- this._xValue = ConvertValue(xValue);
- }
- // Get Date or Time if required
- if(base.series != null && xValue is DateTime)
- {
- if(base.series.XValueType == ChartValueType.Date)
- {
- DateTime time = new DateTime(
- ((DateTime)xValue).Year,
- ((DateTime)xValue).Month,
- ((DateTime)xValue).Day,
- 0,
- 0,
- 0,
- 0);
- this._xValue = time.ToOADate();
- }
- else if(base.series.XValueType == ChartValueType.Time)
- {
- DateTime time = new DateTime(
- 1899,
- 12,
- 30,
- ((DateTime)xValue).Hour,
- ((DateTime)xValue).Minute,
- ((DateTime)xValue).Second,
- ((DateTime)xValue).Millisecond);
- this._xValue = time.ToOADate();
- }
- }
- // Check if one of Y values are not avilable
- bool empty = false;
- foreach(double d in this._yValue)
- {
- if(double.IsNaN(d))
- {
- empty = true;
- break;
- }
- }
- // Set point empty flag and values to zero
- if(empty)
- {
- this.IsEmpty = true;
- for(int valueIndex = 0; valueIndex < this._yValue.Length; valueIndex++)
- {
- this._yValue[valueIndex] = 0.0;
- }
- }
- }
- /// <summary>
- /// Set one or more Y values of the data point.
- /// </summary>
- /// <param name="yValue">List of Y values of the data point.</param>
- [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
- Justification = "Y is a cartesian coordinate and well understood")]
- public void SetValueY(params object[] yValue)
- {
- // Check arguments
- if (yValue == null)
- throw new ArgumentNullException("yValue");
-
- // Check number of parameters. Should be more than 0 and
- if(yValue.Length == 0 || (base.series != null && yValue.Length > base.series.YValuesPerPoint))
- throw(new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesSettingCountMismatch(base.series.YValuesPerPoint.ToString(System.Globalization.CultureInfo.InvariantCulture))));
- // Check if there is a Null Y value
- for( int i = 0 ; i < yValue.Length ; i++ )
- {
- if(yValue[i] == null || yValue[i] is System.DBNull)
- {
- yValue[i] = 0.0;
- if(i == 0)
- {
- this.IsEmpty = true;
- }
- }
- }
- // Check if parameters type matches with series type
- Type paramType = yValue[0].GetType();
- if(base.series != null)
- {
- base.series.CheckSupportedTypes(paramType);
- }
- // Make sure the Y values array is big enough
- if (this._yValue.Length < yValue.Length)
- {
- this._yValue = new double[yValue.Length];
- }
- // Save value in the array
- if(paramType == typeof(String))
- {
- try
- {
- for (int i = 0; i < yValue.Length; i++)
- {
- this._yValue[i] = CommonElements.ParseDouble((string)yValue[i]);
- }
- }
- catch
- {
- // Get reference to the chart object
- if (Common!=null && Common.ChartPicture!=null && Common.ChartPicture.SuppressExceptions)
- {
- this.IsEmpty = true;
- for (int i = 0; i < yValue.Length; i++)
- {
- yValue[i] = 0.0;
- }
- }
- else
- {
- throw (new ArgumentException( SR.ExceptionDataPointYValueStringFormat));
- }
- }
- }
- else if(paramType == typeof(DateTime))
- {
- for( int i = 0 ; i < yValue.Length ; i++ )
- {
- if(yValue[i] == null ||
- (yValue[i] is double && ((double)yValue[i]) == 0.0) )
- {
- this._yValue[i] = DateTime.Now.ToOADate();
- }
- else
- {
- this._yValue[i] = ((DateTime)yValue[i]).ToOADate();
- }
- }
- }
- else
- {
- for( int i = 0 ; i < yValue.Length ; i++ )
- {
- this._yValue[i] = ConvertValue(yValue[i]);
- }
- }
- // Get Date or Time if required
- if(base.series != null)
- {
- for( int i = 0 ; i < yValue.Length ; i++ )
- {
- if(yValue[i] == null ||
- (yValue[i] is double && ((double)yValue[i]) == 0.0) )
- {
- if(base.series.YValueType == ChartValueType.Date)
- {
- this._yValue[i] = Math.Floor(this._yValue[i]);
- }
- else if(base.series.YValueType == ChartValueType.Time)
- {
- this._yValue[i] = this._xValue - Math.Floor(this._yValue[i]);
- }
- }
- else
- {
- if(base.series.YValueType == ChartValueType.Date)
- {
- DateTime yDate;
- if (yValue[i] is DateTime)
- yDate = (DateTime)yValue[i];
- else if (yValue[i] is Double)
- yDate = DateTime.FromOADate((Double)yValue[i]);
- else
- yDate = Convert.ToDateTime(yValue[i], CultureInfo.InvariantCulture); //This will throw an exception in case when the yValue type is not compatible with the DateTime
- DateTime date = new DateTime(
- yDate.Year,
- yDate.Month,
- yDate.Day,
- 0,
- 0,
- 0,
- 0);
- this._yValue[i] = date.ToOADate();
- }
- else if (base.series.YValueType == ChartValueType.Time)
- {
- DateTime yTime;
- if (yValue[i] is DateTime)
- yTime = (DateTime)yValue[i];
- if (yValue[i] is Double)
- yTime = DateTime.FromOADate((Double)yValue[i]);
- else
- yTime = Convert.ToDateTime(yValue[i], CultureInfo.InvariantCulture); //This will throw an exception in case when the yValue type is not compatible with the DateTime
- DateTime time = new DateTime(
- 1899,
- 12,
- 30,
- yTime.Hour,
- yTime.Minute,
- yTime.Second,
- yTime.Millisecond);
- this._yValue[i] = time.ToOADate();
- }
- }
- }
- }
- }
- /// <summary>
- /// Creates an exact copy of this DataPoint object.
- /// </summary>
- /// <returns>An exact copy of this DataPoint object.</returns>
- public DataPoint Clone()
- {
- // Create new data point
- DataPoint clonePoint = new DataPoint();
- // Reset series pointer
- clonePoint.series = null;
- clonePoint.pointCustomProperties = this.pointCustomProperties;
-
- // Copy values
- clonePoint._xValue = this.XValue;
- clonePoint._yValue = new double[this._yValue.Length];
- this._yValue.CopyTo(clonePoint._yValue, 0);
- clonePoint.tempColorIsSet = this.tempColorIsSet;
- clonePoint.isEmptyPoint = this.isEmptyPoint;
- // Copy properties
- foreach(object key in this.properties.Keys)
- {
- clonePoint.properties.Add(key, this.properties[key]);
- }
- return clonePoint;
- }
- /// <summary>
- /// Resize Y values array.
- /// </summary>
- /// <param name="newSize">New number of Y values in array.</param>
- internal void ResizeYValueArray(int newSize)
- {
- // Create new array
- double[] newArray = new Double[newSize];
- // Copy elements
- if(_yValue != null)
- {
- for(int i = 0; i < ((_yValue.Length < newSize) ? _yValue.Length : newSize); i++)
- {
- newArray[i] = _yValue[i];
- }
- }
- _yValue = newArray;
- }
- /// <summary>
- /// Helper function, which returns point value by it's name.
- /// </summary>
- /// <param name="valueName">Point value names. X, Y, Y2,...</param>
- /// <returns>Point value.</returns>
- public double GetValueByName(string valueName)
- {
- // Check arguments
- if (valueName == null)
- throw new ArgumentNullException("valueName");
- valueName = valueName.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
- if(String.Compare(valueName, "X", StringComparison.Ordinal) == 0)
- {
- return this.XValue;
- }
- else if (valueName.StartsWith("Y", StringComparison.Ordinal))
- {
- if(valueName.Length == 1)
- {
- return this.YValues[0];
- }
- else
- {
- int yIndex = 0;
- try
- {
- yIndex = Int32.Parse(valueName.Substring(1), System.Globalization.CultureInfo.InvariantCulture) - 1;
- }
- catch(System.Exception)
- {
- throw(new ArgumentException( SR.ExceptionDataPointValueNameInvalid, "valueName"));
- }
- if(yIndex < 0)
- {
- throw(new ArgumentException( SR.ExceptionDataPointValueNameYIndexIsNotPositive, "valueName"));
- }
- if(yIndex >= this.YValues.Length)
- {
- throw(new ArgumentException( SR.ExceptionDataPointValueNameYIndexOutOfRange, "valueName"));
- }
- return this.YValues[yIndex];
- }
- }
- else
- {
- throw(new ArgumentException( SR.ExceptionDataPointValueNameInvalid, "valueName"));
- }
- }
- /// <summary>
- /// Replaces predefined keyword inside the string with their values.
- /// </summary>
- /// <param name="strOriginal">Original string with keywords.</param>
- /// <returns>Modified string.</returns>
- internal override string ReplaceKeywords(string strOriginal)
- {
- // Nothing to process
- if(strOriginal == null || strOriginal.Length == 0)
- return strOriginal;
- // Replace all "\n" strings with '\n' character
- string result = strOriginal;
- result = result.Replace("\\n", "\n");
- // #LABEL - point label
- result = result.Replace(KeywordName.Label, this.Label);
- // #LEGENDTEXT - series name
- result = result.Replace(KeywordName.LegendText, this.LegendText);
- // #AXISLABEL - series name
- result = result.Replace(KeywordName.AxisLabel, this.AxisLabel);
- // #CUSTOMPROPERTY - one of the custom properties by name
- result = DataPoint.ReplaceCustomPropertyKeyword(result, this);
-
- if(this.series != null)
- {
- // #INDEX - point index
- result = result.Replace(KeywordName.Index, this.series.Points.IndexOf(this).ToString(System.Globalization.CultureInfo.InvariantCulture));
- // Replace series keywords
- result = this.series.ReplaceKeywords(result);
- // #PERCENT - percentage of Y value from total
- result = this.series.ReplaceOneKeyword(
- this.Chart,
- this,
- this.Tag,
- ChartElementType.DataPoint,
- result,
- KeywordName.Percent,
- (this.YValues[0]/(this.series.GetTotalYValue())),
- ChartValueType.Double,
- "P");
- // #VAL[X] - point value X, Y, Y2, ...
- if(this.series.XValueType == ChartValueType.String)
- {
- result = result.Replace(KeywordName.ValX, this.AxisLabel);
- }
- else
- {
- result = this.series.ReplaceOneKeyword(
- this.Chart,
- this,
- this.Tag,
- ChartElementType.DataPoint,
- result,
- KeywordName.ValX,
- this.XValue,
- this.series.XValueType,
- "");
- }
-
- // remove keywords #VAL? for unexisted Y value indices
- for (int index = this.YValues.Length; index <= 7; index++)
- {
- result = this.RemoveOneKeyword(result, KeywordName.ValY + index + 1, SR.FormatErrorString);
- }
- for(int index = 1; index <= this.YValues.Length; index++)
- {
- result = this.series.ReplaceOneKeyword(
- this.Chart,
- this,
- this.Tag,
- ChartElementType.DataPoint,
- result,
- KeywordName.ValY + index,
- this.YValues[index - 1],
- this.series.YValueType,
- "");
- }
- result = this.series.ReplaceOneKeyword(
- Chart,
- this,
- this.Tag,
- ChartElementType.DataPoint,
- result,
- KeywordName.ValY,
- this.YValues[0],
- this.series.YValueType,
- "");
- result = this.series.ReplaceOneKeyword(
- Chart,
- this,
- this.Tag,
- ChartElementType.DataPoint,
- result,
- KeywordName.Val,
- this.YValues[0],
- this.series.YValueType,
- "");
- }
- return result;
- }
- /// <summary>
- /// Removes one keyword from format string.
- /// </summary>
- /// <param name="strOriginal">Original format string</param>
- /// <param name="keyword">The keyword</param>
- /// <param name="strToReplace">String to replace the keyword.</param>
- /// <returns>Modified format string</returns>
- private string RemoveOneKeyword(string strOriginal, string keyword, string strToReplace)
- {
- string result = strOriginal;
- int keyIndex = -1;
- while ((keyIndex = result.IndexOf(keyword, StringComparison.Ordinal)) != -1)
- {
- // Get optional format
- int keyEndIndex = keyIndex + keyword.Length;
- if (result.Length > keyEndIndex && result[keyEndIndex] == '{')
- {
- int formatEnd = result.IndexOf('}', keyEndIndex);
- if (formatEnd == -1)
- {
- throw (new InvalidOperationException(SR.ExceptionDataSeriesKeywordFormatInvalid(result)));
- }
- keyEndIndex = formatEnd + 1;
- }
- // Remove keyword string (with optional format)
- result = result.Remove(keyIndex, keyEndIndex - keyIndex);
- if (!String.IsNullOrEmpty(strToReplace))
- {
- result = result.Insert(keyIndex, strToReplace);
- }
- }
- return result;
- }
- /// <summary>
- /// Replaces all "#CUSTOMPROPERTY(XXX)" (where XXX is the custom attribute name)
- /// keywords in the string provided.
- /// </summary>
- /// <param name="originalString">String where the keyword need to be replaced.</param>
- /// <param name="properties">DataPoint or Series properties class.</param>
- /// <returns>Converted string.</returns>
- internal static string ReplaceCustomPropertyKeyword(string originalString, DataPointCustomProperties properties)
- {
- string result = originalString;
- int keyStartIndex = -1;
- while ((keyStartIndex = result.IndexOf(KeywordName.CustomProperty, StringComparison.Ordinal)) >= 0)
- {
- string attributeValue = string.Empty;
- string attributeName = string.Empty;
- // Forward to the end of the keyword
- int keyEndIndex = keyStartIndex + KeywordName.CustomProperty.Length;
- // An opening bracket '(' must follow
- if (result.Length > keyEndIndex && result[keyEndIndex] == '(')
- {
- ++keyEndIndex;
- int attributeNameStartIndex = keyEndIndex;
- // Search for the closing bracket
- int closingBracketIndex = result.IndexOf(')', keyEndIndex);
- if (closingBracketIndex >= keyEndIndex)
- {
- keyEndIndex = closingBracketIndex + 1;
- attributeName = result.Substring(attributeNameStartIndex, keyEndIndex - attributeNameStartIndex - 1);
- // Get attribute value
- if (properties.IsCustomPropertySet(attributeName))
- {
- attributeValue = properties.GetCustomProperty(attributeName);
- }
- else
- {
- // In case of the DataPoint check if the attribute is set in the parent series
- DataPoint dataPoint = properties as DataPoint;
- if (dataPoint != null && dataPoint.series != null)
- {
- if (dataPoint.series.IsCustomPropertySet(attributeName))
- {
- attributeValue = dataPoint.series.GetCustomProperty(attributeName);
- }
- }
- }
- }
- }
- // Remove keyword string with attribute name
- result = result.Remove(keyStartIndex, keyEndIndex - keyStartIndex);
- // Insert value of the custom attribute
- result = result.Insert(keyStartIndex, attributeValue);
- }
- return result;
- }
- /// <summary>
- /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
- /// </summary>
- /// <returns>
- /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
- /// </returns>
- internal override string ToStringInternal()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendFormat(CultureInfo.CurrentCulture, "{{X={0}, ", XValue);
- if (YValues.Length == 1)
- {
- sb.AppendFormat(CultureInfo.CurrentCulture, "Y={0}", YValues[0]);
- }
- else
- {
- sb.Append("Y={");
- for (int i = 0; i < YValues.Length; i++)
- if (i == 0)
- sb.AppendFormat(CultureInfo.CurrentCulture, "{0}", YValues[i]);
- else
- sb.AppendFormat(CultureInfo.CurrentCulture, ", {0}", YValues[i]);
- sb.Append("}");
- }
- sb.Append("}");
- return sb.ToString();
- }
- #endregion
- #region DataPoint Properties
- /// <summary>
- /// X value of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- Bindable(true),
- SRDescription("DescriptionAttributeDataPoint_XValue"),
- TypeConverter(typeof(DataPointValueConverter)),
- DefaultValue(typeof(double), "0.0"),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- ]
- public double XValue
- {
- get
- {
- return _xValue;
- }
- set
- {
- _xValue = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// List of Y values of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- SRDescription("DescriptionAttributeDataPoint_YValues"),
- Bindable(true),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- TypeConverter(typeof(DoubleArrayConverter)),
- #if DESIGNER
- Editor(typeof(UITypeEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All),
- SerializationVisibilityAttribute(SerializationVisibility.Attribute)
- ]
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
- public double[] YValues
- {
- get
- {
- return _yValue;
- }
- set
- {
- if(value == null)
- {
- // Clear array data
- for(int i=0; i < _yValue.Length; i++)
- {
- _yValue[i] = 0;
- }
- }
- else
- {
- _yValue = value;
- }
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// A flag which indicates whether the data point is empty.
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- Bindable(true),
- SRDescription("DescriptionAttributeDataPoint_Empty"),
- DefaultValue(false)
- ]
- public bool IsEmpty
- {
- get
- {
- return base.isEmptyPoint;
- }
- set
- {
- base.isEmptyPoint = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Name of the data point. This field is reserved for internal use only.
- /// </summary>
- [
- SRCategory("CategoryAttributeData"),
- Bindable(true),
- Browsable(false),
- SRDescription("DescriptionAttributeDataPoint_Name"),
- DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden)
- ]
- public override string Name
- {
- get
- {
- return "DataPoint";
- }
- set
- {
- //Dont call the base method - the names don't need to be unique
- }
- }
- #endregion
- }
- /// <summary>
- /// Stores properties of one Data Point and Data series.
- /// </summary>
- [
- SRDescription("DescriptionAttributeDataPointCustomProperties_DataPointCustomProperties"),
- DefaultProperty("LabelStyle"),
- TypeConverter(typeof(DataPointCustomPropertiesConverter))
- ]
- public class DataPointCustomProperties : ChartNamedElement
- {
- #region Fields and enumerations
- // True indicates data point properties. Otherwise - series.
- internal bool pointCustomProperties = true;
- // Reference to the data point series
- internal Series series = null;
- // Storage for the custom properties names/values
- internal Hashtable properties = new Hashtable();
- // Flag indicating that temp. color was set
- internal bool tempColorIsSet = false;
- // Design time custom properties data
- internal CustomProperties customProperties = null;
- // IsEmpty point indicator
- internal bool isEmptyPoint = false;
- #endregion
- #region Constructors
- /// <summary>
- /// DataPointCustomProperties constructor.
- /// </summary>
- public DataPointCustomProperties()
- {
- // Initialize the data series
- this.series = null;
- this.customProperties = new CustomProperties(this);
- }
- /// <summary>
- /// DataPointCustomProperties constructor.
- /// </summary>
- /// <param name="series">The series which the data point belongs to.</param>
- /// <param name="pointProperties">Indicates whether this is a data point custom properties.</param>
- public DataPointCustomProperties(Series series, bool pointProperties): base( series, String.Empty)
- {
- // Initialize the data series
- this.series = series;
- this.pointCustomProperties = pointProperties;
- this.customProperties = new CustomProperties(this);
- }
- #endregion
- #region Custom Properties methods
- /// <summary>
- /// Checks if custom property with specified name was set.
- /// </summary>
- /// <param name="name">Name of the custom property to check.</param>
- /// <returns>True if custom property was set.</returns>
- virtual public bool IsCustomPropertySet(string name)
- {
- return properties.ContainsKey(name);
- }
- /// <summary>
- /// Checks if the custom property with specified name was set.
- /// </summary>
- /// <param name="property">The CommonCustomProperties object to check for.</param>
- /// <returns>True if attribute was set.</returns>
- internal bool IsCustomPropertySet(CommonCustomProperties property)
- {
- return properties.ContainsKey((int)property);
- }
- /// <summary>
- /// Delete the data point custom property with the specified name.
- /// </summary>
- /// <param name="name">Name of the property to delete.</param>
- virtual public void DeleteCustomProperty(string name)
- {
- if(name == null)
- {
- throw (new ArgumentNullException(SR.ExceptionAttributeNameIsEmpty));
- }
- // Check if trying to delete the common attribute
- string[] AttributesNames = CommonCustomProperties.GetNames(typeof(CommonCustomProperties));
- foreach(string commonName in AttributesNames)
- {
- if(name == commonName)
- {
- DeleteCustomProperty((CommonCustomProperties)Enum.Parse(typeof(CommonCustomProperties), commonName));
- }
- }
- // Remove attribute
- properties.Remove(name);
- }
- /// <summary>
- /// Delete Data Point attribute with specified name.
- /// </summary>
- /// <param name="property">ID of the attribute to delete.</param>
- internal void DeleteCustomProperty(CommonCustomProperties property)
- {
- // Check if trying to delete the common attribute from the series
- if(!this.pointCustomProperties)
- {
- throw(new ArgumentException( SR.ExceptionAttributeUnableToDelete));
- }
- // Remove attribute
- properties.Remove((int)property);
- }
- /// <summary>
- /// Gets the data point custom property with the specified name.
- /// </summary>
- /// <param name="name">Name of the property to get.</param>
- /// <returns>Returns the data point custom property with the specified name. If the requested one is not set,
- /// the default custom property of the data series will be returned.</returns>
- virtual public string GetCustomProperty(string name)
- {
- if(!IsCustomPropertySet(name) && this.pointCustomProperties)
- {
- // Check if we are in serialization mode
- bool serializing = false;
- if(Chart != null && Chart.serializing)
- {
- serializing = true;
- }
- if(!serializing)
- {
- if(this.isEmptyPoint)
- {
- // Return empty point properties from series
- return (string)series.EmptyPointStyle.properties[name];
- }
- // Return properties from series
- return (string)series.properties[name];
- }
- else
- {
- // Return default properties
- return (string)Series.defaultCustomProperties[name];
- }
- }
- return (string)properties[name];
- }
- /// <summary>
- /// Checks if data is currently serialized.
- /// </summary>
- /// <returns>True if serialized.</returns>
- internal bool IsSerializing()
- {
- // Check if series object is provided
- if(series == null)
- {
- return true;
- }
- // Check if we are in serialization mode
- if(Chart != null)
- {
- return Chart.serializing;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// Returns an attribute object of the Data Point. If required attribute is not set
- /// in the Data Point the default attribute of the Data series is returned.
- /// </summary>
- /// <param name="attrib">Attribute name ID.</param>
- /// <returns>Attribute value.</returns>
- internal object GetAttributeObject(CommonCustomProperties attrib)
- {
- // Get series properties
- if(!this.pointCustomProperties || series == null)
- {
- return properties[(int)attrib];
- }
- // Get data point properties
- if(properties.Count == 0 || !IsCustomPropertySet(attrib))
- {
- // Check if we are in serialization mode
- bool serializing = false;
- if(Chart != null)
- {
- serializing = Chart.serializing;
- }
- if(!serializing)
- {
- if(this.isEmptyPoint)
- {
- // Return empty point properties from series
- return series.EmptyPointStyle.properties[(int)attrib];
- }
- // Return properties from series
- return series.properties[(int)attrib];
- }
- else
- {
- // Return default properties
- return Series.defaultCustomProperties.properties[(int)attrib];
- }
- }
- return properties[(int)attrib];
- }
- /// <summary>
- /// Sets a custom property of the data point.
- /// </summary>
- /// <param name="name">Property name.</param>
- /// <param name="propertyValue">Property value.</param>
- virtual public void SetCustomProperty(string name, string propertyValue)
- {
- properties[name] = propertyValue;
- }
- /// <summary>
- /// Sets an attribute of the Data Point as an object.
- /// </summary>
- /// <param name="attrib">Attribute name ID.</param>
- /// <param name="attributeValue">Attribute new value.</param>
- internal void SetAttributeObject(CommonCustomProperties attrib, object attributeValue)
- {
- properties[(int)attrib] = attributeValue;
- }
- /// <summary>
- /// Set the default properties of the data point.
- /// <param name="clearAll">Indicates that previous properties must be cleared.</param>
- /// </summary>
- virtual public void SetDefault(bool clearAll)
- {
- // If setting defaults for the data series - clear all properties and initialize common one
- if(!this.pointCustomProperties)
- {
- if(clearAll)
- {
- properties.Clear();
- }
- // !!! IMPORTANT !!!
- // After changing the default value of the common attribute you must also
- // change the DefaultAttribute of the property representing this attribute.
- if(!IsCustomPropertySet(CommonCustomProperties.ToolTip))
- SetAttributeObject(CommonCustomProperties.ToolTip, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LegendToolTip))
- SetAttributeObject(CommonCustomProperties.LegendToolTip, "");
- if(!IsCustomPropertySet(CommonCustomProperties.Color))
- SetAttributeObject(CommonCustomProperties.Color, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.IsValueShownAsLabel))
- SetAttributeObject(CommonCustomProperties.IsValueShownAsLabel, false);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerStyle))
- SetAttributeObject(CommonCustomProperties.MarkerStyle, MarkerStyle.None);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerSize))
- SetAttributeObject(CommonCustomProperties.MarkerSize, 5);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerImage))
- SetAttributeObject(CommonCustomProperties.MarkerImage, "");
- if(!IsCustomPropertySet(CommonCustomProperties.Label))
- SetAttributeObject(CommonCustomProperties.Label, "");
- if(!IsCustomPropertySet(CommonCustomProperties.BorderWidth))
- SetAttributeObject(CommonCustomProperties.BorderWidth, 1);
- if(!IsCustomPropertySet(CommonCustomProperties.BorderDashStyle))
- SetAttributeObject(CommonCustomProperties.BorderDashStyle, ChartDashStyle.Solid);
- if(!IsCustomPropertySet(CommonCustomProperties.AxisLabel))
- SetAttributeObject(CommonCustomProperties.AxisLabel, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LabelFormat))
- SetAttributeObject(CommonCustomProperties.LabelFormat, "");
- if(!IsCustomPropertySet(CommonCustomProperties.BorderColor))
- SetAttributeObject(CommonCustomProperties.BorderColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.BackImage))
- SetAttributeObject(CommonCustomProperties.BackImage, "");
- if(!IsCustomPropertySet(CommonCustomProperties.BackImageWrapMode))
- SetAttributeObject(CommonCustomProperties.BackImageWrapMode, ChartImageWrapMode.Tile);
- if(!IsCustomPropertySet(CommonCustomProperties.BackImageAlignment))
- SetAttributeObject(CommonCustomProperties.BackImageAlignment, ChartImageAlignmentStyle.TopLeft);
- if(!IsCustomPropertySet(CommonCustomProperties.BackImageTransparentColor))
- SetAttributeObject(CommonCustomProperties.BackImageTransparentColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.BackGradientStyle))
- SetAttributeObject(CommonCustomProperties.BackGradientStyle, GradientStyle.None);
- if(!IsCustomPropertySet(CommonCustomProperties.BackSecondaryColor))
- SetAttributeObject(CommonCustomProperties.BackSecondaryColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.BackHatchStyle))
- SetAttributeObject(CommonCustomProperties.BackHatchStyle, ChartHatchStyle.None);
- if(!IsCustomPropertySet(CommonCustomProperties.Font))
- SetAttributeObject(CommonCustomProperties.Font, null);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerImageTransparentColor))
- SetAttributeObject(CommonCustomProperties.MarkerImageTransparentColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerColor))
- SetAttributeObject(CommonCustomProperties.MarkerColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerBorderColor))
- SetAttributeObject(CommonCustomProperties.MarkerBorderColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.MarkerBorderWidth))
- SetAttributeObject(CommonCustomProperties.MarkerBorderWidth, 1);
- if(!IsCustomPropertySet(CommonCustomProperties.MapAreaAttributes))
- SetAttributeObject(CommonCustomProperties.MapAreaAttributes, "");
- if (!IsCustomPropertySet(CommonCustomProperties.PostBackValue))
- SetAttributeObject(CommonCustomProperties.PostBackValue, "");
- if (!IsCustomPropertySet(CommonCustomProperties.LabelForeColor))
- SetAttributeObject(CommonCustomProperties.LabelForeColor, Color.Black);
- if (!IsCustomPropertySet(CommonCustomProperties.LabelAngle))
- SetAttributeObject(CommonCustomProperties.LabelAngle, 0);
- if (!IsCustomPropertySet(CommonCustomProperties.LabelToolTip))
- SetAttributeObject(CommonCustomProperties.LabelToolTip, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LabelUrl))
- SetAttributeObject(CommonCustomProperties.LabelUrl, "");
- if (!IsCustomPropertySet(CommonCustomProperties.LabelPostBackValue))
- SetAttributeObject(CommonCustomProperties.LabelPostBackValue, "");
- if (!IsCustomPropertySet(CommonCustomProperties.LabelMapAreaAttributes))
- SetAttributeObject(CommonCustomProperties.LabelMapAreaAttributes, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LabelBackColor))
- SetAttributeObject(CommonCustomProperties.LabelBackColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.LabelBorderWidth))
- SetAttributeObject(CommonCustomProperties.LabelBorderWidth, 1);
- if(!IsCustomPropertySet(CommonCustomProperties.LabelBorderDashStyle))
- SetAttributeObject(CommonCustomProperties.LabelBorderDashStyle, ChartDashStyle.Solid);
- if(!IsCustomPropertySet(CommonCustomProperties.LabelBorderColor))
- SetAttributeObject(CommonCustomProperties.LabelBorderColor, Color.Empty);
- if(!IsCustomPropertySet(CommonCustomProperties.Url))
- SetAttributeObject(CommonCustomProperties.Url, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LegendUrl))
- SetAttributeObject(CommonCustomProperties.LegendUrl, "");
- if (!IsCustomPropertySet(CommonCustomProperties.LegendPostBackValue))
- SetAttributeObject(CommonCustomProperties.LegendPostBackValue, "");
- if (!IsCustomPropertySet(CommonCustomProperties.LegendText))
- SetAttributeObject(CommonCustomProperties.LegendText, "");
- if(!IsCustomPropertySet(CommonCustomProperties.LegendMapAreaAttributes))
- SetAttributeObject(CommonCustomProperties.LegendMapAreaAttributes, "");
- if(!IsCustomPropertySet(CommonCustomProperties.IsVisibleInLegend))
- SetAttributeObject(CommonCustomProperties.IsVisibleInLegend, true);
- }
- // If setting defaults for the data point - clear all properties
- else
- {
- properties.Clear();
- }
- }
- #endregion
- #region DataPointCustomProperties Properties
- /// <summary>
- /// Indexer of the custom properties. Returns the DataPointCustomProperties object by index.
- /// </summary>
- /// <param name="index">Index of the custom property.</param>
- public string this[int index]
- {
- get
- {
- int currentIndex = 0;
- foreach(object key in properties.Keys)
- {
- if(currentIndex == index)
- {
- string keyStr = key as string;
- if (keyStr != null)
- {
- return keyStr;
- }
- else if (key is int)
- {
- return Enum.GetName(typeof(CommonCustomProperties), key);
- }
- return key.ToString();
- }
- ++currentIndex;
- }
- // we can't throw IndexOutOfRangeException here, it is reserved
- // by the CLR.
- throw (new InvalidOperationException());
- }
- }
- /// <summary>
- /// Indexer of the custom properties. Returns the DataPointCustomProperties object by name.
- /// </summary>
- /// <param name="name">Name of the custom property.</param>
- public string this[string name]
- {
- get
- {
- // If attribute is not set in data point - try getting it from the series
- if(!IsCustomPropertySet(name) && this.pointCustomProperties)
- {
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.properties[name];
- }
- return (string)series.properties[name];
- }
- return (string)properties[name];
- }
- set
- {
- properties[name] = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// The text of the data point label.
- /// </summary>
- [
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- SRCategory("CategoryAttributeLabel"),
- Bindable(true),
- SRDescription("DescriptionAttributeLabel"),
- ]
- virtual public string Label
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.Label))
- {
- return (string)GetAttributeObject(CommonCustomProperties.Label);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.Label);
- }
- return series.label;
- }
- }
- else
- {
- return series.label;
- }
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- if (this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.Label, value);
- else
- series.label = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// The text of X axis label for the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(true),
- SRDescription("DescriptionAttributeAxisLabel"),
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- ]
- virtual public string AxisLabel
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.AxisLabel))
- {
- return (string)GetAttributeObject(CommonCustomProperties.AxisLabel);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.AxisLabel);
- }
- return series.axisLabel;
- }
- }
- else
- {
- return series.axisLabel;
- }
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.AxisLabel, value);
- else
- series.axisLabel = value;
- // Set flag that there are non-empy axis labels in series or points
- if(value.Length > 0 && series != null)
- {
- series.noLabelsInPoints = false;
- }
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Format string of the data point label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabel"),
- Bindable(true),
- SRDescription("DescriptionAttributeLabelFormat")
- ]
- public string LabelFormat
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelFormat))
- {
- return (string)GetAttributeObject(CommonCustomProperties.LabelFormat);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelFormat);
- }
- return series.labelFormat;
- }
- }
- else
- {
- return series.labelFormat;
- }
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelFormat, value);
- else
- series.labelFormat = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// A flag which indicates whether to show the data point's value on the label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabel"),
- Bindable(true),
- SRDescription("DescriptionAttributeShowLabelAsValue")
- ]
- public bool IsValueShownAsLabel
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.IsValueShownAsLabel))
- {
- return (bool)GetAttributeObject(CommonCustomProperties.IsValueShownAsLabel);
- }
- else
- {
- if(IsSerializing())
- {
- return false;
- }
- if(this.isEmptyPoint)
- {
- return (bool)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.IsValueShownAsLabel);
- }
- return series.showLabelAsValue;
- }
- }
- else
- {
- return series.showLabelAsValue;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.IsValueShownAsLabel, value);
- else
- series.showLabelAsValue = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Color of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeColor4"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color Color
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.Color))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.Color);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.Color);
- }
- return series.color;
- }
- }
- else
- {
- return series.color;
- }
- }
- set
- {
- // Remove the temp color flag
- this.tempColorIsSet = false;
- if(value == Color.Empty && this.pointCustomProperties)
- {
- DeleteCustomProperty(CommonCustomProperties.Color);
- }
- else
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.Color, value);
- else
- series.color = value;
- this.Invalidate(true);
- }
- }
- }
- /// <summary>
- /// Border color of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBorderColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BorderColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BorderColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.BorderColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BorderColor);
- }
- return series.borderColor;
- }
- }
- else
- {
- return series.borderColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BorderColor, value);
- else
- series.borderColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Border style of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBorderDashStyle")
- ]
- public ChartDashStyle BorderDashStyle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BorderDashStyle))
- {
- return (ChartDashStyle)GetAttributeObject(CommonCustomProperties.BorderDashStyle);
- }
- else
- {
- if(IsSerializing())
- {
- return ChartDashStyle.Solid;
- }
- if(this.isEmptyPoint)
- {
- return (ChartDashStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BorderDashStyle);
- }
- return series.borderDashStyle;
- }
- }
- else
- {
- return series.borderDashStyle;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BorderDashStyle, value);
- else
- series.borderDashStyle = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Border width of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBorderWidth"),
- ]
- public int BorderWidth
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BorderWidth))
- {
- return (int)GetAttributeObject(CommonCustomProperties.BorderWidth);
- }
- else
- {
- if(IsSerializing())
- {
- return 1;
- }
- if(this.isEmptyPoint)
- {
- return (int)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BorderWidth);
- }
- return series.borderWidth;
- }
- }
- else
- {
- return series.borderWidth;
- }
- }
- set
- {
- if(value < 0)
- {
- throw (new ArgumentOutOfRangeException("value", SR.ExceptionBorderWidthIsNotPositive));
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BorderWidth, value);
- else
- series.borderWidth = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
-
- /// <summary>
- /// Background image of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBackImage"),
- #if DESIGNER
- Editor(typeof(ImageValueEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string BackImage
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackImage))
- {
- return (string)GetAttributeObject(CommonCustomProperties.BackImage);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackImage);
- }
- return series.backImage;
- }
- }
- else
- {
- return series.backImage;
- }
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackImage, value);
- else
- series.backImage = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the drawing mode of the background image.
- /// </summary>
- /// <value>
- /// A <see cref="ChartImageWrapMode"/> value that defines the drawing mode of the image.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeImageWrapMode")
- ]
- public ChartImageWrapMode BackImageWrapMode
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackImageWrapMode))
- {
- return (ChartImageWrapMode)GetAttributeObject(CommonCustomProperties.BackImageWrapMode);
- }
- else
- {
- if(IsSerializing())
- {
- return ChartImageWrapMode.Tile;
- }
- if(this.isEmptyPoint)
- {
- return (ChartImageWrapMode)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackImageWrapMode);
- }
- return series.backImageWrapMode;
- }
- }
- else
- {
- return series.backImageWrapMode;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackImageWrapMode, value);
- else
- series.backImageWrapMode = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets a color which will be replaced with a transparent color while drawing the background image.
- /// </summary>
- /// <value>
- /// A <see cref="Color"/> value which will be replaced with a transparent color while drawing the image.
- /// </value>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- NotifyParentPropertyAttribute(true),
- SRDescription("DescriptionAttributeImageTransparentColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BackImageTransparentColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackImageTransparentColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.BackImageTransparentColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackImageTransparentColor);
- }
- return series.backImageTransparentColor;
- }
- }
- else
- {
- return series.backImageTransparentColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackImageTransparentColor, value);
- else
- series.backImageTransparentColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the alignment of the background image which is used by ClampUnscale drawing mode.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- NotifyParentPropertyAttribute(true),
- SRDescription("DescriptionAttributeBackImageAlign")
- ]
- public ChartImageAlignmentStyle BackImageAlignment
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackImageAlignment))
- {
- return (ChartImageAlignmentStyle)GetAttributeObject(CommonCustomProperties.BackImageAlignment);
- }
- else
- {
- if(IsSerializing())
- {
- return ChartImageAlignmentStyle.TopLeft;
- }
- if(this.isEmptyPoint)
- {
- return (ChartImageAlignmentStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackImageAlignment);
- }
- return series.backImageAlignment;
- }
- }
- else
- {
- return series.backImageAlignment;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackImageAlignment, value);
- else
- series.backImageAlignment = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the background gradient style.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBackGradientStyle"),
- #if DESIGNER
- Editor(typeof(GradientEditor), typeof(UITypeEditor))
- #endif
- ]
- public GradientStyle BackGradientStyle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackGradientStyle))
- {
- return (GradientStyle)GetAttributeObject(CommonCustomProperties.BackGradientStyle);
- }
- else
- {
- if(IsSerializing())
- {
- return GradientStyle.None;
- }
- if(this.isEmptyPoint)
- {
- return (GradientStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackGradientStyle);
- }
- return series.backGradientStyle;
- }
- }
- else
- {
- return series.backGradientStyle;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackGradientStyle, value);
- else
- series.backGradientStyle = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the secondary background color.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBackSecondaryColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color BackSecondaryColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackSecondaryColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.BackSecondaryColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackSecondaryColor);
- }
- return series.backSecondaryColor;
- }
- }
- else
- {
- return series.backSecondaryColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackSecondaryColor, value);
- else
- series.backSecondaryColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the background hatch style.
- /// </summary>
- [
- SRCategory("CategoryAttributeAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBackHatchStyle"),
- #if DESIGNER
- Editor(typeof(HatchStyleEditor), typeof(UITypeEditor))
- #endif
- ]
- public ChartHatchStyle BackHatchStyle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.BackHatchStyle))
- {
- return (ChartHatchStyle)GetAttributeObject(CommonCustomProperties.BackHatchStyle);
- }
- else
- {
- if(IsSerializing())
- {
- return ChartHatchStyle.None;
- }
- if(this.isEmptyPoint)
- {
- return (ChartHatchStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.BackHatchStyle);
- }
- return series.backHatchStyle;
- }
- }
- else
- {
- return series.backHatchStyle;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.BackHatchStyle, value);
- else
- series.backHatchStyle = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the font of the data point.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeFont")
- ]
- public Font Font
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.Font))
- {
- Font font = GetAttributeObject(CommonCustomProperties.Font) as Font;
- if (font != null)
- return font;
- }
- if(IsSerializing())
- {
- return series.FontCache.DefaultFont;
- }
-
- if(this.isEmptyPoint)
- {
- return series.EmptyPointStyle.Font;
- }
- return series.font;
- }
- else
- {
- return series.font;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.Font, value);
- else
- series.font = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the label color.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeFontColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor))
- #endif
- ]
- public Color LabelForeColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelForeColor))
- {
- Color color = (Color)GetAttributeObject(CommonCustomProperties.LabelForeColor);
- return color;
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Black;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelForeColor);
- }
- if(SystemInformation.HighContrast)
- {
- return SystemColors.WindowText;
- }
- return series.fontColor;
- }
- }
- else
- {
- return series.fontColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelForeColor, value);
- else
- series.fontColor = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the angle of the label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription(SR.Keys.DescriptionAttributeLabel_FontAngle)
- ]
- public int LabelAngle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelAngle))
- {
- return (int)GetAttributeObject(CommonCustomProperties.LabelAngle);
- }
- else
- {
- if(IsSerializing())
- {
- return 0;
- }
- if(this.isEmptyPoint)
- {
- return (int)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelAngle);
- }
- return series.fontAngle;
- }
- }
- else
- {
- return series.fontAngle;
- }
- }
- set
- {
- if(value < -90 || value > 90)
- {
- throw (new ArgumentOutOfRangeException("value", SR.ExceptionAngleRangeInvalid));
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelAngle, value);
- else
- series.fontAngle = value;
- this.Invalidate(false);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the marker style.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerStyle4"),
- #if DESIGNER
- Editor(typeof(MarkerStyleEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All)
- ]
- public MarkerStyle MarkerStyle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerStyle))
- {
- return (MarkerStyle)GetAttributeObject(CommonCustomProperties.MarkerStyle);
- }
- else
- {
- if(IsSerializing())
- {
- return MarkerStyle.None;
- }
- if(this.isEmptyPoint)
- {
- return (MarkerStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerStyle);
- }
- return series.markerStyle;
- }
- }
- else
- {
- return series.markerStyle;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerStyle, value);
- else
- series.markerStyle = value;
- Series thisSeries = this as Series;
- if(thisSeries != null)
- {
- thisSeries.tempMarkerStyleIsSet = false;
- }
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the size of the marker.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerSize"),
- RefreshProperties(RefreshProperties.All)
- ]
- public int MarkerSize
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerSize))
- {
- return (int)GetAttributeObject(CommonCustomProperties.MarkerSize);
- }
- else
- {
- if(IsSerializing())
- {
- return 5;
- }
- if(this.isEmptyPoint)
- {
- return (int)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerSize);
- }
- return series.markerSize;
- }
- }
- else
- {
- return series.markerSize;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerSize, value);
- else
- series.markerSize = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the marker image.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerImage"),
- #if DESIGNER
- Editor(typeof(ImageValueEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All)
- ]
- public string MarkerImage
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerImage))
- {
- return (string)GetAttributeObject(CommonCustomProperties.MarkerImage);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerImage);
- }
- return series.markerImage;
- }
- }
- else
- {
- return series.markerImage;
- }
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerImage, value);
- else
- series.markerImage = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the color which will be replaced with a transparent color while drawing the marker image.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeImageTransparentColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All)
- ]
- public Color MarkerImageTransparentColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerImageTransparentColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.MarkerImageTransparentColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerImageTransparentColor);
- }
- return series.markerImageTransparentColor;
- }
- }
- else
- {
- return series.markerImageTransparentColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerImageTransparentColor, value);
- else
- series.markerImageTransparentColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
-
- /// <summary>
- /// Gets or sets the marker color.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerColor3"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All)
- ]
- public Color MarkerColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.MarkerColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerColor);
- }
- return series.markerColor;
- }
- }
- else
- {
- return series.markerColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerColor, value);
- else
- series.markerColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
-
- /// <summary>
- /// Gets or sets the border color of the marker.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerBorderColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
- #endif
- RefreshProperties(RefreshProperties.All)
- ]
- public Color MarkerBorderColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerBorderColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.MarkerBorderColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerBorderColor);
- }
- return series.markerBorderColor;
- }
- }
- else
- {
- return series.markerBorderColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerBorderColor, value);
- else
- series.markerBorderColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the border width of the marker.
- /// </summary>
- [
- SRCategory("CategoryAttributeMarker"),
- Bindable(true),
- SRDescription("DescriptionAttributeMarkerBorderWidth")
- ]
- public int MarkerBorderWidth
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.MarkerBorderWidth))
- {
- return (int)GetAttributeObject(CommonCustomProperties.MarkerBorderWidth);
- }
- else
- {
- if(IsSerializing())
- {
- return 1;
- }
- if(this.isEmptyPoint)
- {
- return (int)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.MarkerBorderWidth);
- }
- return series.markerBorderWidth;
- }
- }
- else
- {
- return series.markerBorderWidth;
- }
- }
- set
- {
- if(value < 0)
- {
- throw (new ArgumentOutOfRangeException("value", SR.ExceptionBorderWidthIsNotPositive));
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.MarkerBorderWidth, value);
- else
- series.markerBorderWidth = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Gets or sets the extended custom properties of the data point.
- /// Extended custom properties can be specified in the following format:
- /// AttrName1=Value1, AttrName2=Value2, ...
- /// </summary>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(false),
- SRDescription("DescriptionAttributeCustomAttributesExtended"),
- DefaultValue(null),
- RefreshProperties(RefreshProperties.All),
- NotifyParentPropertyAttribute(true),
- DesignOnlyAttribute(true),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SerializationVisibilityAttribute(SerializationVisibility.Hidden),
- EditorBrowsableAttribute(EditorBrowsableState.Never),
- DisplayName("CustomProperties")
- ]
- public CustomProperties CustomPropertiesExtended
- {
- set
- {
- customProperties = value;
- CallOnModifing();
- }
- get
- {
- return customProperties;
- }
- }
- /// <summary>
- /// Gets or sets the custom properties of the data point.
- /// Custom properties can be specified in the following format:
- /// AttrName1=Value1, AttrName2=Value2, ...
- /// </summary>
- [
- SRCategory("CategoryAttributeMisc"),
- Bindable(true),
- Browsable(false),
- SRDescription("DescriptionAttributeCustomAttributesExtended"),
- DefaultValue("")
- ]
- public string CustomProperties
- {
- get
- {
- // Save all custom properties in a string
- string result = "";
- string[] attributesNames = CommonCustomProperties.GetNames(typeof(CommonCustomProperties));
- for(int i = properties.Count - 1; i >= 0; i--)
- {
- if(this[i] != null)
- {
- string attributeName = this[i];
- // Check if attribute is custom
- bool customAttribute = true;
- foreach(string name in attributesNames)
- {
- if(String.Compare(attributeName, name, StringComparison.OrdinalIgnoreCase) == 0)
- {
- customAttribute = false;
- break;
- }
- }
- // Add custom attribute to the string
- if(customAttribute && properties[attributeName] != null)
- {
- if(result.Length > 0)
- {
- result += ", ";
- }
- string attributeValue = properties[attributeName].ToString().Replace(",", "\\,");
- attributeValue = attributeValue.Replace("=", "\\=");
- result += attributeName + "=" + attributeValue;
- }
- }
- }
- return result;
- }
- set
- {
- // Replace NULL with empty string
- if(value == null)
- {
- value = string.Empty;
- }
- // Copy all common properties to the new collection
- Hashtable newAttributes = new Hashtable();
- Array enumValues = Enum.GetValues(typeof(CommonCustomProperties));
- foreach(object val in enumValues)
- {
- if(IsCustomPropertySet((CommonCustomProperties)val))
- {
- newAttributes[(int)val] = properties[(int)val];
- }
- }
-
- if(value.Length > 0)
- {
- // Replace commas in value string
- value = value.Replace("\\,", "\\x45");
- value = value.Replace("\\=", "\\x46");
- // Add new custom properties
- string[] nameValueStrings = value.Split(',');
- foreach(string nameValue in nameValueStrings)
- {
- string[] values = nameValue.Split('=');
- // Check format
- if(values.Length != 2)
- {
- throw(new FormatException( SR.ExceptionAttributeInvalidFormat));
- }
-
- // Check for empty name or value
- values[0] = values[0].Trim();
- values[1] = values[1].Trim();
- if(values[0].Length == 0)
- {
- throw(new FormatException( SR.ExceptionAttributeInvalidFormat));
- }
- // Check if value already defined
- foreach(object existingAttributeName in newAttributes.Keys)
- {
- string existingAttributeNameStr = existingAttributeName as string;
- if (existingAttributeNameStr != null)
- {
- if (String.Compare(existingAttributeNameStr, values[0], StringComparison.OrdinalIgnoreCase) == 0)
- {
- throw(new FormatException( SR.ExceptionAttributeNameIsNotUnique(values[0] ) ) );
- }
- }
- }
-
- string newValue = values[1].Replace("\\x45", ",");
- newAttributes[values[0]] = newValue.Replace("\\x46", "=");
-
- }
- }
- properties = newAttributes;
- this.Invalidate(true);
- }
- }
- #endregion
- #region IMapAreaAttributesutes Properties implementation
- /// <summary>
- /// Tooltip.
- /// </summary>
- [
- SRCategory("CategoryAttributeMapArea"),
- Bindable(true),
- SRDescription("DescriptionAttributeToolTip"),
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string ToolTip
- {
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.ToolTip, value);
- else
- series.toolTip = value;
-
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- }
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.ToolTip))
- {
- return (String)GetAttributeObject(CommonCustomProperties.ToolTip);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.ToolTip);
- }
- return series.toolTip;
- }
- }
- else
- {
- return series.toolTip;
- }
- }
- }
- /// <summary>
- /// Replaces predefined keyword inside the string with their values.
- /// </summary>
- /// <param name="strOriginal">Original string with keywords.</param>
- /// <returns>Modified string.</returns>
- internal virtual string ReplaceKeywords(string strOriginal)
- {
- return strOriginal;
- }
- #endregion
- #region Legend properties
- /// <summary>
- /// Indicates whether the item is shown in the legend.
- /// </summary>
- [
- SRCategory("CategoryAttributeLegend"),
- Bindable(true),
- SRDescription("DescriptionAttributeShowInLegend")
- ]
- public bool IsVisibleInLegend
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.IsVisibleInLegend))
- {
- return (bool)GetAttributeObject(CommonCustomProperties.IsVisibleInLegend);
- }
- else
- {
- if(IsSerializing())
- {
- return true;
- }
- if(this.isEmptyPoint)
- {
- return (bool)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.IsVisibleInLegend);
- }
- return series.showInLegend;
- }
- }
- else
- {
- return series.showInLegend;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.IsVisibleInLegend, value);
- else
- series.showInLegend = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Text of the item in the legend
- /// </summary>
- [
- SRCategory("CategoryAttributeLegend"),
- Bindable(true),
- SRDescription("DescriptionAttributeLegendText"),
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string LegendText
- {
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LegendText, value);
- else
- series.legendText = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LegendText))
- {
- return (String)GetAttributeObject(CommonCustomProperties.LegendText);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LegendText);
- }
- return series.legendText;
- }
- }
- else
- {
- return series.legendText;
- }
- }
- }
- /// <summary>
- /// Tooltip of the item in the legend
- /// </summary>
- [
- SRCategory("CategoryAttributeLegend"),
- Bindable(true),
- SRDescription("DescriptionAttributeLegendToolTip"),
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string LegendToolTip
- {
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LegendToolTip, value);
- else
- series.legendToolTip = value;
-
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- CallOnModifing();
- }
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LegendToolTip))
- {
- return (String)GetAttributeObject(CommonCustomProperties.LegendToolTip);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LegendToolTip);
- }
- return series.legendToolTip;
- }
- }
- else
- {
- return series.legendToolTip;
- }
- }
- }
- /// <summary>
- /// Background color of the data point label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeLabelBackColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
- #endif
- DefaultValue(typeof(Color), ""),
- ]
- public Color LabelBackColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelBackColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.LabelBackColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelBackColor);
- }
- if(SystemInformation.HighContrast)
- {
- return SystemColors.Window;
- }
- return series.labelBackColor;
- }
- }
- else
- {
- return series.labelBackColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelBackColor, value);
- else
- series.labelBackColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Border color of the data point label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBorderColor"),
- TypeConverter(typeof(ColorConverter)),
- #if DESIGNER
- Editor(typeof(ChartColorEditor), typeof(UITypeEditor)),
- #endif
- DefaultValue(typeof(Color), ""),
- ]
- public Color LabelBorderColor
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelBorderColor))
- {
- return (Color)GetAttributeObject(CommonCustomProperties.LabelBorderColor);
- }
- else
- {
- if(IsSerializing())
- {
- return Color.Empty;
- }
- if(this.isEmptyPoint)
- {
- return (Color)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelBorderColor);
- }
- if(SystemInformation.HighContrast)
- {
- return SystemColors.ActiveBorder;
- }
- return series.labelBorderColor;
- }
- }
- else
- {
- return series.labelBorderColor;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelBorderColor, value);
- else
- series.labelBorderColor = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Border style of the label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeLabelBorderDashStyle")
- ]
- public ChartDashStyle LabelBorderDashStyle
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelBorderDashStyle))
- {
- return (ChartDashStyle)GetAttributeObject(CommonCustomProperties.LabelBorderDashStyle);
- }
- else
- {
- if(IsSerializing())
- {
- return ChartDashStyle.Solid;
- }
- if(this.isEmptyPoint)
- {
- return (ChartDashStyle)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelBorderDashStyle);
- }
- return series.labelBorderDashStyle;
- }
- }
- else
- {
- return series.labelBorderDashStyle;
- }
- }
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelBorderDashStyle, value);
- else
- series.labelBorderDashStyle = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Border width of the label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabelAppearance"),
- Bindable(true),
- SRDescription("DescriptionAttributeBorderWidth")
- ]
- public int LabelBorderWidth
- {
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelBorderWidth))
- {
- return (int)GetAttributeObject(CommonCustomProperties.LabelBorderWidth);
- }
- else
- {
- if(IsSerializing())
- {
- return 1;
- }
- if(this.isEmptyPoint)
- {
- return (int)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelBorderWidth);
- }
- return series.labelBorderWidth;
- }
- }
- else
- {
- return series.labelBorderWidth;
- }
- }
- set
- {
- if(value < 0)
- {
- throw(new ArgumentOutOfRangeException("value", SR.ExceptionLabelBorderIsNotPositive));
- }
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelBorderWidth, value);
- else
- series.labelBorderWidth = value;
- this.Invalidate(true);
- CallOnModifing();
- }
- }
- /// <summary>
- /// Tooltip of the data point label.
- /// </summary>
- [
- SRCategory("CategoryAttributeLabel"),
- Bindable(true),
- SRDescription("DescriptionAttributeLabelToolTip"),
- #if DESIGNER
- Editor(typeof(KeywordsStringEditor), typeof(UITypeEditor)),
- #endif
- ]
- public string LabelToolTip
- {
- set
- {
- if(this.pointCustomProperties)
- SetAttributeObject(CommonCustomProperties.LabelToolTip, value);
- else
- series.labelToolTip = value;
-
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- CallOnModifing();
- }
- get
- {
- if(this.pointCustomProperties)
- {
- if(properties.Count != 0 && IsCustomPropertySet(CommonCustomProperties.LabelToolTip))
- {
- return (String)GetAttributeObject(CommonCustomProperties.LabelToolTip);
- }
- else
- {
- if(IsSerializing())
- {
- return "";
- }
- if(this.isEmptyPoint)
- {
- return (string)series.EmptyPointStyle.GetAttributeObject(CommonCustomProperties.LabelToolTip);
- }
- return series.labelToolTip;
- }
- }
- else
- {
- return series.labelToolTip;
- }
- }
- }
- #endregion
- #region Serialization control
- private bool CheckIfSerializationRequired(CommonCustomProperties attribute)
- {
- if(this is DataPoint)
- {
- return IsCustomPropertySet(attribute);
- }
- else
- {
- object attr1 = this.GetAttributeObject(attribute);
- object attr2 = Series.defaultCustomProperties.GetAttributeObject(attribute);
- if(attr1 == null || attr2 == null)
- {
- return false;
- }
- return ! attr1.Equals(attr2);
- }
- }
- private void ResetProperty(CommonCustomProperties attribute)
- {
- if(this is DataPoint)
- {
- DeleteCustomProperty(attribute);
- }
- else
- {
- this.SetAttributeObject(attribute, Series.defaultCustomProperties.GetAttributeObject(attribute));
- }
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabel()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.Label);
- else
- return !String.IsNullOrEmpty(series.label);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeAxisLabel()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.AxisLabel);
- else
- return !String.IsNullOrEmpty(series.axisLabel);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelFormat()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelFormat);
- else
- return !String.IsNullOrEmpty(series.labelFormat);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeIsValueShownAsLabel()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.IsValueShownAsLabel);
- else
- return series.showLabelAsValue != false;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.Color);
- else
- return series.color != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBorderColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BorderColor);
- else
- return series.borderColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBorderDashStyle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BorderDashStyle);
- else
- return series.borderDashStyle != ChartDashStyle.Solid;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBorderWidth()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BorderWidth);
- else
- return series.borderWidth != 1;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerBorderWidth()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerBorderWidth);
- else
- return series.markerBorderWidth != 1;
- }
-
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackImage()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackImage);
- else
- return !String.IsNullOrEmpty(series.backImage);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackImageWrapMode()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackImageWrapMode);
- else
- return series.backImageWrapMode != ChartImageWrapMode.Tile;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackImageTransparentColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackImageTransparentColor);
- else
- return series.backImageTransparentColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
- internal bool ShouldSerializeBackImageAlignment()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackImageAlignment);
- else
- return series.backImageAlignment != ChartImageAlignmentStyle.TopLeft;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackGradientStyle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackGradientStyle);
- else
- return series.backGradientStyle != GradientStyle.None;
- }
-
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackSecondaryColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackSecondaryColor);
- else
- return series.backSecondaryColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeBackHatchStyle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.BackHatchStyle);
- else
- return series.backHatchStyle != ChartHatchStyle.None;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeFont()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.Font);
- else
- {
- return series.font != series.FontCache.DefaultFont;
- }
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
- internal bool ShouldSerializeLabelForeColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelForeColor);
- else
- return series.fontColor != Color.Black;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelAngle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelAngle);
- else
- return series.fontAngle != 0f;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerStyle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerStyle);
- else
- return series.markerStyle != MarkerStyle.None;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerSize()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerSize);
- else
- return series.markerSize != 5;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerImage()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerImage);
- else
- return !String.IsNullOrEmpty(series.markerImage);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerImageTransparentColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerImageTransparentColor);
- else
- return series.markerImageTransparentColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerColor);
- else
- return series.markerColor != Color.Empty;
- }
-
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeMarkerBorderColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.MarkerBorderColor);
- else
- return series.markerBorderColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeToolTip()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.ToolTip);
- else
- return !String.IsNullOrEmpty(series.toolTip);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
- internal bool ShouldSerializeIsVisibleInLegend()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.IsVisibleInLegend);
- else
- return series.showInLegend != true;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLegendText()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LegendText);
- else
- return !String.IsNullOrEmpty(series.legendText);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLegendToolTip()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LegendToolTip);
- else
- return !String.IsNullOrEmpty(series.legendToolTip);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelToolTip()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelToolTip);
- else
- return !String.IsNullOrEmpty(series.labelToolTip);
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelBackColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelBackColor);
- else
- return series.labelBackColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelBorderColor()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelBorderColor);
- else
- return series.labelBorderColor != Color.Empty;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelBorderDashStyle()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelBorderDashStyle);
- else
- return series.labelBorderDashStyle != ChartDashStyle.Solid;
- }
- /// <summary>
- /// Returns true if property should be serialized.
- /// </summary>
-
- internal bool ShouldSerializeLabelBorderWidth()
- {
- if(this.pointCustomProperties)
- return CheckIfSerializationRequired(CommonCustomProperties.LabelBorderWidth);
- else
- return series.labelBorderWidth != 1;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabel()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.Label);
- else
- series.label = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetAxisLabel()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.AxisLabel);
- else
- series.axisLabel = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelFormat()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelFormat);
- else
- series.labelFormat = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- public void ResetIsValueShownAsLabel()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.IsValueShownAsLabel);
- else
- series.IsValueShownAsLabel = false;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.Color);
- else
- series.color = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBorderColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BorderColor);
- else
- series.borderColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBorderDashStyle()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BorderDashStyle);
- else
- series.borderDashStyle = ChartDashStyle.Solid;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBorderWidth()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BorderWidth);
- else
- series.borderWidth = 1;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerBorderWidth()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerBorderWidth);
- else
- series.markerBorderWidth = 1;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBackImage()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BackImage);
- else
- series.backImage = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBackImageWrapMode()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BackImageWrapMode);
- else
- series.backImageWrapMode = ChartImageWrapMode.Tile;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBackImageTransparentColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BackImageTransparentColor);
- else
- series.backImageTransparentColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBackSecondaryColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BackSecondaryColor);
- else
- series.backSecondaryColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetBackHatchStyle()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.BackHatchStyle);
- else
- series.backHatchStyle = ChartHatchStyle.None;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetFont()
- {
- if (this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.Font);
- else
- {
- series.font = series.FontCache.DefaultFont;
- }
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelAngle()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelAngle);
- else
- series.fontAngle = 0;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerStyle()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerStyle);
- else
- series.markerStyle = MarkerStyle.None;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerSize()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerSize);
- else
- series.markerSize = 5;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerImage()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerImage);
- else
- series.markerImage = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerImageTransparentColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerImageTransparentColor);
- else
- series.markerImageTransparentColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerColor);
- else
- series.markerColor = Color.Empty;
- }
-
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetMarkerBorderColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.MarkerBorderColor);
- else
- series.markerBorderColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetToolTip()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.ToolTip);
- else
- series.toolTip = "";
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
- public void ResetIsVisibleInLegend()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.IsVisibleInLegend);
- else
- series.showInLegend = true;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLegendText()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LegendText);
- else
- series.legendText = "";
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLegendToolTip()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LegendToolTip);
- else
- series.legendToolTip = "";
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelBackColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelBackColor);
- else
- series.labelBackColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelBorderColor()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelBorderColor);
- else
- series.labelBorderColor = Color.Empty;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelBorderDashStyle()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelBorderDashStyle);
- else
- series.labelBorderDashStyle = ChartDashStyle.Solid;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelBorderWidth()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelBorderWidth);
- else
- series.labelBorderWidth = 1;
- }
- /// <summary>
- /// Resets property to its default value.
- /// </summary>
-
- internal void ResetLabelToolTip()
- {
- if(this.pointCustomProperties)
- ResetProperty(CommonCustomProperties.LabelToolTip);
- else
- series.labelToolTip = "";
- if(Chart != null && Chart.selection != null)
- {
- Chart.selection.enabledChecked = false;
- }
- }
-
- #endregion
- #region Invalidating method
- /// <summary>
- /// Invalidate chart area.
- /// </summary>
- /// <param name="invalidateLegend">Invalidate legend area only.</param>
- [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "This parameter is used when compiling for the WinForms version of Chart")]
- internal void Invalidate(bool invalidateLegend)
- {
- if(this.series != null)
- {
- series.Invalidate(true, invalidateLegend);
- }
- else
- {
- Series thisSeries = this as Series;
- if (thisSeries != null)
- {
- thisSeries.Invalidate(true, invalidateLegend);
- }
- }
- }
- #endregion
- }
- /// <summary>
- /// Class stores additional information about the data point in 3D space.
- /// </summary>
- internal class DataPoint3D
- {
- #region Fields
- /// <summary>
- /// Reference to the 2D data point object
- /// </summary>
- internal DataPoint dataPoint = null;
- /// <summary>
- /// Data point index.
- /// </summary>
- internal int index = 0;
- /// <summary>
- /// Point X position in relative coordinates.
- /// </summary>
- internal double xPosition = 0.0;
- /// <summary>
- /// Point Y position in relative coordinates.
- /// </summary>
- internal double yPosition = 0.0;
- /// <summary>
- /// Point X center position in relative coordinates. Used for side-by-side charts.
- /// </summary>
- internal double xCenterVal = 0.0;
- /// <summary>
- /// Point Z position in relative coordinates.
- /// </summary>
- internal float zPosition = 0f;
- /// <summary>
- /// Point width.
- /// </summary>
- internal double width = 0.0;
- /// <summary>
- /// Point height.
- /// </summary>
- internal double height = 0.0;
- /// <summary>
- /// Point depth.
- /// </summary>
- internal float depth = 0f;
- /// <summary>
- /// Indicates that point belongs to indexed series.
- /// </summary>
- internal bool indexedSeries = false;
- #endregion
- }
- /// <summary>
- /// Design-time representation of the CustomProperties.
- /// This class is used instead of the string "CustomProperties"
- /// property at design time and supports expandable list
- /// of custom properties.
- /// </summary>
- [ TypeConverter(typeof(CustomPropertiesTypeConverter)) ]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class CustomProperties
- {
- #region Fields
- // Reference to the properties class
- internal DataPointCustomProperties m_DataPointCustomProperties = null;
- #endregion // Fields
- #region Constructor
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="properties">Attributes object.</param>
- internal CustomProperties(DataPointCustomProperties properties)
- {
- this.m_DataPointCustomProperties = properties;
- }
- #endregion // Constructor
- #region Properties
- internal virtual DataPointCustomProperties DataPointCustomProperties
- {
- get
- {
- return this.m_DataPointCustomProperties;
- }
- set
- {
- this.m_DataPointCustomProperties = value;
- }
- }
- #endregion //Properties
- #region Methods
- /// <summary>
- /// Gets a comma separated string of user defined custom properties.
- /// </summary>
- /// <returns>Comma separated string of user defined custom properties.</returns>
- internal virtual string GetUserDefinedCustomProperties()
- {
- return GetUserDefinedCustomProperties(true);
- }
- /// <summary>
- /// Gets a comma separated string of user defined or non-user defined custom properties.
- /// </summary>
- /// <param name="userDefined">True if user defined properties must be returned.</param>
- /// <returns>Comma separated string of user defined custom properties.</returns>
- internal virtual string GetUserDefinedCustomProperties(bool userDefined)
- {
- // Get comma separated string of custom properties
- string customAttribute = this.DataPointCustomProperties.CustomProperties;
- string userDefinedCustomAttribute = string.Empty;
- // Get custom attribute registry
- CustomPropertyRegistry registry = (CustomPropertyRegistry)this.DataPointCustomProperties.Common.container.GetService(typeof(CustomPropertyRegistry));
- // Replace commas in value string
- customAttribute = customAttribute.Replace("\\,", "\\x45");
- customAttribute = customAttribute.Replace("\\=", "\\x46");
- // Split custom properties by commas into individual properties
- if(customAttribute.Length > 0)
- {
- string[] nameValueStrings = customAttribute.Split(',');
- foreach(string nameValue in nameValueStrings)
- {
- string[] values = nameValue.Split('=');
- // Check format
- if(values.Length != 2)
- {
- throw(new FormatException(SR.ExceptionAttributeInvalidFormat));
- }
-
- // Check for empty name or value
- values[0] = values[0].Trim();
- values[1] = values[1].Trim();
- if(values[0].Length == 0)
- {
- throw(new FormatException(SR.ExceptionAttributeInvalidFormat));
- }
- // Check if attribute is registered or user defined
- bool userDefinedAttribute = true;
- foreach(CustomPropertyInfo info in registry.registeredCustomProperties)
- {
- if(string.Compare(info.Name, values[0], StringComparison.OrdinalIgnoreCase) == 0)
- {
- userDefinedAttribute = false;
- }
- }
- // Copy attribute into the output string
- if(userDefinedAttribute == userDefined)
- {
- if(userDefinedCustomAttribute.Length > 0)
- {
- userDefinedCustomAttribute += ", ";
- }
- string val = values[1].Replace("\\x45", ",");
- val = val.Replace("\\x46", "=");
- userDefinedCustomAttribute += values[0] + "=" + val;
- }
- }
- }
- return userDefinedCustomAttribute;
- }
- /// <summary>
- /// Sets user defined custom properties without cleaning registered properties.
- /// </summary>
- /// <param name="val">New user defined properties.</param>
- internal virtual void SetUserDefinedAttributes(string val)
- {
- // Get non-user defined custom properties
- string properties = GetUserDefinedCustomProperties(false);
- // Check if new string is empty
- if(val.Length > 0)
- {
- // Add comma at the end
- if(properties.Length > 0)
- {
- properties += ", ";
- }
- // Add new user defined properties
- properties += val;
- }
- // Set new custom attribute string
- this.DataPointCustomProperties.CustomProperties = properties;
- }
- #endregion // Methods
- }
- }
|