/// <summary> /// 다른 item들이 빈 공간만큼 왼쪽으로 이동한다. /// </summary> /// <param name="index"></param> public void PopAt(int index) { if (_items.ContainsKey(index) == false) { return; //해당 자리에 아무것도 없으면 그냥 리턴 } BitItem item = _items[index]; //item to remove.. _lastOffset -= item.BitSize; _nextOffset -= item.BitSize; ListDic <int, BitItem> newItemList = new ListDic <int, BitItem>(); int sizeToMove = item.BitSize; foreach (int key in _items.Keys) //새로운 list를 만듬.. { if (key < item.StartOffset) //없어질 item을 제외하고, //뒤쪽에 존재하는 item들을 모두 모은다. { newItemList.Add(key, _items[key]); } else if (key > item.StartOffset) { newItemList.Add(key - item.BitSize, _items[key]);//빠질 item의 크기만큼 이동한다 } else { //pass..pop할 item } } _items = newItemList; int i = index; if (_bitArea != null) { while (i < BitSize)//_bitArea를 만듬.. { if (_items[i] != null) { for (int j = 0; j < _items[i].BitSize; j++) { _bitArea[i + j] = _items[i].StartOffset; } i += _items[i].BitSize; continue; } i++; } } if (E_BitItemRemoved != null && EventEnabled) { E_BitItemRemoved(_parent, _items[index]); } }
internal void Add(wTreeNode node, bool occurEvent) { string name = node.Name; if (name == null) { name = GetNewName("node"); } else if (_list.ContainsKey(name)) { name = GetNewName(name); } _list.Add(name, node); whenAddNode(node); if (occurEvent) { if (E_TreeListChanged != null) { E_TreeListChanged(_parent); } } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); //int count = 0; //int index = 0; int count = 0; _pacektHandlingType = PacketHandlingTypes.Static;//default foreach (XmlNode fieldNode in rootNode.ChildNodes) { if (fieldNode.Name.Equals(Properties.Resources.Fields_Field_Tag)) { XmlCommandField field = new XmlCommandField(this); field.LoadXml(xDoc, fieldNode); addItem(count++, field.DataSize, field.FieldType == FieldTypes.Dynamic, field.DataType); _fieldList.Add(field.Name, field); if (field.FieldType == FieldTypes.LoopCount) { _loopCountField = field; //field.DataValue = 0; _pacektHandlingType = PacketHandlingTypes.Loop; } else if (field.FieldType == FieldTypes.VariableSize) { _variableSizeField = field; _pacektHandlingType = PacketHandlingTypes.Serial; } else if (field.FieldType == FieldTypes.Variable) { _variableField = field; if (_structType == StructType.Command) { if (_variableSizeField == null) { throw new Exception("There's no FieldType[VariableSizeField] for this field[" + field.Name + "]"); } else { _variableSizeField.DataValue = Buffer.ByteLength(field.TargetBuffer); } } } } else if (fieldNode.Name.Equals(Properties.Resources.Fields_Loop_Tag)) { XmlCommandFields fields = new XmlCommandFields(_parentFields, _structType); String name = XmlGetter.Attribute(fieldNode, Properties.Resources.Fields_Loop_Name_Attr); fields.LoadXml(xDoc, fieldNode, refLoad); TemplateFields = fields; fields.Name = name; fields.TemplateName = name; //NumberOfFields = Convert.ToInt32(SizeDefineField.DataValue);//default로 지정된 크기를 만들어준다. //_fieldsList.Add(name, fields); } } setBuffSize(); //size를 fix함.. int offset = 0; for (int i = 0; i < _fieldList.Values.Count; i++) { _fieldList.ValueList[i].SetTargetBuffer(this.buffer, offset); if (_fieldList.ValueList[i].FieldType == FieldTypes.Dynamic) { _fieldList.ValueList[i].Data = _fieldList.ValueList[i].Data;//실제 값을 넣어준다. } else if (_fieldList.ValueList[i].FieldType == FieldTypes.LoopCount) { _fieldList.ValueList[i].Data = "0"; } else { _fieldList.ValueList[i].Data = _fieldList.ValueList[i].Data;//실제 값을 넣어준다. } offset += _fieldList.ValueList[i].DataSize; } }