Example #1
0
        public static bool ChoosePoint(IDebuggerEnvironment env, ref double pointToExecute, SequenceWeightedOne seq)
        {
            do
            {
                ConsoleKeyInfo key = env.ReadKeyWithCancel();
                switch (key.KeyChar)
                {
                case 'e':
                    double num;
                    Console.Write("Enter point in interval series of sequence to show: ");
                    String numStr = Console.ReadLine();
                    if (double.TryParse(numStr, System.Globalization.NumberStyles.Float,
                                        System.Globalization.CultureInfo.InvariantCulture, out num))
                    {
                        if (num < 0.0 || num > seq.Numbers[seq.Numbers.Count - 1])
                        {
                            Console.WriteLine("You must specify a floating point number between 0.0 and " + seq.Numbers[seq.Numbers.Count - 1] + "!");
                            break;
                        }
                        pointToExecute = num;
                        return(false);
                    }
                    Console.WriteLine("You must enter a valid floating point number!");
                    break;

                case 's':
                case 'n':
                    return(true);

                default:
                    Console.WriteLine("Illegal choice (Key = " + key.Key
                                      + ")! Only (e)nter number and (s)/(n) to commit and continue allowed! ");
                    break;
                }
            }while(true);
        }
Example #2
0
 public double ChoosePoint(double pointToExecute, SequenceWeightedOne seq)
 {
     return(pointToExecute);
 }
Example #3
0
        private static void PrintSequenceWeightedOne(SequenceWeightedOne seqWeighted, Sequence parent, PrintSequenceContext context)
        {
            if (context.cpPosCounter >= 0)
            {
                PrintChoice(seqWeighted, context);
                ++context.cpPosCounter;
                Console.Write((seqWeighted.Choice ? "$%" : "$") + seqWeighted.OperatorSymbol + "(");
                bool first = true;
                for (int i = 0; i < seqWeighted.Sequences.Count; ++i)
                {
                    if (first)
                    {
                        Console.Write("0.00 ");
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                    PrintSequence(seqWeighted.Sequences[i], seqWeighted, context);
                    Console.Write(" ");
                    Console.Write(seqWeighted.Numbers[i]); // todo: format auf 2 nachkommastellen
                    first = false;
                }
                Console.Write(")");
                return;
            }

            bool highlight = false;

            foreach (Sequence seqChild in seqWeighted.Children)
            {
                if (seqChild == context.highlightSeq)
                {
                    highlight = true;
                }
            }
            if (highlight && context.choice)
            {
                WorkaroundManager.Workaround.PrintHighlighted("$%" + seqWeighted.OperatorSymbol + "(", HighlightingMode.Choicepoint);
                bool first = true;
                for (int i = 0; i < seqWeighted.Sequences.Count; ++i)
                {
                    if (first)
                    {
                        Console.Write("0.00 ");
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                    if (seqWeighted.Sequences[i] == context.highlightSeq)
                    {
                        WorkaroundManager.Workaround.PrintHighlighted(">>", HighlightingMode.Choicepoint);
                    }

                    Sequence highlightSeqBackup = context.highlightSeq;
                    context.highlightSeq = null; // we already highlighted here
                    PrintSequence(seqWeighted.Sequences[i], seqWeighted, context);
                    context.highlightSeq = highlightSeqBackup;

                    if (seqWeighted.Sequences[i] == context.highlightSeq)
                    {
                        WorkaroundManager.Workaround.PrintHighlighted("<<", HighlightingMode.Choicepoint);
                    }
                    Console.Write(" ");
                    Console.Write(seqWeighted.Numbers[i]); // todo: format auf 2 nachkommastellen
                    first = false;
                }
                WorkaroundManager.Workaround.PrintHighlighted(")", HighlightingMode.Choicepoint);
                return;
            }

            Console.Write((seqWeighted.Choice ? "$%" : "$") + seqWeighted.OperatorSymbol + "(");
            bool ffs = true;

            for (int i = 0; i < seqWeighted.Sequences.Count; ++i)
            {
                if (ffs)
                {
                    Console.Write("0.00 ");
                }
                else
                {
                    Console.Write(" ");
                }
                PrintSequence(seqWeighted.Sequences[i], seqWeighted, context);
                Console.Write(" ");
                Console.Write(seqWeighted.Numbers[i]); // todo: format auf 2 nachkommastellen
                ffs = false;
            }
            Console.Write(")");
        }