Example #1
0
 /// <summary>
 /// Insert a useType node into the tree as the child node at the given position.
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="at"></param>
 public void addUseTypeNode(DataNode parentNode, int at)
 {
     if (document_.getDefinitions().count() <= 0)
     {
         MessageBox.Show("No user-defined type in the Definitions section.", "Warning");
         return;
     }
     FormData formData = new FormData();
     formData.DataTypeSource = document_.getUserDefinedTypeNames();
     DialogResult r = DialogResult.No;
     int vi = parentNode.Nodes.Count;
     do
     {
         string vn = "var-" + Convert.ToString(++vi);
         formData.VarName = vn;
         r = formData.ShowDialog(view_);
         if (r != DialogResult.Cancel)
         {
             string stype = formData.SelectedType;
             string svar = formData.VarName;
             UseTypeNode childNode = new UseTypeNode(stype, svar);
             addChildNode(parentNode, new DataNode(childNode), at++);
             document_.setModified();
         }
     } while (r == DialogResult.Yes);
 }
Example #2
0
 /// <summary>
 /// Insert a primitive data type node into the tree as the child node at the given position.
 /// </summary>
 /// <param name="parentNode">Parent node to insert a primitive node, can be StructNode or DatasetNode</param>
 /// <param name="at">Position before which the new node is to be inserted</param>
 public void addPrimitiveNode(DataNode parentNode, int at)
 {
     FormData formData = new FormData();
     formData.DataTypeSource = document_.getPrimitiveTypeNames();
     DialogResult r = DialogResult.No;
     int vi = parentNode.Nodes.Count;
     do
     {
         string vn = "var-" + Convert.ToString(++vi);
         formData.VarName = vn;
         r = formData.ShowDialog(view_);
         if (r != DialogResult.Cancel)
         {
             string stype = formData.SelectedType;
             string svar = formData.VarName;
             PrimitiveNode childNode = new PrimitiveNode(stype, svar);
             addChildNode(parentNode, new DataNode(childNode), at++);
             document_.setModified();
         }
     } while (r == DialogResult.Yes);
 }