public bool AddItem(BaseSnapshotItem obj, int id) { if (obj == null) { Debug.Warning("snapshots", "add null object"); return(false); } if (SnapshotItems.Count + 1 >= MaxItems) { Debug.Warning("snapshots", "too many items"); return(false); } var itemSize = SnapshotItemsInfo.GetSize(obj.GetType()); if (SnapshotSize + itemSize >= Snapshot.MaxSize) { Debug.Warning("snapshots", "too much data"); return(false); } var item = new SnapshotItem(id, obj); SnapshotSize += itemSize; SnapshotItems.Add(item); return(true); }
private void Add_Clicked(TrakHound_UI.Button bt) { var snapshot = new Controls.SnapshotItem(this); snapshot.SettingChanged += Snapshot_SettingChanged; snapshot.RemoveClicked += Snapshot_RemoveClicked; SnapshotItems.Add(snapshot); SettingChanged?.Invoke(null, null, null); }
public void LoadConfiguration(DataTable dt) { LoadGeneratedEventItems(dt); string address = "/GeneratedData/SnapShotData/"; string filter = "address LIKE '" + address + "*'"; DataView dv = dt.AsDataView(); dv.RowFilter = filter; DataTable temp_dt = dv.ToTable(); temp_dt.PrimaryKey = new DataColumn[] { temp_dt.Columns["address"] }; SnapshotItems.Clear(); foreach (DataRow row in temp_dt.Rows) { var snapshot = new Snapshot(); snapshot.Name = DataTable_Functions.TrakHound.GetRowAttribute("name", row); string type = DataTable_Functions.TrakHound.GetLastNode(row); if (type != null) { switch (type.ToLower()) { case "collected": snapshot.Type = SnapshotType.Collected; break; case "generated": snapshot.Type = SnapshotType.Generated; break; case "variable": snapshot.Type = SnapshotType.Variable; break; } } snapshot.Link = DataTable_Functions.TrakHound.GetRowAttribute("link", row); var item = new Controls.SnapshotItem(this, snapshot); item.SettingChanged += Snapshot_SettingChanged; item.RemoveClicked += Snapshot_RemoveClicked; SnapshotItems.Add(item); } if (!Loaded) { LoadCollectedItems(probeData); } }
public T NewItem <T>(int id) where T : BaseSnapshotItem, new() { if (SnapshotItems.Count + 1 >= MaxItems) { Debug.Warning("snapshots", "too many items"); return(null); } var itemSize = SnapshotItemsInfo.GetSize <T>(); if (SnapshotSize + itemSize >= Snapshot.MaxSize) { Debug.Warning("snapshots", "too much data"); return(null); } var item = new SnapshotItem(id, new T()); SnapshotSize += itemSize; SnapshotItems.Add(item); return((T)item.Item); }