public TradingViewControl() { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); InitializeComponent(); if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { try { var splashPictureBox = new PictureBox(); Controls.Add(splashPictureBox); splashPictureBox.Dock = DockStyle.Fill; splashPictureBox.SizeMode = PictureBoxSizeMode.StretchImage; splashPictureBox.Load("https://raw.githubusercontent.com/ExtremeDotneting/UndergroundIRO.TradingViewKit/master/data/splash.jpg"); splashPictureBox.Invalidate(); } catch { } return; } var control = new CefSharpXWebViewControl(); control.Dock = DockStyle.Fill; Controls.Add(control); var xwv = new CefSharpXWebView(control); control.SetVisibilityState(XWebViewVisibility.Visible); TradingView = new TradingView(xwv); }
public MainWindow() { InitializeComponent(); if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } //Load data. var json = File.ReadAllText("testdata.json"); var chart = JsonConvert.DeserializeObject <TradingViewChart>(json); var ctx = new TradingViewContext() { Title = "MyTitle", Chart = chart }; var lastCandle = chart.Ohlcv.Last(); _currentOhlcvTime = (long)lastCandle.DateTime.ToUniversalDateTime(); var prevCandleTime = (long)chart.Ohlcv[chart.Ohlcv.Count - 2].DateTime.ToUniversalDateTime(); _step = _currentOhlcvTime - prevCandleTime; var o = JsonConvert.SerializeObject(lastCandle.Open); var h = JsonConvert.SerializeObject(lastCandle.High); var l = JsonConvert.SerializeObject(lastCandle.Low); var c = JsonConvert.SerializeObject(lastCandle.Close); var v = JsonConvert.SerializeObject(lastCandle.Volume); TextBox1.Text = $"[{o}, {h}, {l}, {c}, {v}]"; TradingView = TradingViewCtr.TradingView; TradingView.TypedContext = ctx; }
async Task OnRefreshed(ITradingView sender, ViewRefreshType viewRefreshType) { foreach (var item in _refreshedEvents) { var t = item(sender, viewRefreshType); if (t != null) { await t; } } }