/// <summary> /// For pruning to work properly and efficiently, it is assumed that you are adding items in order of oldest to newest.<para /> /// Use a minutesToRetain greater than 0 to trim older SnapShots. /// </summary> public void AddSnapShot(DateTime timeStamp, int value, int minutesToRetain = 0) { for (int i = 0; i < SnapShots.Count; i++) { if (SnapShots[i].TimeStamp == timeStamp) { SnapShots[i] = new SnapShot <int>(timeStamp, SnapShots[i].Value + value); return; } } SnapShots.Add(new SnapShot <int>(timeStamp, value)); if (minutesToRetain > 0) { for (int i = 0; i < SnapShots.Count; i++) { if (DateTime.UtcNow - SnapShots[i].TimeStamp <= TimeSpan.FromMinutes(minutesToRetain)) { break; } SnapShots.RemoveAt(i); i--; } } }
protected void textBox_Validated(object sender, EventArgs e) { SceneNodHierachyModel node = _obj as SceneNodHierachyModel; if (node == null) return; TransformNode trans = node.TransformNode.GetCopy(); ObjImage after = new ObjImage { Trans = trans, Shape = null }; //if (_before == after) // return; SnapShots targetSnapShot = new SnapShots("PropertyPanal", _before, after, null); new SysEvn(0, this, OBJTYPE.Building, SYSEVN.Tool, new object[3] { "PropertyPanal", node, targetSnapShot } ); base.OnValidated(e); }
public void Add(SnapShotEntry entry) { SnapShots.Add(entry); this.Write(this.Filename); }