hello,
SO i have a user control with some properties, i use databindng in my program for change this properties :
Here a part of my user control :
public static readonly DependencyProperty ArcAngleProperty =
DependencyProperty.Register(nameof(ArcAngle), typeof(double), typeof(uc_CircularGaugeType1));
public double ArcAngle
{
get { return (double)this.GetValue(ArcAngleProperty); }
set { this.SetCurrentValue(ArcAngleProperty, value);
}
}
<ed:Arc Name="arc_value" ArcThickness="35" ArcThicknessUnit="Pixel" EndAngle="{Binding ElementName=root, Path=ArcAngle}" Fill="{Binding ElementName=root, Path=BackGroundColor}" Stretch="None" Stroke="#00000000" StartAngle="225" RenderTransformOrigin="0.5,0.5"/>
I use databinding in my main program like this :
ArcAngle="{Binding myValue}"
To here everything work good but i want to do is :
This ArcAngle is binded with value always between 0 and 100. I want remap this value to another. I use this funtion who work like a charm :
public static double MappingScaleDouble(double miniBase, double MaxiBase, double miniFinal, double maxiFinal, double value)
{
return miniFinal + (value - miniBase) * (maxiFinal - miniFinal) / (MaxiBase - miniBase);
}
So for example, if my user control is a 1/4 of circle (90°) gauge i will call :
MappingScaleDouble(0, 100, 0, 90, MyValue);
If MyValue is 50 (so 50%) my function return me 45. (50% of 90).
For a half of circle gauge (180°) : if MyValue is 50 my function return me 90. (50% of 180).
Is it possible to make this remap in my user control ?
Thanks in advance, I hope my ask is clear..
here what i have try without success (for an 90° gauge) :
public double ArcAngle
{
get { return (double)this.GetValue(ArcAngleProperty); }
set { this.SetCurrentValue(ArcAngleProperty, MappingScaleDouble(0,100,0,90, value));
}
}