public void LongToStringTest() { var watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 1000000; i++) { //Assert.AreEqual(ByteConverters.LongToHex2(16), "10"); Assert.AreEqual(ByteConverters.LongToString(17, 3), "017"); Assert.AreEqual(ByteConverters.LongToString(1048576), "1048576"); Assert.AreEqual(ByteConverters.LongToString(1024, 4), "1024"); } watch.Stop(); Trace.WriteLine(watch.ElapsedMilliseconds); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); void DrawOneStep(long offSet, Point startPoint) { var str = string.Empty; switch (DataVisualType) { case DataVisualType.Hexadecimal: str = $"0x{ByteConverters.LongToHex(offSet, SavedBits)}"; break; case DataVisualType.Decimal: str = ByteConverters.LongToString(offSet, SavedBits); break; default: break; } #if NET451 var text = new FormattedText(str, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, TypeFace, FontSize, Foreground); #endif #if NET47 var text = new FormattedText(str, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, TypeFace, FontSize, Foreground, PixelPerDip); #endif drawingContext.DrawText(text, startPoint); } void DrawSteps(Func <int, Point> getOffsetLocation) { for (int i = 0; i < StepsCount; i++) { DrawOneStep( i * StepLength + StartStepIndex, getOffsetLocation(i) ); } } if (Orientation == Orientation.Horizontal) { DrawSteps(step => new Point( (CellMargin.Left + CellMargin.Right + CellSize.Width) * step + CellMargin.Left + CellPadding.Left, CellMargin.Top + CellPadding.Top ) ); } else { #if DEBUG //double lastY = 0; #endif DrawSteps(step => new Point( CellMargin.Left + CellPadding.Left, (CellMargin.Top + CellMargin.Bottom + CellSize.Height) * step + CellMargin.Top + CellPadding.Top)); { #if DEBUG //if(lastY != pot.Y) { // lastY = pot.Y; // System.Diagnostics.Debug.WriteLine(lastY); //} #endif //return pot; } } }