0

Didn't really know how to word this correctly so forgive the bad title name.

I'm using a timer to detect when a button is pressed on my Xbox. It's works so far but I use it to print text on the screen. I need it to print it once then stop, at the minute it keeps on printing until I close the app.

Any help is appreciated,

Thanks.

private void timer4_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i <= 17; i++)
            {// all client? yes
                try
                {
                    uint LB = buttonpressed(i);

                    uint RB = buttonpressed(i); 
                    uint A = buttonpressed(i);
                    uint X = buttonpressed(i);
                    uint B = buttonpressed(i);
                    uint dpaddown = buttonpressed(i);
                    if (buttonpressed(0) == 0x4000)//Scrolling
                    {
                        scroll++;
                    }
                    else if (buttonpressed(0) == 0x8000)//Scrolling
                    {
                        scroll--;
                    }

                    if (MainMenu == 1 && scroll == 0)
                    {
                            Jtag.Call(0x82364E18, -1, 0, "v cg_chatHeight \"6\"");
                            Jtag.Call(0x82364E18, -1, 0, "v cg_chatTime \"60000\"");
                            Jtag.Call(0x82364E18, -1, 0, "v cg_hudsayposition \"250 250\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^4Option 1 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 2 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 3 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 4 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 5 Main Menu\"");
                            Jtag.Call(0x8233E8D8, 0, "say \"^1Option 6 Main Menu\"");
                    }
}
                catch
                {
                    MessageBox.Show("Error", "Not Connected");
                }
            }
        }


`
4

1 回答 1

0

使用Timer.Stop方法。您还可以通过将 Enabled 属性设置为 false 来停止计时器。

http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.stop.aspx

于 2013-04-07T13:10:35.813 回答