示例#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()));
        }
示例#2
0
        private void lbxVariables_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBoxItem     lbi = lbxVariables.SelectedItem as ListBoxItem;
            UI_EnumVariable var = lbi.Variable as UI_EnumVariable;

            lbxValues.Items.Clear();
            foreach (string s in var.Elements)
            {
                lbxValues.Items.Add(s);
            }
        }
示例#3
0
        protected override IBaseNode Clone()
        {
            UI_EnumVariable result = new UI_EnumVariable();

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

            result.Value    = Value;
            result.Elements = Elements;

            result.DataPersistence = DataPersistence.Clone();

            FinalizeClone(result);

            return(result);
        }