Beispiel #1
0
        public void Overflow(TickBarPlacement placement, bool isDirectionReversed, double tickWidth, double strokeThickness, string padding, string expected)
        {
            var tickBar = new LinearTick
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                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 void SaveImage(LinearTick tickBar)
        {
            var size = tickBar.Placement == TickBarPlacement.Left || tickBar.Placement == TickBarPlacement.Right
                ? new Size(10, 100)
                : new Size(100, 10);

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

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }
Beispiel #4
0
        private static string GetFileName(LinearTick tickBar)
        {
            var orientation = tickBar.Placement == TickBarPlacement.Left || tickBar.Placement == TickBarPlacement.Right
                ? "_Vertical"
                : "_Horizontal";

            if (double.IsNaN(tickBar.Value))
            {
                return($"LinearTick_Value_NaN{orientation}.png");
            }

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

            return($@"LinearTick_Min_{tickBar.Minimum}_Max_{tickBar.Maximum}_Value_{tickBar.Value}_IsDirectionReversed_{tickBar.IsDirectionReversed}{padding}_TickWidth_{tickBar.TickWidth}_StrokeThickness_{tickBar.StrokeThickness}{orientation}.png"
                   .Replace(" ", "_"));
        }