About ActiveSegmentPair( How do I write a program of ActiveSegmentPair?)

Hello,
How do I write a program of ActiveSegmentPair?
I would like to get the Source segment and Target segment which are active( are edited) in the editor view.
And I would like to write the Target segment which was edited in my form.
I wrote the code in Visual Studio as follows, errors(red wavy lines) are indicated.
//--------------------------------------------------------------------
private void Form1_Shown(object sender, EventArgs e)
        {
            ISegmentPair activeSegmentPair = document.ActiveSegmentPair;
            IAbstractMarkupData markupData = activeSegmentPair.Target.Find(IsIText); // IsItext is a function: bool IsItext(IAbstractMarkupData x) { return x is IText; }
            IText targetText = markupData as IText;
            if (targetText != null)
            {
                targetText.Properties.Text = activeSourceText.ToString();
            }
            ------------
            ISegmentPair activeSegmentPair = document.ActiveSegmentPair;
            document.ProcessSegmentPairs("Copy Source to Target", (sp, args) =>
            {
            if (sp.Properties.Id.Id == activeSegmentPair.Properties.Id.Id)
            {
                foreach (IAbstractMarkupData targetMarkupData in sp.Target)
                {
                    var targetText = targetMarkupData as IText;
                    if (targetText != null)
                    {
                        targetText.Properties.Text = activeSourceText.ToString();
                    }
                }
            }
            );
}