private void ADD_ROW(AFCoreEx.AFIDENTID self, string strRecordName, AFMsg.DataTableAddRow xAddStruct) { AFIObject go = AFCKernel.Instance.GetObject(self); AFIRecordManager xRecordManager = go.GetRecordManager(); Hashtable recordVecDesc = new Hashtable(); Hashtable recordVecData = new Hashtable(); AFCoreEx.AFCDataList RowList = new AFCDataList(); AFCoreEx.AFIDataList varListDesc = new AFCDataList(); for (int k = 0; k < xAddStruct.CellList.Count; ++k) { AFMsg.PBCellData addStruct = (AFMsg.PBCellData)xAddStruct.CellList[k]; if (addStruct.Col >= 0) { int nRow = -1; int nCol = -1; AFCoreEx.AFIDataList.Var_Data xRowData = PBRecordToData(addStruct, ref nRow, ref nCol); RowList.AddDataObject(ref xRowData); varListDesc.AddDataObject(ref xRowData); } } AFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc); } xRecord.AddRow(xAddStruct.Row, RowList); }
private void EGMI_ACK_ADD_ROW(MsgHead head, MemoryStream stream) { AFMsg.EntityDataTableAddRow recordData = ReceiveMsg(stream, EntityDataTableAddRow.Parser) as EntityDataTableAddRow; AFIObject go = AFCKernel.Instance.GetObject(PBToAF(recordData.EntityId)); AFIRecordManager recordManager = go.GetRecordManager(); for (int i = 0; i < recordData.RowData.Count; i++) { ADD_ROW(PBToAF(recordData.EntityId), recordData.TableName, recordData.RowData[i]); } }
private void EGMI_ACK_SWAP_ROW(MsgHead head, MemoryStream stream) { AFMsg.EntityDataTableSwap recordData = ReceiveMsg(stream, EntityDataTableSwap.Parser) as EntityDataTableSwap; AFIObject go = AFCKernel.Instance.GetObject(PBToAF(recordData.EntityId)); AFIRecordManager recordManager = go.GetRecordManager(); AFIRecord record = recordManager.GetRecord(recordData.OriginTableName); //目前认为在同一张表中交换吧 record.SwapRow(recordData.RowOrigin, recordData.RowTarget); }
private void EGMI_ACK_REMOVE_ROW(MsgHead head, MemoryStream stream) { AFMsg.EntityDataTableRemove recordData = EntityDataTableRemove.Parser.ParseFrom(stream); //new AFMsg.ObjectRecordRemove(); // ReceiveMsg(stream, ref recordData); AFIObject go = AFCKernel.Instance.GetObject(PBToAF(recordData.EntityId)); AFIRecordManager recordManager = go.GetRecordManager(); AFIRecord record = recordManager.GetRecord(recordData.TableName); for (int i = 0; i < recordData.RemoveRow.Count; i++) { record.Remove(recordData.RemoveRow[i]); } }
private void EGMI_ACK_RECORD_DATA(MsgHead head, MemoryStream stream) { AFMsg.EntityDataTable recordData = ReceiveMsg(stream, EntityDataTable.Parser) as EntityDataTable; AFIObject go = AFCKernel.Instance.GetObject(PBToAF(recordData.EntityId)); AFIRecordManager recordManager = go.GetRecordManager(); AFIRecord record = recordManager.GetRecord(recordData.TableName); for (int i = 0; i < recordData.TableCellList.Count; i++) { int nRow = -1; int nCol = -1; AFCoreEx.AFIDataList.Var_Data xRowData = PBRecordToData(recordData.TableCellList[i], ref nRow, ref nCol); record.SetDataObject(nRow, nCol, xRowData); } }
public void OnGUI(AFIKernel kernel, int nHeight, int nWidth) { if (buttonLeft == null) { buttonLeft = GUI.skin.button; buttonLeft.alignment = TextAnchor.MiddleLeft; } int nElementWidth = 150; int nElementHeight = 20; GUI.color = Color.red; strInfo = GUI.TextField(new Rect(0, nHeight - 20, nElementWidth * 3f + 120, 20), strInfo); strCommand = GUI.TextField(new Rect(nElementWidth * 3f + 120, nHeight - 20, 350, 20), strCommand); if (GUI.Button(new Rect(nWidth - 100, nHeight - 20, 100, 20), "cmd")) { } GUI.color = Color.white; AFIDataList objectList = kernel.GetObjectList(); scrollPositionFirst = GUI.BeginScrollView(new Rect(0, nElementHeight, nElementWidth / 2 + 20, nHeight), scrollPositionFirst, new Rect(0, 0, nElementWidth, objectList.Count() * (nElementHeight))); //all object for (int i = 0; i < objectList.Count(); i++) { AFIDENTID ident = objectList.ObjectVal(i); if (GUI.Button(new Rect(0, i * nElementHeight, nElementWidth, nElementHeight), ident.nHead64.ToString() + "_" + ident.nData64.ToString())) { xTargetIdent = ident; strTableName = ""; } } GUI.EndScrollView(); //////////////// if (!xTargetIdent.IsNull()) { AFIObject go = kernel.GetObject(xTargetIdent); AFIDataList recordLlist = go.GetRecordManager().GetRecordList(); AFIDataList propertyList = go.GetPropertyManager().GetPropertyList(); int nAllElement = 1; for (int j = 0; j < recordLlist.Count(); j++) { string strRecordName = recordLlist.StringVal(j); if (strRecordName.Length > 0) { nAllElement++; } } for (int j = 0; j < propertyList.Count(); j++) { string strPropertyName = propertyList.StringVal(j); if (strPropertyName.Length > 0) { nAllElement++; } } ////////////////// scrollPositionSecond = GUI.BeginScrollView(new Rect(nElementWidth / 2 + 20, nElementHeight, nElementWidth + 20, nHeight / 2), scrollPositionSecond, new Rect(0, 0, nElementWidth, (nAllElement + 1) * (nElementHeight) + 1)); int nElementIndex = 0; GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), xTargetIdent.nData64.ToString()); nElementIndex++; //all record for (int j = 0; j < recordLlist.Count(); j++) { string strRecordName = recordLlist.StringVal(j); if (strRecordName.Length > 0) { if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), "++" + strRecordName)) { strTableName = strRecordName; } nElementIndex++; } } /////////////////////////////// //all property for (int k = 0; k < propertyList.Count(); k++) { string strPropertyValue = null; string strPropertyName = propertyList.StringVal(k); AFIProperty property = go.GetPropertyManager().GetProperty(strPropertyName); AFIDataList.VARIANT_TYPE eType = property.GetDataType(); switch (eType) { case AFIDataList.VARIANT_TYPE.VTYPE_DOUBLE: strPropertyValue = property.QueryDouble().ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_FLOAT: strPropertyValue = property.QueryFloat().ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_INT: strPropertyValue = property.QueryInt().ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_OBJECT: strPropertyValue = property.QueryObject().nData64.ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_STRING: strPropertyValue = property.QueryString(); break; default: strPropertyValue = "?"; break; } if (strPropertyName.Length > 0) { if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), strPropertyName + ":" + strPropertyValue)) { strTableName = ""; strInfo = strPropertyName + ":" + strPropertyValue; } nElementIndex++; } } GUI.EndScrollView(); //////////////////////// if (strTableName.Length > 0) { AFIRecord record = go.GetRecordManager().GetRecord(strTableName); if (null != record) { int nRow = record.GetRows(); int nCol = record.GetCols(); int nOffest = 30; scrollPositionThird = GUI.BeginScrollView(new Rect(nElementWidth * 1.5f + 40, nElementHeight, nElementWidth * 2, nHeight / 2), scrollPositionThird, new Rect(0, 0, nElementWidth * nCol + nOffest, nRow * nElementHeight + nOffest)); string selString = null; for (int row = 0; row < nRow; row++) { GUI.Button(new Rect(0, row * nElementHeight + nOffest, nOffest, nElementHeight), row.ToString()); //row for (int col = 0; col < nCol; col++) { if (0 == row) { GUI.Button(new Rect(col * nElementWidth + nOffest, 0, nElementWidth, nElementHeight), col.ToString() + " [" + record.GetColType(col) + "]"); } if (record.IsUsed(row)) { AFIDataList.VARIANT_TYPE eType = record.GetColType(col); switch (eType) { case AFIDataList.VARIANT_TYPE.VTYPE_INT: selString = record.QueryInt(row, col).ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_FLOAT: selString = record.QueryFloat(row, col).ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_DOUBLE: selString = record.QueryDouble(row, col).ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_STRING: selString = record.QueryString(row, col).ToString(); break; case AFIDataList.VARIANT_TYPE.VTYPE_OBJECT: selString = record.QueryObject(row, col).nData64.ToString(); break; default: selString = "UnKnowType"; break; } } else { selString = "NoUse"; } if (GUI.Button(new Rect(col * nElementWidth + nOffest, row * nElementHeight + nOffest, nElementWidth, nElementHeight), selString)) { strInfo = "Row:" + row.ToString() + " Col:" + col.ToString() + " " + selString; } } } GUI.EndScrollView(); } } } }