private bool UpdateRobotEvents(RobotHandler rh, byte mode) { byte count = (byte)rh.events.Count; if (!UBT.V2_SaveEventHeader(mode, count, (byte)RobotHandler.ACTION.before)) { return(false); } try { byte[] data = rh.ToBytes(); byte startIdx = 0; while (startIdx < count) { byte batchCount = (byte)(count - startIdx); if (batchCount > CONST.ED.BATCH_SIZE) { batchCount = CONST.ED.BATCH_SIZE; } if (!UBT.V2_SaveEventData(mode, startIdx, batchCount, data)) { return(false); } startIdx += batchCount; } } catch { MessageBox.Show("事件設定不正常, 請小心檢查一下."); return(false); } if (!UBT.V2_SaveEventHeader(mode, count, (byte)RobotHandler.ACTION.after)) { return(false); } return(true); }