private void initializeForm()
        {
            this.r_DynamicParts.Clear();
            this.m_Template = CannedPost.StatusTextTemplate;
            foreach (string key in m_Template.Keys)
            {
                this.r_DynamicParts[key] = string.Format("{{{{{0}}}}}", key);
                Label newLable = new Label
                {
                    Visible = true,
                    Text = key + @":",
                    AutoSize = true
                };

                TextBox newTextbox = new TextBox
                {
                    Left = newLable.Width + 20,
                    Name = "TextBoxDynamic" + key,
                    Anchor = AnchorStyles.Right | AnchorStyles.Left,
                    Width = (int)tableLayoutDyamicNodes.ColumnStyles[1].Width
                };

                tableLayoutDyamicNodes.ColumnStyles[0].SizeType = SizeType.AutoSize;
                tableLayoutDyamicNodes.Controls.Add(newLable);
                tableLayoutDyamicNodes.Controls.Add(newTextbox);
                newTextbox.TextChanged += textBoxDynamic_TextChanged;
            }

            textBoxTemplate.Text = m_Template.Compile(this.r_DynamicParts);
        }
 public static Template Parse(string i_Input)
 {
     Template template = new Template();
     parseWithExistingTemplate(template, i_Input);
     return template;
 }
        /// <summary>
        /// Used for deserialization since the deserializer already created the <see cref="Template"/> object for us
        /// Assumes a new empty <see cref="Template"/> object
        /// </summary>
        private static void parseWithExistingTemplate(Template i_Template, string i_Input)
        {
            int currentInputIndex = 0;
            foreach (Match match in sr_DynamicSectionRegex.Matches(i_Input))
            {
                if (match.Index > currentInputIndex)
                {
                    i_Template.r_TextNodes.Add(new StaticTextNode(i_Input.Substring(currentInputIndex, match.Index - currentInputIndex)));
                }

                DynamicTextNode dynamicTextNode = new DynamicTextNode(match.Groups["name"].Value);
                if (!i_Template.r_DynamicTextNodes.ContainsKey(dynamicTextNode.Name))
                {
                    i_Template.r_DynamicTextNodes.Add(dynamicTextNode.Name, dynamicTextNode);
                }
                else
                {
                    dynamicTextNode = i_Template.r_DynamicTextNodes[dynamicTextNode.Name];
                }

                i_Template.r_TextNodes.Add(dynamicTextNode);
                currentInputIndex = match.Index + match.Length;
            }

            if (i_Input.Length > currentInputIndex)
            {
                i_Template.r_TextNodes.Add(new StaticTextNode(i_Input.Substring(currentInputIndex, i_Input.Length - currentInputIndex)));
            }
        }