Ejemplo n.º 1
0
        public List <string> GetDefineLine()
        {
            var box      = new DefineBox();
            var commands = new List <string>();
            var tmp      = new List <string>();

            for (int m = 0; m < file.Count; ++m)
            {
                tmp.AddRange(file[m].Split('+'));
                if (tmp.Capacity > 1)
                {
                    for (int t = 1; t < tmp.Count; ++t)
                    {
                        tmp[t] = "+" + tmp[t];
                    }
                }
                commands.AddRange(tmp);
                Console.WriteLine("For DefineCode Comands:" + commands.Count);
            }
            //ここからHexを持つワードを探す。
            var ret = new List <string>();

            for (int s = 0; s < commands.Count; ++s)
            {
                for (int i = 0; i < box.KeySwitch.Count; ++i)
                {
                    //Console.WriteLine("一致するコマンドを検索中:" + box.KeySwitch[i] + " and " + commands[s]);

                    if (commands[s].Equals(box.KeySwitch[i].UserSetAs))
                    {
                        if (box.KeySwitch[i].CheckIsHaveUSBHex())
                        {
                            ret.Add("#define " + box.KeySwitch[i].IInputAs + " " + box.KeySwitch[i].USBHex);
                            Console.WriteLine("Defineされる要素:" + box.KeySwitch[i].IInputAs);
                        }
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public string GetLine(int i)
        {
            Console.WriteLine("KeyEvents.GetLineでの現在のリスト:");
            for (int s = 0; s < file.Count; ++s)
            {
                Console.WriteLine("要素" + i.ToString() + ":" + file[s]);
            }
            Console.WriteLine("ReadLine:" + file[i]);
            if (file[i].IndexOf("/string/") != (-1))//arudinoに打ち込む形式で出力する。
            {
                file[i] = file[i].Replace("/string/", "");
                Console.WriteLine("文字列:" + file[i]);
                return("DigiKeyboard.print{(}\"" + file[i] + "\"{)};");
            }
            else
            {
                var box = new DefineBox();
                //同時入力を識別します。
                string[] command = file[i].Split('+');//+で区切る
                commandsN = command.Length;
                Console.WriteLine("KeyEventのGetLineでの要素はこれらです");
                for (i = 0; i < command.Length; ++i)
                {
                    Console.WriteLine(command[i]);
                }
                var list2 = new List <string>();
                list2.AddRange(command);

                if (command.Length > 1)//もしリストの要素が2以上すなわち同時押しがあるなら
                {
                    Console.WriteLine(command.Length + "が重さ");
                    for (int s = 1; s < (command.Length); ++s)//+の復元作業
                    {
                        Console.WriteLine("s:" + s.ToString() + "s=" + s.ToString() + ":" + list2[s]);
                        list2[s] = "+" + list2[s];//
                    }
                }
                var ret   = "";
                var words = 0;
                for (int t = 0; t < command.Length; ++t)//出力する文字列をここから作成
                {
                    for (int s = 0; s < box.KeySwitch.Count; ++s)
                    {
                        if (list2[t].Equals(box.KeySwitch[s].UserSetAs))
                        {
                            Console.WriteLine("正当なWordでした!" + list2[t]);
                            if (words == 0)
                            {
                                ++words;
                                ret += box.KeySwitch[s].IInputAs;
                            }
                            else if (words == 1)
                            {
                                ++words;
                                ret += ",";
                                ret += box.KeySwitch[s].IInputAs;
                            }
                            else
                            {
                                ret += " | ";
                                ret += box.KeySwitch[s].IInputAs;
                            }
                        }
                    }
                }
                if (words == 0)
                {
                    Console.WriteLine("読み込んだ情報がおかしいです。");
                    Console.WriteLine(ret);
                    throw new FileNotFoundException();
                }

                Console.WriteLine("読み込んだret=" + ret);
                return("DigiKeyboard.sendKeyStroke{(}" + ret + "{)};");
            }
        }