Round or Truncate the displayed values

Nov 29, 2010 at 4:12 PM

It's just a little improvement.

Maybe you can truncate or round up the majorTick label and Gauge value.

Something like this :

public static void OnGaugeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var gauge = d as Gauge;
            gauge.UpdateAngle();
            gauge.Value = Math.Round(gauge.Value, 2);
            if (!string.IsNullOrWhiteSpace(gauge.ValueFormat))
                gauge.ValueText.Text = string.Format(gauge.ValueFormat.Replace("{}",""), gauge.Value);
            else
                gauge.ValueText.Text = gauge.Value.ToString();
        }

...

Panel.SetZIndex(majorTick, 1);
                if (this.AutoScale)
                {
                    majorTick.Angle = (i * degreeIncrement) + this.StartAngle;
                    majorTick.Label = (i * labelIncrement).ToString(".##");
                }
                else
                {
                    majorTick.Angle = (i * degreeIncrement) + this.StartAngle;
                    majorTick.Label = ((i * labelIncrement) + this.MinValue).ToString(".##");
                }
                this.MajorTickMarks.Add(majorTick);
                DynamicLayout.Children.Add(majorTick);

And add an animation of the GoalMaker when the gauge value is changing.

Don't forget to remove the useless using, and check your dll with StyleCop and FXCop.

 

Great work,

 

Best regards.

Coordinator
Nov 29, 2010 at 8:30 PM

Hi,

Thanks for your feedback on the control.  It is very much appreciated and always welcome.  These are some good suggestions (especially the useless using and StyleCop/FxCop :) ).  I am not sure your first suggestion would be viable though, seeing as how some developers may want to display a value that has a precision which is higher than that that is hard-coded.  The round would have to be a dep. prop. so that it could be changed.  I think that, sue to this, it is far more flexible to allow the developer to manually apply this logic.  With the MajorTick markers this will be something that I look into.  Of course, the same flexibility would have to persist for those that wish not to round, or wish to round to a different precision.  None the less, this is an excellent suggestion, and one that I will definitely consider.  What type of animation were you thinking for the GoalMarker? 

Thanks!

Terry

Nov 30, 2010 at 8:29 AM

I have found an example of animation on this project : http://dashboarding.codeplex.com/

When the value changing, you can see the hand moving to the new value. It must only be enable if the AutoScall is False.

 

Coordinator
Nov 30, 2010 at 1:01 PM

I will take a look.

Thanks,

Terry