ЧЕГО ХОЧУ?
Я хочу, чтобы, если вы возьмете часть предложения вопроса, вы получили такой же результат, как если бы вы скопировали все предложение.Я уже смотрел метод StartWith, но я не знаю, как его использовать.У кого-нибудь есть решение для этого?Это мой кодЗаранее спасибо.
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Invoke a clipboard monitor
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
private IntPtr _ClipboardViewerNext;
//Make some global variables so we can access them somewhere else later
//This will store all Questions and Answers
//In here will be the Questions and Answers
List<question> questionList = new List<question>();
private void Form1_Load(object sender, EventArgs e)
{
//Set our application as a clipboard viewer
_ClipboardViewerNext = SetClipboardViewer(this.Handle);
//Add question/answer to list
question newQuestion = new question("When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?", "Install a modular power supply.*");
questionList.Add(newQuestion);
newQuestion = new question("vraag2", "antwoord2");
questionList.Add(newQuestion);
newQuestion = new question("vraag3", "antwoord3");
questionList.Add(newQuestion);
}
private void getAnswer(string clipboardText)
{
//Loop through all questions and answers
foreach (question q in questionList)
{
//If we have found an answer that is exactly the same show an Notification
if (q._question == clipboardText)
{
showNotification(q._question, q._answer);
}
}
}
private void showNotification(string question, string answer)
{
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipTitle = question;
notifyIcon1.BalloonTipText = answer;
notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
notifyIcon1.ShowBalloonTip(100);
Clipboard.Clear();
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
{
const int WM_DRAWCLIPBOARD = 0x308;
if (m.Msg == WM_DRAWCLIPBOARD) {
getAnswer(Clipboard.GetText());
}
}
}
}
}
Заранее спасибо