Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CamelCaseTextConverter.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Globalization;
5 using System.Text.RegularExpressions;
6 
7 namespace SiliconStudio.Presentation.ValueConverters
8 {
9  /// <summary>
10  /// This converter will format a CamelCase string by inserting spaces between words.
11  /// </summary>
12  public class CamelCaseTextConverter : OneWayValueConverter<CamelCaseTextConverter>
13  {
14  /// <inheritdoc/>
15  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16  {
17  if (value == null)
18  return null;
19 
20  string strVal = value.ToString();
21  return Regex.Replace(strVal, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
22  }
23  }
24 }
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
This converter will format a CamelCase string by inserting spaces between words.