private void cmdGetMore_KeyPress(object sender, KeyPressEventArgs e) { //I think this only makes sence to use in Decades mode. if (radioYears.Checked) { return; } if (!radioDates.Checked) { return; } if (groupBoxImages.Controls.Count == 0) { return; } int numberKeyed; if (!int.TryParse(e.KeyChar.ToString(), out numberKeyed)) { if (e.KeyChar.ToString() == ".") { numberKeyed = -1; } else { return; } } int date; if (listBoxWorkingLabel.SelectedItem.ToString() == "No Label") { date = numberKeyed * 10; } else { int selectedDate; int.TryParse(listBoxWorkingLabel.SelectedItem.ToString(), out selectedDate); date = selectedDate + numberKeyed; } if (numberKeyed == -1) { date = 0; } PictureBox pictureBox = (PictureBox)groupBoxImages.Controls[0]; int imageID; String tag = pictureBox.Tag.ToString(); int.TryParse(tag.Substring(tag.Length - 12, 8), out imageID); groupBoxImages.Controls.Remove(pictureBox); ImagesDB.UpdateDate(imageID, date); }
private void HandlePictureBoxLeftClick(PictureBox pictureBox, bool allShown, bool skipCommand) { int imageID; String tag = pictureBox.Tag.ToString(); int.TryParse(tag.Substring(tag.Length - 12, 8), out imageID); groupBoxImages.Controls.Remove(pictureBox); if (skipCommand) { return; } String selectedCommand; if (allShown) { selectedCommand = listBoxLabelAllShown.SelectedItem.ToString(); } else { selectedCommand = listBoxClickList.SelectedItem.ToString(); } if (selectedCommand == "Delete") { //File.Delete(label); } else { if (radioDates.Checked) { int date; int.TryParse(selectedCommand, out date); if (radioDecades.Checked) { date = date - 1900; } if (selectedCommand == "No Label") { date = -1; } ImagesDB.UpdateDate(imageID, date); } } }