Example #1
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            List <string> result   = new List <string>();
            IBaseNode     baseNode = context.Instance as IBaseNode;

            IVariableDef variable = VariableDef(baseNode);

            if (variable != null)
            {
                switch (variable.VariableType)
                {
                case eVariableType.enumeration:
                    UI_EnumVariable enumVariable = variable as UI_EnumVariable;
                    result.AddRange(enumVariable.Elements);
                    break;

                case eVariableType.boolean:
                    result.Add(false.ToString());
                    result.Add(true.ToString());
                    break;

                case eVariableType.numeric:
                    UI_NumericVariable intVariable = variable as UI_NumericVariable;
                    if (intVariable.Sequence != 0)
                    {
                        if ((intVariable.Maximum - intVariable.Minimum) / intVariable.Sequence < 20)
                        {
                            for (decimal i = intVariable.Minimum; i <= intVariable.Maximum; i += intVariable.Sequence)
                            {
                                result.Add(i.ToString());
                            }
                        }
                    }
                    break;

                default:
                    result.Add(variable.Value);
                    break;
                }
            }
            else
            {
                IDomainObject domain = DomainObject(baseNode);
                if (domain != null)
                {
                    result.AddRange(domain.Methods.ToArray());
                }
                else
                {
                    return(base.GetStandardValues(context));
                }
            }

            return(new StandardValuesCollection(result.ToArray()));
        }
Example #2
0
        protected override IBaseNode Clone()
        {
            UI_NumericVariable result = new UI_NumericVariable();

            result.Tree        = Tree;
            result.Name        = Name;
            result.Description = _Description;

            result.Value    = Value;
            result.Minimum  = Minimum;
            result.Maximum  = Maximum;
            result.Sequence = Sequence;

            result.DataPersistence = DataPersistence.Clone();

            FinalizeClone(result);

            return(result);
        }