/// <summary> /// Create a TraceExampleItem and store it in a static dictionary. /// </summary> public static TraceExampleItem ByString(string description) { // See if there is data for this object is in trace. var traceId = TraceableObjectManager.GetObjectIdFromTrace(); TraceExampleItem item = null; int id; if (traceId == null) { // If there's no id stored in trace for this object, // then grab the next unused trace id. id = TraceableObjectManager.GetNextUnusedID(); // Create an item item = new TraceExampleItem(description); // Remember to store the updated object in the trace object manager, // so it's available to use the next time around. TraceableObjectManager.RegisterTraceableObjectForId(id, item); } else { // If there's and id stored in trace, then retrieve the object stored // with that id from the trace object manager. item = (TraceExampleItem)TraceableObjectManager.GetTracedObjectById(traceId.IntID) ?? new TraceExampleItem(description); // Update the item item.Description = description; } return(item); }
private PeriodicUpdateExample(double t, int id) { vertexCoords = new Point[width, length]; for (var x = 0; x < width; x += 1) { for (var y = 0; y < length; y += 1) { var z = Math.Sin(Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2)) - t); vertexCoords[x, y] = Point.ByCoordinates(x, y, z); } } t += 0.1; if (t > Math.PI * 2) { t = 0.0; } // Remember to store the updated object in the trace object manager, // so it's available to use the next time around. TraceableObjectManager.RegisterTraceableObjectForId(id, t); }
public static PeriodicUpdateExample PointField() { // See if the data for this object is in trace. var traceId = TraceableObjectManager.GetObjectIdFromTrace(); var t = 0.0; int id; if (traceId == null) { // If there's no id stored in trace for this object, // then grab the next unused trace id. id = TraceableObjectManager.GetNextUnusedID(); } else { // If there's and id stored in trace, then retrieve the object stored // with that id from the trace object manager. id = traceId.IntID; t = (double)TraceableObjectManager.GetTracedObjectById(traceId.IntID); } return(new PeriodicUpdateExample(t, id)); }