/// <summary> /// Replaces all numbers in the given <paramref name="statText"/> with a regex capture group to build a regex pattern for matching /// the correct stat data text and returns a regex created from this pattern. /// </summary> /// <example> /// 60% chance for Poisons inflicted with this Weapon to deal 100% more Damage /// becomes /// (60|#)% chance for Poisons inflicted with this Weapon to deal (100|#)% more Damage /// </example> private static Regex GetStatDataTextRegex(string statText) { string regexString = NumberRegex.Replace(statText, match => $"({Regex.Escape(match.Value)}|{Regex.Escape(Placeholder)})"); const string monsterItemStatSuffix = @" \(×#\)"; string localSuffix = $@" \({Resources.LocalKeyword}\)"; return(new Regex($@"^([\+\-]?{regexString}({monsterItemStatSuffix}|(?<{localStatMatchGroupName}>{localSuffix}))?)$")); }
private void ZoomSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (ZoomSliderStartBox != null && ZoomSliderEndBox != null && ZoomSlider != null) //zoom slider changed value { if (NumberRegex.IsMatch(ZoomSliderStartBox.Text) && NumberRegex.IsMatch(ZoomSliderEndBox.Text)) //first check if the input is in the correct format { int start = int.Parse(ZoomSliderStartBox.Text); int end = int.Parse(ZoomSliderEndBox.Text); if (start >= 0 && start < GaitNumberOfFrames && end >= 0 && end < GaitNumberOfFrames && start < end) //then check if the range of frames is feasible { double sliderVal = ZoomSlider.Value; //will give an integer value between 0 and 100 int frame = Convert.ToInt32((end - start) * (sliderVal / 100) + start); //convert that number to an actual frame number and update with the new frame GaitCurrentFrame = frame; UpdateFrame(true); } } } }