private void HandlePictureViewBoxSelectionChangeEvent(PictureViewBox pvb) { if (Control.ModifierKeys == Keys.None || m_lastSelected == null) { this.Select(PictureSelectionMode.None); pvb.Select(true); } else { if (Control.ModifierKeys.HasFlag(Keys.Shift)) { int indexOfLastSelected = this.Controls.IndexOf(m_lastSelected); int indexOfNextSelected = this.Controls.IndexOf(pvb); if (indexOfLastSelected < indexOfNextSelected) { for (int current_pvb_index = indexOfLastSelected + 1; current_pvb_index <= indexOfNextSelected; current_pvb_index++) { PictureViewBox current_pvb = (PictureViewBox)this.Controls[current_pvb_index]; current_pvb.Select(true); } } else { for (int current_pvb_index = indexOfLastSelected - 1; current_pvb_index >= indexOfNextSelected; current_pvb_index--) { PictureViewBox current_pvb = (PictureViewBox)this.Controls[current_pvb_index]; current_pvb.Select(true); } } } else if (Control.ModifierKeys.HasFlag(Keys.Control)) { pvb.Select(!pvb.IsSelected); } } m_lastSelected = pvb; }
public static PictureViewBox Create(string filePath) { PictureViewBox pvb = new PictureViewBox(); pvb.LoadPictureAsync(filePath); return pvb; }