English 中文(简体)
B. 利用主要压力对ms进行模拟
原标题:Simulating sms style typing using keypress
  • 时间:2011-10-26 08:57:24
  •  标签:
  • c#
  • keypress

是否有任何人向我提出正确方向,以便用数字板上的关键压力来模拟打字体。

I can get each number to print out a letter but am unsure of how to get my program to treat a number of keypresses on the same key as the same event (i.e. scrolling through several letters if the key is pressed again within a period of (for example) 2 seconds).

我研究了多个关键词,但总是以关键组合(剪辑、带、删除等)。

最佳回答

首先,需要储存现有的组合:

    static char[] num1 = {  A ,  B ,  C ,  1  };
    static char[] num2 = {  D ,  E ,  F ,  2  };
    // etc...

之后,我们就把组合描绘成产生这些组合的正确关键特性:

    Dictionary<char, char[]> map = new Dictionary<char, char[]>()
    {
        { 1 , num1},
        { 2 , num2} 
    };

跟踪的一些变量:

    char[] curr = null;
    char currChar =  - ;
    int index = 0;

印刷功能:

    void Print()
    {
        Console.WriteLine(curr[index]);
    }

逻辑:

    private void Form1_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (map.ContainsKey(e.KeyChar))
        {
            if (curr == null || e.KeyChar != currChar)
            {
                curr = map[e.KeyChar];
                index = 0;
                currChar = e.KeyChar;
                Print();
            }
            else
            {
                ++index;
                if (index == curr.Length)
                    index = 0;
                Print();
            }
        }
    }

确保对关键图的逻辑基本检查含有这些关键编码。 如果我们不追踪任何情况,或者如果它不同于我们目前重新追踪的情况,就使用这一特定地图和第一个指数。

否则,如果它重复出现关键压力,就会增加指数(如果我们结束,就可回头)。

问题回答

你们需要国家机器,并计算每个关键媒体的数量,以确定这封信。 然后将本函(利用事件)转达给你的其余部分。

各位是否注意到数字键盘上的数字与电话上的数字不同? (789名是顶板上的上行和电话上的底层行)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签