/// <summary>
 /// Handles the Click event of ParagraphPropertiesButton object.
 /// </summary>
 private void ParagraphPropertiesButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if visual editor has focused paragraph
         OpenXmlParagraphProperties paragraphProperties = VisualEditor.GetParagraphProperties();
         if (paragraphProperties != null)
         {
             // show paragraph properties form
             OpenXmlParagraphPropertiesForm paragraphPropertiesForm = new OpenXmlParagraphPropertiesForm();
             paragraphPropertiesForm.ParagraphProperties = paragraphProperties;
             if (paragraphPropertiesForm.ShowDialog() == DialogResult.OK)
             {
                 // set paragraph properties
                 paragraphProperties = paragraphPropertiesForm.GetChangedParagraphProperties();
                 if (paragraphProperties != null)
                 {
                     VisualEditor.SetParagraphProperties(paragraphProperties);
                 }
             }
             // set focus to parent form
             Parent.FindForm().Owner.Focus();
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
 /// <summary>
 /// Handles the Click event of ParagraphNumberingButton object.
 /// </summary>
 private void ParagraphNumberingButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if focused paragraph has numeration
         if (paragraphNumberingButton.Checked)
         {
             // remove numeration
             OpenXmlParagraphProperties paragraphProperties = new OpenXmlParagraphProperties();
             paragraphProperties.RemoveNumeration();
             VisualEditor.SetParagraphProperties(paragraphProperties);
         }
         else
         {
             // if visual editor has focused paragraph
             if (VisualEditor.GetParagraphProperties() != null)
             {
                 // set numeration properties
                 using (SetOpenXmlParagraphNumerationForm form = new SetOpenXmlParagraphNumerationForm(VisualEditor))
                 {
                     form.ShowDialog();
                 }
                 // set focus to parent form
                 Parent.FindForm().Owner.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
        /// <summary>
        /// Returns the paragraph properties, which contain changed properties.
        /// </summary>
        /// <returns>The paragraph properties, which contain changed properties.</returns>
        public OpenXmlParagraphProperties GetChangedParagraphProperties()
        {
            OpenXmlParagraphProperties result = OpenXmlParagraphProperties.GetChanges(_intalParagraphProperties, _paragraphProperties);

            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
 /// <summary>
 /// Updates the User Interface.
 /// </summary>
 private void UpdateUI()
 {
     numerationDefinitionsListBox.Items.Clear();
     if (_documentEditor.Numbering.Items != null)
     {
         foreach (DocxDocumentNumbering numbering in _documentEditor.Numbering.Items)
         {
             numerationDefinitionsListBox.Items.Add(numbering);
         }
         OpenXmlParagraphProperties paragraphProperties = _documentVisualEditor.GetParagraphProperties();
         if (paragraphProperties.Numeration != null)
         {
             numerationDefinitionsListBox.SelectedItem = paragraphProperties.Numeration;
         }
     }
 }
        /// <summary>
        /// Updates the UI.
        /// </summary>
        private void UpdateUI()
        {
            _isUiUpdating = true;

            TextRegionSymbol symbol = VisualEditor.FocusedTextSymbol;


            OpenXmlParagraphProperties paragraphProperties = null;

            if (symbol != null)
            {
                paragraphProperties = VisualEditor.GetParagraphProperties(symbol);
            }
            UpdateParagraphPropertiesUI(paragraphProperties);

            _isUiUpdating = false;
        }
 /// <summary>
 /// Updates the UI for specified paragraph properties.
 /// </summary>
 /// <param name="paragraphProperties">The paragraph properties.</param>
 private void UpdateParagraphPropertiesUI(OpenXmlParagraphProperties paragraphProperties)
 {
     paragraphProperties = paragraphProperties ?? new OpenXmlParagraphProperties();
     if (paragraphProperties.Justification.HasValue)
     {
         paragraphJBothButton.Checked   = paragraphProperties.Justification.Value == OpenXmlParagraphJustification.Both;
         paragraphJLeftButton.Checked   = paragraphProperties.Justification.Value == OpenXmlParagraphJustification.Left;
         paragraphJRightButton.Checked  = paragraphProperties.Justification.Value == OpenXmlParagraphJustification.Right;
         paragraphJCenterButton.Checked = paragraphProperties.Justification.Value == OpenXmlParagraphJustification.Center;
     }
     else
     {
         paragraphJBothButton.Checked   = false;
         paragraphJLeftButton.Checked   = false;
         paragraphJRightButton.Checked  = false;
         paragraphJCenterButton.Checked = false;
     }
     paragraphNumberingButton.Checked = paragraphProperties.Numeration != null;
 }