private void btnSet_Click(object sender, System.EventArgs e) { if(lstAddresses.SelectedItems.Count == 0) return; uint addr = 0; ulong val = 0; lock(m_lockobj) { addr = Convert.ToUInt32(lstAddresses.SelectedItems[0].Text.Substring(2), 16); val = Convert.ToUInt64(lstAddresses.SelectedItems[0].SubItems[1].Text); } if(addr == 0) { txtMessages.Text = String.Format(Resources.ErrorInvalidAddressFormatString, lstAddresses.SelectedItems[0].Text);; return; } SetNext sn = new SetNext(false, addr, val); if(sn.ShowDialog(this) == DialogResult.OK) { lock(m_lockobj) { object obj = getValue(sn.Value); if(obj == null) { txtMessages.Text = Resources.ErrorFailedToConvert; return; } try { if(m_pm.SetValue(addr, obj)) txtMessages.Text = String.Format(Resources.ValueAtAddressSetFormatString, addr.ToString("X8"), sn.Value); else txtMessages.Text = String.Format(Resources.ErrorValueNotSetFormatString, m_pm.LastError); UpdateList(); } catch(System.Exception f) { txtMessages.Text = String.Format(Resources.ErrorSetValueFailedFormatString, f.Message); } } } else { txtMessages.Text = Resources.SetValueCanceled; } }
private void btnFindNext_Click(object sender, System.EventArgs e) { DisableUpdate(); SetNext sn = new SetNext(true, 0, 0); if(sn.ShowDialog(this) == DialogResult.OK) { lock(m_lockobj) { object obj = getValue(sn.Value); if(obj == null) { txtMessages.Text = Resources.ErrorFailedToConvert; goto Done; } txtMessages.Text = String.Format(Resources.SearchingForFormatString, sn.Value); ProgressBarWindow pb = new ProgressBarWindow(); pb.Owner = this; pb.Show(); try { UInt64 count = m_pm.FindNext(obj, pb); txtMessages.Text = String.Format(Resources.FindNextFoundFormatString, count); } catch(System.Exception f) { txtMessages.Text = String.Format(Resources.FindNextFailedFormatString, f.Message); } Thread.Sleep(500); pb.Hide(); pb.Close(); pb = null; UpdateList(); } } else { txtMessages.Text = Resources.FindNextCanceled; } Done: EnableUpdate(); }