public void InchesToPixelsTest() { const float length = 1F; float actual = ConvertEx.InchesToPixels(length, DPI); Assert.AreEqual(DPI, actual); }
private void SetRulerRectangles() { int rulerWidth = (int)ConvertEx.InchesToPixels(_RulerLength, _Dpi); int rulerHeight = Height - Padding.Top - Padding.Bottom; _RulerRectangle = new Rectangle(Padding.Left, Padding.Top, rulerWidth, rulerHeight); if (_RightOffset > 0) { int offsetInchPixels = (int)Math.Round(ConvertEx.InchesToPixels(_RightOffset, _Dpi)); int rightMarginOffsetHeight = _RulerRectangle.Height; int rightMarginOffsetLeft = _RulerRectangle.Right - offsetInchPixels; int rightMarginOffsetTop = _RulerRectangle.Top; int rightMarginOffsetWidth = _RulerRectangle.Right - rightMarginOffsetLeft + 2; _RightOffsetRectangle = new Rectangle(rightMarginOffsetLeft, rightMarginOffsetTop, rightMarginOffsetWidth, rightMarginOffsetHeight); } else { _RightOffsetRectangle = new Rectangle(); } Invalidate(); }
protected float GetPixelsFromRuler(int paddingLeft, float rulerLength) { return(ConvertEx.InchesToPixels(FromRight ? (rulerLength - Inches) : Inches, Dpi) + paddingLeft); }