Пример #1
0
        public void Undo()
        {
            if (UndoStack.Count > 0)
            {
                //SaveXml();//현재상태 저장

                //XmlDocument doc = UndoStack.Pop();
                RedoStack.Push(_xDoc);//현재상태는 일단 Redo stack으로..
            
                XmlDocument doc = UndoStack.Pop();
                _xDoc = doc;//현재상태 갱신..
                XmlNode rootNode = XmlGetter.FirstChild(doc);// XmlGetter.RootNode(out _xDoc, _filePath, ".\\ComponentSchemas\\LayoutCollectionSchema.xsd", XmlSchemaValidation);
                //try
                {
                    LoadXml(_xDoc, rootNode);
                }
                this.Interface.RunEvent(
            }
        }
Пример #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;
                }
            }
        }
Пример #3
0
        void GetRows(XmlNodeList xRows)
        {
            for (int i = 0; i < xRows.Count; i++)//Row 들
            {
                XmlNode rowNode = xRows[i];
                String  name    = rowNode.Attributes["Name"].Value;
                if (rowNode.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }

                XmlNodeList rowChildren             = xRows[i].ChildNodes;
                int         rowHeight               = -1;
                Dictionary <String, object> relObjs = new Dictionary <string, object>();
                object[] args     = new object[_columnTypes.Count];
                String[] tooltips = new string[_columnTypes.Count];
                for (int chi = 0; chi < rowNode.ChildNodes.Count; chi++)
                {
                    XmlNode child = rowChildren[chi];
                    if (child.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }

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

                            if (info.Name.Equals("Height"))
                            {
                                rowHeight = 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;
                                    }

                                    relObjs[obj.Attributes["Name"].Value] = obj.Attributes["Value"].Value;
                                }
                            }
                        }
                    }
                    else if (child.Name.Equals("Cells")) //cells
                    {
                        XmlNodeList cells = child.ChildNodes;
                        if (cells.Count < _columnTypes.Count)
                        {
                            MessageBox.Show("ParsingError: Table/Rows/Row/Cells/ 아래의 Cell 태그의 수가 Column의 개수보다 적습니다. Row:" + i);
                            return;
                        }
                        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;
                            }

                            XmlAttribute attr = null;

                            if (cell.Attributes != null)
                            {
                                attr = cell.Attributes["Tooltip"];
                            }
                            if (attr != null)
                            {
                                tooltips[count] = attr.Value;
                            }
                            else
                            {
                                tooltips[count] = "";
                            }

                            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)(_itemTypes.ToList().IndexOf(xItemType.Value));
                                    }
                                }
                                args[count] = info;
                            }
                            else //simple value
                            {
                                if (cell.InnerText == null)
                                {
                                    args[count] = GetSimpleValue(count, "");
                                }
                                else
                                {
                                    args[count] = GetSimpleValue(count, cell.InnerText);
                                }
                            }
                            count++;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Parsing Error: /Table/Rows/Row/ 아래에는 RowInfo 나 Cells 만 올 수 있습니다.");
                        return;
                    }
                }//Row's Children

                EasyGridRow row;
                if (relObjs.Count == 0)
                {
                    row = AddARow(args);
                }
                else
                {
                    row = AddARow(relObjs, args, tooltips);
                }
                _rows[name] = row;
            }
        }