When I use this code to modify the properties of the chartcontrol I get a directx exception, which freezes the application and I have to kill the process to exit.
private void setChartControlProperties() { if (this.ChartControl != null && this.ChartControl.Dispatcher != null ) { this.ChartControl.Dispatcher.InvokeAsync(new Action(() => { this.ChartControl.Properties.ChartBackground = new SolidColorBrush(myconfig.ChartControlBackground.Value); this.ChartControl.Properties.AxisPen = new Stroke(new SolidColorBrush(myconfig.ChartControlAxisColor.Value), ConvertDashStyle(myconfig.ChartControlAxisDashStyle), myconfig.ChartControlAxisWidth); this.ChartControl.Properties.GridLineHPen = new GridLine(new Stroke(new SolidColorBrush(myconfig.ChartControlGridHorizontalColor.Value), ConvertDashStyle(myconfig.ChartControlGridHorizontalDashStyle), myconfig.ChartControlGridHorizontalWidth), myconfig.ChartControlGridHorizontalEnabled); this.ChartControl.Properties.GridLineVPen = new GridLine(new Stroke(new SolidColorBrush(myconfig.ChartControlGridVerticalColor.Value), ConvertDashStyle(myconfig.ChartControlGridVerticalDashStyle), myconfig.ChartControlGridVerticalWidth), myconfig.ChartControlGridVerticalEnabled); this.ForceRefresh(); })); } }
The exception message is:
************** Exception Text ************** SharpDX.SharpDXException: HRESULT: [0x88990001], Module: [SharpDX.Direct2D1], ApiCode: [D2DERR_WRONG_STATE/WrongState], Message: Unknown at SharpDX.Result.CheckError() at SharpDX.Direct2D1.WindowRenderTarget.Resize(Size2 ixelSizeRef) at NinjaTrader.Gui.Chart.Direct2DForm.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds() at System.Windows.Forms.Control.WmWindowPosChanged(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at NinjaTrader.Gui.Chart.Direct2DForm.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks very much.
Comment