void DataKey_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == -1 || (ArchiveMaintainer != null && ArchiveMaintainer.LoadingInitialData)) { return; } DataSetCollectionWrapper item = (DataSetCollectionWrapper)Items[e.Index]; lock (Palette.PaletteLock) { using (var thickPen = Palette.CreatePen(item.Sets[ArchiveInterval.FiveSecond].Uuid, Palette.PEN_THICKNESS_THICK)) { e.Graphics.DrawLine(thickPen, new Point(e.Bounds.Left + 2, e.Bounds.Top + e.Bounds.Height / 2), new Point(e.Bounds.Left + e.Bounds.Height - 4, e.Bounds.Top + e.Bounds.Height / 2)); } } int lineWidth = e.Bounds.Height; int width = Drawing.MeasureText(e.Graphics, Items[e.Index].ToString(), Font).Width; Rectangle textRect = new Rectangle(e.Bounds.Left + lineWidth, e.Bounds.Top, width, e.Bounds.Height); Drawing.DrawText(e.Graphics, Items[e.Index].ToString(), e.Font, textRect, e.ForeColor, e.BackColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter); width += lineWidth; if (HorizontalExtent < width) { HorizontalExtent = width; } }
protected override void OnSelectedValueChanged(EventArgs e) { if (LastValueSelected == (DataSetCollectionWrapper)SelectedItem) { return; } LastValueSelected = (DataSetCollectionWrapper)SelectedItem; base.OnSelectedValueChanged(e); }
private void DataKey_SelectedIndexChanged(object sender, EventArgs e) { if (SelectedSet != null) { SelectedSet.Selected = false; } SelectedSet = (DataSetCollectionWrapper)SelectedItem; if (SelectedSet != null) { SelectedSet.Selected = true; } }
/// <summary> /// Uses Sets (which is used for drawing) so must be on the event thread) /// </summary> public void UpdateItems() { Program.AssertOnEventThread(); if (DataPlot == null || DataPlot.DataPlotNav == null) { return; } List <DataSetCollectionWrapper> wrappers = new List <DataSetCollectionWrapper>(); for (int i = 0; i < ArchiveMaintainer.Archives[ArchiveInterval.FiveSecond].Sets.Count; i++) { DataSetCollectionWrapper wrapper = new DataSetCollectionWrapper(); DataSet fivesecond = ArchiveMaintainer.Archives[ArchiveInterval.FiveSecond].Sets[i]; if (!DataSourceUUIDsToShow.Contains(fivesecond.Uuid)) { continue; } Predicate <DataSet> uuidpredicate = new Predicate <DataSet>(delegate(DataSet item) { return(item.Uuid == fivesecond.Uuid); }); wrapper.Sets.Add(ArchiveInterval.FiveSecond, fivesecond); if (ArchiveMaintainer.Archives[ArchiveInterval.OneMinute].Sets.Contains(fivesecond)) { wrapper.Sets.Add(ArchiveInterval.OneMinute, ArchiveMaintainer.Archives[ArchiveInterval.OneMinute].Sets.Find(uuidpredicate)); } if (ArchiveMaintainer.Archives[ArchiveInterval.OneHour].Sets.Contains(fivesecond)) { wrapper.Sets.Add(ArchiveInterval.OneHour, ArchiveMaintainer.Archives[ArchiveInterval.OneHour].Sets.Find(uuidpredicate)); } if (ArchiveMaintainer.Archives[ArchiveInterval.OneDay].Sets.Contains(fivesecond)) { wrapper.Sets.Add(ArchiveInterval.OneDay, ArchiveMaintainer.Archives[ArchiveInterval.OneDay].Sets.Find(uuidpredicate)); } wrappers.Add(wrapper); } bool anynew = false; foreach (DataSetCollectionWrapper wrapper in wrappers) { if (!CurrentKeys.Contains(wrapper)) { CurrentKeys.Add(wrapper); anynew = true; } else if (CurrentKeys[CurrentKeys.IndexOf(wrapper)].Sets.Count < wrapper.Sets.Count) { CurrentKeys.Remove(wrapper); CurrentKeys.Add(wrapper); anynew = true; } } CurrentKeys.RemoveAll(new Predicate <DataSetCollectionWrapper>(delegate(DataSetCollectionWrapper item) { if (!wrappers.Contains(item)) { anynew = true; return(true); } return(false); })); if (!anynew) { Refresh(); // is this necessary return; } BeginUpdate(); try { Items.Clear(); foreach (DataSetCollectionWrapper key in CurrentKeys) { if (key.Show) { Items.Add(key); } } Sort(); } finally { EndUpdate(); Refresh(); } }
/// <summary> /// Uses Sets (which is used for drawing) so must be on the event thread) /// </summary> public void UpdateItems() { Program.AssertOnEventThread(); if (DataPlot == null || DataPlot.DataPlotNav == null) { return; } var wrappers = new List <DataSetCollectionWrapper>(); var archives = ArchiveMaintainer.Archives; var fiveSecSets = archives[ArchiveInterval.FiveSecond].Sets; foreach (DataSet fivesecond in fiveSecSets) { var wrapper = new DataSetCollectionWrapper(); if (!DataSourceUUIDsToShow.Contains(fivesecond.Uuid)) { continue; } wrapper.Sets.Add(ArchiveInterval.FiveSecond, fivesecond); var intervals = new[] { ArchiveInterval.OneMinute, ArchiveInterval.OneHour, ArchiveInterval.OneDay }; foreach (var interval in intervals) { var found = archives[interval].Sets.FirstOrDefault(s => s.Uuid == fivesecond.Uuid); if (found != null) { wrapper.Sets.Add(interval, found); } } wrappers.Add(wrapper); } bool anynew = false; foreach (DataSetCollectionWrapper wrapper in wrappers) { if (!CurrentKeys.Contains(wrapper)) { CurrentKeys.Add(wrapper); anynew = true; } else if (CurrentKeys[CurrentKeys.IndexOf(wrapper)].Sets.Count < wrapper.Sets.Count) { CurrentKeys.Remove(wrapper); CurrentKeys.Add(wrapper); anynew = true; } } CurrentKeys.RemoveAll(item => { if (!wrappers.Contains(item)) { anynew = true; return(true); } return(false); }); if (!anynew) { Refresh(); // is this necessary return; } BeginUpdate(); try { Items.Clear(); foreach (DataSetCollectionWrapper key in CurrentKeys) { if (key.Show) { Items.Add(key); } } Sort(); } finally { EndUpdate(); Refresh(); } }