Exemplo n.º 1
0
        private void DebugStep(object sender, DebugStepEventArgs e)
        {
            Paragraph oldData     = new Paragraph();
            TextRange oldDataText = new TextRange(oldData.ContentStart, oldData.ContentEnd);

            oldDataText.Text = e.OldData;
            new TextRange(oldDataText.Start.GetPositionAtOffset(e.ReplacementStart), oldDataText.Start.GetPositionAtOffset(e.ReplacementStart + e.OldReplacementLength))
            .ApplyPropertyValue(TextElement.BackgroundProperty, lightRed);
            Paragraph newData     = new Paragraph();
            TextRange newDataText = new TextRange(newData.ContentStart, newData.ContentEnd);

            newDataText.Text = e.NewData;
            new TextRange(newDataText.Start.GetPositionAtOffset(e.ReplacementStart), newDataText.Start.GetPositionAtOffset(e.ReplacementStart + e.NewReplacementLength))
            .ApplyPropertyValue(TextElement.BackgroundProperty, lightGreen);
            rtbData.Document.Blocks.Clear();
            rtbData.Document.Blocks.Add(oldData);
            rtbData.Document.Blocks.Add(newData);
            rtbProgram.Document.Blocks.Clear();
            foreach (Tuple <Regex, string> pair in (sender as RebelProgram).Pairs)
            {
                Paragraph regex = new Paragraph();
                regex.Inlines.Add(pair.Item1.ToString());
                Paragraph replacement = new Paragraph();
                replacement.Inlines.Add(pair.Item2);
                if (pair == e.ReplacementPair)
                {
                    regex.Inlines.FirstInline.Background       = lightRed;
                    replacement.Inlines.FirstInline.Background = lightGreen;
                }
                rtbProgram.Document.Blocks.Add(regex);
                rtbProgram.Document.Blocks.Add(replacement);
            }
            e.Continue          = stepContinue;
            btnStep.Visibility  = Visibility.Visible;
            btnRun.Visibility   = Visibility.Visible;
            btnPause.Visibility = Visibility.Collapsed;
            btnStop.Visibility  = Visibility.Collapsed;
        }
Exemplo n.º 2
0
 private void program_DebugStep(object sender, DebugStepEventArgs e)
 {
     Dispatcher.Invoke(new Action <object, DebugStepEventArgs>(DebugStep), sender, e);
 }