Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-6678 integer slider improvement. #15093

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Libraries/CoreNodeModelsWpf/SliderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ public T Value
if (value.CompareTo(model.Min) == -1)
model.Min = value;

if(value is IFormattable formattableval)
var stepValueString = model.Step.ToString();
var decimalPoints = 0;
if (stepValueString.Contains('.'))
{
decimalPoints = stepValueString.Substring(stepValueString.IndexOf('.') + 1).Length;
}

if (value is IFormattable formattableval)
{
var invariantString = formattableval.ToString(null,CultureInfo.InvariantCulture);
model.UpdateValue(new Dynamo.Graph.UpdateValueParams(nameof(Value), invariantString));
var sliderValue = Math.Round(decimal.Parse(invariantString), decimalPoints);
model.UpdateValue(new Dynamo.Graph.UpdateValueParams(nameof(Value), sliderValue.ToString()));
}
else
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone know in which case the else block here gets triggered? I am thinking if we should round the value there as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any. I believe int, float, double, long, are all IFormattable.

Expand Down
Loading