Пример #1
0
        public void Overflow(bool isDirectionReversed, double tickWidth, double strokeThickness, string padding, string expected)
        {
            var tickBar = new AngularTickBar
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                TickFrequency       = 1,
                TickWidth           = tickWidth,
                Stroke              = Brushes.Black,
                Fill                = Brushes.Red,
                IsDirectionReversed = isDirectionReversed,
                Padding             = padding.AsThickness(),
            };

            var gauge = new AngularGauge {
                Content = tickBar
            };

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

            gauge.Measure(new Size(10, 10));
            gauge.Arrange(new Rect(new Size(10, 10)));
            Assert.AreEqual(expected, tickBar.Overflow.ToString());
            Assert.AreEqual(expected, gauge.ContentOverflow.ToString());
        }
Пример #2
0
        private static string GetFileName(AngularTickBar tickBar)
        {
            if (DoubleUtil.AreClose(tickBar.Value, 0))
            {
                return("AngularTickBar_Value_0.png");
            }

            var ticks = tickBar.Ticks != null
                ? $"_Ticks_{tickBar.Ticks.ToString(CultureInfo.InvariantCulture)}"
                : string.Empty;

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

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

            var value = double.IsNaN(tickBar.Value) ||
                        DoubleUtil.AreClose(tickBar.Value, tickBar.Maximum)
                ? string.Empty
                : $"_Value_{tickBar.Value}";
            var thickness = double.IsInfinity(tickBar.Thickness) ? "inf" : tickBar.Thickness.ToString(CultureInfo.InvariantCulture);

            return($@"AngularTickBar{value}_IsDirectionReversed_{tickBar.IsDirectionReversed}{padding}_TickWidth_{tickBar.TickWidth}_TickShape_{tickBar.TickShape}_StrokeThickness_{tickBar.StrokeThickness}_Thickness_{thickness}{tickFrequency}{ticks}.png"
                   .Replace(" ", "_"));
        }
Пример #3
0
        public void RenderWithPadding(TestCase testCase)
        {
            var tickBar = new AngularTickBar
            {
                StrokeThickness     = testCase.StrokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                Value               = testCase.Value,
                TickFrequency       = testCase.TickFrequency,
                TickShape           = testCase.TickShape,
                Ticks               = testCase.Ticks,
                Fill                = Brushes.Red,
                TickWidth           = testCase.TickWidth,
                Thickness           = testCase.Thickness,
                Stroke              = Brushes.Black,
                IsDirectionReversed = testCase.IsDirectionReversed,
                Padding             = testCase.Padding,
            };

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }
Пример #4
0
 private static void SaveImage(AngularTickBar tickBar)
 {
     Directory.CreateDirectory(@"C:\Temp\AngularTickBar");
     tickBar.SaveImage(new Size(100, 100), $@"C:\Temp\AngularTickBar\{GetFileName(tickBar)}");
 }