Ejemplo n.º 1
0
        Range TrimRange(Range range, TextTrimDialog.Result result)
        {
            var index  = range.Start;
            var length = range.Length;

            Data.Trim(ref index, ref length, result.TrimChars, result.Start, result.End);
            if ((index == range.Start) && (length == range.Length))
            {
                return(range);
            }
            return(Range.FromIndex(index, length));
        }
Ejemplo n.º 2
0
        static string TrimString(string str, TextTrimDialog.Result result)
        {
            var start = 0;
            var end   = str.Length;

            if (result.Start)
            {
                while ((start < end) && (result.TrimChars.Contains(str[start])))
                {
                    ++start;
                }
            }
            if (result.End)
            {
                while ((start < end) && (result.TrimChars.Contains(str[end - 1])))
                {
                    --end;
                }
            }
            return(str.Substring(start, end - start));
        }
Ejemplo n.º 3
0
 void Command_Text_Select_Trim(TextTrimDialog.Result result) => SetSelections(Selections.AsParallel().AsOrdered().Select(range => TrimRange(range, result)).ToList());
Ejemplo n.º 4
0
 void Command_Text_Trim(TextTrimDialog.Result result) => ReplaceSelections(Selections.AsParallel().AsOrdered().Select(str => TrimString(GetString(str), result)).ToList());