public Boolean RemovePromptGroup(PromptGroup aPromptGroup)
        {
            Boolean tRemoved = _promptGroups.Remove(aPromptGroup);

            renumberPromptGroups();
            return(tRemoved);
        }
Exemple #2
0
            public static PromptGroup Parse(Object aParent, XmlElement anXmlElement)
            {
                if (!(aParent is Template))
                {
                    throw new IllegalParentException("Illegal type! Expected instance of type: Template");
                }

                Template tParent = aParent as Template;

                String tName       = getRequiredAttribute(anXmlElement, "name");
                String tRepeatable = getRequiredAttribute(anXmlElement, "repeatable");
                String tMaxRepeats = getOptionalAttribute(anXmlElement, "maxRepeats", "");

                PromptGroup tPromptGroup = new PromptGroup();

                tPromptGroup.Name = tName;
                tPromptGroup.SetRepeatableFromString(tRepeatable);
                tPromptGroup.SetMaxRepeatsFromString(tMaxRepeats);

                //Process prompts
                foreach (XmlNode tNode in anXmlElement.ChildNodes)
                {
                    if (tNode is XmlElement)
                    {
                        XmlElement     tElement = tNode as XmlElement;
                        AbstractPrompt tPrompt  = AbstractPrompt.Factory.Parse(tPromptGroup, tElement);
                        tPromptGroup.AddPrompt(tPrompt);
                    }
                }

                return(tPromptGroup);
            }
Exemple #3
0
 public AbstractPrompt()
 {
     this.Name        = "PromptName";
     this.Description = "Description here";
     this.Parent      = null;
     this.OrderKey    = 0;
 }
Exemple #4
0
 private void mnuPromptGroup_MoveDown_Click(object sender, EventArgs e)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt prompt = (AbstractPrompt)idPack["Data"];
             if (prompt.Parent.MoveDownPrompt(prompt))
             {
                 refreshTreeView();
             }
         }
         else if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup promptGroup = (PromptGroup)idPack["Data"];
             if (promptGroup.Parent.MoveDownPromptGroup(promptGroup))
             {
                 refreshTreeView();
             }
         }
     } catch (Exception ex) {
         MessageBox.Show("Error moving down prompt group: " + ex.Message);
     }
 }
            public static AbstractPrompt Parse(PromptGroup aParent, XmlElement anXmlElement)
            {
                PromptText tPrompt = (PromptText)AbstractPrompt.Factory.CreateInstance(typeof(PromptText));

                parsePromptChildren(tPrompt, anXmlElement);

                return(tPrompt);
            }
Exemple #6
0
            private static AbstractPrompt producePrompt(PromptGroup aParent, XmlElement anXmlElement)
            {
                AbstractPrompt tPrompt      = null;
                String         tName        = null;
                String         tDescription = null;

                foreach (XmlNode tPromptNode in anXmlElement.ChildNodes)
                {
                    String tType = null;

                    if (tPromptNode.Name == "type")
                    {
                        tType = tPromptNode.InnerText;
                    }
                    else if (tPromptNode.Name == "name")
                    {
                        tName = tPromptNode.InnerText;
                    }
                    else if (tPromptNode.Name == "description")
                    {
                        tDescription = tPromptNode.InnerText;
                    }

                    if (tType == AbstractPrompt.FIELD_TEXT)
                    {
                        tPrompt = PromptText.Factory.Parse(aParent, anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_MULTILINE)
                    {
                        tPrompt = PromptMultiline.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_NUMBER)
                    {
                        tPrompt = PromptNumber.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_DATE)
                    {
                        tPrompt = PromptDate.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_CHECKBOX)
                    {
                        tPrompt = PromptCheckbox.Factory.Parse(anXmlElement);
                    }
                    else if (tType == AbstractPrompt.FIELD_USERDEFINED)
                    {
                        tPrompt = PromptUserDefined.Factory.Parse(anXmlElement);
                    }
                }

                if (tPrompt != null)
                {
                    tPrompt.Name        = tName;
                    tPrompt.Description = tDescription;
                }

                return(tPrompt);
            }
Exemple #7
0
        public Prompt(string name, PromptType type, string label, PromptGroup parent)
        {
            this.Name     = name;
            this.Type     = type;
            this.Parent   = parent;
            this.OrderKey = Parent.Count;

            this.Description  = "Description here";
            this.Hint         = "Hint here";
            this.Label        = "Label here";
            this.DefaultValue = "Default here";
        }
Exemple #8
0
 private void CreatePromptGroupHandler(Type aType)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup tPromptGroup = (PromptGroup)idPack["Data"];
             produceAndAddPrompt(tPromptGroup, aType, null);
         }
     } catch (Exception ex) {
         MessageBox.Show("Error creating prompt from PromptGroup menu: " + ex.Message);
     }
 }
Exemple #9
0
        private void produceAndAddPrompt(PromptGroup aPromptGroup, Type aType, AbstractPrompt aReferencePrompt)
        {
            AbstractPrompt newPrompt = AbstractPrompt.Factory.CreateInstance(aType);

            if (aReferencePrompt != null)
            {
                aPromptGroup.AddPromptAfter(newPrompt, aReferencePrompt);
            }
            else
            {
                aPromptGroup.AddPrompt(newPrompt);
            }
            refreshTreeView();
        }
Exemple #10
0
 private void CreatePromptHandler(Type aType)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "prompt")
         {
             AbstractPrompt tPrompt      = (AbstractPrompt)idPack["Data"];
             PromptGroup    tPromptGroup = tPrompt.Parent;
             produceAndAddPrompt(tPromptGroup, aType, tPrompt);
         }
     } catch (Exception ex) {
         MessageBox.Show("Error creating prompt from Prompt menu: " + ex.Message);
     }
 }
Exemple #11
0
        public static string GetVariableName(PromptGroup promptGroup, string promtName)
        {
            string variable = "";

            if (promptGroup.Repeatable)
            {
                variable  = "\r\n<#list " + promptGroup.Name + ".repeats as var>\r\n";
                variable += "${var." + promtName + "}\r\n";
                variable += "</#list>";
            }
            else
            {
                variable = "${" + promptGroup.Name + "." + promtName + "}";
            }
            return(variable);
        }
        public bool MoveUpPromptGroup(PromptGroup promptGroup)
        {
            bool isChanged  = false;
            bool foundLower = false;

            _promptGroups.ForEach(delegate(PromptGroup p) { if (p.OrderKey == promptGroup.OrderKey - 1)
                                                            {
                                                                p.OrderKey = promptGroup.OrderKey; foundLower = true;
                                                            }
                                  });
            if (foundLower)
            {
                promptGroup.OrderKey = promptGroup.OrderKey - 1;
                isChanged            = true;
            }
            return(isChanged);
        }
Exemple #13
0
 private void mnuPromptGroup_Delete_Click(object sender, EventArgs e)
 {
     try {
         TreeNode  node   = leftTabs_DocumentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup promptGroup = (PromptGroup)idPack["Data"];
             if (promptGroup.Parent.RemovePromptGroup(promptGroup))
             {
                 refreshTreeView();
             }
         }
     } catch (Exception ex) {
         MessageBox.Show("Error deleting prompt group: " + ex.Message);
     }
 }
 private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         TreeNode  node        = documentTree.SelectedNode;
         Hashtable idPack      = node.Tag as Hashtable;
         bool      foundHigher = false;
         if ((string)idPack["Type"] == "prompt")
         {
             Prompt prompt = (Prompt)idPack["Data"];
             prompt.Parent.ForEach(delegate(Prompt p) { if (p.OrderKey == prompt.OrderKey + 1)
                                                        {
                                                            p.OrderKey = prompt.OrderKey; foundHigher = true;
                                                        }
                                   });
             if (foundHigher)
             {
                 prompt.OrderKey = prompt.OrderKey + 1;
                 doc.Changed     = true;
                 updateFormTitle(doc.FileName);
                 refreshTreeView();
             }
         }
         else if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup promptGroup = (PromptGroup)idPack["Data"];
             promptGroup.Parent.ForEach(delegate(PromptGroup p) { if (p.OrderKey == promptGroup.OrderKey + 1)
                                                                  {
                                                                      p.OrderKey = promptGroup.OrderKey; foundHigher = true;
                                                                  }
                                        });
             if (foundHigher)
             {
                 promptGroup.OrderKey = promptGroup.OrderKey + 1;
                 doc.Changed          = true;
                 updateFormTitle(doc.FileName);
                 refreshTreeView();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error reordering: " + ex.Message);
     }
 }
 private void addPromptToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         TreeNode  node   = documentTree.SelectedNode;
         Hashtable idPack = node.Tag as Hashtable;
         if ((string)idPack["Type"] == "promptgroup")
         {
             PromptGroup promptGroup = (PromptGroup)idPack["Data"];
             promptGroup.Add(new Prompt("NewPrompt", Prompt.PromptType.TEXT, "", promptGroup));
             refreshTreeView();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error creating prompt: " + ex.Message);
     }
 }
        public void loadFromXML()
        {
            if (FormConfigXML == string.Empty)
            {
                throw new Exception("No form config xml found.");
            }
            XmlDocument root = new XmlDocument();

            root.InnerXml = FormConfigXML;

            XmlNode templateNode = (XmlNode)root.DocumentElement;

            if (templateNode is XmlElement)
            {
                foreach (XmlNode templateNodeChild in templateNode.ChildNodes)
                {
                    if (templateNodeChild is XmlElement)
                    {
                        if (templateNodeChild.Name == "name")
                        {
                            Name = templateNodeChild.InnerText;
                        }
                        if (templateNodeChild.Name == "description")
                        {
                            Description = templateNodeChild.InnerText;
                        }
                        //Process groups
                        if (templateNodeChild.Name == "promptgroups")
                        {
                            foreach (XmlNode groupNode in templateNodeChild.ChildNodes)
                            {
                                if (groupNode is XmlElement)
                                {
                                    XmlElement  tPromptGroupNode = groupNode as XmlElement;
                                    PromptGroup tPromptGroup     = PromptGroup.Factory.Parse(this, tPromptGroupNode);
                                    AddPromptGroup(tPromptGroup);
                                }
                            }
                        }
                    }
                }
            }
            root = null;
        }
 public void AddPromptGroup(PromptGroup aPromptGroup)
 {
     aPromptGroup.Parent   = this;
     aPromptGroup.OrderKey = _promptGroups.Count + 1;
     _promptGroups.Add(aPromptGroup);
 }
Exemple #18
0
        public static void PromptGroup_Click(object data)
        {
            PromptGroup castedObject = data as PromptGroup;

            editor_pg.SelectedObject = castedObject;
        }
Exemple #19
0
            public static AbstractPrompt Parse(PromptGroup aParent, XmlElement anXmlElement)
            {
                AbstractPrompt tPrompt = producePrompt(aParent, anXmlElement);

                return(tPrompt);
            }