I have a class that checks for bad words - on pressing the enter key or the button in the application it is running in it throws an alert that says it is a bad word. now this is global so any app running- like notepad - if you are typing a bad word in is effected by it- how do I clear that bad word or change the bad word to hash marks (####)
using System;
using System.Collections.Generic
;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Management;
using System.Xml;
using System.Xml.Schema;
using System.IO;
using System.Security;
using System.Runtime.InteropServ
ices;
namespace Nomad
{
public partial class frmMain : Form
{
BadWordFilter newBadwordFilter;
public frmMain()
{
InitializeComponent();
comboBox1.SelectedIndex = 0;
newBadwordFilter = BadWordFilter.Instance;
InterceptKeys.AttachHook(); <- this starts the bad word process
//bool a = which one
//a = newBadwordFilter.IsCleanSt
ring("Fuck
");//to check
//a = newBadwordFilter.IsCleanSt
ring("Duck
");//to check
int c = 0;
}
private void comboBox1_SelectedIndexCha
nged(objec
t sender, EventArgs e)
{
webBrowser1.Navigate(new Uri(comboBox1.SelectedItem
.ToString(
)));
}
private void btnStartLP_Click(object sender, EventArgs e)
{
var proc = new Process();
proc.StartInfo.FileName = "chat/chat.exe";
proc.StartInfo.Arguments = "-v -s -a";
proc.Start();
proc.WaitForExit();
var exitCode = proc.ExitCode;
proc.Close();
}
//////////////////////////
/////Knowl
edge Base//////////////////
/// <summary>
/// Question answer Pair
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
///
private void btnSearchKnowledge_Click(o
bject sender, EventArgs e)
{
char[] delimiters = new char[] { ',', ' ' };
string[] keywords = txtBoxKnowledgeQuestion.Te
xt.Split(d
elimiters,
StringSplitOptions.RemoveE
mptyEntrie
s);
XmlDocument doc = new XmlDocument();
doc.Load("XMLQandA.xml");
XmlElement root = doc.DocumentElement;
XmlNodeList nodeList = root.SelectNodes("/message
s/messageI
tem");
foreach (XmlNode node in nodeList)
{
bool hasAllWords = true;
bool hasAnyWord = false;
foreach (string keyword in keywords)
{
if (node.InnerText.Contains(k
eyword))
{
hasAnyWord = true;
}
else hasAllWords = false;
}
if (hasAllWords)
{
// add the node to found-items-list
lstBoxQA.Items.Add(node.In
nerText);
lstBoxQA.Items.Add("======
==========
======");
//lstBoxQA.Items.AddRange(
node.Inner
Text);
return;
}
if (hasAnyWord)
{
//process found-items-list
lstBoxQA.Items.Add(node.In
nerText);
lstBoxQA.Items.Add("======
==========
======");
//lstBoxQA.Items.AddRange(
node.Inner
Text);
}
}
//frmWarning frm = new frmWarning();
//frm.Show();
MessageBox.Show("You have typed a word that has been deemed \n inapropriate - it will be blanked out - Next time an email \n will be sent to HR and IT to have your access cut off"); <-this is the test area
int c = 1;
}
private void btnEVid_Click(object sender, EventArgs e)
{
webBEVid.Navigate(new Uri("
http://172.0.0.1//Login.aspx"));
}
private void textBox1_TextChanged(objec
t sender, EventArgs e)
{
}
private void btnLogon_Click(object sender, EventArgs e)
{
}
private void frmMain_Load(object sender, EventArgs e)
{
}
private void webBrowser2_DocumentComple
ted(object
sender, WebBrowserDocumentComplete
dEventArgs
e)
{
}
private void btnCamp_Click(object sender, EventArgs e)
{
webBrowser2.Navigate(new Uri("
http://et2app01/Ensercle/index.htm"));
}
private void btnClear_Click(object sender, EventArgs e)
{
lstBoxQA.Items.Clear();
txtBoxKnowledgeQuestion.Cl
ear();
}
private void frmMain_FormClosing(object
sender, FormClosingEventArgs e)
{
InterceptKeys.DetachHook()
; <- this ends the bad word process
}
}
}