/** * rotateExcuteType => 1.sendKey 2. sendScript * @ param Data.EncoderValue encoder . 실행 타입을 구별하고 실행 값을 뽑을 엔코더 객체 * @ param int index . 돌리기 번호 * @ param string direction 방향 타입 * @ exception 예외사항 */ public void EncoderData(DeviceData.Payload payload, int group, int number, string direction, int s, string appName) { this.excuteType = payload.E_excuteType[number]; if (this.excuteType.Equals("") || String.IsNullOrEmpty(this.excuteType)) { nullOverlay(group, number, true); return; } this.messageType = payload.E_messageType[number]; this.actionType = payload.E_actionType[number]; this.typeKey = payload.E_typeKey[number]; int dir = Int32.Parse(direction); int speed = s / 10; this.keycode1 = (dir == 2) ? payload.E_leftKeyCode[number] : payload.E_rightKeyCode[number]; this.multi1 = (dir == 2) ? payload.E_leftisMulti[number] : payload.E_rightisMulti[number]; speed = (dir == 2) ? (speed * -1) : (speed * 1); Type t = this.GetType(); MethodInfo method = t.GetMethod(this.excuteType, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (method != null) { method.Invoke(this, new object[] { messageType, actionType, typeKey, speed.ToString(), keycode1, multi1, appName, group, number, true });; } }
/** * pressExcuteType => 1.sendKey 2. sendScript * @ param Data.EncoderValue encoder . 실행 타입을 구별하고 실행 값을 뽑을 엔코더 객체 * @ exception 예외사항 */ public void ButtonData(DeviceData.Payload payload, int group, int number, string appName) { this.excuteType = payload.B_excuteType[number]; //sendKey, sendScript -> 함수이름. if (this.excuteType.Equals("") || String.IsNullOrEmpty(this.excuteType) == true) { nullOverlay(group, number, false); return; } this.messageType = payload.B_messageType[number]; this.actionType = payload.B_actionType[number]; this.typeKey = payload.B_typeKey[number]; this.keycode1 = payload.B_keyCode[number]; this.multi1 = payload.B_isMulti[number]; Type t = this.GetType(); System.Reflection.MethodInfo method = t.GetMethod(this.excuteType, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (method != null) { method.Invoke(this, new object[] { messageType, actionType, typeKey, null, keycode1, multi1, appName, group, number, false }); } }
//가져온 프리셋 값을 데이터에 바인딩 public void settingPreset() { try { mn = MainForm.getInstance; Thread.Sleep(100); DeviceData.Payload[] payloads = new DeviceData.Payload[4]; for (int i = 0; i < 4; i++) { payloads[i] = new DeviceData.Payload(); } string presetPath = mn.PresetPath + @"\" + mn.AppName + @"\" + mn.PresetName + ".xml"; int groupIndex = 0; int encoderIndex = 0; int buttonIndex = 0; using (XmlReader reader = XmlReader.Create(presetPath)) { while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { case "preset": string Name = reader["name"]; break; case "group": string gnum = reader["gnum"]; string gname = reader["gname"]; if (gnum != "") { groupIndex = Int32.Parse(gnum) - 1; payloads[groupIndex].groupName = gname; //그룹이름 세팅 } break; case "encoder": string encoder_number = reader["enum"]; string encoder_excuteType = reader["excuteType"]; string encoder_messageType = reader["messageType"]; string encoder_actionType = reader["actionType"]; string encoder_typeKey = reader["typeKey"]; string encoder_formName = reader["formName"]; string encoder_Left_Keycode = reader["Lkeycode"]; string encoder_Right_Keycode = reader["Rkeycode"]; string encoder_Left_Multi = reader["Lmulti"]; string encoder_Right_Multi = reader["Rmulti"]; string encoder_Left_SubName = reader["LsubName"]; string encoder_Right_SubName = reader["RsubName"]; if (encoder_messageType != "" && encoder_actionType != "") { encoderIndex = Int32.Parse(encoder_number) - 1; payloads[groupIndex].E_excuteType[encoderIndex] = encoder_excuteType; payloads[groupIndex].E_messageType[encoderIndex] = encoder_messageType; payloads[groupIndex].E_actionType[encoderIndex] = encoder_actionType; payloads[groupIndex].E_typeKey[encoderIndex] = encoder_typeKey; payloads[groupIndex].E_formName[encoderIndex] = encoder_formName; } else if (encoder_Left_Keycode != "" && encoder_Right_Keycode != "" && encoder_Left_Multi != "" && encoder_Right_Multi != "") { encoderIndex = Int32.Parse(encoder_number) - 1; int encoder_Lkeycode = Int32.Parse(encoder_Left_Keycode); int encoder_Lmulti = Int32.Parse(encoder_Left_Multi); int encoder_Rkeycode = Int32.Parse(encoder_Right_Keycode); int encoder_Rmulti = Int32.Parse(encoder_Right_Multi); payloads[groupIndex].E_excuteType[encoderIndex] = encoder_excuteType; payloads[groupIndex].E_formName[encoderIndex] = encoder_formName; payloads[groupIndex].E_leftKeyCode[encoderIndex] = encoder_Lkeycode; payloads[groupIndex].E_rightKeyCode[encoderIndex] = encoder_Rkeycode; payloads[groupIndex].E_leftisMulti[encoderIndex] = encoder_Lmulti; payloads[groupIndex].E_rightisMulti[encoderIndex] = encoder_Rmulti; payloads[groupIndex].E_leftSubName[encoderIndex] = encoder_Left_SubName; payloads[groupIndex].E_rightSubName[encoderIndex] = encoder_Right_SubName; } break; case "button": string button_number = reader["bnum"]; string button_excuteType = reader["excuteType"]; string button_messageType = reader["messageType"]; string button_actionType = reader["actionType"]; string button_typeKey = reader["typeKey"]; string button_formName = reader["formName"]; string button_subName = reader["subName"]; string button_keycode = reader["keycode"]; string button_multi = reader["multi"]; if (button_number != "") { buttonIndex = Int32.Parse(button_number) - 1; payloads[groupIndex].B_excuteType[buttonIndex] = button_excuteType; payloads[groupIndex].B_messageType[buttonIndex] = button_messageType; payloads[groupIndex].B_actionType[buttonIndex] = button_actionType; payloads[groupIndex].B_typeKey[buttonIndex] = button_typeKey; payloads[groupIndex].B_formName[buttonIndex] = button_formName; payloads[groupIndex].B_subName[buttonIndex] = button_subName; payloads[groupIndex].B_keyCode[buttonIndex] = Int32.Parse(button_keycode); payloads[groupIndex].B_isMulti[buttonIndex] = Int32.Parse(button_multi); } break; } } } } mn.Payloads = payloads; return; } catch (Exception ex) { Console.WriteLine(ex.Message); } }