void SetSessionIndexEvent(object sender, SetSessionIndexEventArgs e) { // An external form has changed the spectrum selection, update UI if (e.StartIndex == -1 && e.EndIndex == -1) { lbSession.ClearSelected(); return; } if (e.StartIndex >= lbSession.Items.Count || e.EndIndex >= lbSession.Items.Count || e.StartIndex < 0 || e.EndIndex < 0) return; lbSession.ClearSelected(); if (e.StartIndex < e.EndIndex) // Bizarre, but true { int tmp = e.StartIndex; e.StartIndex = e.EndIndex; e.EndIndex = tmp; } if (e.StartIndex == e.EndIndex) { int idx1 = lbSession.FindStringExact(session.Name + " - " + e.StartIndex.ToString()); if (idx1 != ListBox.NoMatches) lbSession.SetSelected(idx1, true); } else { int idx1 = lbSession.FindStringExact(session.Name + " - " + e.StartIndex.ToString()); int idx2 = lbSession.FindStringExact(session.Name + " - " + e.EndIndex.ToString()); for (int i = idx1; i < idx2; i++) { if (i == idx2 - 1) selectionRun = false; lbSession.SetSelected(i, true); if (i == idx1) selectionRun = true; } } }
private void pane_MouseClick(object sender, MouseEventArgs e) { if (session == null || bmpPane == null || WindowState == FormWindowState.Minimized) return; if (e.Button == MouseButtons.Left && SetSessionIndexEvent != null) { SetSessionIndexEventArgs args = new SetSessionIndexEventArgs(); if (ModifierKeys.HasFlag(Keys.Shift) && SelectedSessionIndex1 != -1) { args.StartIndex = SelectedSessionIndex1; args.EndIndex = Utils.ToArgb(bmpPane.GetPixel(e.X, bmpPane.Height - 1)); } else { args.StartIndex = args.EndIndex = Utils.ToArgb(bmpPane.GetPixel(e.X, bmpPane.Height - 1)); } SetSessionIndexEvent(this, args); } }
private void menuItemUnselect_Click(object sender, EventArgs e) { if (SetSessionIndexEvent != null) { SetSessionIndexEventArgs args = new SetSessionIndexEventArgs(); args.StartIndex = args.EndIndex = -1; SetSessionIndexEvent(this, args); } }
private void gmap_OnMarkerClick(GMapMarker item, MouseEventArgs e) { if (SetSessionIndexEvent != null) { SetSessionIndexEventArgs args = new SetSessionIndexEventArgs(); Spectrum s = (Spectrum)item.Tag; args.StartIndex = args.EndIndex = s.SessionIndex; SetSessionIndexEvent(this, args); } }