private bool UnlockTrophy(int trophyId, DateTime trophyTime, ListViewItem lvi) { if (trophyId == 0 && tconf.HasPlatinium && (GetCountBaseTrophiesAchieved() < baseGamaCount)) { MessageBox.Show(Properties.strings.CantUnloclPlatinumBeforOther); return(false); } if (ValidateSelectedDate(trophyTime)) { try { tpsn.PutTrophy(trophyId, tusr.trophyTypeTable[trophyId].Type, trophyTime); tusr.UnlockTrophy(trophyId, trophyTime); lvi.SubItems[4].Text = Properties.strings.yes; lvi.BackColor = Color.White; lvi.SubItems[6].Text = trophyTime.ToString(Properties.strings.DateFormatString); CompletionRates(); haveBeenEdited = true; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } } return(false); }
private void listViewEx1_DoubleClick(object sender, EventArgs e) { int trophyID = ((ListView)sender).SelectedItems[0].ImageIndex;// 在這裡imageid其實等於trophy ID ex 白金0號, 1... ListViewItem lvi = ((ListView)sender).SelectedItems[0]; if (tpsn[trophyID].HasValue && tpsn[trophyID].Value.IsSync) // 尚未同步的才可編輯 { MessageBox.Show(Properties.strings.SyncedTrophyCanNotEdit); } else if (tpsn[trophyID].HasValue) // 已經取得的獎杯,刪除之 { if (trophyID != 0 && (tpsn.Count == tusr.all_trophy_number)) { MessageBox.Show(Properties.strings.CantLoclPlatinumBeforOther); } else if (MessageBox.Show(Properties.strings.DeleteTrophyConfirm, Properties.strings.Delete, MessageBoxButtons.YesNo) == DialogResult.Yes) { tpsn.DeleteTrophyByID(trophyID); tusr.LockTrophy(trophyID); lvi.SubItems[4].Text = Properties.strings.no; lvi.BackColor = Color.LightGray; lvi.SubItems[6].Text = new DateTime(0).ToString(dtpForm.dateTimePicker1.CustomFormat); tusr.LockTrophy(trophyID); CompletionRates(); haveBeenEdited = true; } } else // nonget { if (trophyID == 0 && tconf.HasPlatinium && (tpsn.Count < baseGamaCount)) { MessageBox.Show(Properties.strings.CantUnloclPlatinumBeforOther); //if the ammount of unlcoked trophies >= baseGameCount it will also let you unlock platinium } else if (dtpForm.ShowDialog(this) == DialogResult.OK) { tpsn.PutTrophy(trophyID, tusr.trophyTypeTable[trophyID].Type, dtpForm.dateTimePicker1.Value); tusr.UnlockTrophy(trophyID, dtpForm.dateTimePicker1.Value); lvi.SubItems[4].Text = Properties.strings.yes; lvi.BackColor = ((ListView)sender).BackColor; lvi.SubItems[6].Text = dtpForm.dateTimePicker1.Value.ToString(dtpForm.dateTimePicker1.CustomFormat); tusr.UnlockTrophy(trophyID, dtpForm.dateTimePicker1.Value); CompletionRates(); haveBeenEdited = true; } } }