예제 #1
0
        /// <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]);
            }
        }
예제 #2
0
        public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false)
        {
            if (rootNode == null)
            {
                return;
            }
            XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this);

            String name = XmlGetter.Attribute(rootNode, "Name");
            //if (rowNode.NodeType == XmlNodeType.Comment) continue;

            XmlNodeList rowChildren = rootNode.ChildNodes;

            //Dictionary<String, object> relObjs = new Dictionary<string, object>();

            for (int chi = 0; chi < rowChildren.Count; chi++)
            {
                XmlNode rowNode = rowChildren[chi];
                //if (child.NodeType == XmlNodeType.Comment) continue;

                if (rowNode.Name.Equals("RowInfo"))
                {
                    for (int ri = 0; ri < rowNode.ChildNodes.Count; ri++)
                    {
                        XmlNode info = rowNode.ChildNodes[ri];
                        if (info.NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }

                        if (info.Name.Equals("Height"))
                        {
                            if (info.InnerText != null && info.InnerText.Length > 0)
                            {
                                this.Height = int.Parse(info.InnerText);
                            }
                        }
                        else if (info.Name.Equals("RelativeObjects"))
                        {
                            for (int roi = 0; roi < info.ChildNodes.Count; roi++)
                            {
                                XmlNode obj = info.ChildNodes[roi];
                                if (obj.NodeType == XmlNodeType.Comment)
                                {
                                    continue;
                                }

                                this.RelativeObject[XmlGetter.Attribute(obj, "Name")] = XmlGetter.Attribute(obj, "Value");
                            }
                        }
                    }
                }
                else if (rowNode.Name.Equals("Cells")) //cells
                {
                    XmlNodeList cells = rowNode.ChildNodes;
                    if (cells.Count < _table.ColumnCount)
                    {
                        throw new Exception("ParsingError: Table/Rows/Row/Cells/ 아래의 Cell 태그의 수가 Column의 개수보다 적습니다. Row:" + name);
                    }
                    object[] args     = new object[_table.ColumnCount];
                    String[] tooltips = new string[_table.ColumnCount];

                    int count = 0;
                    for (int ci = 0; ci < cells.Count; ci++) //Cell
                    {
                        XmlNode cell = cells[ci];
                        if (cell.NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }
                        else if (cell.Name.Equals("Cell") == false)
                        {
                            continue;
                        }

                        //string value = XmlGetter.Attribute(cell, "Value");
                        string tooltip = XmlGetter.Attribute(cell, "Tooptip");

                        if (tooltip.Length > 0)
                        {
                            tooltips[count] = tooltip;
                        }

                        string value = XmlGetter.Attribute(cell, "Value");
                        if (value.Length > 0)
                        {
                            //if (value == null) args[count] = GetSimpleValue(count, "");
                            //else
                            args[count] = GetSimpleValue(count, value);
                        }
                        else
                        {
                            XmlNode firstChild = XmlGetter.FirstChild(cell);

                            if (firstChild != null && firstChild.Name.Equals("ItemInfo")) //itemInfo
                            {
                                EasyGridCellInfo info = GetCellInfo(count, firstChild.ChildNodes);
                                if (firstChild.Attributes != null)
                                {
                                    XmlAttribute xItemType = firstChild.Attributes["ItemType"];
                                    if (xItemType != null)
                                    {
                                        info.ItemType = (ItemTypes)(XmlScenarioTable.ItemTypesText.ToList().IndexOf(xItemType.Value));
                                    }
                                }
                                args[count] = info;
                            }
                            else //simple value
                            {
                                if (value == null)
                                {
                                    args[count] = GetSimpleValue(count, "");               //빈 셀일때 default값을 받아온다.
                                }
                                else
                                {
                                    args[count] = GetSimpleValue(count, cell.InnerText);
                                }
                            }
                        }
                        count++;
                    }
                    this.MakeCells(args, tooltips);
                }
                else if (rowNode.Name.Equals("ChosenCells")) //cells
                {
                    XmlNodeList cells = rowNode.ChildNodes;


                    ListDic <String, String> ttps   = new ListDic <string, string>();
                    ListDic <String, object> argDic = new ListDic <string, object>();

                    /*
                     * for (int i = 0; i < _table.ColumnCount; i++)
                     * {
                     *  argDic[_table.ColumnName(i)] = GetSimpleValue(i, "");
                     *  ttps[_table.ColumnName(i)] = "";
                     * }
                     */
                    for (int ci = 0; ci < cells.Count; ci++) //Cell
                    {
                        XmlNode cell    = cells[ci];
                        String  colName = XmlGetter.Attribute(cell, "ColumnName");

                        if (cell.NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }
                        else if (cell.Name.Equals("Cell") == false)
                        {
                            continue;                                         //반드시 Cell Tag여야 한다.
                        }
                        else if (colName.Length == 0)
                        {
                            continue;                          //반드시 columnName이 있어야 한다.
                        }
                        string value   = XmlGetter.Attribute(cell, "Value");
                        string tooltip = XmlGetter.Attribute(cell, "Tooptip");

                        ttps[colName] = tooltip;
                        if (value.Length > 0)
                        {
                            argDic[colName] = value;
                        }
                        else
                        {
                            XmlNode itemInfo = XmlGetter.FirstChild(cell);

                            if (itemInfo != null && itemInfo.Name.Equals("ItemInfo")) //itemInfo
                            {
                                String    itemTypeText = XmlGetter.Attribute(itemInfo, "ItemType");
                                ItemTypes itemType     = (ItemTypes)(XmlScenarioTable.ItemTypesText.ToList().IndexOf(itemTypeText));

                                EasyGridCellInfo info = GetCellInfo(itemType, itemInfo.ChildNodes);
                                argDic[colName] = info;
                            }
                            else
                            {
                                throw new Exception("Cell의 내부 Tag로서 유효한 것은 ItemInfo밖에 없습니다. ChosenCell의 값은 반드시 있어야합니다.");
                            }
                        }
                    }
                    this.MakeCells(argDic, ttps);
                }
                else
                {
                    MessageBox.Show("Parsing Error: /Table/Rows/Row/ 아래에는 RowInfo 나 Cells 또는 ChosenCells 만 올 수 있습니다.");
                    return;
                }
            }
        }