Esempio n. 1
0
        public void Overflow(bool isDirectionReversed, double tickGap, double strokeThickness, string padding, string expected)
        {
            var tickBar = new AngularBlockBar
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                TickFrequency       = 1,
                TickGap             = tickGap,
                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());
        }
Esempio n. 2
0
        private static string GetFileName(AngularBlockBar tickBar)
        {
            if (DoubleUtil.AreClose(tickBar.Value, 0))
            {
                return("AngularBlockBar_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($@"AngularBlockBar{value}_IsDirectionReversed_{tickBar.IsDirectionReversed}{padding}_TickGap_{tickBar.TickGap}_TickShape_{tickBar.TickShape}_StrokeThickness_{tickBar.StrokeThickness}_Thickness_{thickness}{tickFrequency}{ticks}.png"
                   .Replace(" ", "_"));
        }
 public void MeasureOverride(string size, double minAngle, double maxAngle, double value, bool isDirectionReversed, string expected)
 {
     var bar = new AngularBlockBar
                       {
                           MinAngle = minAngle,
                           MaxAngle = maxAngle,
                           Minimum = 0,
                           Maximum = 100,
                           Value = value,
                           IsDirectionReversed = isDirectionReversed
                       };
     var availableSize = size.AsSize();
     var desiredSize = bar.MeasureOverride(availableSize);
     Assert.AreEqual(expected, desiredSize.ToString("F0"));
 }
Esempio n. 4
0
        public void RenderWithPadding(TestCase testCase)
        {
            var tickBar = new AngularBlockBar
            {
                StrokeThickness     = testCase.StrokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                Value               = testCase.Value,
                TickShape           = testCase.TickShape,
                TickFrequency       = testCase.TickFrequency,
                Ticks               = testCase.Ticks,
                Fill                = Brushes.Red,
                TickGap             = testCase.TickGap,
                Thickness           = testCase.Thickness,
                Stroke              = Brushes.Black,
                IsDirectionReversed = testCase.IsDirectionReversed,
                Padding             = testCase.Padding,
            };

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }
Esempio n. 5
0
 private static void SaveImage(AngularBlockBar tickBar)
 {
     Directory.CreateDirectory(@"C:\Temp\AngularBlockBar");
     tickBar.SaveImage(new Size(100, 100), $@"C:\Temp\AngularBlockBar\{GetFileName(tickBar)}");
 }