Ejemplo n.º 1
0
 /// <summary>
 /// Handles the Click event of TextPropertiesButton object.
 /// </summary>
 private void TextPropertiesButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if visual editor has focused text
         OpenXmlTextProperties textProperties = VisualEditor.GetTextProperties();
         if (textProperties != null)
         {
             // show text properties form
             OpenXmlTextPropertiesForm textPropertiesForm = new OpenXmlTextPropertiesForm(VisualEditor.GetFontNames());
             textPropertiesForm.TextProperties = textProperties;
             if (textPropertiesForm.ShowDialog() == DialogResult.OK)
             {
                 // set text properties
                 textProperties = textPropertiesForm.GetChangedTextProperties();
                 if (textProperties != null)
                 {
                     VisualEditor.SetTextProperties(textProperties);
                 }
             }
             // set focus to the parent form
             Parent.FindForm().Owner.Focus();
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
        /// <summary>
        /// Returns the text properties, which contain changed properties.
        /// </summary>
        /// <returns>The text properties, which contain changed properties.</returns>
        public OpenXmlTextProperties GetChangedTextProperties()
        {
            OpenXmlTextProperties result = OpenXmlTextProperties.GetChanges(_intalTextProperties, _textProperties);

            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the SelectedIndexChanged event of FontNameComboBox object.
        /// </summary>
        private void FontNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_isUiUpdating)
            {
                // create text properties
                OpenXmlTextProperties textProperties = new OpenXmlTextProperties();
                textProperties.FontName = fontNameComboBox.Text;

                // set text properties for text
                VisualEditor.Actions.CreateSetTextProperties(textProperties).Execute();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the UI for specified text properties.
        /// </summary>
        /// <param name="textProperties">The text properties.</param>
        private void UpdateTextPropertiesUI(OpenXmlTextProperties textProperties)
        {
            OpenXmlTextProperties properties = textProperties ?? new OpenXmlTextProperties();

            if (properties.FontName != null)
            {
                SetFontName(properties.FontName);
            }
            else
            {
                fontNameComboBox.Text = "";
            }
            fontSizeComboBox.Text = properties.FontSize.HasValue ? properties.FontSize.ToString() : "";
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the UI.
        /// </summary>
        private void UpdateUI()
        {
            _isUiUpdating = true;

            TextRegionSymbol symbol = VisualEditor.FocusedTextSymbol;

            OpenXmlTextProperties textProperties = null;

            if (symbol != null)
            {
                textProperties = VisualEditor.GetTextProperties(symbol);
            }
            UpdateTextPropertiesUI(textProperties);

            _isUiUpdating = false;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the UI for specified text properties.
        /// </summary>
        /// <param name="textProperties">The text properties.</param>
        private void UpdateTextPropertiesUI(OpenXmlTextProperties textProperties)
        {
            OpenXmlTextProperties properties = textProperties ?? new OpenXmlTextProperties();

            changeBoldButton.Checked      = properties.IsBold ?? false;
            changeItalicButton.Checked    = properties.IsItalic ?? false;
            changeUnderlineButton.Checked = properties.IsUnderline ?? false;
            changeStrikeoutButton.Checked = properties.IsStrike ?? false;
            if (properties.VerticalAlignment.HasValue)
            {
                changeSubscriptButton.Checked   = properties.VerticalAlignment.Value == OpenXmlTextVerticalPositionType.Subscript;
                changeSuperscriptButton.Checked = properties.VerticalAlignment.Value == OpenXmlTextVerticalPositionType.Superscript;
            }
            else
            {
                changeSubscriptButton.Checked   = false;
                changeSuperscriptButton.Checked = false;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Handles the TextChanged event of FontSizeComboBox object.
        /// </summary>
        private void FontSizeComboBox_TextChanged(object sender, EventArgs e)
        {
            if (!_isUiUpdating)
            {
                try
                {
                    float value;
                    if (float.TryParse(fontSizeComboBox.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
                    {
                        // create text properties
                        OpenXmlTextProperties textProperties = new OpenXmlTextProperties();
                        textProperties.FontSize = value;

                        // set text properties for text
                        VisualEditor.Actions.CreateSetTextProperties(textProperties).Execute();
                    }
                }
                catch (Exception ex)
                {
                    DemosTools.ShowErrorMessage(ex);
                }
            }
        }