Exemple #1
0
 /// <summary>
 /// Add an array data element.
 /// </summary>
 /// <param name="parentNode">parent node that contains this new node</param>
 /// <param name="at">position before which the new node is inserted</param>
 public void addArrayTypeNode(DataNode parentNode, int at, bool defineType)
 {
     FormArray formArray = new FormArray();
     if (!defineType)
     {
         formArray.Text = "Build an array element";
         formArray.ChangeLabel("Var Name:");
         formArray.TypeName = "myArray-" + Convert.ToString(parentNode.Nodes.Count);	//TODO: check for duplicate names
     }
     else
     {
         formArray.TypeName = "MyArray-" + Convert.ToString(++typeArrayCounter_);
     }
     formArray.DataTypeSource = document_.getTypeNames();
     DialogResult r = formArray.ShowDialog(view_);
     if (r == DialogResult.OK)
     {
         string varName = formArray.TypeName;
         string arrayType = formArray.ArrayTypeName;
         ArrayNode an = new ArrayNode(arrayType, (defineType)?"":varName);
         //if variable, add sizeRef
         if (formArray.ArrayType == 2)
         {
             AbstractNode data = new PrimitiveNode(formArray.SizeRef);
             an.setSizeRef( data );
         }
         AbstractNode aNode = an;
         if (defineType)
         {
             aNode = new DefineTypeNode(formArray.TypeName, an);
         }
         DataNode dn = new DataNode(aNode);
         addChildNode(dn, formArray.DataType, "");	//element data type as first child node of array
         if (formArray.ArrayType == 3) //arrayStreamed containing only one dim
         {
             //an.addDimension("", 0);
             addChildNode(dn, new DataNode(new DimNode("", 0)), 1);	//dim as second child node of array
         }
         else	//fixed or variable
         {
             DataNode tmpNode = dn;
             foreach (ListViewItem itm in formArray.getDimensions())
             {
                 string scount = itm.Text;
                 string sdimname = itm.SubItems[1].Text;
                 if (!scount.Equals(""))
                 {
                     //DataNode dNode = new DataNode(an.addDimension(sdimname, scount));
                     DataNode dNode = new DataNode(new DimNode(sdimname, scount));
                     addChildNode(tmpNode, dNode, 1);
                     tmpNode = dNode;
                 }
             }
         }
         addChildNode(parentNode, dn, at);
         document_.setModified();
         parentNode.ExpandAll();
     }
 }
Exemple #2
0
        /// <summary>
        /// Add an array data element.
        /// </summary>
        /// <param name="parentNode">parent node that contains this new node</param>
        /// <param name="at">position before which the new node is inserted</param>
        public void addArrayTypeNode(DataNode parentNode, int at, bool defineType)
        {
            FormArray formArray = new FormArray();

            if (!defineType)
            {
                formArray.Text = "Build an array element";
                formArray.ChangeLabel("Var Name:");
                formArray.TypeName = "myArray-" + Convert.ToString(parentNode.Nodes.Count);                     //TODO: check for duplicate names
            }
            else
            {
                formArray.TypeName = "MyArray-" + Convert.ToString(++typeArrayCounter_);
            }
            formArray.DataTypeSource = document_.getTypeNames();
            DialogResult r = formArray.ShowDialog(view_);

            if (r == DialogResult.OK)
            {
                string    varName   = formArray.TypeName;
                string    arrayType = formArray.ArrayTypeName;
                ArrayNode an        = new ArrayNode(arrayType, (defineType)?"":varName);
                //if variable, add sizeRef
                if (formArray.ArrayType == 2)
                {
                    AbstractNode data = new PrimitiveNode(formArray.SizeRef);
                    an.setSizeRef(data);
                }
                AbstractNode aNode = an;
                if (defineType)
                {
                    aNode = new DefineTypeNode(formArray.TypeName, an);
                }
                DataNode dn = new DataNode(aNode);
                addChildNode(dn, formArray.DataType, "");     //element data type as first child node of array
                if (formArray.ArrayType == 3)                 //arrayStreamed containing only one dim
                {
                    //an.addDimension("", 0);
                    addChildNode(dn, new DataNode(new DimNode("", 0)), 1); //dim as second child node of array
                }
                else                                                       //fixed or variable
                {
                    DataNode tmpNode = dn;
                    foreach (ListViewItem itm in formArray.getDimensions())
                    {
                        string scount   = itm.Text;
                        string sdimname = itm.SubItems[1].Text;
                        if (!scount.Equals(""))
                        {
                            //DataNode dNode = new DataNode(an.addDimension(sdimname, scount));
                            DataNode dNode = new DataNode(new DimNode(sdimname, scount));
                            addChildNode(tmpNode, dNode, 1);
                            tmpNode = dNode;
                        }
                    }
                }
                addChildNode(parentNode, dn, at);
                document_.setModified();
                parentNode.ExpandAll();
            }
        }