Exemplo n.º 1
0
            public override string DoConvertBackToString(object value, Type targetType, object parameter, CultureInfo culture)
            {
                ConverterPropertyData data = (ConverterPropertyData)parameter;

                if (value is string)
                {
                    if (string.IsNullOrWhiteSpace(value as string))
                    {
                        return("");
                    }
                    value = double.Parse(value as string);
                }
                if (value == null)
                {
                    return("");
                }
                switch (data.Conversion)
                {
                default:
                    return(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", value));

                case "SCREENX":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.XField, (double)value));

                case "SCREENY":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.YField, (double)value));

                case "SCREENW":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.WField, (double)value));

                case "SCREENH":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.HField, (double)value));
                }
            }
Exemplo n.º 2
0
            public override object DoConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                Logger.Trace(string.Format("{0} args: {1}", GetTraceInfo(), string.Join(", ", value, targetType, parameter, culture)));
                ConverterPropertyData data = (ConverterPropertyData)parameter;

                if (value is string)
                {
                    if (string.IsNullOrWhiteSpace(value as string))
                    {
                        return(null);
                    }
                    value = double.Parse(value as string, NumberStyles.Float, CultureInfo.InvariantCulture);
                }
                if (value == null)
                {
                    return(null);
                }
                switch (data.Conversion)
                {
                default:
                    return((double)value);

                case "SCREENX":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.XField, (double)value));

                case "SCREENY":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.YField, (double)value));

                case "SCREENW":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.WField, (double)value));

                case "SCREENH":
                    return(data.Window.ToSqfString(EditingSnap.FieldTypeEnum.HField, (double)value));
                }
            }
Exemplo n.º 3
0
            public override object DoConvertFromString(string value, Type targetType, object parameter, CultureInfo culture)
            {
                ConverterPropertyData data = (ConverterPropertyData)parameter;

                switch (data.Conversion)
                {
                default:
                    return(double.Parse(value));

                case "SCREENX":
                    return(data.Window.FromSqfString(EditingSnap.FieldTypeEnum.XField, value));

                case "SCREENY":
                    return(data.Window.FromSqfString(EditingSnap.FieldTypeEnum.YField, value));

                case "SCREENW":
                    return(data.Window.FromSqfString(EditingSnap.FieldTypeEnum.WField, value));

                case "SCREENH":
                    return(data.Window.FromSqfString(EditingSnap.FieldTypeEnum.HField, value));
                }
            }
Exemplo n.º 4
0
            public override object DoConvert(ConfigField value, Type targetType, object parameter, CultureInfo culture)
            {
                Logger.Trace(string.Format("{0} args: {1}", GetTraceInfo(), string.Join(", ", value, targetType, parameter, culture)));
                ConverterPropertyData data = (ConverterPropertyData)parameter;

                switch (data.Conversion)
                {
                default:
                    return(value.IsNumber ? value.Number : -1);

                case "SCREENX":
                    return(value.IsNumber ? value.Number : value.IsString && !string.IsNullOrWhiteSpace(value.String) ? data.Window.FromSqfString(EditingSnap.FieldTypeEnum.XField, value.String) : -1);

                case "SCREENY":
                    return(value.IsNumber ? value.Number : value.IsString && !string.IsNullOrWhiteSpace(value.String) ? data.Window.FromSqfString(EditingSnap.FieldTypeEnum.YField, value.String) : -1);

                case "SCREENW":
                    return(value.IsNumber ? value.Number : value.IsString && !string.IsNullOrWhiteSpace(value.String) ? data.Window.FromSqfString(EditingSnap.FieldTypeEnum.WField, value.String) : -1);

                case "SCREENH":
                    return(value.IsNumber ? value.Number : value.IsString && !string.IsNullOrWhiteSpace(value.String) ? data.Window.FromSqfString(EditingSnap.FieldTypeEnum.HField, value.String) : -1);
                }
            }