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); }
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 void Prompt_Click(object data) { if (data is PromptText) { PromptText castedObject = data as PromptText; editor_pg.SelectedObject = castedObject; } else if (data is PromptMultiline) { PromptMultiline castedObject = data as PromptMultiline; editor_pg.SelectedObject = castedObject; } else if (data is PromptDate) { PromptDate castedObject = data as PromptDate; editor_pg.SelectedObject = castedObject; } else if (data is PromptCheckbox) { PromptCheckbox castedObject = data as PromptCheckbox; editor_pg.SelectedObject = castedObject; } else if (data is PromptUserDefined) { PromptUserDefined castedObject = data as PromptUserDefined; editor_pg.SelectedObject = castedObject; } else { AbstractPrompt castedObject = data as AbstractPrompt; editor_pg.SelectedObject = castedObject; } }
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); }
private void handleBeforePromptDelete(AbstractPrompt prompt) { if (String.IsNullOrEmpty(template.TemplateText)) { return; } string oldVariableName = prompt.VariableName; template.TemplateText = template.TemplateText.Replace(oldVariableName, ""); refreshTemplateText(); }
private void handlePromptRename(AbstractPrompt prompt, string newName) { string oldVariableName = prompt.VariableName; string newVariableName = prompt.GetVariableName(prompt.Parent, newName); template.TemplateText = template.TemplateText.Replace(oldVariableName, newVariableName); refreshTemplateText(); Object tObject = leftTabs_Properties.SelectedObject; TreeViewClickHandler.Prompt_Click(tObject); }
private void mnuPrompt_InsertVariable_Click(object sender, EventArgs e) { TreeNode node = leftTabs_DocumentTree.SelectedNode; try { Hashtable idPack = node.Tag as Hashtable; if ((string)idPack["Type"] == "prompt") { AbstractPrompt prompt = (AbstractPrompt)idPack["Data"]; insertIntoTemplateEditor(this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea, this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea.Caret.Offset, prompt.VariableName); } } catch { } }
private void mnuPrompt_CopyAs_Click(object sender, EventArgs e) { TreeNode node = leftTabs_DocumentTree.SelectedNode; try { Hashtable idPack = node.Tag as Hashtable; if ((string)idPack["Type"] == "prompt") { AbstractPrompt prompt = (AbstractPrompt)idPack["Data"]; prompt.Parent.AddPrompt(prompt.Clone()); refreshTreeView(); } } catch { } }
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(); }
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); } }
private void mnuPrompt_Delete_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"]; prompt.Remove(); refreshTreeView(); } } catch (Exception ex) { MessageBox.Show("Error creating prompt: " + ex.Message); } }
private void leftTabs_DocumentTree_MouseDoubleClick(object sender, MouseEventArgs e) { // Point where the mouse is clicked. Point p = new Point(e.X, e.Y); // Get the node that the user has clicked. TreeNode node = leftTabs_DocumentTree.GetNodeAt(p); try { Hashtable idPack = node.Tag as Hashtable; if ((string)idPack["Type"] == "prompt") { AbstractPrompt prompt = (AbstractPrompt)idPack["Data"]; insertIntoTemplateEditor(this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea, this.topTabs_TemplateEditor.ActiveTextAreaControl.TextArea.Caret.Offset, prompt.VariableName); } } catch { } }
public bool MoveUpPrompt(AbstractPrompt prompt) { bool isChanged = false; bool foundLower = false; _prompts.ForEach(delegate(AbstractPrompt p) { if (p.OrderKey == prompt.OrderKey - 1) { p.OrderKey = prompt.OrderKey; foundLower = true; } }); if (foundLower) { prompt.OrderKey = prompt.OrderKey - 1; isChanged = true; } return(isChanged); }
private void mnuPrompt_MoveUp_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.MoveUpPrompt(prompt)) { refreshTreeView(); } ; } } catch (Exception ex) { MessageBox.Show("Error reordering: " + ex.Message); } }
private void topTabs_TemplateEditor_DragDrop(object sender, DragEventArgs e) { TreeNode node = (TreeNode)e.Data.GetData(typeof(TreeNode)); ICSharpCode.TextEditor.TextArea textArea = (ICSharpCode.TextEditor.TextArea)sender; try { Hashtable idPack = node.Tag as Hashtable; switch (idPack["Type"] as string) { case "promptgroup": return; case "prompt": break; } //Build the variable to insert here AbstractPrompt prompt = idPack["Data"] as AbstractPrompt; Point p = textArea.PointToClient(new Point(e.X, e.Y)); textArea.BeginUpdate(); textArea.Document.UndoStack.StartUndoGroup(); int offset = textArea.Caret.Offset; if (e.Data.GetDataPresent(typeof(DefaultSelection))) { ISelection sel = (ISelection)e.Data.GetData(typeof(DefaultSelection)); if (sel.ContainsPosition(textArea.Caret.Position)) { return; } int len = sel.Length; textArea.Document.Remove(sel.Offset, len); if (sel.Offset < offset) { offset -= len; } } insertIntoTemplateEditor(textArea, offset, prompt.VariableName); } finally { textArea.Document.UndoStack.EndUndoGroup(); textArea.EndUpdate(); } }
public void AddPromptAfter(AbstractPrompt aNewPrompt, AbstractPrompt aPrompt) { aNewPrompt.Parent = this; aNewPrompt.OrderKey = aPrompt.OrderKey; int count = _prompts.Count; foreach (AbstractPrompt p in _prompts) { p.OrderKey = p.OrderKey - count; if (p == aPrompt) { break; } } _prompts.Add(aNewPrompt); renumberPrompts(); }
public static AbstractPrompt Parse(PromptGroup aParent, XmlElement anXmlElement) { AbstractPrompt tPrompt = producePrompt(aParent, anXmlElement); return(tPrompt); }
public void AddPrompt(AbstractPrompt aPrompt) { aPrompt.Parent = this; aPrompt.OrderKey = _prompts.Count + 1; _prompts.Add(aPrompt); }
public void RemovePrompt(AbstractPrompt aPrompt) { _prompts.Remove(aPrompt); renumberPrompts(); }