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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Converters/PointConverter.cs

    r2768 r4068  
    11using System;
    2 using System.Collections.Generic;
    3 using System.Text;
    42using System.ComponentModel;
    53using System.Drawing;
    64using System.Globalization;
    7 namespace Netron.Diagramming.Core
    8 {
     5namespace Netron.Diagramming.Core {
     6  /// <summary>
     7  /// Type converter for a <see cref="Point"/> structure.
     8  /// </summary>
     9  public class PointConverter : TypeConverter {
    910    /// <summary>
    10     /// Type converter for a <see cref="Point"/> structure.
     11    /// Determines whether this instance can convert from the specified context.
    1112    /// </summary>
    12     public class PointConverter : TypeConverter
    13     {
    14         /// <summary>
    15         /// Determines whether this instance can convert from the specified context.
    16         /// </summary>
    17         /// <param name="context">The context.</param>
    18         /// <param name="t">The t.</param>
    19         /// <returns>
    20         ///   <c>true</c> if this instance [can convert from] the specified context; otherwise, <c>false</c>.
    21         /// </returns>
    22         public override bool CanConvertFrom(ITypeDescriptorContext context, Type t)
    23         {
    24             if(t == typeof(string))
    25             {
    26                 return true;
    27             }
    28             return base.CanConvertFrom(context, t);
     13    /// <param name="context">The context.</param>
     14    /// <param name="t">The t.</param>
     15    /// <returns>
     16    ///   <c>true</c> if this instance [can convert from] the specified context; otherwise, <c>false</c>.
     17    /// </returns>
     18    public override bool CanConvertFrom(ITypeDescriptorContext context, Type t) {
     19      if (t == typeof(string)) {
     20        return true;
     21      }
     22      return base.CanConvertFrom(context, t);
     23    }
     24    /// <summary>
     25    /// Converts the point to a string representation.
     26    /// </summary>
     27    /// <param name="context">The context.</param>
     28    /// <param name="culture">The culture.</param>
     29    /// <param name="value">The value.</param>
     30    /// <param name="destinationType">Type of the destination.</param>
     31    /// <returns></returns>
     32    public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
     33      if (value is Point) {
     34        Point point = (Point)value;
     35        return "(" + point.X + "," + point.Y + ")";
     36      }
     37      return base.ConvertTo(context, culture, value, destinationType);
     38
     39
     40    }
     41
     42    /// <summary>
     43    /// Converts the given object to the type of this converter, using the specified context and culture information.
     44    /// </summary>
     45    /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
     46    /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"></see> to use as the current culture.</param>
     47    /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
     48    /// <returns>
     49    /// An <see cref="T:System.Object"></see> that represents the converted value.
     50    /// </returns>
     51    /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
     52    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
     53      if (value is string) {
     54
     55        try {
     56          string thething = (string)value;
     57          //remove brackets if any
     58          thething = thething.Replace("(", "").Replace(")", "");
     59          //now we should have only a comma
     60          string[] parts = thething.Split(new char[] { ',' });
     61          return new Point(int.Parse(parts[0]), int.Parse(parts[1]));
    2962        }
    30         /// <summary>
    31         /// Converts the point to a string representation.
    32         /// </summary>
    33         /// <param name="context">The context.</param>
    34         /// <param name="culture">The culture.</param>
    35         /// <param name="value">The value.</param>
    36         /// <param name="destinationType">Type of the destination.</param>
    37         /// <returns></returns>
    38         public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
    39         {
    40             if(value is Point)
    41             {
    42                 Point point = (Point) value;
    43                 return "(" + point.X + "," + point.Y + ")";
    44             }
    45             return base.ConvertTo(context, culture, value, destinationType);
    46            
    47            
     63        catch (Exception) {
     64
     65          return Point.Empty;
    4866        }
     67      }
     68      return base.ConvertFrom(context, culture, value);
    4969
    50         /// <summary>
    51         /// Converts the given object to the type of this converter, using the specified context and culture information.
    52         /// </summary>
    53         /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
    54         /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"></see> to use as the current culture.</param>
    55         /// <param name="value">The <see cref="T:System.Object"></see> to convert.</param>
    56         /// <returns>
    57         /// An <see cref="T:System.Object"></see> that represents the converted value.
    58         /// </returns>
    59         /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
    60         public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    61         {
    62             if(value is string)
    63              {
    6470
    65                 try
    66                 {
    67                     string thething = (string) value;
    68                     //remove brackets if any
    69                     thething = thething.Replace("(", "").Replace(")", "");
    70                     //now we should have only a comma
    71                     string[] parts = thething.Split(new char[] { ',' });
    72                     return new Point(int.Parse(parts[0]), int.Parse(parts[1]));
    73                 }
    74                 catch(Exception)
    75                 {
    7671
    77                     return Point.Empty;
    78                 }
    79             }
    80             return base.ConvertFrom(context, culture, value);
    81            
    82            
    83            
    84         }
     72    }
    8573
    86         /// <summary>
    87         /// Returns whether this object supports properties, using the specified context.
    88         /// </summary>
    89         /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
    90         /// <returns>
    91         /// true if <see cref="M:System.ComponentModel.TypeConverter.GetProperties(System.Object)"></see> should be called to find the properties of this object; otherwise, false.
    92         /// </returns>
    93         public override bool GetPropertiesSupported(ITypeDescriptorContext context)
    94         {
    95             return true;
    96         }
     74    /// <summary>
     75    /// Returns whether this object supports properties, using the specified context.
     76    /// </summary>
     77    /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
     78    /// <returns>
     79    /// true if <see cref="M:System.ComponentModel.TypeConverter.GetProperties(System.Object)"></see> should be called to find the properties of this object; otherwise, false.
     80    /// </returns>
     81    public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
     82      return true;
     83    }
    9784
    98         /// <summary>
    99         /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes.
    100         /// </summary>
    101         /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
    102         /// <param name="value">An <see cref="T:System.Object"></see> that specifies the type of array for which to get properties.</param>
    103         /// <param name="attributes">An array of type <see cref="T:System.Attribute"></see> that is used as a filter.</param>
    104         /// <returns>
    105         /// A <see cref="T:System.ComponentModel.PropertyDescriptorCollection"></see> with the properties that are exposed for this data type, or null if there are no properties.
    106         /// </returns>
    107         public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
    108         {
    109             return TypeDescriptor.GetProperties(value, attributes);
    110         }
     85    /// <summary>
     86    /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes.
     87    /// </summary>
     88    /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that provides a format context.</param>
     89    /// <param name="value">An <see cref="T:System.Object"></see> that specifies the type of array for which to get properties.</param>
     90    /// <param name="attributes">An array of type <see cref="T:System.Attribute"></see> that is used as a filter.</param>
     91    /// <returns>
     92    /// A <see cref="T:System.ComponentModel.PropertyDescriptorCollection"></see> with the properties that are exposed for this data type, or null if there are no properties.
     93    /// </returns>
     94    public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
     95      return TypeDescriptor.GetProperties(value, attributes);
    11196    }
     97  }
    11298}
Note: See TracChangeset for help on using the changeset viewer.