示例#1
0
        // Constructor
        /// <summary> Creates a child ElementItem from the XSD file. </summary>
        /// <param name="xsdNode"> The XmlNode from the XSD Functions file that represents this item. </param>
        /// <param name="parent"> The parent of this item. </param>
        /// <param name="isFunction"> [Optional] Note if this is a Function. </param>
        public ElementItem(XmlNode xsdNode, GroupItem parent, bool isFunction = false)
            : base(xsdNode, parent, isFunction)
        {
            // Check
            Debug.Assert(XsdParser.HasAttributes(xsdNode), "XSD Node '" + Name + "' had no attributes.");
            Debug.Assert(XsdParser.HasType(xsdNode), "XSD Node '" + Name + "' had no type.");

            _complexType = Structure.CreateComplexType(XsdParser.GetType(xsdNode));

            // Check
            Debug.Assert(_complexType != null, "Alternative: Structure.FindComplexType(xsdNode) Failed!");

            // Set the (default) selected type.
            SelectType(_complexType);

            // Create this item's control
            CreateGeneralControl(_complexType);
        }
示例#2
0
        public ComplexType DuplicateStructure()
        {
            var newElements = new List<ElementType>();

            if (Constant != null)
                newElements.Add(Constant.DuplicateStructure());
            if (Variable != null)
                newElements.Add(Variable.DuplicateStructure());
            if (Function != null)
                newElements.Add(Function.DuplicateStructure());
            if (Keyword != null)
                newElements.Add(Keyword.DuplicateStructure());
            if (Reference != null)
                newElements.Add(Reference.DuplicateStructure());

            var newComplexType = new ComplexType(Name, newElements);

            return newComplexType;
        }
示例#3
0
        private void CreateGeneralControl(ComplexType complexType)
        {
            var list = new List<CustomControlType>();

            // Possible Options
            List<string> typeOptions = complexType.GetTypeOptions();//Constant/Variable/Function
            List<string> unitOptions = null;                        //Constant/Variable
            List<string> xUnitOptions = null;                       //Variable
            List<string> functionOptions = null;                    //Function
            List<string> keyOptions = null;                         //Keyword
            // Reference Options cannot be gathered during XSD Load.//Reference

            // Default values
            var defaultValues = new Dictionary<CustomControlType, string>();
            string defaultUnitValue = null;
            string defaultXUnitValue = null;

            //Gather information for the controls creation
            unitOptions = complexType.GetUnitOptions();
            xUnitOptions = complexType.GetX_UnitOptions();
            functionOptions = complexType.GetFunctionNames();
            keyOptions = complexType.GetKeywordOptions();

            // Handle types selection on this element
            if (complexType.Constant != null)
            {
                list.Add(CustomControlType.Constant);
                defaultValues[CustomControlType.Constant] = complexType.Constant.DefaultValue;
                defaultUnitValue = complexType.Constant.DefaultUnit;
            }
            if (complexType.Variable != null)
            {
                list.Add(CustomControlType.Variable);
                defaultValues[CustomControlType.Variable] = complexType.Variable.DefaultValue;
                defaultUnitValue = complexType.Variable.DefaultUnit;
                defaultXUnitValue = complexType.Variable.DefaultXUnit;
            }
            if (complexType.Function != null)
            {
                list.Add(CustomControlType.Function);
            }
            if (complexType.Keyword != null)
            {
                list.Add(CustomControlType.Keyword);
                defaultValues[CustomControlType.Keyword] = complexType.Keyword.DefaultValue;
            }
            if (complexType.Reference != null)
            {
                list.Add(CustomControlType.Reference);
            }

            // Create the Controls for this ElementItem with the gathered information.
            Control = new GeneralControl(Name, IsRequired, Help, list,
                typeOptions, unitOptions, xUnitOptions, functionOptions, keyOptions,
                defaultValues, defaultUnitValue, defaultXUnitValue,
                ValidateAndSave, SaveVariable, SelectType, UnitChange, XUnitChange);
        }
示例#4
0
 /* PRIVATE METHODS */
 private void SelectType(ComplexType complexType)
 {
     if (complexType.Constant != null)
         SelectedType = complexType.Constant;
     else if (complexType.Variable != null)
         SelectedType = complexType.Variable;
     else if (complexType.Function != null)
         SelectedType = complexType.Function;
     else if (complexType.Keyword != null)
         SelectedType = complexType.Keyword;
     else if (complexType.Reference != null)
         SelectedType = complexType.Reference;
     else
         throw new Exception("ComplexType of item '" + Name + "' does not contain types.");
 }
示例#5
0
 public static void Add(ComplexType type)
 {
     _types.Add(type); _complexTypes.Add(type);
 }