public override void RenderTo(IElementRenderer renderer, double x, double y) { renderer.RenderElement(this.BaseBox, x, y); if (this.Over) { // Draw delimeter and script boxes over base box. var centerY = y - this.BaseBox.Height - this.DelimiterBox.Width; var translationX = x + this.DelimiterBox.Width / 2; var translationY = centerY + this.DelimiterBox.Width / 2; RenderDelimiter(translationX, translationY); // Draw script box as superscript. RenderScriptBox(centerY - this.Kern - this.ScriptBox !.Depth); // Nullable TODO: This probably needs null checking } else { // Draw delimeter and script boxes under base box. var centerY = y + this.BaseBox.Depth + this.DelimiterBox.Width; var translationX = x + this.DelimiterBox.Width / 2; var translationY = centerY - this.DelimiterBox.Width / 2; RenderDelimiter(translationX, translationY); // Draw script box as subscript. RenderScriptBox(centerY + this.Kern + this.ScriptBox !.Height); // Nullable TODO: This probably needs null checking } void RenderDelimiter(double translationX, double translationY) { var transformations = new Transformation[] { new Transformation.Translate(translationX, translationY), new Transformation.Rotate(90) }; renderer.RenderTransformed( this.DelimiterBox, transformations, -this.DelimiterBox.Width / 2, -this.DelimiterBox.Depth + this.DelimiterBox.Width / 2); } void RenderScriptBox(double yPosition) { if (this.ScriptBox != null) { renderer.RenderElement(this.ScriptBox, x, yPosition); } } }
public override void RenderTo(IElementRenderer renderer, double x, double y) { renderer.RenderElement(BaseBox, x, y); if (Over) { // Draw delimeter and script boxes over base box. var centerY = y - BaseBox.Height - DelimeterBox.Width; var translationX = x + DelimeterBox.Width / 2; var translationY = centerY + DelimeterBox.Width / 2; RenderDelimiter(translationX, translationY); // Draw script box as superscript. RenderScriptBox(centerY - Kern - ScriptBox.Depth); } else { // Draw delimeter and script boxes under base box. var centerY = y + BaseBox.Depth + DelimeterBox.Width; var translationX = x + DelimeterBox.Width / 2; var translationY = centerY - DelimeterBox.Width / 2; RenderDelimiter(translationX, translationY); // Draw script box as subscript. RenderScriptBox(centerY + Kern + ScriptBox.Height); } void RenderDelimiter(double translationX, double translationY) { var transformations = new Transformation[] { new Transformation.Translate(translationX, translationY), new Transformation.Rotate(90) }; renderer.RenderTransformed( DelimeterBox, transformations, -DelimeterBox.Width / 2, -DelimeterBox.Depth + DelimeterBox.Width / 2); } void RenderScriptBox(double yPosition) { if (ScriptBox != null) { renderer.RenderElement(ScriptBox, x, yPosition); } } }