Beispiel #1
0
        public void Overflow(TickBarPlacement placement, bool isDirectionReversed, double tickWidth, double strokeThickness, string padding, string expected)
        {
            var tickBar = new LinearTickBar
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                TickFrequency       = 1,
                TickWidth           = tickWidth,
                Stroke              = Brushes.Black,
                Fill                = Brushes.Red,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Padding             = padding.AsThickness(),
            };

            var gauge = new LinearGauge {
                Content = tickBar
            };

            gauge.Arrange(new Rect(new Size(10, 10)));
            Assert.AreEqual(expected, gauge.ContentOverflow.ToString());
            Assert.AreEqual(expected, tickBar.Overflow.ToString());

            gauge.Measure(new Size(10, 10));
            gauge.Arrange(new Rect(new Size(10, 10)));
            Assert.AreEqual(expected, gauge.ContentOverflow.ToString());
            Assert.AreEqual(expected, tickBar.Overflow.ToString());
        }
Beispiel #2
0
        private static string GetFileName(LinearTickBar tickBar)
        {
            var ticks = tickBar.Ticks != null
                ? $"_Ticks_{tickBar.Ticks}"
                : string.Empty;

            var tickFrequency = tickBar.TickFrequency > 0
                ? $"_TickFrequency_{tickBar.TickFrequency}"
                : string.Empty;

            var orientation = tickBar.Placement == TickBarPlacement.Left || tickBar.Placement == TickBarPlacement.Right
                ? "_Vertical"
                : "_Horizontal";

            var padding = tickBar.Padding.IsZero()
                ? string.Empty
                : $"_Padding_{tickBar.Padding}";

            var value = double.IsNaN(tickBar.Value) || DoubleUtil.AreClose(tickBar.Value, tickBar.Maximum)
                ? string.Empty
                : $"_Value_{Math.Round(tickBar.Value, 0)}";

            if (DoubleUtil.AreClose(tickBar.Value, 0))
            {
                return($"LinearTickBar_Value_0{orientation}.png");
            }

            return($@"LinearTickBar_Min_{tickBar.Minimum}_Max_{tickBar.Maximum}{value}_IsDirectionReversed_{tickBar.IsDirectionReversed}{padding}_TickWidth_{tickBar.TickWidth}_StrokeThickness_{tickBar.StrokeThickness}{tickFrequency}{ticks}{orientation}.png"
                   .Replace(" ", "_"));
        }
Beispiel #3
0
        private static void SaveImage(LinearTickBar tickBar)
        {
            var size = tickBar.Placement == TickBarPlacement.Left || tickBar.Placement == TickBarPlacement.Right
                ? new Size(10, 100)
                : new Size(100, 10);

            Directory.CreateDirectory(@"C:\Temp\LinearTickBar");
            tickBar.SaveImage(size, $@"C:\Temp\LinearTickBar\{GetFileName(tickBar)}");
        }
Beispiel #4
0
        public void Render(TestCase testCase)
        {
            var tickBar = new LinearTickBar
            {
                StrokeThickness     = testCase.StrokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                Value               = testCase.Value,
                TickFrequency       = testCase.TickFrequency,
                Ticks               = testCase.Ticks,
                TickWidth           = testCase.TickWidth,
                Stroke              = Brushes.Black,
                Fill                = Brushes.Red,
                Placement           = testCase.Placement,
                IsDirectionReversed = testCase.IsDirectionReversed,
                Padding             = testCase.Padding,
            };

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }