Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

Location:
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/ToolBox.Formatting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/ToolBox.Formatting/TextFormat.cs

    r2768 r4068  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Text;
    42
    5 namespace ToolBox.Formatting
    6 {
    7     [Serializable()]
    8     public enum TextFormat
    9     {
    10         // ------------------------------------------------------------------
    11         /// <summary>
    12         /// No formatting is applied.
    13         /// </summary>
    14         // ------------------------------------------------------------------
    15         String,
     3namespace ToolBox.Formatting {
     4  [Serializable()]
     5  public enum TextFormat {
     6    // ------------------------------------------------------------------
     7    /// <summary>
     8    /// No formatting is applied.
     9    /// </summary>
     10    // ------------------------------------------------------------------
     11    String,
    1612
    17         // ------------------------------------------------------------------
    18         /// <summary>
    19         /// Culturally aware currency format.
    20         /// </summary>
    21         // ------------------------------------------------------------------
    22         Currency,
     13    // ------------------------------------------------------------------
     14    /// <summary>
     15    /// Culturally aware currency format.
     16    /// </summary>
     17    // ------------------------------------------------------------------
     18    Currency,
    2319
    24         // ------------------------------------------------------------------
    25         /// <summary>
    26         /// Only supports integral numbers. Displays a string using decimal
    27         /// digits preceded by a minus sign if negative.
    28         /// </summary>
    29         // ------------------------------------------------------------------
    30         Decimal,
     20    // ------------------------------------------------------------------
     21    /// <summary>
     22    /// Only supports integral numbers. Displays a string using decimal
     23    /// digits preceded by a minus sign if negative.
     24    /// </summary>
     25    // ------------------------------------------------------------------
     26    Decimal,
    3127
    32         // ------------------------------------------------------------------
    33         /// <summary>
    34         /// Displays numbers in the form ±d.ddddddE±dd where d is a decimal
    35         /// digit.
    36         /// </summary>
    37         // ------------------------------------------------------------------
    38         ScientificNotation,
     28    // ------------------------------------------------------------------
     29    /// <summary>
     30    /// Displays numbers in the form ±d.ddddddE±dd where d is a decimal
     31    /// digit.
     32    /// </summary>
     33    // ------------------------------------------------------------------
     34    ScientificNotation,
    3935
    40         // ------------------------------------------------------------------
    41         /// <summary>
    42         /// Displays a series of decimal digits with a decimal point and
    43         /// additional digits.
    44         /// </summary>
    45         // ------------------------------------------------------------------
    46         FixedPoint,
     36    // ------------------------------------------------------------------
     37    /// <summary>
     38    /// Displays a series of decimal digits with a decimal point and
     39    /// additional digits.
     40    /// </summary>
     41    // ------------------------------------------------------------------
     42    FixedPoint,
    4743
    48         // ------------------------------------------------------------------
    49         /// <summary>
    50         /// Displays either as a fixed-point or scientific notation based
    51         /// on the size of the number.
    52         /// </summary>
    53         // ------------------------------------------------------------------
    54         General,
     44    // ------------------------------------------------------------------
     45    /// <summary>
     46    /// Displays either as a fixed-point or scientific notation based
     47    /// on the size of the number.
     48    /// </summary>
     49    // ------------------------------------------------------------------
     50    General,
    5551
    56         // ------------------------------------------------------------------
    57         /// <summary>
    58         /// Similar to fixed point but uses a separator character (such as ,)
    59         /// for groups of digits.
    60         /// </summary>
    61         // ------------------------------------------------------------------
    62         Number,
     52    // ------------------------------------------------------------------
     53    /// <summary>
     54    /// Similar to fixed point but uses a separator character (such as ,)
     55    /// for groups of digits.
     56    /// </summary>
     57    // ------------------------------------------------------------------
     58    Number,
    6359
    64         // ------------------------------------------------------------------
    65         /// <summary>
    66         /// Multiplies the number by 100 and displays with a percent symbol.
    67         /// </summary>
    68         // ------------------------------------------------------------------
    69         Percentage,
     60    // ------------------------------------------------------------------
     61    /// <summary>
     62    /// Multiplies the number by 100 and displays with a percent symbol.
     63    /// </summary>
     64    // ------------------------------------------------------------------
     65    Percentage,
    7066
    71         // ------------------------------------------------------------------
    72         /// <summary>
    73         /// Formats a floating-point number so that it can be successfully
    74         /// converted back to its original value.
    75         /// </summary>
    76         // ------------------------------------------------------------------
    77         RoundTrip,
     67    // ------------------------------------------------------------------
     68    /// <summary>
     69    /// Formats a floating-point number so that it can be successfully
     70    /// converted back to its original value.
     71    /// </summary>
     72    // ------------------------------------------------------------------
     73    RoundTrip,
    7874
    79         // ------------------------------------------------------------------
    80         /// <summary>
    81         /// Displays an integral number using the base-16 number system.
    82         /// </summary>
    83         // ------------------------------------------------------------------
    84         Hexadecimal
    85     }
     75    // ------------------------------------------------------------------
     76    /// <summary>
     77    /// Displays an integral number using the base-16 number system.
     78    /// </summary>
     79    // ------------------------------------------------------------------
     80    Hexadecimal
     81  }
    8682}
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/ToolBox.Formatting/TextFormatter.cs

    r2768 r4068  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Text;
    42
    5 namespace ToolBox.Formatting
    6 {
    7     public class TextFormatter
    8     {
    9         // ------------------------------------------------------------------
    10         /// <summary>
    11         /// Returns a string that's formatted using the specified format for
    12         /// the number specified.
    13         /// </summary>
    14         /// <param name="format">TextFormat</param>
    15         /// <param name="number">double</param>
    16         /// <param name="significantDigits">int</param>
    17         /// <returns>string</returns>
    18         // ------------------------------------------------------------------
    19         public static string Format(
    20             TextFormat format,
    21             double number,
    22             int significantDigits)
    23         {
    24             return Format(format, number.ToString(), significantDigits);
     3namespace ToolBox.Formatting {
     4  public class TextFormatter {
     5    // ------------------------------------------------------------------
     6    /// <summary>
     7    /// Returns a string that's formatted using the specified format for
     8    /// the number specified.
     9    /// </summary>
     10    /// <param name="format">TextFormat</param>
     11    /// <param name="number">double</param>
     12    /// <param name="significantDigits">int</param>
     13    /// <returns>string</returns>
     14    // ------------------------------------------------------------------
     15    public static string Format(
     16        TextFormat format,
     17        double number,
     18        int significantDigits) {
     19      return Format(format, number.ToString(), significantDigits);
     20    }
     21
     22    // ------------------------------------------------------------------
     23    /// <summary>
     24    /// Returns a string that's formatted using the specified format for
     25    /// the text specified.  If a format other than 'String' is specified,
     26    /// the text is first converted to a double, then the resultant string
     27    /// that represents the number in the specified format is returned.  If
     28    /// the conversion from the text to a double fails, no exception is
     29    /// thrown.  The supplied text is simply returned.
     30    /// </summary>
     31    /// <param name="format">TextFormat</param>
     32    /// <param name="text">string</param>
     33    /// <param name="significantDigits">int</param>
     34    /// <returns>string</returns>
     35    // ------------------------------------------------------------------
     36    public static string Format(
     37        TextFormat format,
     38        string text,
     39        int significantDigits) {
     40      double myNumber = double.MaxValue;
     41      string result = "";
     42
     43      // Only if the format specified isn't a string,
     44      // then try to convert the text to a number.  If the
     45      // conversion fails, just return the text.
     46      if (format != TextFormat.String) {
     47        try {
     48          myNumber = double.Parse(text);
    2549        }
     50        catch {
     51          return text;
     52        }
     53      }
    2654
    27         // ------------------------------------------------------------------
    28         /// <summary>
    29         /// Returns a string that's formatted using the specified format for
    30         /// the text specified.  If a format other than 'String' is specified,
    31         /// the text is first converted to a double, then the resultant string
    32         /// that represents the number in the specified format is returned.  If
    33         /// the conversion from the text to a double fails, no exception is
    34         /// thrown.  The supplied text is simply returned.
    35         /// </summary>
    36         /// <param name="format">TextFormat</param>
    37         /// <param name="text">string</param>
    38         /// <param name="significantDigits">int</param>
    39         /// <returns>string</returns>
    40         // ------------------------------------------------------------------
    41         public static string Format(
    42             TextFormat format,
    43             string text,
    44             int significantDigits)
    45         {
    46             double myNumber = double.MaxValue;
    47             string result = "";
     55      // Used for the number of sig digs.  For one sig dig, this
     56      // will be #.#.  For two sig digs, it'll be #.##.
     57      string sigDigIdentifier = "#";
    4858
    49             // Only if the format specified isn't a string,
    50             // then try to convert the text to a number.  If the
    51             // conversion fails, just return the text.
    52             if (format != TextFormat.String)
    53             {
    54                 try
    55                 {
    56                     myNumber = double.Parse(text);
    57                 }
    58                 catch
    59                 {
    60                     return text;
    61                 }
    62             }
     59      if (significantDigits > 0) {
     60        sigDigIdentifier = "#.";
     61        for (int i = 0; i < significantDigits; i++) {
     62          sigDigIdentifier += "#";
     63        }
     64      }
     65      switch (format) {
     66        case TextFormat.String:
     67          result = text;
     68          break;
    6369
    64             // Used for the number of sig digs.  For one sig dig, this
    65             // will be #.#.  For two sig digs, it'll be #.##.
    66             string sigDigIdentifier = "#";
     70        case TextFormat.Currency:
     71          result = String.Format("{0:c}", myNumber);
     72          break;
    6773
    68             if (significantDigits > 0)
    69             {
    70                 sigDigIdentifier = "#.";
    71                 for (int i = 0; i < significantDigits; i++)
    72                 {
    73                     sigDigIdentifier += "#";
    74                 }
    75             }
    76             switch (format)
    77             {
    78                 case TextFormat.String:
    79                     result = text;
    80                     break;
     74        case TextFormat.Decimal:
     75          result = String.Format("{0:d}", (int)myNumber);
     76          break;
    8177
    82                 case TextFormat.Currency:
    83                     result = String.Format("{0:c}", myNumber);
    84                     break;
     78        case TextFormat.FixedPoint:
     79          result = String.Format("{0:f}", myNumber);
     80          break;
    8581
    86                 case TextFormat.Decimal:
    87                     result = String.Format("{0:d}", (int)myNumber);
    88                     break;
     82        case TextFormat.General:
     83          result = String.Format("{0:g}", myNumber);
     84          break;
    8985
    90                 case TextFormat.FixedPoint:
    91                     result = String.Format("{0:f}", myNumber);
    92                     break;
     86        case TextFormat.Hexadecimal:
     87          result = String.Format("{0:x}", (int)myNumber);
     88          break;
    9389
    94                 case TextFormat.General:
    95                     result = String.Format("{0:g}", myNumber);
    96                     break;
     90        case TextFormat.Number:
     91          //result = String.Format("{0:n}", myNumber);
     92          result = myNumber.ToString(sigDigIdentifier);
     93          break;
    9794
    98                 case TextFormat.Hexadecimal:
    99                     result = String.Format("{0:x}", (int) myNumber);
    100                     break;
     95        case TextFormat.Percentage:
     96          result = String.Format("{0:p}", myNumber);
     97          break;
    10198
    102                 case TextFormat.Number:
    103                     //result = String.Format("{0:n}", myNumber);
    104                     result = myNumber.ToString(sigDigIdentifier);
    105                     break;
     99        case TextFormat.RoundTrip:
     100          result = String.Format("{0:r}", myNumber);
     101          break;
    106102
    107                 case TextFormat.Percentage:
    108                     result = String.Format("{0:p}", myNumber);
    109                     break;
     103        case TextFormat.ScientificNotation:
     104          //result = String.Format("{0:e}", myNumber);
     105          result = myNumber.ToString(sigDigIdentifier + "E+0");
     106          break;
    110107
    111                 case TextFormat.RoundTrip:
    112                     result = String.Format("{0:r}", myNumber);
    113                     break;
    114 
    115                 case TextFormat.ScientificNotation:
    116                     //result = String.Format("{0:e}", myNumber);
    117                     result = myNumber.ToString(sigDigIdentifier + "E+0");
    118                     break;
    119 
    120                 default: result = text;
    121                     break;
    122             }
    123             return result;
    124         }
     108        default: result = text;
     109          break;
     110      }
     111      return result;
    125112    }
     113  }
    126114}
Note: See TracChangeset for help on using the changeset viewer.