本文整理汇总了C#中KeyHandler类的典型用法代码示例。如果您正苦于以下问题:C# KeyHandler类的具体用法?C# KeyHandler怎么用?C# KeyHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyHandler类属于命名空间,在下文中一共展示了KeyHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow
public MainWindow()
{
InitializeComponent();
var keyHandler = new KeyHandler(this, DisplayControl);
KeyDown += keyHandler.OnKeyDown;
}
示例2: Daleks
public Daleks() : super("Daleks") {
setSize(1020, 820);
setResizable(false);
this.addWindowListener(new FrameListener());
var menuBar = new MenuBar();
this.setMenuBar(menuBar);
var menu = new Menu("File");
menuBar.add(menu);
var menuItem = new MenuItem("New Game");
menu.add(menuItem);
menuItem.addActionListener(p => newGame());
menuItem = new MenuItem("-");
menu.add(menuItem);
menuItem = new MenuItem("Exit");
menu.add(menuItem);
menuItem.addActionListener(p => dispose());
this.setLayout(new BorderLayout());
this.add(status = new Label("To start: File > New Game"), BorderLayout.SOUTH);
this.keyHandler = new KeyHandler(this);
this.addKeyListener(keyHandler);
this.timer = new Timer(true);
}
示例3: Run
public void Run()
{
Log.InfoFormat("Starting timer with a sample rate of {0} ms", _sampleRateMilliseconds);
var timer = new Timer();
timer.AutoReset = true;
timer.Interval = _sampleRateMilliseconds;
timer.Elapsed += (s, e) => Tick();
timer.Start();
var keyHandler = new KeyHandler();
keyHandler.WaitForExit();
}
示例4: Page_Loaded
void Page_Loaded(object sender, RoutedEventArgs e)
{
this.Focus();
Page.Keyhandler = new KeyHandler();
Page.Keyhandler.Attach(this);
//Page.MouseHandler = new MouseHandler();
//Page.MouseHandler.Attach(this);
Page.SceneLoop = new SceneLoop();
Page.SceneLoop.Attach(this.mainCanvas);
view = new TankView();
view.Ended += new EventHandler(view_Ended);
this.mainCanvas.Children.Add(view);
}
示例5: Page_Loaded
public void Page_Loaded(object o, EventArgs e)
{
// Required to initialize variables
_splash = new Splash();
canvas.Children.Add(_splash);
_splash.SetValue(Canvas.ZIndexProperty, 20000);
KeyHandler = new KeyHandler();
KeyHandler.Attach(this);
Focus();
gameLoop = new GameLoop();
gameLoop.Attach(parentCanvas);
gameLoop.Update += gameLoop_Update;
Fps fps = new Fps();
canvas.Children.Add(fps);
fps.SetValue(Canvas.ZIndexProperty, 1000);
_mainMenu = new MainMenu();
canvas.Children.Add(_mainMenu);
_mainMenu.MenuItemSelected += mainMenu_MenuItemSelected;
Page_SizeChanged(null, null);
}
示例6: Handler
public Handler (ConsoleKeyInfo cki, KeyHandler h, bool resetCompletion = true)
{
CKI = cki;
KeyHandler = h;
ResetCompletion = resetCompletion;
}
示例7: CreateHook
public static void CreateHook(KeyHandler _kh)
{
Process _this = Process.GetCurrentProcess();
ProcessModule mod = _this.MainModule;
hd = HookFunc;
kh = _kh;
hhk = API.SetWindowsHookEx(13, hd, API.GetModuleHandle(mod.ModuleName), 0);
//13 is the parameter specifying that we're gonna do a low-level keyboard hook
//MessageBox.Show(Marshal.GetLastWin32Error().ToString()); //for debugging
//Note that this could be a Console.WriteLine(), as well. I just happened
//to be debugging this in a Windows Application
//to get the errors, in VS 2005+ (possibly before) do Tools -> Error Lookup
}
示例8: EditLoop
void EditLoop ()
{
ConsoleKeyInfo cki;
while (!done){
cki = Console.ReadKey (true);
bool handled = false;
foreach (Handler handler in handlers){
ConsoleKeyInfo t = handler.CKI;
if (t.Key == cki.Key && t.Modifiers == cki.Modifiers){
handled = true;
handler.KeyHandler ();
last_handler = handler.KeyHandler;
break;
} else if (t.KeyChar == cki.KeyChar && t.Key == ConsoleKey.Zoom){
handled = true;
handler.KeyHandler ();
last_handler = handler.KeyHandler;
break;
}
}
if (handled){
if (searching != 0){
if (last_handler != CmdReverseSearch){
searching = 0;
SetPrompt (prompt);
}
}
continue;
}
if (cki.KeyChar != (char) 0)
HandleChar (cki.KeyChar);
}
}
示例9: Control
public static Handler Control (char c, KeyHandler h)
{
return new Handler ((char) (c - 'A' + 1), h);
}
示例10: Handler
public Handler (char c, KeyHandler h)
{
KeyHandler = h;
// Use the "Zoom" as a flag that we only have a character.
CKI = new ConsoleKeyInfo (c, ConsoleKey.Zoom, false, false, false);
}
示例11: Unmap
/// <summary>
/// Unmaps a key
/// </summary>
/// <param name="keyCombination">The combo</param>
/// <param name="keyHandler">The handler</param>
public KeyboardMapper Unmap(KeyCombination keyCombination, KeyHandler keyHandler)
{
#if DEBUG
if (DebugMode)
Debug.Log("KeyboardMapper.Unmap: " + keyCombination);
#endif
if (_mappings.ContainsKey(keyCombination))
{
_mappings[keyCombination].Remove(keyHandler);
if (_mappings[keyCombination].Count == 0)
_mappings.Remove(keyCombination);
}
if (_oneShotMappings.ContainsKey(keyCombination))
{
_oneShotMappings[keyCombination].Remove(keyHandler);
if (_oneShotMappings[keyCombination].Count == 0)
_oneShotMappings.Remove(keyCombination);
}
return this;
}
示例12: Handler
public Handler(ConsoleKeyInfo myConsoleKeyInfo, KeyHandler myKeyHandler)
{
CKI = myConsoleKeyInfo;
KeyHandler = myKeyHandler;
}
示例13: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
KeyHandler ghk;
ghk = new KeyHandler(Keys.F1, this);
ghk.Register();
}
示例14: EditLoop
private void EditLoop()
{
ConsoleKeyInfo cki;
while (!done) {
ConsoleModifiers mod;
cki = Console.ReadKey(true);
if (cki.Key == ConsoleKey.Escape) {
cki = Console.ReadKey(true);
mod = ConsoleModifiers.Alt;
} else
mod = cki.Modifiers;
var handled = false;
foreach (var handler in handlers) {
var t = handler.CKI;
if (t.Key == cki.Key && t.Modifiers == mod) {
handled = true;
handler.KeyHandler();
last_handler = handler.KeyHandler;
break;
}
if (t.KeyChar == cki.KeyChar && t.Key == ConsoleKey.Zoom) {
handled = true;
handler.KeyHandler();
last_handler = handler.KeyHandler;
break;
}
}
if (handled) {
if (searching != 0) {
if (last_handler != CmdReverseSearch) {
searching = 0;
SetPrompt(Prompt);
}
}
continue;
}
if (cki.KeyChar != (char) 0)
HandleChar(cki.KeyChar);
}
}
示例15: Control
public static Handler Control (char c, KeyHandler h, bool resetCompletion = true)
{
return new Handler ((char) (c - 'A' + 1), h, resetCompletion);
}