Prod.: Engine, ver.: 6, ID: 60001607, HowTo : Is it possible to keep the history of the latest 20 points ?

HowTo : Is it possible to keep the history of the latest 20 points ?

Article60001607
TypeHowTo
ProductEngine
Version6
Date Added1/19/2012
Submitted byGizem Basturk
Keywords

Subject

Is it possible to keep the history of the latest 20 points ?

Summary

Is it possible to keep the history of the latest 20 points that the user input when a command (like cmdLine etc) was active ?

Solution

You need to create a Queue of gPoints in your application that is managed and filled in the FilterActionPoint event, like : In form load event define the event handler :
         Doc.FilterActionPoint += new vdDocument.FilterActionPointEventHandler(ActiveDocument_FilterActionPoint);
Define the Queue :
        Queue queue = new Queue(20);
And the code you need for the event:
        void ActiveDocument_FilterActionPoint(object sender, object action, ref gPoint pt)
        {
            if (queue.Contains(pt) || queue.Count>19) // keep only 20 gPoints in history
            {
               gPoint toPt = queue.Dequeue();
            }
            queue.Enqueue(pt);
        }
If you want to check the for debuging you can use a TextBox and fill it like :
            string str = "";
            gPoint[] array = new gPoint[queue.Count];

            // Copy the Queue to the int array.
            queue.CopyTo(array, 0);

            // Loop through and display the array in order.
            str += "Array:" + "\r\n";
            for (int i = 0; i < array.Length; i++)
            {
                str= str + i.ToString() + "  " + array[i].ToString()+"\r\n";
            }
            textBox1.Text = str;