internal string ProcessText(string text, double delta) { var mode = GetMode(this); var minValue = GetMinimum(this); var maxValue = GetMaximum(this); switch (mode) { case SpecialMode.Number: { double value; if (!FlexibleParser.TryParseDouble(text, out value)) { return(null); } if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { delta *= 0.1; } if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { delta *= 10.0; } if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) { delta *= 2.0; } value += delta; value = Math.Max(Math.Min(value, maxValue), minValue); return(FlexibleParser.ReplaceDouble(text, value)); } case SpecialMode.Integer: #pragma warning disable 612 case SpecialMode.Positive: { #pragma warning restore 612 int value; if (!FlexibleParser.TryParseInt(text, out value)) { return(null); } if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { delta *= 10.0; } if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) { delta *= 2.0; } value = (int)Math.Max(Math.Min((int)(value + delta), maxValue), minValue); #pragma warning disable 612 if (mode == SpecialMode.Positive && value < 1) { #pragma warning restore 612 value = 1; } return(FlexibleParser.ReplaceDouble(text, value)); } case SpecialMode.IntegerOrLabel: #pragma warning disable 612 case SpecialMode.IntegerOrMinusOneLabel: case SpecialMode.IntegerOrZeroLabel: { #pragma warning restore 612 int value; var skip = !FlexibleParser.TryParseInt(text, out value); if (skip) { value = GetLabelValue(); } if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { delta *= 10.0; } if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) { delta *= 2.0; } value = (int)Math.Max(Math.Min((int)(value + delta), maxValue), minValue); var label = GetModeLabel(this); if (value == GetLabelValue() && label != null) { return(label); } return(skip ? value.ToString(CultureInfo.InvariantCulture) : FlexibleParser.ReplaceDouble(text, value)); } case SpecialMode.Time: { var splitted = text.Split(':'); int totalSeconds; switch (splitted.Length) { case 2: { int hours, minutes; if (!FlexibleParser.TryParseInt(splitted[0], out hours) || !FlexibleParser.TryParseInt(splitted[1], out minutes)) { return(null); } totalSeconds = (splitted[0].StartsWith(@"-") ? -1 : 1) * (Math.Abs(hours) * 60 + Math.Abs(minutes)) * 60; break; } case 3: { int hours, minutes, seconds; if (!FlexibleParser.TryParseInt(splitted[0], out hours) || !FlexibleParser.TryParseInt(splitted[1], out minutes) || !FlexibleParser.TryParseInt(splitted[2], out seconds)) { return(null); } totalSeconds = (splitted[0].StartsWith(@"-") ? -1 : 1) * (Math.Abs(hours) * 60 + Math.Abs(minutes)) * 60 + Math.Abs(seconds); break; } default: return(null); } if (!Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { delta *= 60; } if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift)) { delta *= 60; } if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) { delta *= 15; } if (double.IsNegativeInfinity(minValue)) { minValue = 0d; } totalSeconds += (int)delta; totalSeconds = (int)Math.Max(Math.Min(totalSeconds, maxValue), minValue); var t = Math.Abs(totalSeconds); return(splitted.Length == 2 ? $@"{(totalSeconds < 0 ? @"-" : "")}{t / 3600:D2}:{t / 60 % 60:D2}" : $@"{(totalSeconds < 0 ? @"-" : "")}{t / 3600:D2}:{t / 60 % 60:D2}:{t % 60:D2}"); } case SpecialMode.Version: { var splitted = text.Split('.'); var index = splitted.Length - 1; if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { index--; } if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { index--; } if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) { index--; } if (index < 0) { index = 0; } int value; if (FlexibleParser.TryParseInt(splitted[index], out value)) { splitted[index] = FlexibleParser.ReplaceDouble(splitted[index], value + delta); } return(string.Join(@".", splitted)); } default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } }