Bonjour,

Je veux faire un plug-in dans VisualStudio pour le logiciel Antidote. Sauf qu'après application de ma correction, je perds ma sélection (Normal). Sauf qu'après la correction il faut que je retrouve le point d'origine de ma sélection.

J'ai essayé :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
   //Soit l'un des cas suivant :
   TextPoint point = selectionCourrante.ActivePoint;
   //ou
   TextPoint point = selectionCourrante.AnchorPoint;
   //ou
   TextPoint point = selectionCourrante.BottomPoint;
 
   selectionCourrante.MoveToPoint(point);
   _activeDocument.Selection.CharRight(true, comment.Length);

mais rien a faire je me retrouve toujours à la fin de l'ancienne sélection.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EnvDTE;
 
namespace Antidote.AddIns
{
   class CorrectSelectedText : ICorrectionStrategy
   {
      Document _activeDocument = null;
      public IDictionary<int, string> ReadComments(ProjectItem projectItem)
      {
         _activeDocument = projectItem.Document;
 
         Dictionary<int,string> comments = new Dictionary<int,string> ();
         comments.Add(0, _activeDocument.Selection.Text);
         return comments;
      }
 
      public void ApplyCorrection(int key, string comment)
      {
         TextSelection selectionCourrante = _activeDocument.Selection as TextSelection;
 
         if (selectionCourrante != null && selectionCourrante.Text.Length > 0)
            selectionCourrante.Text = comment;
 
         //À ce niveau je voudrais ré-appliquer la sélection à mon document
         //Début de mon ancienne sélection jusqu'à comment.Length
      }
   }
}
Merci de m'aider.