Ejemplo n.º 1
0
 /*Funcion que marca el texto seleccionado con la etiqueta*/
 private void markupButtonTag_Click(object sender, EventArgs e)
 {
     Button senderMarkupButton = (Button)sender;
     String tagName = senderMarkupButton.Name;
     String openTag = "[" + senderMarkupButton.Name + "]";
     String closeTag = "[/" + senderMarkupButton.Name + "]";
     if (this.richTextBoxMarkup.SelectedText != "" && this.richTextBoxMarkup.SelectedText != null)
     {
         /*Creamos la apertura y cierre de etiqueta con color*/
         this.richTextBoxTemp.Clear();
         this.richTextBoxTemp.Font = new Font("Arial", 11, FontStyle.Regular);
         this.richTextBoxTemp.ForeColor = this.colors[indexColorTag];
         this.richTextBoxTemp.Text = openTag + closeTag;
         /*Insetamos la seleccion entre las etiquetas*/
         this.richTextBoxTemp.Select(openTag.Length, 0);
         this.richTextBoxTemp.SelectedRtf = this.richTextBoxMarkup.SelectedRtf;
         this.richTextBoxTemp.SelectAll();
         /*Si la etiqueta tiene atributos los editamos en caso contrario solo reemplazamos*/
         if (this.tags.getAttributes(tagName) != null)
         {
             this.editAttribute = EditAttribute.Instance;
             this.editAttribute.TagName = tagName;
             this.editAttribute.SelectedRtb.Rtf = this.richTextBoxTemp.SelectedRtf;
             this.editAttribute.startEditAttribute();
             this.editAttribute.ShowDialog();
             /*Reeplazamos*/
             this.richTextBoxMarkup.SelectedRtf = this.editAttribute.SelectedRtb.SelectedRtf;
         }
         else
         {
             this.richTextBoxMarkup.SelectedRtf = this.richTextBoxTemp.SelectedRtf;
         }
     }
 }
Ejemplo n.º 2
0
 private void buttonEditAttr_Click(object sender, EventArgs e)
 {
     String selectedTag = this.getSelectedTag();
     if (selectedTag == null || selectedTag == "")
     {
         int end = this.richTextBoxMarkup.Find(" ", this.richTextBoxMarkup.SelectionStart, RichTextBoxFinds.None);
         int start = this.richTextBoxMarkup.Find("[", 0, end, RichTextBoxFinds.Reverse) + 1;
         this.richTextBoxMarkup.Select(start, (end - start));
         selectedTag = this.richTextBoxMarkup.SelectedText.Trim();
     }
     if (selectedTag != null && this.tags.Dtd.FindElement(selectedTag) != null)
     {
         if (this.tags.getAttributes(selectedTag) != null)
         {
             this.selectTagContent(selectedTag);
             this.editAttribute = EditAttribute.Instance;
             this.editAttribute.TagName = selectedTag;
             this.editAttribute.SelectedRtb.Rtf = this.richTextBoxMarkup.SelectedRtf;
             this.editAttribute.startEditAttribute();
             /*Reeplazamos*/
             if (this.editAttribute.ShowDialog() == DialogResult.OK)
             {
                 this.richTextBoxMarkup.SelectedRtf = this.editAttribute.SelectedRtb.SelectedRtf;
             }
         }
         else
         {
             MessageBox.Show(Resources.ValidateMarkup_messageTagWithoutAttr);
         }
     }
     else
     {
         MessageBox.Show(Resources.ValidateMarkup_messageNoTagSelection);
     }
 }