Exemple #1
0
        public static GaugeViewModel Gradometer(GaugeUnit unit)
        {
            return(new GaugeViewModel()
            {
                Unit = unit,
                DisplayDirectionArrow = unit.NormalizedDifference,
                Precision = unit.Max * 0.005,
                Orientation = GaugeOrientation.Vertical,
                SetLabel = x =>
                {
                    if (unit.Max > 400)
                    {
                        return x % 100 == 0 ? x.ToString("###0", CultureInfo.InvariantCulture) : null;
                    }

                    return x % 5 == 0 ? x.ToString("N0", CultureInfo.InvariantCulture) : null;
                },
                PartitionSize = unit.Unit == GaugeUnit.UnitEnum.Mils ? 6.25 : 0.5,
                PartitionGroupSize = unit.Unit == GaugeUnit.UnitEnum.Mils ? 4 : 5,
                DisplayRange = unit.Unit == GaugeUnit.UnitEnum.Mils ? 200 : 10,
            });
        }
Exemple #2
0
        public static GaugeViewModel Compass(GaugeUnit unit)
        {
            return(new GaugeViewModel()
            {
                Unit = unit,
                DisplayDirectionArrow = unit.NormalizedDifference,
                Precision = unit.Max * 0.005,
                SetLabel = x =>
                {
                    double degree = (x + unit.Max) % unit.Max;

                    // ReSharper disable CompareOfFloatsByEqualityOperator
                    if (degree == 0)
                    {
                        return "N";
                    }

                    if (degree == 1.0 * unit.Max / 16)
                    {
                        return "NNE";
                    }

                    if (degree == 2.0 * unit.Max / 16)
                    {
                        return "NE";
                    }

                    if (degree == 3.0 * unit.Max / 16)
                    {
                        return "ENE";
                    }

                    if (degree == 4.0 * unit.Max / 16)
                    {
                        return "E";
                    }

                    if (degree == 5.0 * unit.Max / 16)
                    {
                        return "ESE";
                    }

                    if (degree == 6.0 * unit.Max / 16)
                    {
                        return "SE";
                    }

                    if (degree == 7.0 * unit.Max / 16)
                    {
                        return "SSE";
                    }

                    if (degree == 8.0 * unit.Max / 16)
                    {
                        return "S";
                    }

                    if (degree == 9.0 * unit.Max / 16)
                    {
                        return "SSW";
                    }

                    if (degree == 10.0 * unit.Max / 16)
                    {
                        return "SW";
                    }

                    if (degree == 11.0 * unit.Max / 16)
                    {
                        return "WSW";
                    }

                    if (degree == 12.0 * unit.Max / 16)
                    {
                        return "W";
                    }

                    if (degree == 13.0 * unit.Max / 16)
                    {
                        return "WNW";
                    }

                    if (degree == 14.0 * unit.Max / 16)
                    {
                        return "NW";
                    }

                    if (degree == 15.0 * unit.Max / 16)
                    {
                        return "NNW";
                    }

                    // ReSharper restore CompareOfFloatsByEqualityOperator
                    return null;
                },
                PartitionSize = unit.Unit == GaugeUnit.UnitEnum.Mils ? 5 : 0.5,
                DisplayRange = unit.Unit == GaugeUnit.UnitEnum.Mils ? 200 : 20,
            });
        }