Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DebugEngine/Utils.cs @ 4909

Last change on this file since 4909 was 4909, checked in by epitzer, 13 years ago

Several GUI improvements (#47)

  • add icons and tool tips
  • add support for suspending the operator trace view
  • faster skipping of stack-only operations
  • remove log view and execution time view
File size: 1006 bytes
Line 
1using System;
2using System.Text;
3using System.Text.RegularExpressions;
4using HeuristicLab.Persistence.Auxiliary;
5
6namespace HeuristicLab.DebugEngine {
7  public static class Utils {
8    public static string TypeName(object obj) {
9      if (obj == null)
10        return "null";
11      return TypeNameParser.Parse(obj.GetType().ToString()).GetTypeNameInCode(true);
12    }
13    public static string Wrap(string text, int columns) {
14      StringBuilder sb = new StringBuilder();
15      Regex whitespace = new Regex("\\s");
16      int lineLength = 0;
17      foreach (var word in whitespace.Split(text)) {
18        if (lineLength + word.Length < columns) {
19          if (lineLength > 0) {
20            sb.Append(' ');
21            lineLength++;
22          }
23          sb.Append(word);
24          lineLength += word.Length;
25        } else {
26          sb.Append(Environment.NewLine).Append(word);
27          lineLength = word.Length;
28        }
29      }
30      return sb.ToString();
31    }
32  }
33}
Note: See TracBrowser for help on using the repository browser.