| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088 |
- using MuchInfo.Chart.Data.EnumTypes;
- namespace IndexFormula.Finance.Win
- {
- using IndexFormula.Finance;
- using IndexFormula.Finance.DataProvider;
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.Drawing.Printing;
- using System.Globalization;
- using System.IO;
- using System.Text;
- using System.Windows.Forms;
- public class ChartWinControl : UserControl, IObjectCanvas
- {
- private bool adjustData = true;
- private double afterBars = 0.1;
- private string areaPercent = "3;1;1;1;1";
- private FormulaChart chart;
- private IndexFormula.Finance.ChartDragMode chartDragMode = IndexFormula.Finance.ChartDragMode.Axis;
- private ContextMenu cmMain;
- public ContextMenu cmRight;
- private double columnWidth = 4.0;
- private Container components = null;
- private Graphics ControlGraphics;
- private MouseAction crossCursorMouseMode = MouseAction.MouseMove;
- private Bitmap CrossMemBmp;
- private Graphics CrossMemBmpG;
- private DataCycle currentDataCycle = DataCycle.Day;
- private DataManagerBase CurrentDataManager;
- private Cursor defaultCursor = null;
- private const string defaultFavoriteCycles = "MINUTE1;MINUTE5;MINUTE15;MINUTE30;HOUR1;DAY1;WEEK1;MONTH1;YEAR1";
- private string defaultFormulas;
- private static Color defaultZoomBackColor = Color.FromArgb(0x20, Color.Green);
- private bool designing;
- private ChartDragInfo DragInfo;
- private EventHandler ehFavoriteIndicator;
- private bool EnableResize;
- private bool EnableXScale;
- private bool EnableYScale;
- private DateTime endTime;
- private string favoriteCycles = "MINUTE1;MINUTE5;MINUTE15;MINUTE30;HOUR1;DAY1;WEEK1;MONTH1;YEAR1";
- private ArrayList favoriteFormulas;
- private bool fixedTime;
- private Rectangle fixedZoomRect = Rectangle.Empty;
- private DataManagerBase historyDataManager;
- private DataManagerBase intraDataManager;
- private ExchangeIntraday intradayInfo = ExchangeIntraday.US;
- private int LastCursorPos;
- private FormulaHitInfo LastHitInfo;
- private IDataProvider LastProvider;
- private int LastX;
- private int LastY;
- private IndexFormula.Finance.LatestValueType latestValueType = IndexFormula.Finance.LatestValueType.All;
- private double maxColumnWidth = 500.0;
- private double maxPrice;
- private Bitmap MemBmp;
- private bool memoryCrossCursor;
- private MenuItem miAddFormula;
- private MenuItem miAdjust;
- private MenuItem miAxisType;
- private MenuItem miCalculator;
- private MenuItem miChart;
- private MenuItem miChartCopy;
- private MenuItem miChartEdit;
- private MenuItem miCloseFormula;
- private MenuItem miCopy;
- private MenuItem miCrossCursor;
- private MenuItem miCycle;
- private MenuItem miEdit;
- private MenuItem miFavorite;
- private MenuItem miFormulaManager;
- private MenuItem miIndicator;
- private MenuItem miLog;
- private double minColumnWidth = 0.01;
- private MenuItem miNormal;
- private double minPrice;
- private MenuItem miSkin;
- private MenuItem miSp1;
- private MenuItem miSp2;
- private MenuItem miSp4;
- private MenuItem miStatistic;
- private MenuItem miStatisticWindow;
- private MenuItem miView;
- private FormulaHitInfo MouseDownInfo;
- private IndexFormula.Finance.Win.MouseWheelMode mouseWheelMode = IndexFormula.Finance.Win.MouseWheelMode.Scroll;
- private Color mouseZoomBackColor = defaultZoomBackColor;
- private Bitmap MouseZoomBmp;
- private Graphics MouseZoomBmpG;
- private IndexFormula.Finance.Win.MouseZoomMode mouseZoomMode = IndexFormula.Finance.Win.MouseZoomMode.Rect;
- private RectangleF MouseZoomRect;
- private bool nativeContextMenu = true;
- private bool needAutoScaleY = true;
- private bool needDrawCursor;
- private bool needDrawLastBarOnly = false;
- private bool needRebind;
- private bool needRedraw;
- private bool needRefresh;
- private bool needResetCursorPos;
- private bool needSetDefaultFormulas;
- public static IndexFormula.Finance.Win.OnSelectFormula OnSelectFormula = new IndexFormula.Finance.Win.OnSelectFormula(ChartWinControl.DefaultSelectFormula);
- public static OnSelectString OnSelectMethod = new OnSelectString(ChartWinControl.DefaultSelectMethod);
- public static OnSelectString OnSelectSymbol = null;
- private int Page;
- private PrintPreviewDialog previewDialog;
- private PrintDialog printDialog;
- private PrintDocument printDocument;
- private bool resetYAfterXChanged = true;
- private IndexFormula.Finance.ScaleType scaleType = IndexFormula.Finance.ScaleType.Default;
- private MouseAction selectFormulaMouseMode = MouseAction.MouseDown;
- private PageSetupDialog setupDialog;
- private bool showCrossCursor = true;
- private bool showCursorLabel = true;
- private ShowLineMode showHorizontalGrid;
- private bool showIndicatorValues = true;
- private bool showOverlayValues = true;
- private bool showStatistic = true;
- private bool showTopLine = true;
- private ShowLineMode showVerticalGrid;
- private string skin = "RedWhite";
- private DateTime startTime;
- public StatisticControl StatisticWindow = null;
- private IndexFormula.Finance.StickRenderType stickRenderType = IndexFormula.Finance.StickRenderType.Default;
- private int stockBars = 150;
- private IndexFormula.Finance.StockRenderType stockRenderType = IndexFormula.Finance.StockRenderType.Default;
- private string symbol = "MSFT";
- public FormulaUserSkin UserSkin = new FormulaUserSkin();
- private IndexFormula.Finance.ValueTextMode valueTextMode = IndexFormula.Finance.ValueTextMode.Default;
- private ZoomCenterPosition zoomPosition = ZoomCenterPosition.Center;
- [Description("Occurs after apply skin"), Category("Stock Chart")]
- public event EventHandler AfterApplySkin;
- [Description("Occurs after data bind"), Category("Stock Chart")]
- public event IndexFormula.Finance.Win.AfterBindData AfterBindData;
- [Category("Stock Chart"), Description("Occurs after data cycle changed")]
- public event EventHandler AfterCycleChange;
- [Description("Occurs after mouse move"), Category("Stock Chart")]
- public event IndexFormula.Finance.Win.AfterMouseMove AfterMouseMove;
- [Description("Occurs before apply skin"), Category("Stock Chart")]
- public event ApplySkinHandler BeforeApplySkin;
- [Description("Occurs before data cycle changed"), Category("Stock Chart")]
- public event EventHandler BeforeCycleChange;
- [Description("Occurs when cursor pos changed"), Category("Stock Chart")]
- public event IndexFormula.Finance.Win.CursorPosChanged CursorPosChanged;
- [Category("Stock Chart"), Description("Occurs when stock data or data cycle changed")]
- public event EventHandler DataChanged;
- [Category("Stock Chart"), Description("Occurs when paint extra informations on the chart, it was used by Easy Stock Object")]
- public event NativePaintHandler ExtraPaint;
- [Category("Stock Chart"), Description("Occurs when paint the chart on native canvas")]
- public event NativePaintHandler NativePaint;
- [Description("Occurs when the value of ShowStatistic Changed"), Category("Stock Chart")]
- public event EventHandler ShowStatisticChanged;
- [Category("Stock Chart"), Description("Occurs when stock view changed")]
- public event ViewChangedHandler ViewChanged;
- public ChartWinControl()
- {
- this.InitializeComponent();
- SetLanguage.SetcurrentLanguage(ChartLanguageType.SimplifiedChinese);
- this.Page = 10;
- this.LastCursorPos = -1;
- this.favoriteFormulas = new ArrayList();
- this.EnableYScale = true;
- this.EnableXScale = true;
- this.EnableResize = true;
- this.chart = new FormulaChart();
- this.chart.BitmapCache = true;
- this.chart.LatestValueType = this.LatestValueType;
- base.MouseWheel += new MouseEventHandler(this.ChartWinControl_MouseWheel);
- this.AfterApplySkin = (EventHandler)Delegate.Combine(this.AfterApplySkin, new EventHandler(this.ChartWinControl_AfterApplySkin));
- this.chart.NativePaint += new NativePaintHandler(this.Chart_NativePaint);
- this.chart.ExtraPaint += new NativePaintHandler(this.Chart_ExtraPaint);
- this.chart.ViewChanged += new ViewChangedHandler(this.Chart_ViewChanged);
- this.chart.AddArea("MAIN", 3.0);
- this.FavoriteFormulas = "VOLMA;RSI;CCI;OBV;ATR;FastSTO;SlowSTO;ROC;TRIX;WR;AD;CMF;PPO;StochRSI;ULT;BBWidth;PVO";
- this.CursorPosChanged = (IndexFormula.Finance.Win.CursorPosChanged)Delegate.Combine(this.CursorPosChanged, new IndexFormula.Finance.Win.CursorPosChanged(this.ShowStatisticWindow));
- this.ehFavoriteIndicator = new EventHandler(this.mmFavorite_SelectedIndexChanged);
- this.CreateCycleMenu();
- this.StatisticWindow.OnHide += new EventHandler(this.StatisticWindow_OnHide);
- }
- private void ApplySkin()
- {
- FormulaSkin skinByName = FormulaSkin.GetSkinByName(this.skin);
- this.ApplySkin(skinByName);
- }
- public void ApplySkin(FormulaSkin fs)
- {
- if (fs != null)
- {
- if (this.BeforeApplySkin != null)
- {
- this.BeforeApplySkin(this, fs);
- }
- this.chart.SetSkin(fs);
- this.chart[0].Back.TopPen.Width = this.ShowTopLine ? 2 : 0;
- this.chart[0].AxisY.Back.TopPen.Width = this.ShowTopLine ? 2 : 0;
- if (this.AfterApplySkin != null)
- {
- this.AfterApplySkin(this, new EventArgs());
- }
- foreach (FormulaArea area in this.chart.Areas)
- {
- area.RemoveAutoMultiplyForStockYAxis();
- }
- }
- }
- private void AreasToDefaultFormulas()
- {
- this.defaultFormulas = string.Join(";", this.chart.AreaToStrings());
- }
- public void AutoAdjustYAxis()
- {
- foreach (FormulaArea area in this.chart.Areas)
- {
- foreach (FormulaAxisY sy in area.AxisYs)
- {
- this.AutoAdjustYAxis(sy);
- }
- }
- }
- public void AutoAdjustYAxis(FormulaAxisY fay)
- {
- this.MinPrice = 0.0;
- fay.AutoScale = true;
- this.NeedRedraw();
- }
- public void AutoScaleAxisY()
- {
- foreach (FormulaArea area in this.chart.Areas)
- {
- foreach (FormulaAxisY sy in area.AxisYs)
- {
- sy.AutoScale = true;
- }
- }
- this.NeedRebind();
- }
- public bool BindData()
- {
- bool flag = true;
- if ((this.HistoryDataManager != null) && (this.IntraDataManager != null))
- {
- CommonDataProvider cdp = null;
- if (this.currentDataCycle.CycleBase >= DataCycleBase.DAY)
- {
- this.CurrentDataManager = this.HistoryDataManager;
- }
- else
- {
- this.CurrentDataManager = this.IntraDataManager;
- this.CurrentDataManager.IsFix = this.fixedTime;
- this.chart.FixedTime = this.fixedTime;
- }
- if (this.CurrentDataManager.VirtualFetch)
- {
- this.CurrentDataManager.StartTime = this.startTime;
- this.CurrentDataManager.EndTime = this.endTime;
- }
- flag = false;
- try
- {
- cdp = (CommonDataProvider)this.CurrentDataManager[this.symbol];
- if (this.AfterBindData != null)
- {
- this.AfterBindData(this, new BindDataEventArgs(cdp, this.CurrentDataManager));
- }
- flag = cdp != null;
- }
- catch
- {
- }
- if (cdp != null)
- {
- this.chart.SetDataProviderNoBind(cdp);
- }
- else
- {
- this.endTime = DateTime.MinValue;
- }
- if (this.fixedTime && (cdp != null))
- {
- cdp.IntradayInfo = this.IntradayInfo;
- }
- if ((this.chart.DataProvider != null) && (this.chart.DataProvider is CommonDataProvider))
- {
- if (this.HasData())
- {
- if (this.chart.DataProvider.DataCycle.ToString() != this.currentDataCycle.ToString())
- {
- this.ColumnWidth = 5.0;
- this.StartBar = 0;
- this.chart.DataProvider.DataCycle = this.currentDataCycle;
- }
- if (this.DataChanged != null)
- {
- this.DataChanged(this, new EventArgs());
- }
- }
- (this.chart.DataProvider as CommonDataProvider).Adjusted = this.adjustData;
- }
- this.chart.SetAreaPercent(this.areaPercent);
- this.chart.Bind();
- this.ApplySkin();
- }
- return flag;
- }
- private void BuildFavoriteMenu()
- {
- this.cmRight.MenuItems.Remove(this.miFavorite);
- this.miFavorite = new MenuItem("&Favorite Indicators");
- this.cmRight.MenuItems.Add(0, this.miFavorite);
- foreach (string str in this.favoriteFormulas)
- {
- this.miFavorite.MenuItems.Add(str, this.ehFavoriteIndicator);
- }
- }
- private void CancelMouseZoom()
- {
- if (this.MouseZoomBmp != null)
- {
- this.DragInfo = null;
- this.MouseZoomBmp = null;
- this.MouseZoomRect = Rectangle.Empty;
- }
- }
- private void ChangeCursorPos()
- {
- if (((this.chart != null) && (this.chart.DataProvider != null)) && ((this.LastCursorPos != this.chart.CursorPos) || (this.LastProvider != this.chart.DataProvider)))
- {
- IDataProvider dataProvider = this.chart.DataProvider;
- if ((this.chart.CursorPos >= 0) && (this.chart.CursorPos < dataProvider.Count))
- {
- this.LastProvider = this.chart.DataProvider;
- this.LastCursorPos = this.chart.CursorPos;
- if (this.CursorPosChanged != null)
- {
- this.CursorPosChanged(this, this.chart, this.LastCursorPos, dataProvider);
- }
- }
- }
- }
- private void Chart_ExtraPaint(object sender, NativePaintArgs e)
- {
- if (this.ExtraPaint != null)
- {
- this.ExtraPaint(this, e);
- }
- }
- private void Chart_NativePaint(object sender, NativePaintArgs e)
- {
- if (this.NativePaint != null)
- {
- this.NativePaint(this, e);
- }
- }
- private void Chart_ViewChanged(object sender, ViewChangedArgs e)
- {
- if (this.ViewChanged != null)
- {
- this.ViewChanged(this, e);
- }
- }
- private void ChartWinControl_AfterApplySkin(object sender, EventArgs e)
- {
- this.chart.ExtendYAxis(TwoYAxisType.AreaSame);
- }
- private void ChartWinControl_DoubleClick(object sender, EventArgs e)
- {
- if (this.MouseDownInfo.HitType == FormulaHitType.htAxisY)
- {
- this.AutoAdjustYAxis(this.MouseDownInfo.AxisY);
- }
- }
- private void ChartWinControl_Enter(object sender, EventArgs e)
- {
- base.Invalidate();
- }
- private void ChartWinControl_KeyDown(object sender, KeyEventArgs e)
- {
- int start;
- int cursorPos;
- if (this.chart != null)
- {
- start = this.chart.Start;
- cursorPos = this.chart.CursorPos;
- int num3 = e.Control ? this.Page : 1;
- switch (e.KeyCode)
- {
- case Keys.End:
- this.chart.AdjustCursorByPos(this.ControlGraphics, 0x7fffffff, this.chart.Start);
- e.Handled = true;
- goto Label_0221;
- case Keys.Home:
- this.chart.AdjustCursorByPos(this.ControlGraphics, 0, this.chart.Start);
- e.Handled = true;
- goto Label_0221;
- case Keys.Left:
- this.chart.AdjustCursorByPos(this.ControlGraphics, this.chart.CursorPos - num3, this.chart.Start + (e.Shift ? num3 : 0));
- e.Handled = true;
- goto Label_0221;
- case Keys.Up:
- case Keys.Add:
- if (e.Control)
- {
- this.NextArea(-1);
- e.Handled = true;
- }
- else
- {
- this.ScaleChart(0.05);
- }
- goto Label_0221;
- case Keys.Right:
- this.chart.AdjustCursorByPos(this.ControlGraphics, this.chart.CursorPos + num3, this.chart.Start - (e.Shift ? num3 : 0));
- e.Handled = true;
- goto Label_0221;
- case Keys.Down:
- case Keys.Subtract:
- if (e.Control)
- {
- this.NextArea(1);
- e.Handled = true;
- }
- else
- {
- this.ScaleChart(-0.05);
- }
- goto Label_0221;
- case Keys.Escape:
- this.CancelMouseZoom();
- base.Invalidate();
- break;
- case Keys.Multiply:
- this.NextFormula(1);
- e.Handled = true;
- goto Label_0221;
- case Keys.Divide:
- this.NextFormula(-1);
- e.Handled = true;
- goto Label_0221;
- case Keys.F7:
- case Keys.F8:
- this.NextCycle(1 - ((e.KeyCode == Keys.F8) ? 0 : 2));
- e.Handled = true;
- goto Label_0221;
- }
- }
- return;
- Label_0221:
- if (e.Handled)
- {
- this.ChangeCursorPos();
- }
- if ((cursorPos != this.chart.CursorPos) && (start != this.chart.Start))
- {
- this.NeedRedraw();
- }
- if (this.needRedraw)
- {
- if (start != this.chart.Start)
- {
- this.MoveChartXBars(3, 1, start - this.chart.Start);
- }
- this.needDrawCursor = true;
- }
- else
- {
- this.DrawCursorByPos(this.ControlGraphics);
- }
- }
- private void ChartWinControl_MouseDown(object sender, MouseEventArgs e)
- {
- this.MouseDownInfo = this.chart.GetHitInfo((float)e.X, (float)e.Y);
- if (this.MouseDownInfo.Area != null)
- {
- this.chart.SelectedArea = this.MouseDownInfo.Area;
- if ((this.selectFormulaMouseMode == MouseAction.MouseDown) && !this.Designing)
- {
- this.chart.SetSelectedData(this.MouseDownInfo);
- }
- if (((e.Button != MouseButtons.Right) && (this.CrossCursorMouseMode == MouseAction.MouseDown)) && !this.Designing)
- {
- this.MouseCrossCursor(this.ControlGraphics, this.MouseDownInfo);
- }
- this.NeedRedraw();
- }
- if ((e.Button == MouseButtons.Right) && !this.Designing)
- {
- if (this.MouseZoomBmp != null)
- {
- this.CancelMouseZoom();
- }
- else if (base.Visible)
- {
- ContextMenu cmRight = this.cmRight;
- if (!this.nativeContextMenu)
- {
- cmRight = this.ContextMenu;
- }
- if (cmRight != null)
- {
- cmRight.Show(this, new Point(e.X, e.Y));
- }
- }
- }
- else if (!this.Designing)
- {
- this.DragInfo = new ChartDragInfo(this.chart, this.MouseDownInfo);
- if (((this.MouseDownInfo.HitType == FormulaHitType.htArea) && (this.mouseZoomMode != IndexFormula.Finance.Win.MouseZoomMode.None)) && !this.FixedTime)
- {
- this.LastX = e.X;
- this.LastY = e.Y;
- this.MemBmp = this.GetBitmap(false, true);
- this.MouseZoomBmp = new Bitmap(this.MemBmp.Width, this.MemBmp.Height, PixelFormat.Format32bppPArgb);
- this.MouseZoomBmpG = Graphics.FromImage(this.MouseZoomBmp);
- this.HideCursor();
- }
- }
- }
- private void ChartWinControl_MouseLeave(object sender, EventArgs e)
- {
- if ((this.chart != null) && (this.CrossCursorMouseMode == MouseAction.MouseMove))
- {
- this.HideCursor();
- }
- }
- private void ChartWinControl_MouseMove(object sender, MouseEventArgs e)
- {
- try
- {
- if (this.Designing)
- {
- return;
- }
- int totalPart = 3 - ((this.ChartDragMode == IndexFormula.Finance.ChartDragMode.Chart) ? 1 : 0);
- if ((this.LastX == e.X) && (this.LastY == e.Y))
- {
- return;
- }
- FormulaHitInfo hitInfo = this.chart.GetHitInfo((float)e.X, (float)e.Y);
- if (this.DragInfo != null)
- {
- float deltaY = this.DragInfo.HitInfo.Y - hitInfo.Y;
- float deltaX = this.DragInfo.HitInfo.X - hitInfo.X;
- FormulaArea fa = this.DragInfo.HitInfo.Area;
- if (this.MouseZoomBmp != null)
- {
- RectangleF fixedZoomRect;
- RectangleF ef2;
- if (this.FixedZoomRect != Rectangle.Empty)
- {
- fixedZoomRect = this.FixedZoomRect;
- fixedZoomRect.Offset((float)e.X, (float)e.Y);
- ef2 = this.FixedZoomRect;
- ef2.Offset((float)this.LastX, (float)this.LastY);
- }
- else
- {
- fixedZoomRect = this.GetRect(this.DragInfo.HitInfo.X, this.DragInfo.HitInfo.Y, (float)e.X, (float)e.Y);
- ef2 = this.GetRect(this.DragInfo.HitInfo.X, this.DragInfo.HitInfo.Y, (float)this.LastX, (float)this.LastY);
- }
- this.MouseZoomRect = RectangleF.Union(fixedZoomRect, ef2);
- this.MouseZoomBmpG.DrawImage(this.MemBmp, this.MouseZoomRect, this.MouseZoomRect, GraphicsUnit.Pixel);
- Rectangle rect = Rectangle.Truncate(fixedZoomRect);
- rect.Width--;
- rect.Height--;
- this.MouseZoomBmpG.DrawRectangle(Pens.Black, rect);
- if (this.mouseZoomBackColor.A != 0)
- {
- this.MouseZoomBmpG.FillRectangle(new SolidBrush(this.mouseZoomBackColor), rect);
- }
- this.ControlGraphics.DrawImage(this.MouseZoomBmp, this.MouseZoomRect, this.MouseZoomRect, GraphicsUnit.Pixel);
- }
- else if (this.EnableResize && (this.DragInfo.HitInfo.HitType == FormulaHitType.htSize))
- {
- for (int i = 0; i < this.chart.Areas.Count; i++)
- {
- this.chart.Areas[i].HeightPercent = this.DragInfo.AreaHeight[i];
- }
- int index = this.chart.Areas.IndexOf(fa);
- if (index < (this.chart.Areas.Count - 1))
- {
- FormulaArea area2 = this.chart.Areas[index + 1];
- double num6 = this.DragInfo.AreaHeight[index] - deltaY;
- double num7 = this.DragInfo.AreaHeight[index + 1] + deltaY;
- if (num6 < 40.0)
- {
- num7 -= 40.0 - num6;
- num6 = 40.0;
- }
- if (num7 < 40.0)
- {
- num6 -= 40.0 - num7;
- num7 = 40.0;
- }
- fa.HeightPercent = num6;
- area2.HeightPercent = num7;
- this.NeedRedraw(fa);
- this.NeedRedraw(area2);
- }
- this.areaPercent = this.chart.GetAreaPercent();
- }
- else if (this.ChartDragMode != IndexFormula.Finance.ChartDragMode.None)
- {
- if ((this.EnableXScale && !this.chart.FixedTime) && (this.DragInfo.HitInfo.HitType == FormulaHitType.htAxisX))
- {
- this.MoveChartX(fa, totalPart, this.DragInfo.HitInfo.XPart(totalPart), deltaX);
- }
- else if (this.EnableYScale && (this.DragInfo.HitInfo.HitType == FormulaHitType.htAxisY))
- {
- this.MoveChartY(fa, totalPart, this.DragInfo.HitInfo.YPart(totalPart), deltaY);
- }
- else if ((this.ChartDragMode == IndexFormula.Finance.ChartDragMode.Chart) && (this.DragInfo.HitInfo.HitType == FormulaHitType.htArea))
- {
- if (!this.chart.FixedTime)
- {
- this.MoveChartX(fa, 3, 1, deltaX);
- }
- this.MoveChartY(fa, 3, 1, deltaY);
- }
- }
- }
- else
- {
- if (this.CrossCursorMouseMode == MouseAction.MouseMove)
- {
- this.MouseCrossCursor(this.ControlGraphics, hitInfo);
- }
- if ((this.selectFormulaMouseMode == MouseAction.MouseMove) && !object.Equals(this.chart.GetSelectedData(), hitInfo.Data))
- {
- this.chart.SetSelectedData(hitInfo);
- this.NeedRedraw();
- }
- if (hitInfo.Area != null)
- {
- switch (hitInfo.HitType)
- {
- case FormulaHitType.htSize:
- if (this.EnableResize)
- {
- this.Cursor = Cursors.HSplit;
- }
- goto Label_05D3;
- case FormulaHitType.htAxisX:
- {
- if ((!this.EnableXScale || this.chart.FixedTime) || (this.ChartDragMode == IndexFormula.Finance.ChartDragMode.None))
- {
- goto Label_0518;
- }
- int num8 = hitInfo.XPart(totalPart);
- if ((num8 != 0) && (num8 != (totalPart - 1)))
- {
- break;
- }
- this.Cursor = Cursors.SizeWE;
- goto Label_05D3;
- }
- case FormulaHitType.htAxisY:
- {
- if (!this.EnableYScale || (this.ChartDragMode == IndexFormula.Finance.ChartDragMode.None))
- {
- goto Label_0568;
- }
- int num9 = hitInfo.YPart(totalPart);
- if ((num9 != 0) && (num9 != (totalPart - 1)))
- {
- goto Label_055B;
- }
- this.Cursor = Cursors.SizeNS;
- goto Label_05D3;
- }
- case FormulaHitType.htArea:
- if (this.selectFormulaMouseMode == MouseAction.None)
- {
- goto Label_05B7;
- }
- if (hitInfo.Formula == null)
- {
- goto Label_05A9;
- }
- this.Cursor = Cursors.Hand;
- goto Label_05D3;
- default:
- this.Cursor = this.DefaultCursor;
- goto Label_05D3;
- }
- this.Cursor = Cursors.Hand;
- }
- }
- goto Label_05D3;
- Label_0518:
- this.Cursor = this.DefaultCursor;
- goto Label_05D3;
- Label_055B:
- this.Cursor = Cursors.Hand;
- goto Label_05D3;
- Label_0568:
- this.Cursor = this.DefaultCursor;
- goto Label_05D3;
- Label_05A9:
- this.Cursor = this.DefaultCursor;
- goto Label_05D3;
- Label_05B7:
- this.Cursor = this.DefaultCursor;
- Label_05D3:
- this.LastX = e.X;
- this.LastY = e.Y;
- if (this.AfterMouseMove != null)
- {
- this.AfterMouseMove(this, e, hitInfo);
- }
- }
- catch
- {
- }
- }
- private void ChartWinControl_MouseUp(object sender, MouseEventArgs e)
- {
- if (this.DragInfo != null)
- {
- this.DragInfo = null;
- base.Invalidate();
- }
- if (this.MouseZoomBmp != null)
- {
- if (((e.Button == MouseButtons.Left) && !this.MouseZoomRect.IsEmpty) && (this.MouseZoomRect.Width > 100f))
- {
- FormulaHitInfo hitInfo = this.chart.GetHitInfo(this.MouseZoomRect.X, this.MouseZoomRect.Y);
- FormulaHitInfo info2 = this.chart.GetHitInfo(this.MouseZoomRect.Right, this.MouseZoomRect.Bottom);
- int cursorPos = hitInfo.CursorPos;
- int num2 = info2.CursorPos;
- if (this.chart.DataProvider != null)
- {
- double[] numArray = this.chart.DataProvider["DATE"];
- if (cursorPos < numArray.Length)
- {
- this.StartTime = this.chart.IndexToDate(hitInfo.CursorPos);
- this.EndTime = this.chart.IndexToDate(info2.CursorPos);
- }
- }
- }
- this.MouseZoomBmp = null;
- this.MouseZoomRect = Rectangle.Empty;
- }
- }
- private void ChartWinControl_MouseWheel(object sender, MouseEventArgs e)
- {
- if (((this.mouseWheelMode != IndexFormula.Finance.Win.MouseWheelMode.None) && (this.chart != null)) && !this.FixedTime)
- {
- int moveBars = Math.Sign(e.Delta) * (((Control.ModifierKeys & Keys.Alt) != Keys.None) ? 1 : 12);
- if (this.mouseWheelMode == IndexFormula.Finance.Win.MouseWheelMode.Scroll)
- {
- this.MoveChartXBars(3, 1, moveBars);
- }
- else
- {
- this.ScaleChart(((double)moveBars) / 100.0);
- }
- this.needResetCursorPos = true;
- this.needDrawCursor = false;
- this.LastHitInfo = this.chart.GetHitInfo((float)e.X, (float)e.Y);
- }
- }
- private void ChartWinControl_Paint(object sender, PaintEventArgs e)
- {
- if (this.chart != null)
- {
- this.StatisticWindow.Visible = this.showStatistic && this.StatisticWindow.HasData();
- if (this.needSetDefaultFormulas)
- {
- this.DefaultFormulasToAreas();
- this.needSetDefaultFormulas = false;
- }
- if (this.needRefresh)
- {
- this.RecreateFormula();
- }
- bool flag = true;
- if (this.needRebind)
- {
- flag = this.BindData();
- }
- if (this.needRedraw && flag)
- {
- if (this.chart.FixedTime && (this.CurrentDataManager != null))
- {
- this.chart.StartTime = this.startTime;
- this.chart.EndTime = this.endTime;
- }
- else if (this.chart.DataProvider != null)
- {
- double[] numArray = this.chart.DataProvider["DATE"];
- if (this.endTime == DateTime.MinValue)
- {
- if (numArray.Length > 0)
- {
- this.chart.EndTime = DateTime.FromOADate(numArray[numArray.Length - 1]);
- this.chart.StartTime = DateTime.FromOADate(numArray[Math.Max(0, numArray.Length - this.stockBars)]);
- this.EndTime = this.chart.EndTime;
- this.StartTime = this.chart.StartTime;
- }
- }
- else
- {
- int num2;
- int num = this.chart.DateToIndex(this.endTime);
- if (this.afterBars < 1.0)
- {
- num2 = (int)((numArray.Length - 1) * (1.0 + this.afterBars));
- }
- else
- {
- num2 = (numArray.Length - 1) + ((int)this.afterBars);
- }
- if (num > num2)
- {
- this.endTime = this.chart.IndexToDate(num2);
- }
- this.chart.StartTime = this.startTime;
- this.chart.EndTime = this.endTime;
- }
- }
- FormulaArea mainArea = this.chart.MainArea;
- if (mainArea != null)
- {
- if (this.minPrice > 0.0)
- {
- mainArea.AxisY.MinY = this.minPrice;
- mainArea.AxisY.MaxY = this.maxPrice;
- mainArea.AxisY.AutoScale = false;
- }
- if (this.stockRenderType != IndexFormula.Finance.StockRenderType.Default)
- {
- mainArea.StockRenderType = this.stockRenderType;
- }
- if (this.HasData() && (this.scaleType != IndexFormula.Finance.ScaleType.Default))
- {
- mainArea.AxisY.Scale = this.scaleType;
- }
- }
- this.chart.ValueTextMode = this.valueTextMode;
- if (this.stickRenderType != IndexFormula.Finance.StickRenderType.Default)
- {
- this.chart.StickRenderType = this.stickRenderType;
- }
- this.chart.LatestValueType = this.latestValueType;
- this.chart.ShowCursorLabel = this.showCursorLabel;
- if (this.showVerticalGrid != ShowLineMode.Default)
- {
- if (this.showVerticalGrid == ShowLineMode.HidePrice)
- {
- mainArea.AxisY.MajorTick.ShowLine = false;
- }
- else
- {
- foreach (FormulaArea area2 in this.chart.Areas)
- {
- area2.AxisY.MajorTick.ShowLine = this.showVerticalGrid == ShowLineMode.Show;
- }
- }
- }
- if (this.showHorizontalGrid != ShowLineMode.Default)
- {
- if (this.showHorizontalGrid == ShowLineMode.HidePrice)
- {
- mainArea.AxisX.MajorTick.ShowLine = false;
- }
- else
- {
- foreach (FormulaArea area3 in this.chart.Areas)
- {
- area3.AxisX.MajorTick.ShowLine = this.showHorizontalGrid == ShowLineMode.Show;
- }
- }
- }
- this.chart.NeedRedraw = true;
- this.chart.ExtraNeedRedraw = true;
- }
- if (this.needResetCursorPos)
- {
- this.SetCursorPos();
- this.ChangeCursorPos();
- this.needResetCursorPos = false;
- }
- this.RenderChart(e.Graphics);
- this.needRedraw = false;
- this.needRebind = false;
- this.needRefresh = false;
- }
- }
- private void ChartWinControl_SizeChanged(object sender, EventArgs e)
- {
- this.ControlGraphics = base.CreateGraphics();
- if (this.chart != null)
- {
- Rectangle clientRectangle = base.ClientRectangle;
- this.chart.Rect = clientRectangle;
- }
- else
- {
- this.ControlGraphics.Clear(this.BackColor);
- }
- this.NeedRedraw();
- }
- public void CloseArea(FormulaArea fa)
- {
- int index = this.chart.Areas.IndexOf(fa);
- if ((index >= 0) && (this.chart.Areas.Count > 1))
- {
- this.chart.Areas.RemoveAt(index);
- this.areaPercent = this.chart.GetAreaPercent();
- this.SaveChartProperties();
- this.NeedRebind();
- }
- }
- private void cmRight_Popup(object sender, EventArgs e)
- {
- this.miStatisticWindow.Checked = this.ShowStatistic;
- this.miAdjust.Checked = this.AdjustData;
- FormulaArea selectedArea = this.chart.SelectedArea;
- if (selectedArea != null)
- {
- this.miFavorite.Enabled = !selectedArea.IsMain();
- if (selectedArea.Formulas.Count > 0)
- {
- foreach (MenuItem item in this.miFavorite.MenuItems)
- {
- item.Checked = string.Compare(item.Text, selectedArea.Formulas[0].Name, true) == 0;
- }
- }
- }
- }
- public void CopyAreaToClipboard(string Separatar)
- {
- Clipboard.SetDataObject(this.chart.GetAreaTextData(Separatar, true));
- }
- public void CopyToClipboard(string Separatar)
- {
- Clipboard.SetDataObject(this.chart.GetChartTextData(Separatar, true));
- }
- private void CreateCycleMenu()
- {
- if (this.favoriteCycles != null)
- {
- this.miCycle.MenuItems.Clear();
- foreach (string str in this.favoriteCycles.Split(new char[] { ';' }))
- {
- this.miCycle.MenuItems.Add(str, new EventHandler(this.miCycle_SelectedIndexChanged));
- }
- }
- }
- private void DefaultFormulasToAreas()
- {
- if (this.defaultFormulas != null)
- {
- this.chart.Areas.Clear();
- this.chart.StringsToArea(this.defaultFormulas.Split(new char[] { ';' }));
- }
- }
- private static string DefaultSelectFormula(string Default, string[] FilterPrefixes, bool SelectLine)
- {
- return new SelectFormula().Select(Default, FilterPrefixes, SelectLine);
- }
- private static string DefaultSelectMethod(string Default)
- {
- return new SelectMethod().Select(Default);
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing && (this.components != null))
- {
- this.components.Dispose();
- }
- base.Dispose(disposing);
- }
- public static string DoSelectFormula(string Default, string[] FilterPrefixes, bool SelectLine)
- {
- if (OnSelectFormula != null)
- {
- return OnSelectFormula(Default, FilterPrefixes, SelectLine);
- }
- return Default;
- }
- public static string DoSelectSymbol(string Default)
- {
- if (OnSelectSymbol != null)
- {
- return OnSelectSymbol(Default);
- }
- return Default;
- }
- private void DrawCursor(Graphics g)
- {
- this.chart.DrawCursor(g, this.LastHitInfo.X, this.LastHitInfo.Y, false);
- }
- private void DrawCursorByPos(Graphics g)
- {
- this.DrawCursorByPos(g, float.NaN);
- }
- private void DrawCursorByPos(Graphics g, float DefaultY)
- {
- float num;
- float num2;
- this.chart.GetXYFromPos(out num, out num2);
- this.LastHitInfo = this.chart.GetHitInfo(num, num2);
- if (!float.IsNaN(DefaultY))
- {
- this.LastHitInfo.Y = DefaultY;
- }
- if ((this.LastHitInfo.HitType == FormulaHitType.htArea) && (g != null))
- {
- this.DrawCursor(g);
- }
- else
- {
- this.LastHitInfo.X = -1f;
- }
- }
- public void DrawCursorByTime(DateTime t)
- {
- int num = this.chart.DateToIndex(t.ToOADate());
- if (num != this.chart.CursorPos)
- {
- this.chart.CursorPos = num;
- this.DrawCursorByPos(this.ControlGraphics, -1f);
- this.ChangeCursorPos();
- }
- }
- public void EditFormula()
- {
- FormulaArea selectedArea = this.chart.SelectedArea;
- if ((selectedArea != null) && (selectedArea.Formulas.Count > 0))
- {
- FormulaBase fb = null;
- if (selectedArea.SelectedFormula != null)
- {
- fb = selectedArea.SelectedFormula;
- }
- else
- {
- fb = selectedArea.Formulas[0];
- }
- if (EditFormula(fb))
- {
- return;
- }
- }
- MessageBox.Show("Can't edit the source code of this formula");
- }
- public void EditFormula(FormulaArea fa)
- {
- if (fa != null)
- {
- FormulaManager manager = new FormulaManager();
- if (manager.ShowForm(fa, fa.SelectedFormula) == DialogResult.OK)
- {
- this.SetAreaByName(fa, manager.CurrentFormulas);
- }
- }
- else
- {
- this.EditOverlay();
- }
- }
- public static bool EditFormula(FormulaBase fb)
- {
- string formulaFile = PluginManager.GetFormulaFile(fb);
- if (formulaFile != null)
- {
- string directoryName = Path.GetDirectoryName(formulaFile);
- formulaFile = Path.GetFileNameWithoutExtension(formulaFile).Replace('_', '.');
- formulaFile = directoryName + @"\" + formulaFile;
- if (File.Exists(formulaFile))
- {
- OpenFormulaSourceEditor(formulaFile, fb.GetType().ToString());
- return true;
- }
- }
- return false;
- }
- public void EditOverlay()
- {
- }
- private void ExpandDefaultFormulas(int Count)
- {
- double percent = this.chart.Areas[0].HeightPercent / 3.0;
- if (percent < 1.0)
- {
- percent = 1.0;
- }
- while (Count > this.chart.Areas.Count)
- {
- this.chart.AddArea("VOLMA", percent);
- }
- }
- public MenuItem GetAreaMenu(int Count)
- {
- this.miIndicator.MenuItems.Clear();
- for (int i = 0; i < Count; i++)
- {
- this.miIndicator.MenuItems.Add(new MenuItem(string.Concat(new object[] { "&", i + 1, " area", (i > 0) ? "s" : "" }), new EventHandler(this.miIndicator_SelectedIndexChanged), (Shortcut)(0x40031 + i)));
- }
- return this.miIndicator;
- }
- public MenuItem GetAxisMenu()
- {
- return this.miAxisType;
- }
- public Bitmap GetBitmap(bool ShowStatistic, bool ShowExtra)
- {
- this.chart.ExtraNeedRedraw = ShowExtra;
- Bitmap memBitmap = this.chart.GetMemBitmap();
- Bitmap image = new Bitmap(memBitmap);
- Graphics g = Graphics.FromImage(image);
- g.DrawImage(memBitmap, 0, 0);
- g.DrawLine(Pens.Black, 0, 0, image.Width, 0);
- if (ShowStatistic)
- {
- this.StatisticWindow.PaintTo(g);
- }
- return image;
- }
- public MenuItem GetChartMenu()
- {
- return this.GetChartMenu(true, true, true, true);
- }
- public MenuItem GetChartMenu(bool Skin, bool Cycle, bool Area, bool Axis)
- {
- this.miChart.MenuItems.Clear();
- if (Skin)
- {
- this.miChart.MenuItems.Add(this.GetSkinMenu());
- }
- if (Cycle)
- {
- this.miChart.MenuItems.Add(this.miCycle);
- }
- if (Area)
- {
- this.miChart.MenuItems.Add(this.GetAreaMenu(9));
- }
- if (Axis)
- {
- this.miChart.MenuItems.Add(this.GetAxisMenu());
- }
- return this.miChart;
- }
- public DateTime GetCurrentTime()
- {
- return this.chart.IndexToDate();
- }
- public MenuItem GetEditMenu()
- {
- return this.miChartEdit;
- }
- private RectangleF GetRect(float x1, float y1, float x2, float y2)
- {
- return new RectangleF(Math.Min(x1, x2), Math.Min(y1, y2), Math.Abs((float)(x2 - x1)), Math.Abs((float)(y2 - y1)));
- }
- public MenuItem GetSkinMenu()
- {
- string[] buildInSkins = FormulaSkin.GetBuildInSkins();
- this.miSkin.MenuItems.Clear();
- foreach (string str in buildInSkins)
- {
- this.miSkin.MenuItems.Add(str, new EventHandler(this.mmSkin_SelectedIndexChanged));
- }
- return this.miSkin;
- }
- public MenuItem GetViewMenu()
- {
- return this.miView;
- }
- public void HandleKeyEvent(object sender, KeyEventArgs e)
- {
- if (base.ContainsFocus)
- {
- this.OnKeyDown(e);
- }
- }
- private bool HasData()
- {
- return ((this.chart != null) && (this.chart.DataProvider != null));
- }
- private void HideCursor()
- {
- this.chart.HideCursor(this.ControlGraphics);
- }
- private void InitializeComponent()
- {
- this.cmRight = new ContextMenu();
- this.miAddFormula = new MenuItem();
- this.miCloseFormula = new MenuItem();
- this.miFormulaManager = new MenuItem();
- this.miEdit = new MenuItem();
- this.miFavorite = new MenuItem();
- this.miSp4 = new MenuItem();
- this.miStatisticWindow = new MenuItem();
- this.miAdjust = new MenuItem();
- this.miSp2 = new MenuItem();
- this.miCopy = new MenuItem();
- this.cmMain = new ContextMenu();
- this.miChart = new MenuItem();
- this.miSkin = new MenuItem();
- this.miCycle = new MenuItem();
- this.miIndicator = new MenuItem();
- this.miAxisType = new MenuItem();
- this.miNormal = new MenuItem();
- this.miLog = new MenuItem();
- this.miView = new MenuItem();
- this.miCrossCursor = new MenuItem();
- this.miStatistic = new MenuItem();
- this.miSp1 = new MenuItem();
- this.miCalculator = new MenuItem();
- this.miChartEdit = new MenuItem();
- this.miChartCopy = new MenuItem();
- this.StatisticWindow = new StatisticControl();
- base.SuspendLayout();
- this.cmRight.MenuItems.AddRange(new MenuItem[] { this.miAddFormula, this.miCloseFormula, this.miFormulaManager, this.miEdit, this.miFavorite, this.miSp4, this.miStatisticWindow, this.miAdjust, this.miSp2, this.miCopy });
- this.cmRight.Popup += new EventHandler(this.cmRight_Popup);
- this.miAddFormula.Index = 0;
- this.miAddFormula.Text = "&Add New Formula Area";
- this.miAddFormula.Click += new EventHandler(this.miAddFormula_Click);
- this.miCloseFormula.Index = 1;
- this.miCloseFormula.MergeOrder = 10;
- this.miCloseFormula.Text = "Close Selected Formula";
- this.miCloseFormula.Click += new EventHandler(this.miCloseFormula_Click);
- this.miFormulaManager.Index = 2;
- this.miFormulaManager.MergeOrder = 20;
- this.miFormulaManager.Text = "E&dit Formula";
- this.miFormulaManager.Click += new EventHandler(this.miFormulaEditor_Click);
- this.miEdit.Index = 3;
- this.miEdit.MergeOrder = 30;
- this.miEdit.Shortcut = Shortcut.CtrlE;
- this.miEdit.Text = "&Edit Formula Source Code";
- this.miEdit.Click += new EventHandler(this.miEdit_Click);
- this.miFavorite.Index = 4;
- this.miFavorite.MergeOrder = 40;
- this.miFavorite.Text = "&Favorite Indicators";
- this.miSp4.Index = 5;
- this.miSp4.MergeOrder = 50;
- this.miSp4.Text = "-";
- this.miStatisticWindow.Index = 6;
- this.miStatisticWindow.MergeOrder = 80;
- this.miStatisticWindow.Text = "Show &statistic window";
- this.miStatisticWindow.Click += new EventHandler(this.miStatisticWindow_Click);
- this.miAdjust.Index = 7;
- this.miAdjust.MergeOrder = 90;
- this.miAdjust.Text = "&Adjust Data";
- this.miAdjust.Click += new EventHandler(this.miAdjust_Click);
- this.miSp2.Index = 8;
- this.miSp2.MergeOrder = 100;
- this.miSp2.Text = "-";
- this.miCopy.Index = 9;
- this.miCopy.MergeOrder = 110;
- this.miCopy.Shortcut = Shortcut.CtrlC;
- this.miCopy.Text = "&Copy";
- this.miCopy.Click += new EventHandler(this.miCopy_Click);
- this.cmMain.MenuItems.AddRange(new MenuItem[] { this.miChart, this.miView, this.miChartEdit });
- this.miChart.Index = 0;
- this.miChart.MenuItems.AddRange(new MenuItem[] { this.miSkin, this.miCycle, this.miIndicator, this.miAxisType });
- this.miChart.Text = "&Chart";
- this.miSkin.Index = 0;
- this.miSkin.Text = "&Skin";
- this.miCycle.Index = 1;
- this.miCycle.Text = "&Cycle";
- this.miCycle.Click += new EventHandler(this.miCycle_Popup);
- this.miIndicator.Index = 2;
- this.miIndicator.Text = "&Indicator Areas";
- this.miAxisType.Index = 3;
- this.miAxisType.MenuItems.AddRange(new MenuItem[] { this.miNormal, this.miLog });
- this.miAxisType.Text = "&Axis Type";
- this.miNormal.Index = 0;
- this.miNormal.RadioCheck = true;
- this.miNormal.Shortcut = Shortcut.CtrlN;
- this.miNormal.Text = "Normal";
- this.miNormal.Click += new EventHandler(this.miNormalAxis_Click);
- this.miLog.Index = 1;
- this.miLog.MergeOrder = 1;
- this.miLog.RadioCheck = true;
- this.miLog.Shortcut = Shortcut.CtrlL;
- this.miLog.Text = "Logarithm";
- this.miLog.Click += new EventHandler(this.miNormalAxis_Click);
- this.miView.Index = 1;
- this.miView.MenuItems.AddRange(new MenuItem[] { this.miCrossCursor, this.miStatistic, this.miSp1, this.miCalculator });
- this.miView.Text = "&View";
- this.miView.Popup += new EventHandler(this.miView_Popup);
- this.miCrossCursor.Checked = true;
- this.miCrossCursor.Index = 0;
- this.miCrossCursor.Text = "Cross Cursor";
- this.miCrossCursor.Click += new EventHandler(this.miCrossCursor_Click);
- this.miStatistic.Index = 1;
- this.miStatistic.Text = "Statistic Window";
- this.miStatistic.Click += new EventHandler(this.miStatistic_Click);
- this.miSp1.Index = 2;
- this.miSp1.Text = "-";
- this.miCalculator.Index = 3;
- this.miCalculator.Shortcut = Shortcut.CtrlJ;
- this.miCalculator.Text = "&Calculator";
- this.miCalculator.Click += new EventHandler(this.miCalculator_Click);
- this.miChartEdit.Index = 2;
- this.miChartEdit.MenuItems.AddRange(new MenuItem[] { this.miChartCopy });
- this.miChartEdit.Text = "&Edit";
- this.miChartCopy.Index = 0;
- this.miChartCopy.Text = "&Copy";
- this.miChartCopy.Click += new EventHandler(this.miChartCopy_Click);
- this.StatisticWindow.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
- this.StatisticWindow.BackColor = SystemColors.Info;
- this.StatisticWindow.Cursor = Cursors.Arrow;
- this.StatisticWindow.ForeColor = Color.Black;
- this.StatisticWindow.Location = new Point(-1000, 0x38);
- this.StatisticWindow.Name = "StatisticWindow";
- this.StatisticWindow.Size = new Size(0xc0, 0x128);
- this.StatisticWindow.TabIndex = 0;
- this.StatisticWindow.Visible = false;
- base.CausesValidation = false;
- base.Controls.Add(this.StatisticWindow);
- base.Name = "ChartWinControl";
- base.Size = new Size(0x248, 0x1c0);
- base.SizeChanged += new EventHandler(this.ChartWinControl_SizeChanged);
- base.Enter += new EventHandler(this.ChartWinControl_Enter);
- base.MouseUp += new MouseEventHandler(this.ChartWinControl_MouseUp);
- base.Paint += new PaintEventHandler(this.ChartWinControl_Paint);
- base.KeyDown += new KeyEventHandler(this.ChartWinControl_KeyDown);
- base.DoubleClick += new EventHandler(this.ChartWinControl_DoubleClick);
- base.MouseMove += new MouseEventHandler(this.ChartWinControl_MouseMove);
- base.MouseLeave += new EventHandler(this.ChartWinControl_MouseLeave);
- base.MouseDown += new MouseEventHandler(this.ChartWinControl_MouseDown);
- base.ResumeLayout(false);
- }
- public void InsertNewFormula()
- {
- this.InsertNewFormula("");
- }
- public void InsertNewFormula(string Default)
- {
- FormulaArea fa = new FormulaArea(this.chart);
- FormulaManager manager = new FormulaManager();
- manager.CurrentFormulas = Default;
- if (manager.ShowForm() == DialogResult.OK)
- {
- fa.HeightPercent = this.chart[0].HeightPercent / 3.0;
- this.chart.Areas.Add(fa);
- this.SetAreaByName(fa, manager.CurrentFormulas);
- this.NeedRebind();
- }
- }
- private void InvalidateHitInfo(FormulaHitInfo fhi)
- {
- Region region = new Region(new RectangleF(fhi.X - 1f, 0f, 2f, (float)this.chart.Rect.Height));
- region.Union(new RectangleF(0f, fhi.Y - 1f, (float)this.chart.Rect.Width, 2f));
- foreach (FormulaArea area in this.chart.Areas)
- {
- RectangleF lastCursorRect = area.AxisX.LastCursorRect;
- region.Union(new RectangleF(fhi.X - lastCursorRect.Width, lastCursorRect.Y, lastCursorRect.Width * 2f, lastCursorRect.Height));
- region.Union(new RectangleF((float)area.Rect.X, (float)area.Rect.Y, (float)area.Rect.Width, 20f));
- foreach (FormulaAxisY sy in area.AxisYs)
- {
- lastCursorRect = sy.LastCursorRect;
- if (!lastCursorRect.IsEmpty)
- {
- region.Union(new RectangleF(lastCursorRect.X, fhi.Y, lastCursorRect.Width, lastCursorRect.Height));
- }
- }
- }
- base.Invalidate(region);
- }
- public void MergeRightMenu(ContextMenu cm)
- {
- this.cmRight.MergeMenu(cm);
- }
- private void miAddFormula_Click(object sender, EventArgs e)
- {
- this.InsertNewFormula();
- }
- private void miAdjust_Click(object sender, EventArgs e)
- {
- this.AdjustData = !this.AdjustData;
- }
- private void miCalculator_Click(object sender, EventArgs e)
- {
- Process.Start("Calc.exe");
- }
- private void miChartCopy_Click(object sender, EventArgs e)
- {
- this.CopyToClipboard(",");
- }
- private void miCloseFormula_Click(object sender, EventArgs e)
- {
- this.CloseArea(this.chart.SelectedArea);
- }
- private void miCopy_Click(object sender, EventArgs e)
- {
- this.CopyAreaToClipboard(",");
- }
- private void miCrossCursor_Click(object sender, EventArgs e)
- {
- this.ShowCrossCursor = !this.ShowCrossCursor;
- }
- private void miCycle_Popup(object sender, EventArgs e)
- {
- foreach (MenuItem item in this.miCycle.MenuItems)
- {
- item.Checked = item.Text == this.currentDataCycle.ToString();
- }
- }
- private void miCycle_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.EndTime = DateTime.MinValue;
- this.CurrentDataCycle = DataCycle.Parse((sender as MenuItem).Text);
- }
- private void miEdit_Click(object sender, EventArgs e)
- {
- this.EditFormula();
- }
- private void miFormulaEditor_Click(object sender, EventArgs e)
- {
- this.EditFormula(this.chart.SelectedArea);
- }
- private void miIndicator_SelectedIndexChanged(object sender, EventArgs e)
- {
- this.AreaCount = (sender as MenuItem).Index + 1;
- }
- private void miNormalAxis_Click(object sender, EventArgs e)
- {
- foreach (MenuItem item in this.miAxisType.MenuItems)
- {
- item.Checked = false;
- }
- MenuItem item2 = sender as MenuItem;
- item2.Checked = true;
- this.ScaleType = (IndexFormula.Finance.ScaleType)item2.MergeOrder;
- }
- private void miOverlay_Click(object sender, EventArgs e)
- {
- this.EditOverlay();
- }
- private void miStatistic_Click(object sender, EventArgs e)
- {
- this.ShowStatistic = !this.ShowStatistic;
- }
- private void miStatisticWindow_Click(object sender, EventArgs e)
- {
- this.ShowStatistic = !this.ShowStatistic;
- }
- private void miView_Popup(object sender, EventArgs e)
- {
- this.miStatistic.Checked = this.ShowStatistic;
- }
- private void mmFavorite_SelectedIndexChanged(object sender, EventArgs e)
- {
- FormulaArea selectedArea = this.chart.SelectedArea;
- if ((selectedArea != null) && !selectedArea.IsMain())
- {
- this.SetAreaByName(selectedArea, (sender as MenuItem).Text);
- }
- }
- private void mmSkin_SelectedIndexChanged(object sender, EventArgs e)
- {
- foreach (MenuItem item in this.miSkin.MenuItems)
- {
- item.Checked = false;
- }
- MenuItem item2 = (MenuItem)sender;
- item2.Checked = true;
- string text = item2.Text;
- this.Skin = text;
- }
- private void MouseCrossCursor(Graphics g, FormulaHitInfo HitInfo)
- {
- if (!this.Designing)
- {
- if (HitInfo.HitType == FormulaHitType.htArea)
- {
- this.chart.CursorPos = HitInfo.CursorPos;
- if (this.memoryCrossCursor)
- {
- this.InvalidateHitInfo(this.LastHitInfo);
- this.InvalidateHitInfo(HitInfo);
- }
- else
- {
- this.chart.DrawCursor(g, HitInfo.X, HitInfo.Y, false);
- }
- this.ChangeCursorPos();
- this.LastHitInfo = HitInfo;
- }
- else
- {
- this.HideCursor();
- this.LastHitInfo.X = 0f;
- }
- }
- }
- public void MoveArea(FormulaArea fa, int NewIndex)
- {
- int index = this.chart.Areas.IndexOf(fa);
- if (index >= 0)
- {
- if (NewIndex > index)
- {
- NewIndex--;
- }
- if (NewIndex >= 0)
- {
- this.chart.Areas.RemoveAt(index);
- if (NewIndex > this.chart.Areas.Count)
- {
- NewIndex = this.chart.Areas.Count;
- }
- this.chart.Areas.Insert(NewIndex, fa);
- this.areaPercent = this.chart.GetAreaPercent();
- this.SaveChartProperties();
- this.NeedRebind();
- }
- }
- }
- public void MoveAreaDown(FormulaArea fa)
- {
- int index = this.chart.Areas.IndexOf(fa);
- this.MoveArea(fa, index + 2);
- }
- public void MoveAreaUp(FormulaArea fa)
- {
- int index = this.chart.Areas.IndexOf(fa);
- this.MoveArea(fa, index - 1);
- }
- private void MoveChartX(FormulaArea fa, int TotalPart, int CurrentPart, float DeltaX)
- {
- if (DeltaX != 0f)
- {
- if (this.EndTime == DateTime.MinValue)
- {
- this.EndTime = this.chart.EndTime;
- this.StartTime = this.chart.StartTime;
- }
- int num = this.chart.DateToIndex(this.chart.EndTime, -1);
- int num2 = this.chart.DateToIndex(this.chart.StartTime);
- double num3 = (num - num2) + 1;
- int moveBars = (int)((num3 * DeltaX) / ((double)fa.Rect.Width));
- this.MoveChartXBars(TotalPart, CurrentPart, this.DragInfo.StartTime, this.DragInfo.EndTime, moveBars);
- }
- }
- public void MoveChartXBars(int MoveBars)
- {
- this.MoveChartXBars(3, 1, MoveBars);
- }
- private void MoveChartXBars(int TotalPart, int CurrentPart, int MoveBars)
- {
- this.MoveChartXBars(TotalPart, CurrentPart, this.chart.StartTime, this.chart.EndTime, MoveBars);
- }
- private void MoveChartXBars(int TotalPart, int CurrentPart, DateTime StartTime, DateTime EndTime, int MoveBars)
- {
- if ((this.chart != null) && (this.chart.DataProvider != null))
- {
- double[] numArray = this.chart.DataProvider["DATE"];
- DateTime startTime = this.StartTime;
- DateTime endTime = this.EndTime;
- bool flag = false;
- if (CurrentPart > 0)
- {
- int i = this.chart.DateToIndex(EndTime, -1) + MoveBars;
- if (i < 0)
- {
- i = 0;
- flag = true;
- }
- if (this.chart.CursorPos > i)
- {
- this.chart.CursorPos = i;
- this.ChangeCursorPos();
- }
- this.EndTime = this.chart.IndexToDate(i);
- }
- if (CurrentPart < (TotalPart - 1))
- {
- int num2 = this.chart.DateToIndex(StartTime) + MoveBars;
- if (num2 >= (numArray.Length - 1))
- {
- num2 = numArray.Length - 2;
- flag = true;
- }
- if (num2 < 0)
- {
- num2 = 0;
- }
- if (this.chart.CursorPos < num2)
- {
- this.chart.CursorPos = num2;
- this.ChangeCursorPos();
- }
- this.StartTime = this.chart.IndexToDate(num2);
- }
- if (flag && (CurrentPart == 1))
- {
- this.StartTime = startTime;
- this.EndTime = endTime;
- }
- if (this.resetYAfterXChanged)
- {
- FormulaArea mainArea = this.chart.MainArea;
- if (mainArea != null)
- {
- this.minPrice = 0.0;
- mainArea.AxisY.AutoScale = true;
- }
- }
- if ((this.CurrentDataManager != null) && this.CurrentDataManager.VirtualFetch)
- {
- this.NeedRebind();
- }
- }
- }
- private void MoveChartY(FormulaArea fa, int Part, int CurrentPart, float DeltaY)
- {
- if (DeltaY != 0f)
- {
- FormulaAxisY axisY = this.DragInfo.HitInfo.AxisY;
- if (axisY == null)
- {
- axisY = fa.AxisY;
- }
- axisY.AutoScale = false;
- double num = ((this.DragInfo.AreaMaxY - this.DragInfo.AreaMinY) / ((double)fa.Rect.Height)) * DeltaY;
- if (CurrentPart > 0)
- {
- axisY.MinY = this.DragInfo.AreaMinY - num;
- }
- if (CurrentPart < (Part - 1))
- {
- axisY.MaxY = this.DragInfo.AreaMaxY - num;
- }
- this.minPrice = 0.0;
- this.maxPrice = 0.0;
- this.NeedRedraw(fa);
- }
- }
- public void NeedRebind()
- {
- this.NeedRebind(true);
- }
- public void NeedRebind(bool AutoScaleY)
- {
- this.NeedRebind(AutoScaleY, false);
- }
- private void NeedRebind(bool AutoScaleY, bool DrawLastBarOnly)
- {
- this.needAutoScaleY = AutoScaleY;
- this.needDrawLastBarOnly = DrawLastBarOnly;
- this.needRedraw = true;
- this.needRebind = true;
- base.Invalidate();
- }
- public void NeedRedraw()
- {
- this.NeedRedraw(null);
- }
- public void NeedRedraw(FormulaArea fa)
- {
- this.needRedraw = true;
- if (fa != null)
- {
- Rectangle rect = fa.Rect;
- rect.Inflate(1, 1);
- base.Invalidate(rect);
- }
- else
- {
- base.Invalidate();
- }
- }
- public void NeedRefresh()
- {
- this.needRedraw = true;
- this.needRebind = true;
- this.needRefresh = true;
- base.Invalidate();
- }
- private void NextArea(int Delta)
- {
- int num = ((this.chart.Areas.IndexOf(this.chart.SelectedArea) + Delta) + this.chart.Areas.Count) % this.chart.Areas.Count;
- if (num < this.chart.Areas.Count)
- {
- this.chart.SelectedArea = this.chart[num];
- }
- this.NeedRedraw();
- }
- private void NextCycle(int Delta)
- {
- if ((this.favoriteCycles != null) && (this.favoriteCycles != ""))
- {
- ArrayList list = new ArrayList();
- list.AddRange(this.favoriteCycles.Split(new char[] { ';' }));
- int index = list.IndexOf(this.CurrentDataCycle.ToString());
- if (index < 0)
- {
- index = 0;
- }
- index = ((index + Delta) + list.Count) % list.Count;
- if (!this.fixedTime)
- {
- this.EndTime = DateTime.MinValue;
- }
- this.CurrentDataCycle = DataCycle.Parse(list[index].ToString());
- }
- }
- private void NextFormula(int Delta)
- {
- int index = this.chart.Areas.IndexOf(this.chart.SelectedArea);
- if (index < 0)
- {
- index = this.chart.Areas.Count - 1;
- }
- if (index >= 0)
- {
- FormulaArea area = this.chart[index];
- if (!area.IsMain())
- {
- string str = area.FormulaToString('#');
- int length = str.IndexOf('(');
- if (length >= 0)
- {
- str = str.Substring(0, length);
- }
- int num3 = -1;
- for (int i = 0; i < this.favoriteFormulas.Count; i++)
- {
- if (string.Compare(str, (string)this.favoriteFormulas[i], true) == 0)
- {
- num3 = i;
- }
- }
- if (num3 < 0)
- {
- num3 = 0;
- }
- num3 = ((num3 + Delta) + this.favoriteFormulas.Count) % this.favoriteFormulas.Count;
- this.SetAreaByName(index, (string)this.favoriteFormulas[num3]);
- this.NeedRebind();
- }
- }
- }
- protected override void OnPaintBackground(PaintEventArgs pevent)
- {
- if ((this.chart == null) || (this.chart.DataProvider == null))
- {
- base.OnPaintBackground(pevent);
- }
- }
- public static void OpenFormulaSourceEditor()
- {
- OpenFormulaSourceEditor("", "");
- }
- public static void OpenFormulaSourceEditor(string Filename, string Formula)
- {
- FormulaSourceEditor.Open(Filename, Formula);
- }
- public void Print()
- {
- this.SetupPrinting();
- if (this.printDialog.ShowDialog() == DialogResult.OK)
- {
- this.printDocument.Print();
- }
- }
- private void printDocument_PrintPage(object sender, PrintPageEventArgs e)
- {
- Bitmap image = this.GetBitmap(true, true);
- e.Graphics.DrawImage(image, e.MarginBounds, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
- }
- public void PrintPreview()
- {
- this.SetupPrinting();
- this.previewDialog.ShowDialog();
- }
- public void PrintSetup()
- {
- this.SetupPrinting();
- this.setupDialog.ShowDialog();
- }
- private void RebindLastBar()
- {
- this.needDrawLastBarOnly = true;
- this.BindData();
- this.RenderChart(this.ControlGraphics);
- }
- private void RecreateFormula()
- {
- if (this.chart != null)
- {
- foreach (FormulaArea area in this.chart.Areas)
- {
- this.RecreateFormula(area);
- }
- }
- this.SaveChartProperties();
- }
- private void RecreateFormula(FormulaArea fa)
- {
- string[] ss = fa.FormulaToStrings();
- fa.Formulas.Clear();
- fa.StringsToFormula(ss);
- }
- public void RenderChart(Graphics g)
- {
- Graphics graphics = g;
- if (this.memoryCrossCursor)
- {
- Rectangle rect = this.chart.Rect;
- if (((this.CrossMemBmp == null) || (this.CrossMemBmp.Width != rect.Width)) || (this.CrossMemBmp.Height != rect.Height))
- {
- this.CrossMemBmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppPArgb);
- this.CrossMemBmpG = Graphics.FromImage(this.CrossMemBmp);
- }
- Region r = null;
- if (this.needDrawLastBarOnly && this.needRebind)
- {
- r = new Region();
- r.MakeEmpty();
- }
- g = this.CrossMemBmpG;
- g.SetClip(graphics);
- this.chart.Render(g, r);
- graphics.SetClip(g);
- if (this.LastHitInfo.X != 0f)
- {
- if (this.needRebind)
- {
- this.SetCursorPos();
- }
- if (this.needDrawCursor)
- {
- this.DrawCursorByPos(g);
- this.needDrawCursor = false;
- }
- else
- {
- this.DrawCursor(g);
- }
- }
- }
- else
- {
- this.chart.Render(g);
- if (this.needDrawCursor)
- {
- this.chart.DrawCursor(g);
- this.needDrawCursor = false;
- }
- else if ((this.crossCursorMouseMode == MouseAction.MouseDown) && (this.LastHitInfo.X != 0f))
- {
- this.LastHitInfo = this.chart.GetHitInfo(this.LastHitInfo.X, this.LastHitInfo.Y);
- this.MouseCrossCursor(this.ControlGraphics, this.LastHitInfo);
- }
- }
- if (this.MouseZoomBmp != null)
- {
- g.DrawImage(this.MouseZoomBmp, this.MouseZoomRect, this.MouseZoomRect, GraphicsUnit.Pixel);
- }
- if (this.memoryCrossCursor)
- {
- graphics.DrawImage(this.CrossMemBmp, 0, 0);
- }
- }
- public void Reset(int columnWidth)
- {
- this.EndTime = DateTime.MinValue;
- this.StockBars = base.Width / columnWidth;
- this.AutoScaleAxisY();
- }
- public void SaveChartProperties()
- {
- this.AreasToDefaultFormulas();
- this.areaPercent = this.chart.GetAreaPercent();
- }
- public void ScaleChart(double ScaleFactor)
- {
- if ((this.chart != null) && !this.chart.FixedTime)
- {
- int moveBars = (int)((this.chart.GetTotalBars() * ScaleFactor) + 0.5);
- if (moveBars == 0)
- {
- if (ScaleFactor > 0.0)
- {
- moveBars = 1;
- }
- else
- {
- moveBars = -1;
- }
- }
- int num3 = -moveBars;
- if (this.zoomPosition == ZoomCenterPosition.Left)
- {
- moveBars = 0;
- }
- if (this.zoomPosition == ZoomCenterPosition.Right)
- {
- num3 = 0;
- }
- this.MoveChartXBars(3, 0, moveBars);
- this.MoveChartXBars(3, 2, num3);
- }
- }
- public void SetAreaByName(string FormulaName)
- {
- FormulaArea selectedArea = this.chart.SelectedArea;
- if (selectedArea == null)
- {
- selectedArea = this.chart.Areas[this.chart.Areas.Count - 1];
- }
- this.SetAreaByName(selectedArea, FormulaName);
- }
- public void SetAreaByName(FormulaArea fa, string FormulaName)
- {
- if (fa != null)
- {
- int index = this.chart.Areas.IndexOf(fa);
- if (index >= 0)
- {
- string s = fa.FormulaToString('#');
- try
- {
- this.SetDefaultFormulas(index, FormulaName);
- }
- catch
- {
- this.SetDefaultFormulas(index, s);
- throw;
- }
- this.SaveChartProperties();
- this.NeedRebind();
- }
- }
- }
- public void SetAreaByName(int AreaIndex, string FormulaName)
- {
- if ((AreaIndex >= 0) && (AreaIndex < this.chart.Areas.Count))
- {
- this.SetAreaByName(this.chart.Areas[AreaIndex], FormulaName);
- }
- }
- private void SetAreaCount(int Count)
- {
- if (this.chart.Areas.Count != Count)
- {
- while (this.chart.Areas.Count > Count)
- {
- this.chart.Areas.RemoveAt(Count);
- }
- int num = this.chart.Areas.Count;
- this.ExpandDefaultFormulas(Count);
- double num2 = 1.0;
- if (this.chart.Areas.Count > 0)
- {
- num2 = this.chart[0].HeightPercent / 3.0;
- }
- for (int i = num; i < this.chart.Areas.Count; i++)
- {
- this.chart[i].HeightPercent = num2;
- }
- this.areaPercent = this.chart.GetAreaPercent();
- this.NeedRebind();
- }
- this.UseDefaultFormulas(false);
- }
- private void SetCursorPos()
- {
- this.chart.CursorPos = this.LastHitInfo.CursorPos;
- }
- private void SetDefaultFormulas(int Index, string s)
- {
- this.ExpandDefaultFormulas(Index);
- this.chart[Index].Formulas.Clear();
- this.chart[Index].StringToFormula(s, '#');
- }
- private void SetupPrinting()
- {
- if (this.printDialog == null)
- {
- this.printDialog = new PrintDialog();
- this.printDocument = new PrintDocument();
- this.previewDialog = new PrintPreviewDialog();
- this.setupDialog = new PageSetupDialog();
- this.printDocument.DefaultPageSettings.Landscape = true;
- this.printDocument.DefaultPageSettings.Margins = new Margins(30, 30, 30, 30);
- this.printDialog.Document = this.printDocument;
- this.printDocument.PrintPage += new PrintPageEventHandler(this.printDocument_PrintPage);
- this.previewDialog.Document = this.printDocument;
- this.setupDialog.Document = this.printDocument;
- }
- }
- public void ShowAllBars()
- {
- if ((this.chart != null) && (this.chart.DataProvider != null))
- {
- double[] numArray = this.chart.DataProvider["DATE"];
- if (numArray.Length > 0)
- {
- this.StartTime = DateTime.FromOADate(numArray[0]);
- this.EndTime = DateTime.FromOADate(numArray[numArray.Length - 1]);
- }
- }
- }
- private void ShowStatisticWindow(object Sender, FormulaChart Chart, int Pos, IDataProvider idp)
- {
- if (this.ShowStatistic)
- {
- if (this.StatisticWindow.Left < 0)
- {
- this.StatisticWindow.Left = 10;
- }
- string format = "f2";
- if ((Chart.MainArea != null) && Chart.MainArea.IsMain())
- {
- format = Chart.MainArea.AxisY.Format;
- }
- double d = idp["DATE"][Chart.CursorPos];
- double num2 = idp["OPEN"][Chart.CursorPos];
- double num3 = idp["HIGH"][Chart.CursorPos];
- double num4 = idp["LOW"][Chart.CursorPos];
- double num5 = idp["CLOSE"][Chart.CursorPos];
- double num6 = idp["VOLUME"][Chart.CursorPos];
- string str2 = "";
- string str3 = "";
- string str4 = "";
- if (Chart.CursorPos > 0)
- {
- double num7 = idp["CLOSE"][Chart.CursorPos - 1];
- if (num7 != double.NaN)
- {
- str2 = FormulaHelper.FormatDouble(num7, format);
- str3 = (num5 - num7).ToString("f2");
- str4 = ((num5 - num7) / num7).ToString("p2");
- }
- }
- StringBuilder builder = new StringBuilder();
- builder.Append("Symbol=" + idp.GetStringData("Code") + ";");
- builder.Append("Date=" + DateTime.FromOADate(d).ToString(Chart.XCursorFormat, DateTimeFormatInfo.InvariantInfo) + ";");
- builder.Append("Current=" + FormulaHelper.FormatDouble(num5, format) + ";");
- builder.Append("Last=" + str2 + ";");
- builder.Append("Open=" + FormulaHelper.FormatDouble(num2, format) + ";");
- builder.Append("High=" + FormulaHelper.FormatDouble(num3, format) + ";");
- builder.Append("Low=" + FormulaHelper.FormatDouble(num4, format) + ";");
- builder.Append("Close=" + FormulaHelper.FormatDouble(num5, format) + ";");
- builder.Append("Volume=" + num6.ToString() + ";");
- builder.Append("Change=" + str3 + ";");
- builder.Append("Percent=" + str4 + ";");
- if (this.ShowIndicatorValues)
- {
- try
- {
- for (int i = this.showOverlayValues ? 0 : 1; i < Chart.Areas.Count; i++)
- {
- int num9 = 0;
- int num10 = 0;
- foreach (FormulaData data in Chart[i].FormulaDataArray)
- {
- string displayName;
- if (num10 == 0)
- {
- displayName = Chart[i].Formulas[num9].DisplayName;
- }
- else
- {
- displayName = "";
- }
- if (data.ValueTextMode != IndexFormula.Finance.ValueTextMode.None)
- {
- string str6 = (displayName + data.Name).Trim();
- if (str6 != "")
- {
- builder.Append(str6 + "=" + FormulaHelper.FormatDouble(data[Chart.CursorPos], Chart[i].AxisYs[data.AxisYIndex].Format) + ";");
- }
- }
- num10++;
- if (num10 == Chart[i].Packages[num9].Count)
- {
- num9++;
- num10 = 0;
- }
- }
- }
- }
- catch
- {
- }
- }
- this.StatisticWindow.RefreshData(builder.ToString());
- this.LastProvider = Chart.DataProvider;
- this.LastCursorPos = Chart.CursorPos;
- }
- }
- private string[] Split(string s, char separator)
- {
- ArrayList list = new ArrayList();
- int num = 0;
- int startIndex = 0;
- for (int i = 0; i < s.Length; i++)
- {
- if (s[i] == '(')
- {
- num++;
- }
- else if (s[i] == ')')
- {
- num--;
- }
- if ((num == 0) && (s[i] == separator))
- {
- list.Add(s.Substring(startIndex, i - startIndex));
- startIndex = i + 1;
- }
- }
- return (string[])list.ToArray(typeof(string));
- }
- private void StatisticWindow_OnHide(object sender, EventArgs e)
- {
- this.ShowStatistic = this.StatisticWindow.Visible;
- }
- public void UseDefaultFormulas(bool b)
- {
- this.needSetDefaultFormulas = b;
- }
- [Category("Stock Chart"), DefaultValue(true), Description("Adjust the data automatically when there is price split")]
- public bool AdjustData
- {
- get
- {
- return this.adjustData;
- }
- set
- {
- this.adjustData = value;
- this.NeedRebind();
- }
- }
- [DefaultValue((double)0.1), Category("Stock Chart Time"), Description("How many right space after the last bar of the chart. If the value between 0 and 1, it means the percentage of the bar.")]
- public double AfterBars
- {
- get
- {
- return this.afterBars;
- }
- set
- {
- this.afterBars = value;
- }
- }
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
- public int AreaCount
- {
- get
- {
- return this.chart.Areas.Count;
- }
- set
- {
- this.SetAreaCount(value);
- }
- }
- [Category("Stock Chart"), DefaultValue("3;1;1;1;1"), Description("Height percentage of each area,separated by semi colon.")]
- public string AreaPercent
- {
- get
- {
- return this.areaPercent;
- }
- set
- {
- this.areaPercent = value;
- }
- }
- [Browsable(false)]
- public string Caption
- {
- get
- {
- IDataProvider dataProvider = this.chart.DataProvider;
- string stringData = dataProvider.GetStringData("Code");
- string str2 = dataProvider.GetStringData("Name");
- if (str2 != null)
- {
- stringData = stringData + "(" + str2 + ")";
- }
- string str3 = dataProvider.GetStringData("Exchange");
- if (str3 != null)
- {
- stringData = stringData + "@" + str3;
- }
- return (stringData + " - " + this.CurrentDataCycle);
- }
- }
- [Browsable(false)]
- public FormulaChart Chart
- {
- get
- {
- return this.chart;
- }
- }
- [DefaultValue(1), Description("Behaver when drag the chart"), Category("Stock Chart")]
- public IndexFormula.Finance.ChartDragMode ChartDragMode
- {
- get
- {
- return this.chartDragMode;
- }
- set
- {
- this.chartDragMode = value;
- }
- }
- [Browsable(false), DefaultValue((double)4.0), Category("Stock Chart Time")]
- public double ColumnWidth
- {
- get
- {
- return this.columnWidth;
- }
- set
- {
- this.columnWidth = value;
- }
- }
- [DefaultValue(1), Category("Stock Chart"), Description("How to show the cross cursor according mouse action, mouse move or mouse down")]
- public MouseAction CrossCursorMouseMode
- {
- get
- {
- return this.crossCursorMouseMode;
- }
- set
- {
- this.crossCursorMouseMode = value;
- }
- }
- [Description("Data Cycle"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), DefaultValue(typeof(DataCycle), "DAY1"), Category("Stock Chart")]
- public DataCycle CurrentDataCycle
- {
- get
- {
- return this.currentDataCycle;
- }
- set
- {
- if (this.currentDataCycle != value)
- {
- if (this.BeforeCycleChange != null)
- {
- this.BeforeCycleChange(this, new EventArgs());
- }
- if ((value.CycleBase >= DataCycleBase.DAY) && this.chart.FixedTime)
- {
- this.fixedTime = false;
- this.chart.FixedTime = false;
- }
- this.NeedRebind();
- this.currentDataCycle = value;
- if (this.AfterCycleChange != null)
- {
- this.AfterCycleChange(this, new EventArgs());
- }
- }
- }
- }
- [Browsable(false)]
- public DataManagerBase DataManager
- {
- set
- {
- this.HistoryDataManager = value;
- this.IntraDataManager = value;
- }
- }
- [Description("Default cursor"), DefaultValue((string)null), Category("Stock Chart")]
- public Cursor DefaultCursor
- {
- get
- {
- return this.defaultCursor;
- }
- set
- {
- this.defaultCursor = value;
- }
- }
- [Category("Stock Chart"), DefaultValue("VOLMA;RSI(14)#RSI(28);MACD;SlowSTO")]
- public string DefaultFormulas
- {
- get
- {
- return this.defaultFormulas;
- }
- set
- {
- this.defaultFormulas = value;
- this.needSetDefaultFormulas = true;
- this.NeedRebind();
- }
- }
- [Browsable(false)]
- public Control DesignerControl
- {
- get
- {
- return this;
- }
- }
- [Browsable(false)]
- public bool Designing
- {
- get
- {
- return this.designing;
- }
- set
- {
- this.designing = value;
- }
- }
- [Description("End time of the chart, if leave this field empty, will use StockBars instead"), DefaultValue(typeof(DateTime), "1-1-1"), Category("Stock Chart Time")]
- public DateTime EndTime
- {
- get
- {
- return this.endTime;
- }
- set
- {
- this.endTime = value;
- if (this.fixedTime || ((this.CurrentDataManager != null) && this.CurrentDataManager.VirtualFetch))
- {
- this.NeedRebind();
- }
- else
- {
- this.NeedRedraw();
- }
- if (this.memoryCrossCursor)
- {
- this.needDrawCursor = true;
- }
- }
- }
- [Category("Stock Chart"), DefaultValue("MINUTE1;MINUTE5;MINUTE15;MINUTE30;HOUR1;DAY1;WEEK1;MONTH1;YEAR1")]
- public string FavoriteCycles
- {
- get
- {
- return this.favoriteCycles;
- }
- set
- {
- this.favoriteCycles = value;
- this.CreateCycleMenu();
- }
- }
- [Category("Stock Chart")]
- public string FavoriteFormulas
- {
- get
- {
- return string.Join(";", (string[])this.favoriteFormulas.ToArray(typeof(string)));
- }
- set
- {
- if ((value != null) && (value != ""))
- {
- this.favoriteFormulas.Clear();
- this.favoriteFormulas.AddRange(value.Split(new char[] { ';' }));
- this.BuildFavoriteMenu();
- }
- }
- }
- [DefaultValue(false), Category("Stock Chart"), Description("Fixed time frame between StartTime and EndTime, used for intraday chart")]
- public bool FixedTime
- {
- get
- {
- return this.fixedTime;
- }
- set
- {
- this.fixedTime = value;
- this.NeedRebind();
- }
- }
- [Category("Stock Chart Mouse Zoom"), Description("Rectangle for fixed zoom box. Empty box will draw the zoom box by hand. Center fixed zoom box (-150,-150,300,300), TopLeft fixed zoom box (0,0,300,300)"), DefaultValue(typeof(Rectangle), "0, 0, 0, 0")]
- public Rectangle FixedZoomRect
- {
- get
- {
- return this.fixedZoomRect;
- }
- set
- {
- this.fixedZoomRect = value;
- }
- }
- [DefaultValue((string)null), Browsable(false)]
- public DataManagerBase HistoryDataManager
- {
- get
- {
- return this.historyDataManager;
- }
- set
- {
- if (value != this.historyDataManager)
- {
- this.historyDataManager = value;
- this.NeedRebind();
- }
- }
- }
- [Browsable(false), DefaultValue((string)null)]
- public DataManagerBase IntraDataManager
- {
- get
- {
- return this.intraDataManager;
- }
- set
- {
- if (value != this.intraDataManager)
- {
- this.intraDataManager = value;
- this.NeedRebind();
- }
- }
- }
- [Description("Intraday exchange informations"), Browsable(false)]
- public ExchangeIntraday IntradayInfo
- {
- get
- {
- return this.intradayInfo;
- }
- set
- {
- this.intradayInfo = value;
- this.NeedRebind();
- }
- }
- [Browsable(false)]
- public bool IsDragging
- {
- get
- {
- return (this.DragInfo != null);
- }
- }
- [Category("Stock Chart"), DefaultValue(2), Description("How to show the latest value in the axis-Y")]
- public IndexFormula.Finance.LatestValueType LatestValueType
- {
- get
- {
- return this.latestValueType;
- }
- set
- {
- this.latestValueType = value;
- this.NeedRedraw();
- }
- }
- [DefaultValue((double)500.0), Category("Stock Chart")]
- public double MaxColumnWidth
- {
- get
- {
- return this.maxColumnWidth;
- }
- set
- {
- this.maxColumnWidth = value;
- }
- }
- [Browsable(false)]
- public double MaxPrice
- {
- get
- {
- return this.maxPrice;
- }
- set
- {
- this.maxPrice = value;
- }
- }
- [DefaultValue(false), Description("Draw cross cursor in memory , this will prevent flicker"), Category("Stock Chart")]
- public bool MemoryCrossCursor
- {
- get
- {
- return this.memoryCrossCursor;
- }
- set
- {
- this.memoryCrossCursor = value;
- }
- }
- [Category("Stock Chart"), DefaultValue((double)0.01)]
- public double MinColumnWidth
- {
- get
- {
- return this.minColumnWidth;
- }
- set
- {
- this.minColumnWidth = value;
- }
- }
- [Browsable(false)]
- public double MinPrice
- {
- get
- {
- return this.minPrice;
- }
- set
- {
- this.minPrice = value;
- }
- }
- [Description("Use mouse wheel to scroll or zoom the chart"), DefaultValue(1), Category("Stock Chart")]
- public IndexFormula.Finance.Win.MouseWheelMode MouseWheelMode
- {
- get
- {
- return this.mouseWheelMode;
- }
- set
- {
- this.mouseWheelMode = value;
- }
- }
- [DefaultValue(typeof(Color), "32, 0, 128, 0"), Description("The background color of the mouse zoom"), Category("Stock Chart Mouse Zoom")]
- public Color MouseZoomBackColor
- {
- get
- {
- return this.mouseZoomBackColor;
- }
- set
- {
- this.mouseZoomBackColor = value;
- }
- }
- [Description("Use mouse to zoom the chart"), DefaultValue(1), Category("Stock Chart Mouse Zoom")]
- public IndexFormula.Finance.Win.MouseZoomMode MouseZoomMode
- {
- get
- {
- return this.mouseZoomMode;
- }
- set
- {
- this.mouseZoomMode = value;
- }
- }
- [Description("Use native context menu"), Category("Stock Chart"), DefaultValue(true)]
- public bool NativeContextMenu
- {
- get
- {
- return this.nativeContextMenu;
- }
- set
- {
- this.nativeContextMenu = value;
- }
- }
- [Description("If you specify this, will add these text in the price area,Sample format:Prev Close:{LC}O:{OPEN}H:{HIGH}L:{LOW}C:{CLOSE}V:{VOLUME}Chg:{Change} {D:yyyy-MM-dd}"), Category("Stock Chart")]
- public string PriceLabelFormat
- {
- get
- {
- return this.chart.PriceLabelFormat;
- }
- set
- {
- this.chart.PriceLabelFormat = value;
- }
- }
- [Category("Stock Chart"), DefaultValue(true), Description("Reset Y-axis to auto scale when X-axis changed.")]
- public bool ResetYAfterXChanged
- {
- get
- {
- return this.resetYAfterXChanged;
- }
- set
- {
- this.resetYAfterXChanged = value;
- }
- }
- [DefaultValue(3), Category("Stock Chart"), Description("Get or set the scale type of main stock area")]
- public IndexFormula.Finance.ScaleType ScaleType
- {
- get
- {
- return this.scaleType;
- }
- set
- {
- this.scaleType = value;
- this.NeedRedraw();
- }
- }
- [DefaultValue(2), Description("How to select a formula through mouse"), Category("Stock Chart")]
- public MouseAction SelectFormulaMouseMode
- {
- get
- {
- return this.selectFormulaMouseMode;
- }
- set
- {
- this.selectFormulaMouseMode = value;
- }
- }
- [DefaultValue(true), Description("Show cross cursor on the chart"), Category("Stock Chart")]
- public bool ShowCrossCursor
- {
- get
- {
- return this.showCrossCursor;
- }
- set
- {
- this.showCrossCursor = value;
- this.miCrossCursor.Checked = value;
- this.chart.ShowHLine = value;
- this.chart.ShowVLine = value;
- if (!value)
- {
- base.Invalidate();
- }
- }
- }
- [DefaultValue(true), Category("Stock Chart")]
- public bool ShowCursorLabel
- {
- get
- {
- return this.showCursorLabel;
- }
- set
- {
- this.showCursorLabel = value;
- this.NeedRebind();
- }
- }
- [Category("Stock Chart"), Description("How to show the horizontal grid line"), DefaultValue(0)]
- public ShowLineMode ShowHorizontalGrid
- {
- get
- {
- return this.showHorizontalGrid;
- }
- set
- {
- this.showHorizontalGrid = value;
- this.NeedRedraw();
- }
- }
- [DefaultValue(true), Category("Stock Chart"), Description("Show indicator values in the statistic window")]
- public bool ShowIndicatorValues
- {
- get
- {
- return this.showIndicatorValues;
- }
- set
- {
- this.showIndicatorValues = value;
- }
- }
- [DefaultValue(true), Description("Show overlay values in the statistic window"), Category("Stock Chart")]
- public bool ShowOverlayValues
- {
- get
- {
- return this.showOverlayValues;
- }
- set
- {
- this.showOverlayValues = value;
- }
- }
- [Category("Stock Chart"), DefaultValue(true), Description("Show statistic windows on the chart")]
- public bool ShowStatistic
- {
- get
- {
- return this.showStatistic;
- }
- set
- {
- bool flag = (this.showStatistic != value) && (this.ShowStatisticChanged != null);
- this.showStatistic = value;
- if (flag)
- {
- this.ShowStatisticChanged(this, new EventArgs());
- }
- }
- }
- [Description("Draw a line on top of the chart control"), Category("Stock Chart"), DefaultValue(true)]
- public bool ShowTopLine
- {
- get
- {
- return this.showTopLine;
- }
- set
- {
- this.showTopLine = value;
- }
- }
- [Description("How to show the vertical grid line"), DefaultValue(0), Category("Stock Chart")]
- public ShowLineMode ShowVerticalGrid
- {
- get
- {
- return this.showVerticalGrid;
- }
- set
- {
- this.showVerticalGrid = value;
- this.NeedRedraw();
- }
- }
- [TypeConverter(typeof(SkinConverter)), Category("Stock Chart"), DefaultValue("RedWhite")]
- public string Skin
- {
- get
- {
- return this.skin;
- }
- set
- {
- this.skin = value;
- this.NeedRebind();
- }
- }
- [Browsable(false), DefaultValue(0), Category("Stock Chart Time")]
- public int StartBar
- {
- get
- {
- return this.chart.Start;
- }
- set
- {
- if (value < 0)
- {
- value = 0;
- }
- this.chart.Start = value;
- if (!this.chart.FixedTime)
- {
- this.chart.StartTime = DateTime.MinValue;
- this.chart.EndTime = DateTime.MaxValue;
- }
- this.NeedRedraw();
- }
- }
- [Category("Stock Chart Time"), Description("Start time of the chart"), DefaultValue(typeof(DateTime), "1-1-1")]
- public DateTime StartTime
- {
- get
- {
- return this.startTime;
- }
- set
- {
- this.startTime = value;
- if (this.fixedTime || ((this.CurrentDataManager != null) && this.CurrentDataManager.VirtualFetch))
- {
- this.NeedRebind();
- }
- else
- {
- this.NeedRedraw();
- }
- if (this.memoryCrossCursor)
- {
- this.needDrawCursor = true;
- }
- }
- }
- [DefaultValue(4), Description("Stick render type is used for Volumn Stick,Color Stick and Stick Line"), Category("Stock Chart")]
- public IndexFormula.Finance.StickRenderType StickRenderType
- {
- get
- {
- return this.stickRenderType;
- }
- set
- {
- this.stickRenderType = value;
- this.NeedRebind();
- }
- }
- [Category("Stock Chart Time"), Description("This will take effect when EndTime is empty."), DefaultValue(150)]
- public int StockBars
- {
- get
- {
- return this.stockBars;
- }
- set
- {
- if (value < 1)
- {
- value = 1;
- }
- this.stockBars = value;
- this.NeedRedraw();
- this.EndTime = DateTime.MinValue;
- }
- }
- [Description("Stock chart render type"), Category("Stock Chart"), DefaultValue(4)]
- public IndexFormula.Finance.StockRenderType StockRenderType
- {
- get
- {
- return this.stockRenderType;
- }
- set
- {
- this.stockRenderType = value;
- this.NeedRebind();
- }
- }
- [DefaultValue("MSFT"), Description("Stock Symbol"), Category("Stock Chart")]
- public string Symbol
- {
- get
- {
- return this.symbol;
- }
- set
- {
- if (value != this.symbol)
- {
- this.symbol = value;
- this.NeedRebind();
- }
- }
- }
- [Description("How to draw the value text"), DefaultValue(4), Category("Stock Chart")]
- public IndexFormula.Finance.ValueTextMode ValueTextMode
- {
- get
- {
- return this.valueTextMode;
- }
- set
- {
- this.valueTextMode = value;
- this.NeedRebind();
- }
- }
- [Category("Stock Chart Mouse Zoom"), DefaultValue(0), Description("Position of the zoom center")]
- public ZoomCenterPosition ZoomPosition
- {
- get
- {
- return this.zoomPosition;
- }
- set
- {
- this.zoomPosition = value;
- }
- }
- }
- }
|