Example #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());
        }
Example #2
0
 internal static Vector GetDrawOffset(FormattedText formattedText, TickBarPlacement placement, double actualWidth, double actualHeight)
 {
     var offsetX = 0.0;
     var offsetY = 0.0;
     switch (placement)
     {
         case TickBarPlacement.Left:
             offsetX = 0;
             offsetY = -1 * formattedText.Height / 2;
             break;
         case TickBarPlacement.Top:
             offsetX = -1 * formattedText.Width / 2;
             offsetY = 0;
             break;
         case TickBarPlacement.Right:
             offsetX = -1 * formattedText.Width + actualWidth;
             offsetY = -1 * formattedText.Height / 2;
             break;
         case TickBarPlacement.Bottom:
             offsetX = -1 * formattedText.Width / 2;
             offsetY = actualHeight - formattedText.Height;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return new Vector(offsetX, offsetY);
 }
Example #3
0
        public void Overflow(TickBarPlacement placement, bool isDirectionReversed, double strokeThickness, PenLineCap startLineCap, PenLineCap endLineCap, string padding, string expected)
        {
            var tickBar = new LinearLineBar
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                Stroke              = Brushes.Black,
                StrokeStartLineCap  = startLineCap,
                StrokeEndLineCap    = endLineCap,
                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());
        }
 public void VerticalUpPoint(TickBarPlacement placement, string expected)
 {
     var textPositionOptions = new TextPositionOptions(  placement, TextOrientation.VerticalUp);
     var textSize = new Size(this.text.Width, this.text.Height);
     var textPosition = new TextPosition(textSize,textPositionOptions, new Point(0, 0), 0);
     Assert.AreEqual(expected, textPosition.Point.ToString("F0"));
 }
Example #5
0
        public void Overflow(TickBarPlacement placement, bool isDirectionReversed, double value, string expected)
        {
            var range = new LinearIndicator
            {
                Value = value,
                Style = StyleHelper.DefaultStyle <LinearIndicator>(),
            };

            var gauge = new LinearGauge
            {
                Minimum             = 0,
                Maximum             = 100,
                Value               = value,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Content             = range,
                Style               = StyleHelper.DefaultStyle <LinearGauge>(),
            };

            gauge.Arrange(new Rect(new Size(10, 10)));
            Assert.AreEqual(expected, gauge.ContentOverflow.ToString());
            Assert.AreEqual(expected, range.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, range.Overflow.ToString());
        }
Example #6
0
        public void Overflow(TickBarPlacement placement, bool isDirectionReversed, string padding, string expected)
        {
            var tickBar = new LinearTextBar
            {
                Minimum             = 0,
                Maximum             = 10,
                TickFrequency       = 1,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Padding             = padding.AsThickness(),
                FontFamily          = new FontFamily("Arial"), // Seoge UI is measured differently on Win 7 and Win 10 for some reason
                FontSize            = 12,
            };

            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());
        }
Example #7
0
        private static bool IsValidTickBarPlacement(object o)
        {
            TickBarPlacement placement = (TickBarPlacement)o;

            return(placement == TickBarPlacement.Left ||
                   placement == TickBarPlacement.Top ||
                   placement == TickBarPlacement.Right ||
                   placement == TickBarPlacement.Bottom);
        }
Example #8
0
 public TestCase(
     TickBarPlacement placement,
     bool isDirectionReversed,
     double value,
     double tickWidth,
     double strokeThickness,
     Thickness padding)
 {
     this.Placement           = placement;
     this.IsDirectionReversed = isDirectionReversed;
     this.Value           = value;
     this.TickWidth       = tickWidth;
     this.StrokeThickness = strokeThickness;
     this.Padding         = padding;
 }
Example #9
0
 public TestCase(
     TickBarPlacement placement,
     bool isDirectionReversed,
     HorizontalTextAlignment horizontalTextAlignment,
     VerticalTextAlignment verticalTextAlignment,
     double tickFrequency,
     DoubleCollection ticks,
     Thickness padding)
 {
     this.Placement           = placement;
     this.IsDirectionReversed = isDirectionReversed;
     this.TickFrequency       = tickFrequency;
     this.Ticks   = ticks;
     this.Padding = padding;
     this.HorizontalTextAlignment = horizontalTextAlignment;
     this.VerticalTextAlignment   = verticalTextAlignment;
 }
Example #10
0
        public void Render(TickBarPlacement placement, bool isDirectionReversed, double strokeThickness, double value, PenLineCap startLineCap, PenLineCap endLineCap, string padding)
        {
            var tickBar = new LinearLineBar
            {
                StrokeThickness     = strokeThickness,
                Minimum             = 0,
                Maximum             = 10,
                Stroke              = Brushes.Black,
                StrokeStartLineCap  = startLineCap,
                StrokeEndLineCap    = endLineCap,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Padding             = padding.AsThickness(),
                Value = value,
            };

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }
Example #11
0
 public TestCase(
     TickBarPlacement placement,
     bool isDirectionReversed,
     double value,
     double tickGap,
     double strokeThickness,
     double tickFrequency,
     DoubleCollection ticks,
     Thickness padding)
 {
     this.Placement           = placement;
     this.IsDirectionReversed = isDirectionReversed;
     this.Value           = value;
     this.TickGap         = tickGap;
     this.StrokeThickness = strokeThickness;
     this.TickFrequency   = tickFrequency;
     this.Ticks           = ticks;
     this.Padding         = padding;
 }
Example #12
0
        public Line(double actualWidth, double actualHeight, double reservedSpace, TickBarPlacement placement, bool isDirectionReversed)
        {
            Point p1;
            Point p2;

            switch (placement)
            {
            case TickBarPlacement.Left:
                p1 = new Point(0, actualHeight - (reservedSpace / 2));
                p2 = new Point(0, reservedSpace / 2);
                break;

            case TickBarPlacement.Top:
                p1 = new Point(reservedSpace / 2, 0);
                p2 = new Point(actualWidth - (reservedSpace / 2), 0);
                break;

            case TickBarPlacement.Right:
                p1 = new Point(actualWidth, actualHeight - (reservedSpace / 2));
                p2 = new Point(actualWidth, reservedSpace / 2);
                break;

            case TickBarPlacement.Bottom:
                p1 = new Point(reservedSpace / 2, actualHeight);
                p2 = new Point(actualWidth - (reservedSpace / 2), actualHeight);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(placement));
            }

            if (isDirectionReversed)
            {
                this.StartPoint = p2;
                this.EndPoint   = p1;
            }
            else
            {
                this.StartPoint = p1;
                this.EndPoint   = p2;
            }
        }
Example #13
0
        public void Render(TickBarPlacement placement, bool isDirectionReversed, double value, string padding)
        {
            var tickBar = new LinearDotBar
            {
                Minimum             = 0,
                Maximum             = 100,
                Value               = value,
                TickFrequency       = 25,
                Ticks               = new DoubleCollection(new double[] { 10, 20, 60 }),
                Fill                = Brushes.Red,
                Stroke              = Brushes.Black,
                StrokeThickness     = 1,
                TickDiameter        = 5,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Padding             = padding.AsThickness(),
            };

            ImageAssert.AreEqual(GetFileName(tickBar), tickBar);
        }
Example #14
0
        public void Render(TickBarPlacement placement, bool isDirectionReversed, double start, double end)
        {
            var range = new LinearRange
            {
                Background = Brushes.Black,
                Start      = start,
                End        = end,
            };

            var gauge = new LinearGauge
            {
                Minimum             = 0,
                Maximum             = 100,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Content             = range,
            };

            ImageAssert.AreEqual(GetFileName(range), gauge);
        }
Example #15
0
 protected virtual void OnPlacementChanged(TickBarPlacement placement)
 {
     switch (placement)
     {
         case TickBarPlacement.Left:
             this.PlacementTransform.Angle = 90;
             break;
         case TickBarPlacement.Top:
             this.PlacementTransform.Angle = 180;
             break;
         case TickBarPlacement.Right:
             this.PlacementTransform.Angle = -90;
             break;
         case TickBarPlacement.Bottom:
             this.PlacementTransform.Angle = 0;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Example #16
0
        public void Render(TickBarPlacement placement, bool isDirectionReversed, double value)
        {
            var range = new LinearIndicator
            {
                Value = value,
                Style = StyleHelper.DefaultStyle <LinearIndicator>(),
            };

            var gauge = new LinearGauge
            {
                Minimum             = 0,
                Maximum             = 100,
                Value               = value,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                Content             = range,
            };

            ImageAssert.AreEqual(GetFileName(range), gauge);
        }
Example #17
0
 public Line(double actualWidth, double actualHeight, double reservedSpace, TickBarPlacement placement, bool isDirectionReversed)
 {
     Point p1;
     Point p2;
     switch (placement)
     {
         case TickBarPlacement.Left:
             p1 = new Point(0, actualHeight - reservedSpace / 2);
             p2 = new Point(0, reservedSpace / 2);
             break;
         case TickBarPlacement.Top:
             p1 = new Point(reservedSpace / 2, 0);
             p2 = new Point(actualWidth - reservedSpace / 2, 0);
             break;
         case TickBarPlacement.Right:
             p1 = new Point(actualWidth, actualHeight - reservedSpace / 2);
             p2 = new Point(actualWidth, reservedSpace / 2);
             break;
         case TickBarPlacement.Bottom:
             p1 = new Point(reservedSpace / 2, actualHeight);
             p2 = new Point(actualWidth - reservedSpace / 2, actualHeight);
             break;
         default:
             throw new ArgumentOutOfRangeException("placement");
     }
     if (isDirectionReversed)
     {
         this.StartPoint = p2;
         this.EndPoint = p1;
     }
     else
     {
         this.StartPoint = p1;
         this.EndPoint = p2;
     }
 }
Example #18
0
        public void Render(TickBarPlacement placement, bool isDirectionReversed, double value)
        {
            var gauge = new LinearGauge
            {
                Minimum             = 0,
                Maximum             = 100,
                Value               = value,
                Placement           = placement,
                IsDirectionReversed = isDirectionReversed,
                MajorTickFrequency  = 25,
                MajorTicks          = new DoubleCollection {
                    15
                },
                MinorTickFrequency = 10,
                MinorTicks         = new DoubleCollection {
                    8
                },
                FontFamily = new FontFamily("Arial"), // Seoge UI is measured differently on Win 7 and Win 10 for some reason
                FontSize   = 12,
                Style      = StyleHelper.DefaultStyle <LinearGauge>(),
            };

            ImageAssert.AreEqual(GetFileName(gauge), gauge);
        }
Example #19
0
 public Line(Size size, double reservedSpace, TickBarPlacement placement, bool isDirectionReversed)
     : this(size.Width, size.Height, reservedSpace, placement, isDirectionReversed)
 {
 }
Example #20
0
 internal static bool IsHorizontal(this TickBarPlacement placement) => placement == TickBarPlacement.Top ||
 placement == TickBarPlacement.Bottom;
Example #21
0
 public Line(Size size, double reservedSpace, TickBarPlacement placement, bool isDirectionReversed)
     :this(size.Width, size.Height,reservedSpace, placement, isDirectionReversed)
 {
 }
Example #22
0
 public double Interpolate(Size size, Thickness padding, TickBarPlacement placement, bool isDirectionReversed) => placement.IsHorizontal()
     ? this.InterpolateHorizontal(size, padding, isDirectionReversed)
     : this.InterpolateVertical(size, padding, isDirectionReversed);
Example #23
0
        public static IntPtr Box_TickBarPlacement(TickBarPlacement val)
        {
            IntPtr ret = NoesisGUI_PINVOKE.Box_TickBarPlacement((int)val);

            return(ret);
        }
Example #24
0
        public static TickBarPlacement Unbox_TickBarPlacement(IntPtr val)
        {
            TickBarPlacement ret = (TickBarPlacement)NoesisGUI_PINVOKE.Unbox_TickBarPlacement(val);

            return(ret);
        }