public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value == null)
     {
         return(null);
     }
     if (value is Point)
     {
         try
         {
             return(_pointConverter.ConvertToInvariantString(value));
         }
         catch
         {
         }
     }
     return(Binding.DoNothing);
 }
예제 #2
0
        private object ProcessGetValue(Type type, MemberInfo memInfo, object result)
        {
            if (type == typeof(string))
            {
                if (memInfo == null)
                {
                    return(result);
                }
                object[] olist = memInfo.GetCustomAttributes(XObjectHelper.XCDataAttributeType, false);
                if (olist == null || olist.Length < 1 || result == null)
                {
                    return(result);
                }

                XCDataAttribute attr = olist[0] as XCDataAttribute;
                if (attr == null || attr.EnableCData == false)
                {
                    return(result);
                }
                return("<![CDATA[" + result.ToString() + "]]>");
            }

            if (type == typeof(Color))
            {
                ColorConverter cc = new ColorConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Font))
            {
                FontConverter cc = new FontConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Point))
            {
                PointConverter cc = new PointConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Rectangle))
            {
                RectangleConverter cc = new RectangleConverter();
                return(cc.ConvertToInvariantString(result));
            }

            if (type == typeof(Size))
            {
                SizeConverter cc = new SizeConverter();
                return(cc.ConvertToInvariantString(result));
            }

            //if (type == typeof(Type))
            //{
            //    if (result == null) return "";
            //    return result.ToString();
            //}

            if (!XObjectHelper.IsXBaseType(type))
            {
                TypeConverter tc = TypeDescriptor.GetConverter(type);
                if (tc != null)
                {
                    return(tc.ConvertToInvariantString(result));
                }
            }

            return(result);
        }
예제 #3
0
 public static string PointToString(Point point)
 {
     return((string)_pc.ConvertToInvariantString(point));
 }