コード例 #1
0
 /*
  * data format
  * gestureId:GestureName{id:command,id:command,....,id:command}
  * gestureId:GestureName2{id:command,id:command,....,id:command}
  * gestureId:GestureName3
  * ...
  */
 public static void saveData(string path)
 {
     using (StreamWriter file = new StreamWriter(path))
     {
         // go over all the gestures
         foreach (KeyValuePair <int, GestureInfo> pair in gestureList)
         {
             GestureInfo   gesture = pair.Value;
             StringBuilder sb      = new StringBuilder();
             sb.Append(pair.Key + ":" + gesture.getName());
             if (gesture.getAllCommands().Count > 0)
             {
                 sb.Append("{");
                 bool first = true;
                 // go over all the commands in the gesture
                 foreach (KeyValuePair <int, AppKeyInfo> commands in gesture.getAllCommands())
                 {
                     if (first)
                     {
                         sb.Append(commands.Key + ":" + commands.Value.ToString());
                         first = false;
                     }
                     else
                     {
                         sb.Append("," + commands.Key + ":" + commands.Value.ToString());
                     }
                 }
                 sb.Append("}");
             }
             file.WriteLine(sb.ToString());
         }
     }
 }
コード例 #2
0
 public static void resetGestureInfo()
 {
     for (int i = 0; i < gestureList.Count; i++)
     {
         KeyValuePair <int, GestureInfo> pair = gestureList.ElementAt(i);
         gestureList.Remove(pair.Key);
         GestureInfo info = new GestureInfo(pair.Value.getName());
         gestureList.Add(pair.Key, info);
     }
 }
コード例 #3
0
        public static void loadData(string path)
        {
            changeDataFile(path);
            string[] lines = File.ReadAllLines(path);

            gestureList = new Dictionary <int, GestureInfo>();
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                string gestureId = line.Substring(0, line.IndexOf(":"));
                string name;

                if (line.IndexOf("{") == -1)
                {
                    name = line.Substring(line.IndexOf(":") + 1, line.Length - line.IndexOf(":") - 1);
                }
                else
                {
                    name = line.Substring(line.IndexOf(":") + 1, line.IndexOf("{") - line.IndexOf(":") - 1);
                }
                GestureInfo gesture = new GestureInfo(name);

                // if it is bined to specific key command to specific application
                if (line.IndexOf("{") != -1)
                {
                    string   keyAssignment = line.Substring(line.IndexOf("{") + 1, line.IndexOf("}") - line.IndexOf("{") - 1);
                    string[] assignments   = keyAssignment.Split(',');
                    // assign application key commands
                    for (int j = 0; j < assignments.Length; j++)
                    {
                        string assignment = assignments[j].Trim();
                        if (assignment != "")
                        {
                            string[]   command = assignment.Split(':');
                            AppKeyInfo keyInfo = new AppKeyInfo(command[1]);
                            gesture.setAppCommand(int.Parse(command[0]), keyInfo);
                        }
                    }
                }

                gestureList.Add(int.Parse(gestureId), gesture);
            }
        }
コード例 #4
0
 public static void resetGestureInfo()
 {
     for (int i = 0; i < gestureList.Count; i++)
     {
         KeyValuePair<int, GestureInfo> pair = gestureList.ElementAt(i);
         gestureList.Remove(pair.Key);
         GestureInfo info = new GestureInfo(pair.Value.getName());
         gestureList.Add(pair.Key, info);
     }
 }
コード例 #5
0
        public static void loadData(string path)
        {
            changeDataFile(path);
            string[] lines = File.ReadAllLines(path);

            gestureList = new Dictionary<int, GestureInfo>();
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i];

                string gestureId = line.Substring(0, line.IndexOf(":"));
                string name;

                if(line.IndexOf("{") == -1)
                    name = line.Substring(line.IndexOf(":") + 1, line.Length - line.IndexOf(":") - 1);
                else
                    name = line.Substring(line.IndexOf(":") + 1, line.IndexOf("{") - line.IndexOf(":") - 1);
                GestureInfo gesture = new GestureInfo(name);

                // if it is bined to specific key command to specific application
                if (line.IndexOf("{") != -1)
                {
                    string keyAssignment = line.Substring(line.IndexOf("{") + 1, line.IndexOf("}") - line.IndexOf("{") - 1);
                    string[] assignments = keyAssignment.Split(',');
                    // assign application key commands
                    for (int j = 0; j < assignments.Length; j++)
                    {
                        string assignment = assignments[j].Trim();
                        if (assignment != "")
                        {
                            string[] command = assignment.Split(':');
                            AppKeyInfo keyInfo = new AppKeyInfo(command[1]);
                            gesture.setAppCommand(int.Parse(command[0]), keyInfo);
                        }
                    }
                }

                gestureList.Add(int.Parse(gestureId), gesture);
            }
        }