1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
/// <summary>
/// Insère un texte mis en forme après le range spécifié
/// </summary>
/// <param name="range">position</param>
/// <param name="value">texte à insérer</param>
/// <param name="text_color">couleur du texte à insérer</param>
/// <param name="size">taille du texte à insérer</param>
/// <param name="bold">gras (1)/ normal (0) pour le texte à insérer</param>
/// <param name="italic">italique (1) / normal (0) pour le texte à insérer</param>
/// <param name="alignment">alignement du paragraphe [0 gauche | 1 centré | 2 droite | 3 justifié ]</param>
private void AddFormatedTextAfter(Range range, string value, WdColor text_color = WdColor.wdColorBlack, int size = 11, int bold = 0, int italic = 0, int alignment = 0)
{
object save_pos = range.End - 1;
range.InsertAfter(value);
object current_pos = range.End - 1;
nvDoc.Range(save_pos, current_pos).Font.Color = text_color;
nvDoc.Range(save_pos, current_pos).Font.Size = size;
nvDoc.Range(save_pos, current_pos).Font.Bold = bold;
nvDoc.Range(save_pos, current_pos).Font.Italic = italic;
nvDoc.Range(save_pos, current_pos).ParagraphFormat.SpaceAfter = 1;
switch (alignment)
{
case 0:
nvDoc.Range(save_pos, current_pos).ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
break;
case 1:
nvDoc.Range(save_pos, current_pos).ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
break;
case 2:
nvDoc.Range(save_pos, current_pos).ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
break;
case 3:
nvDoc.Range(save_pos, current_pos).ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify;
break;
}
} |