public void AddMatchAndReplace(MatchAndReplace.MatchAndReplace matchAndReplace) { lstMatchReplace.Add(matchAndReplace); if (NewMatchAndReplace != null) NewMatchAndReplace(matchAndReplace); }
void data_NewMatchAndReplace(MatchAndReplace.MatchAndReplace matchAndReplace) { string typeMatch = string.Empty; if (matchAndReplace.replaceIncomming && matchAndReplace.replaceOutcomming) { typeMatch = "In/Out"; } else if (matchAndReplace.replaceIncomming) { typeMatch = "In"; } else { typeMatch = "Out"; } object[] row = new object[] { matchAndReplace.enabled, typeMatch, matchAndReplace.name, ASCIIEncoding.ASCII.GetString(matchAndReplace.match), ASCIIEncoding.ASCII.GetString(matchAndReplace.replace) }; dgvMatchAndReplace.Rows.Add(row); dgvMatchAndReplace.Rows[dgvMatchAndReplace.Rows.Count - 1].Tag = matchAndReplace; }
private void removeMatchReplace_Click(object sender, EventArgs e) { if (dgvMatchAndReplace.SelectedRows.Count == 0) { return; } // remove from data MatchAndReplace.MatchAndReplace match = (MatchAndReplace.MatchAndReplace)dgvMatchAndReplace.SelectedRows[0].Tag; Program.data.RemoveMatchAndReplace(match); // remove from gui dgvMatchAndReplace.Rows.Remove(dgvMatchAndReplace.SelectedRows[0]); }
private bool CreateMatch() { bool rIncomming = false; bool rOutcomming = false; string name = tbName.Text; if (cbType.Text.ToLower() == "In".ToLower()) { rIncomming = true; } else if (cbType.Text.ToLower() == "Out".ToLower()) { rOutcomming = true; } else { rIncomming = true; rOutcomming = true; } try { hbMatch.ByteProvider.ApplyChanges(); hbReplace.ByteProvider.ApplyChanges(); mStreamReplace.Seek(0, SeekOrigin.Begin); mStreamMatch.Seek(0, SeekOrigin.Begin); byte[] replace = new byte[mStreamReplace.Length]; byte[] match = new byte[mStreamMatch.Length]; mStreamMatch.Seek(0, SeekOrigin.Begin); mStreamReplace.Seek(0, SeekOrigin.Begin); mStreamReplace.Read(replace, 0, replace.Length); mStreamMatch.Read(match, 0, match.Length); returnedMatch = new MatchAndReplace.MatchAndReplace(name, match, replace, rIncomming, rOutcomming); } catch { return(false); } return(true); }
private bool CreateMatch() { bool rIncomming = false; bool rOutcomming = false; string name = tbName.Text; if (cbType.Text.ToLower() == "In".ToLower()) rIncomming = true; else if (cbType.Text.ToLower() == "Out".ToLower()) rOutcomming = true; else { rIncomming = true; rOutcomming = true; } try { hbMatch.ByteProvider.ApplyChanges(); hbReplace.ByteProvider.ApplyChanges(); mStreamReplace.Seek(0, SeekOrigin.Begin); mStreamMatch.Seek(0, SeekOrigin.Begin); byte[] replace = new byte[mStreamReplace.Length]; byte[] match = new byte[mStreamMatch.Length]; mStreamMatch.Seek(0, SeekOrigin.Begin); mStreamReplace.Seek(0, SeekOrigin.Begin); mStreamReplace.Read(replace, 0, replace.Length); mStreamMatch.Read(match, 0, match.Length); returnedMatch = new MatchAndReplace.MatchAndReplace(name, match, replace, rIncomming, rOutcomming); } catch { return false; } return true; }
public void RemoveMatchAndReplace(MatchAndReplace.MatchAndReplace matchAndReplace) { lstMatchReplace.Remove(matchAndReplace); }
private void btCancel_Click(object sender, EventArgs e) { returnedMatch = null; this.Close(); }