//Plot a specific trace (specifiy by zero-based index)
        public void PlotTrace(int n)
        {
            double currentTime = CurrentSim.GetCurrentTime();


            StreamGeometry geo = new StreamGeometry();

            if (Traces[n].Value.VariableId != -1)
            {
                List <Point> points = new List <Point>();
                for (int i = 0; i > -CurrentSim.GetNumberOfTicks(); i--)
                {
                    Point point = GetPoint(CurrentSim.GetCurrentTime(i) - currentTime,
                                           CurrentSim.GetValueOfVar(Traces[n].Value.VariableId, i));
                    if (point.Y < 0)
                    {
                        point.Y = 0.1;
                    }
                    if (point.Y > TraceArea.ActualHeight)
                    {
                        point.Y = TraceArea.ActualHeight;
                    }
                    points.Add(point);

                    if (point.X < -120)
                    {
                        break;
                    }
                }
                TraceArea.SetTracePoints(n, points);
            }
        }
 //Delete all traces
 public void ResetAll()
 {
     TraceArea.Reset();
     for (int i = 0; i < MaxNumberOfTraces; i++)
     {
         Traces[i] = null;
     }
 }
 //Add a trace given name and variable ID
 //Returns a bool indicating success or failure
 //If successful a Trace struct will be set containing the ID
 public bool AddTrace(string name, int varId, ref Trace traceData)
 {
     for (int i = 0; i < MaxNumberOfTraces; i++)
     {
         if (!Traces[i].HasValue)
         {
             Trace t = new Trace(i, TraceColours[i], varId, name);
             traceData = t;
             Traces[i] = t;
             TraceArea.AddTrace(TraceColours[i]);
             return(true);
         }
     }
     return(false);
 }
 public TraceAreaViewModel(TraceArea TraceArea)
 {
     traceArea = TraceArea;
 }
 public TraceAreaViewModel(TraceArea TraceArea)
 {
     traceArea = TraceArea;
 }