예제 #1
0
 public void LoadFromFieldValue(NumericFieldValue value)
 {
     this.numericUpDown1.Minimum       = value.MyType.MinValue;
     this.numericUpDown1.Maximum       = value.MyType.MaxValue;
     this.numericUpDown1.DecimalPlaces = value.MyType.DecimalPlaces;
     this.numericUpDown1.Increment     = value.MyType.Increment;
     this.numericUpDown1.Value         = value.Value;
     _value = value;
 }
예제 #2
0
        private static void getMinAndMaxForGraphicsLayer(GraphicsLayer graphicsLayer, FieldInfo attributeField, out double min, out double max)
        {
            min = double.NaN;
            max = double.NaN;
            if (graphicsLayer != null && attributeField != null && !string.IsNullOrEmpty(attributeField.Name))
            {
                foreach (Graphic g in graphicsLayer.Graphics)
                {
                    object o;
                    if (g.Attributes.TryGetValue(attributeField.Name, out o))
                    {
                        if (o == null)
                        {
                            continue;
                        }
                        double            value;
                        NumericFieldValue numericFieldValue = o as NumericFieldValue;
                        if (numericFieldValue != null)
                        {
                            o = numericFieldValue.Value;
                        }
                        else
                        {
                            CurrencyFieldValue currencyFieldValue = o as CurrencyFieldValue;
                            if (currencyFieldValue != null)
                            {
                                o = currencyFieldValue.Value;
                            }
                        }

                        if (double.TryParse(
                                string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", o),
                                System.Globalization.NumberStyles.Any,
                                System.Globalization.CultureInfo.InvariantCulture, out value))
                        {
                            if (double.IsNaN(min)) // first value
                            {
                                min = value;
                            }
                            else
                            {
                                min = Math.Min(min, value);
                            }

                            if (double.IsNaN(max)) // first value
                            {
                                max = value;
                            }
                            else
                            {
                                max = Math.Max(max, value);
                            }
                        }
                    }
                }
            }
            if (double.IsNaN(min))
            {
                min = 0d;
            }
            if (double.IsNaN(max))
            {
                max = 0d;
            }
        }