private void ModifyFont(FontType fontType, bool applied, bool addUndo)
 {
     int startIndex = SelectedItems > 0 ? SelectionStartIndex : SelectionStartIndex + SelectedItems;
     int count = (SelectedItems > 0 ? SelectionStartIndex + SelectedItems : SelectionStartIndex) - startIndex;
     int[] oldFormats = formats.GetRange(startIndex, count).ToArray();
     for (int i = startIndex; i < startIndex + count; i++)
     {
         formats[i] = textManager.GetFormatIdForNewFont(formats[i], fontType);
     }
     if (addUndo)
     {
         TextFormatAction tfa = new TextFormatAction(this, startIndex, oldFormats, formats.GetRange(startIndex, count).ToArray());
         UndoManager.AddUndoAction(tfa);
     }
 }
 private void ModifyFormat(string format, bool applied, bool addUndo)
 {
     int startIndex = SelectedItems > 0 ? SelectionStartIndex : SelectionStartIndex + SelectedItems;
     int count = (SelectedItems > 0 ? SelectionStartIndex + SelectedItems : SelectionStartIndex) - startIndex;
     int[] oldFormats = formats.GetRange(startIndex, count).ToArray();
     for (int i = startIndex; i < startIndex + count; i++)
     {
         switch (format.ToLower())
         {
             case "underline":
                 formats[i] = textManager.GetFormatIdForNewUnderline(formats[i], applied);
                 break;
             case "bold":
                 formats[i] = textManager.GetFormatIdForNewWeight(formats[i], applied ? FontWeights.Bold : FontWeights.Normal);
                 break;
             case "italic":
                 formats[i] = textManager.GetFormatIdForNewStyle(formats[i], applied ? FontStyles.Italic : FontStyles.Normal);
                 break;
             default:
                 throw new ArgumentException("Incorrect value passed with font format change request."); ;
         }
     }
     if (addUndo)
     {
         TextFormatAction tfa = new TextFormatAction(this, startIndex, oldFormats, formats.GetRange(startIndex, count).ToArray());
         UndoManager.AddUndoAction(tfa);
     }
 }