/// <summary> /// Retrieves a set of FieldData rows in the Fields data table in the Header Data Set object linked to the DataAccess class that are contained /// in the structure/union specified in the function's StructName parameter. Each field in a structure/union will be keyed by the name of the /// structure/union concatenated with the index of the field. /// </summary> /// <param name="strStructName"></param> /// <returns></returns> public CHeaderDataSet.tblFieldsRow[] GetStructFields(string strStructName) { try { CHeaderDataSet.tblStructuresRow rowStruct = GetStruct(strStructName); if (rowStruct == null) { return(null); } CHeaderDataSet.tblFieldsRow[] rowFields = new CHeaderDataSet.tblFieldsRow[rowStruct.FieldCount]; for (int iFieldIndex = 0; iFieldIndex < rowFields.Length; iFieldIndex++) { rowFields[iFieldIndex] = FieldsTable.FindByFieldKey(rowStruct.StructName + "_" + iFieldIndex.ToString()); }//next iFieldIndex return(rowFields); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in GetStructFields function of DataAccess class."); return(null); } }
private void BindData() { AdditionalParamsTable.DataSource = GetDataFoAdditionalTable(); AdditionalParamsTable.DataBind(); FieldsTable.DataSource = GetDataForFieldsTable(); FieldsTable.DataBind(); }
/// <summary> /// Removes those parent task recomputes that were arguments for the subform. /// We want do it when the subform is closed before a Call with a destination. /// </summary> /// <param name="parentTask"></param> /// <param name="subformTask"></param> internal override void RemoveRecomputes(Task parentTask, Task subformTask) { FieldsTable fieldsTable = parentTask.DataView.GetFieldsTab() as FieldsTable; Field field; if (subformTask != null && subformTask.RefreshOnVars != null) { foreach (int fieldIdx in subformTask.RefreshOnVars) { field = fieldsTable.getField(fieldIdx) as Field; field.RemoveSubformFromRecompute(subformTask); } } }
/// <summary> /// Adda recomputes for the parent task if this task is a subform and has arguments from the parent. /// </summary> private void AddRecomputes(Task task) { // QCR #423434. if (task.ParentTask == null) { return; } FieldsTable fieldsTable = task.ParentTask.DataView.GetFieldsTab() as FieldsTable; Field field; foreach (int fieldIdx in task.RefreshOnVars) { field = fieldsTable.getField(fieldIdx) as Field; field.AddSubformRecompute(task); } }
/// <summary> /// update changes in called task to fields in arguments from calling task /// </summary> /// <param name="task"></param> /// <param name="args"></param> internal override void UpdateArguments(Task task, ArgumentsList args) { FieldsTable fieldsTable = task.DataView.GetFieldsTab() as FieldsTable; int numberOfArguments = (args != null) ? args.getSize() : 0; int currentArgIndex = 0; // index of currently handled argument bool taskHasParameters = ((DataView)task.DataView).ParametersExist(); if (numberOfArguments > 0) { int dvPos = ((DataView)task.DataView).GetRecordMainIdx(); int dvSize = ((DataView)task.DataView).GetRecordMainSize(); // Go over the fields, find the fields which had arguments set to for (int i = dvPos; (i < dvSize) && (currentArgIndex < numberOfArguments); i++) { Field field = fieldsTable.getField(i) as Field; if (!field.IsForArgument(taskHasParameters)) { continue; } // get the argument Argument arg = args.getArg(currentArgIndex); currentArgIndex++; // ignore skipped arguments if (arg.skipArg()) { continue; } // ignore arguments which are not fields Field argField = arg.getField(); if (argField == null) { continue; } SetArgumentToField(field, argField); } } }
/// <summary> /// Queries the data type associated with the field with the specified field name passed to the function. The linked data type record will be returned /// by the function. Depending on what type of data type is associated with the field, will determine whether a structure data row, typedef data row /// or primitive data object is returned by the function. Primtive data types will not be stored in the Header Data Set and will have its data returned /// from the Global Primitive data object. /// </summary> /// <param name="strFieldKey"></param> /// <returns></returns> public object QueryFieldTypeDataByName(string strFieldName) { try { CHeaderDataSet.tblFieldsRow rowField = FieldsTable.Where(f => f.FieldName == strFieldName).FirstOrDefault(); if (rowField == null) { return(null); } return(QueryFieldTypeDataByKey(rowField.FieldKey)); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in QueryFieldTypeDataByName function of DataAccess class."); return(null); } }
internal List <IFieldView> Build(Task task) { List <IFieldView> result = new List <IFieldView>(); FieldsTable fieldsTable = (FieldsTable)task.DataView.GetFieldsTab(); int size = fieldsTable.getSize(); for (int i = 0; i < size; i++) { Field field = (Field)fieldsTable.getField(i); if (!field.IsEventHandlerField) { result.Add(new FieldAdaptor() { Field = field }); } } return(result); }
/// <summary> /// Queries the data type associated with the field with the specified key passed to the function. The linked data type record will be returned /// by the function. Depending on what type of data type is associated with the field, will determine whether a structure data row, typedef data row /// or primitive data object is returned by the function. Primtive data types will not be stored in the Header Data Set and will have its data returned /// from the Global Primitive data object. /// </summary> /// <param name="strFieldKey"></param> /// <returns></returns> public object QueryFieldTypeDataByKey(string strFieldKey) { try { CHeaderDataSet.tblFieldsRow rowField = FieldsTable.FindByFieldKey(strFieldKey); if (rowField == null) { return(null); } switch ((FieldTypeEnum)rowField.FieldType) { case FieldTypeEnum.Primitive: case FieldTypeEnum.Enum: case FieldTypeEnum.Pointer: object[] aryPrimTypeData = new object[] { rowField.FieldTypeName, DataAccess.PrimDataTypes[rowField.FieldTypeName] }; return(aryPrimTypeData); case FieldTypeEnum.TypeDef: CHeaderDataSet.tblTypeDefsRow rowTypeDef = TypeDefsTable.FindByTypeDefName(rowField.FieldTypeName); return(rowTypeDef); case FieldTypeEnum.Structure: CHeaderDataSet.tblStructuresRow rowStruct = StructuresTable.FindByStructName(rowField.FieldTypeName); return(rowStruct); } ; return(null); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in QueryFieldTypeDataByKey function of DataAccess class."); return(null); } }
/// <summary> /// Adds a set of rows to the Fields data table in the Header Data Set object linked to the DataAccess class using the data contained in the /// list of FieldData objects passed to the function. The FieldData object will contain all the required information needed to create a field record /// in the Fields table. /// </summary> /// <param name="lstFields"></param> /// <returns></returns> public bool AddFieldRows(List <FieldData> lstFields) { try { CHeaderDataSet.tblFieldsRow rowField = null; foreach (FieldData fdField in lstFields) { rowField = FieldsTable.NewtblFieldsRow(); rowField.FieldKey = fdField.FieldKey; rowField.FieldName = fdField.FieldName; rowField.ParentName = fdField.ParentName; rowField.FieldIndex = fdField.FieldIndex; rowField.FieldType = (int)fdField.FieldType; rowField.FieldTypeName = fdField.FieldTypeName; rowField.Elements = fdField.Elements; rowField.DataSize = fdField.DataSize; if (fdField.Bits > 0) { rowField.FieldName += "<bit: " + fdField.Bits.ToString() + ">"; } rowField.FieldByteOffset = fdField.FieldByteOffset; FieldsTable.AddtblFieldsRow(rowField); }//next fdField return(true); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in AddFieldRows function of DataAccess class."); return(false); } }
public void UpdateIcons(int towerIndex) { switch (towerIndex) { case 0: { iconPosition = new Vector2(489, 170); portraitIndex = new Point(0, 0); iconCurrentFrame.Y = 0; podiumIndex = 0; range = 75; currentFrame = new Point(0, 0); if (GlobalVars.money < Sentry.cost) { iconCurrentFrame.X = 2; return; } } break; case 1: { iconPosition = new Vector2(489, 217); iconCurrentFrame.Y = 1; portraitIndex = new Point(0, 1); podiumIndex = 1; currentFrame = new Point(0, 1); range = 50; if (GlobalVars.money < Bomb.cost) { iconCurrentFrame.X = 2; return; } } break; case 2: { iconPosition = new Vector2(540, 170); iconCurrentFrame.Y = 7; portraitIndex = new Point(0, 7); podiumIndex = 3; currentFrame = new Point(0, 7); range = 75; if (GlobalVars.money < Minigun.cost) { iconCurrentFrame.X = 2; return; } } break; } circle = Tower.CreateCircle(range); prevMouseState = mouseState; mouseState = Mouse.GetState(); if (new Rectangle( (int)iconPosition.X, (int)iconPosition.Y, iconFrameSize.X, iconFrameSize.Y).Contains(new Point(mouseState.X, mouseState.Y))) { iconCurrentFrame.X = 1; if (prevMouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == ButtonState.Released) { GlobalVars.onMouse = true; GlobalVars.towerIndexUnderMouse = towerIndex; } } else { iconCurrentFrame.X = 0; if (mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released) { if (GlobalVars.onMouse && GlobalVars.towerIndexUnderMouse == towerIndex) { try { { Vector2 pos = new Vector2(mouseState.X / 30 * 30 + 15, mouseState.Y / 30 * 30 + 15); switch (towerIndex) { case 0: if (FieldsTable.EasyMapSet(mouseState.X, mouseState.Y, 2)) { GlobalVars.money -= Sentry.cost; SpriteManager.towerList.Add(new Sentry(pos)); } break; case 1: if (FieldsTable.EasyMapSet(mouseState.X, mouseState.Y, 2)) { GlobalVars.money -= Bomb.cost; SpriteManager.towerList.Add(new Bomb(pos)); } break; case 2: if (FieldsTable.EasyMapSet(mouseState.X, mouseState.Y, 2)) { GlobalVars.money -= Minigun.cost; SpriteManager.towerList.Add(new Minigun(pos)); } break; } GlobalVars.onMouse = false; } } catch (Exception) { } } } } if (GlobalVars.onMouse) { TowerUnderMouseSprite.Update(portraitIndex); } }
public override void Update(GameTime gameTime, Rectangle clientBounds) { #region Направление switch (CurrentDirection) { case direction.Right: { if (FieldsTable.EasyMapGet((int)position.X + frameSize.X / 2, (int)position.Y) == 1) { base.speed.X = speed; angle = 0; } else { base.speed.X = 0; if (FieldsTable.EasyMapGet((int)position.X, (int)position.Y + frameSize.Y / 2) == 1) { CurrentDirection = direction.Down; } else { CurrentDirection = direction.Up; } } } break; case direction.Left: { if (FieldsTable.EasyMapGet((int)position.X - frameSize.X / 2, (int)position.Y) == -1) { //финиширует только по этому направлению, т.к. уровень один Remove = true; return; } if (FieldsTable.EasyMapGet((int)position.X - frameSize.X / 2, (int)position.Y) == 1) { base.speed.X = -speed; angle = (float)Math.PI; } else { base.speed.X = 0; if (FieldsTable.EasyMapGet((int)position.X, (int)position.Y + frameSize.Y / 2) == 1) { CurrentDirection = direction.Down; } else { CurrentDirection = direction.Up; } } } break; case direction.Down: { if (FieldsTable.EasyMapGet((int)position.X, (int)position.Y + frameSize.Y / 2) == 1) { base.speed.Y = speed; angle = (float)Math.PI / 2; } else { base.speed.Y = 0; if (FieldsTable.EasyMapGet((int)position.X + frameSize.X, (int)position.Y) == 1) { CurrentDirection = direction.Right; } else { CurrentDirection = direction.Left; } } } break; case direction.Up: { if (FieldsTable.EasyMapGet((int)position.X, (int)position.Y - frameSize.Y / 2) == 1) { base.speed.Y = -speed; angle = -(float)Math.PI / 2; } else { base.speed.Y = 0; if ( FieldsTable.EasyMapGet((int)position.X + frameSize.X, (int)position.Y - FieldsTable.cellTable.Y / 4) == 1) { CurrentDirection = direction.Right; } else { CurrentDirection = direction.Left; } } } break; } #endregion if (Health <= 0) { if (!isDead) { GlobalVars.money += Bounty; GlobalVars.score += Score; } isDead = true; Speed = Vector2.Zero; base.layerDepth = 0.01f; if (base.currentFrame.X < 4) { base.currentFrame.X = 4; } timeSinceLastFrame += gameTime.ElapsedGameTime.Milliseconds; if (timeSinceLastFrame > 500) { timeSinceLastFrame = 0; base.currentFrame.X++; if (base.currentFrame.X > 5) { Remove = true; } } } else { base.Update(gameTime, clientBounds); } }