After exporting as Assembly to another computer the rendering is done higher on the screen than it should. See the second image below.
I am using Wpf, and a set of functions to simplify the translation between price to screen coordinates. Please see the short code for DrawDXLine.
protected void DrawDXLine(int idxslot1, int idxslot2, double val1, double val2, Stroke stroke, ChartControl chartControl, Gui.Chart.ChartScale chartScale) { DrawDXLine(idxslot1, idxslot2, val1, val2, stroke.Brush, stroke.DashStyleHelper, stroke.Width, chartControl, chartScale, stroke.Opacity); } protected void DrawDXLine(int idxslot1, int idxslot2, double val1, double val2, Brush brush, DashStyleHelper dashStyle, float width, Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100) { Point p1 = new Point(BarToX(idxslot1, chartControl), PriceToY(val1, chartScale)); Point p2 = new Point(BarToX(idxslot2, chartControl), PriceToY(val2, chartScale)); DrawDXLine(p1, p2, brush, dashStyle, width, chartControl, chartScale, opacity); } protected void DrawDXLine(double x1, double x2, double y1, double y2, Brush brush, DashStyleHelper dashStyle, float width, Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100) { Point p1 = new Point(x1, y1); Point p2 = new Point(x2, y2); DrawDXLine(p1, p2, brush, dashStyle, width, chartControl, chartScale, opacity); } protected void DrawDXLine(Point p1, Point p2, Brush brush, DashStyleHelper dashStyle, float width, ChartControl chartControl, Gui.Chart.ChartScale chartScale, int opacity = 100) { SharpDX.Direct2D1.DashStyle _dashStyle; if (!Enum.TryParse(dashStyle.ToString(), true, out _dashStyle)) _dashStyle = SharpDX.Direct2D1.DashStyle.Dash; SharpDX.Direct2D1.StrokeStyleProperties properties = new SharpDX.Direct2D1.StrokeStyleProperties() {DashStyle=_dashStyle}; SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(Core.Globals.D2DFact ory, properties); SharpDX.Direct2D1.Brush dxBrush = brush.ToDxBrush(RenderTarget); dxBrush.Opacity = opacity/100f; RenderTarget.DrawLine(p1.ToVector2(), p2.ToVector2(), dxBrush, width, strokeStyle); dxBrush.Dispose(); strokeStyle.Dispose(); } //retrieve the x coordinate in pixel of a a relative bar index. protected double BarToX(int bars, Gui.Chart.ChartControl chartControl, bool atMiddle = false) { return chartControl.GetXByBarIndex(chartControl.BarsArray[0], bars) - (atMiddle ? (chartControl.Properties.BarDistance / 2) : 0); } //retrieve the y coordinate in pixel of a a relative price. protected double PriceToY(double val, Gui.Chart.ChartScale chartScale) { return chartScale.GetYByValueWpf(val); }
Comment