コード例 #1
0
        void Put_AddValExpUnitCommand(XmlDocument putDoc, ValExpUnitPutCommand command)
        {
            XmlNode      xmlNode = putDoc.DocumentElement;
            TreeViewItem tvNode  = (TreeViewItem)treeView.Items[0];

            MergeTrees(xmlNode, tvNode, Put_AddValExpUnitCommandMergeTrees, command);
        }
コード例 #2
0
        bool Put_AddValExpUnitCommandMergeTrees(XmlNode xmlNode, TreeViewItem tvNode, Object valExpUnitCommand) // not really all val exp unit, see Put_AddTextRange
        {
            ValExpUnitPutCommand command = valExpUnitCommand as ValExpUnitPutCommand;

            if (XmlNodeChildIsValExpUnit(xmlNode) || xmlNode.FirstChild.NodeType == XmlNodeType.Text)
            {
                CreateOrModifyControlBuilder(tvNode).AddValExpUnitPutCommand(command);
                return(true);
            }

            return(false);
        }
コード例 #3
0
        bool Put_AddValExpUnitRange(String[] commands)
        {
            XmlDocument[] commandDocs = new XmlDocument[6];

            for (int i = 0; i < 6; i++)
            {
                commandDocs[i] = new XmlDocument();
                commandDocs[i].LoadXml(commands[i]);
            }

            int[]    values     = new int[6];
            int[]    exps       = new int[6];
            string[] units      = new string[6];
            String   parentName = ""; // so we don't get a false positive with multiple numeric puts with the same step in a row

            // TODO: check entire xpath rather than just parent name...

            for (int i = 0; i < 6; i++)
            {
                XmlNodeList valNodeList = commandDocs[i].GetElementsByTagName("Val");

                if (valNodeList.Count != 0 && valNodeList[0].FirstChild != null)
                {
                    if (i == 0)
                    {
                        parentName = valNodeList[0].ParentNode.Name;
                    }
                    else if (valNodeList[0].ParentNode.Name != parentName)
                    {
                        return(false);
                    }


                    XmlNodeList expNodeList  = commandDocs[i].GetElementsByTagName("Exp");
                    XmlNodeList unitNodeList = commandDocs[i].GetElementsByTagName("Unit");

                    if (expNodeList.Count == 0 || unitNodeList.Count == 0)
                    {
                        return(false);
                    }

                    if (!int.TryParse(valNodeList[0].FirstChild.InnerText, out values[i]) || !int.TryParse(expNodeList[0].FirstChild.InnerText, out exps[i]))
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            int diff1 = values[1] - values[0];
            int diff2 = values[2] - values[1];

            int diff3 = values[4] - values[3];
            int diff4 = values[5] - values[4];


            if (diff1 == diff2 && diff1 == diff3 && diff1 == diff4)
            {
                XmlNode valNode = commandDocs[0].GetElementsByTagName("Val")[0];
                valNode.FirstChild.InnerText = "{0}";
                ValExpUnitPutCommand command = new ValExpUnitPutCommand();
                command.CommandString = commandDocs[0].OuterXml;
                command.Step          = diff1;
                command.Min           = values[0];
                command.Max           = values[5];
                command.Unit          = commandDocs[0].GetElementsByTagName("Unit")[0].InnerText;
                command.Exp           = int.Parse(commandDocs[0].GetElementsByTagName("Exp")[0].InnerText);

                Put_AddValExpUnitCommand(commandDocs[0], command);
                return(true);
            }

            return(false);
        }
コード例 #4
0
        bool Put_AddTextRange(String[] commands)
        {
            //some of these are not val exp unit commands but they are treated as such since its a small special case, just make sure don't look for val exp unit stuff here it will break stuff.
            XmlDocument[] commandDocs = new XmlDocument[6];
            for (int i = 0; i < 6; i++)
            {
                commandDocs[i] = new XmlDocument();
                commandDocs[i].LoadXml(commands[i]);
            }


            int[]   values = new int[6];
            String  xpath;
            XmlNode xmlNode;

            for (xmlNode = commandDocs[0].DocumentElement; xmlNode.FirstChild != null; xmlNode = xmlNode.FirstChild)
            {
                ;
            }

            if (xmlNode.Value == null)
            {
                return(false);
            }

            if (!int.TryParse(xmlNode.Value, out values[0]))
            {
                return(false);
            }

            xpath = GetXpath(xmlNode);

            for (int i = 1; i < 6; i++)
            {
                for (xmlNode = commandDocs[i].DocumentElement; xmlNode.FirstChild != null; xmlNode = xmlNode.FirstChild)
                {
                    ;
                }
                String xpath2 = GetXpath(xmlNode);

                if (xpath != xpath2)
                {
                    return(false);
                }

                if (!int.TryParse(xmlNode.Value, out values[i]))
                {
                    return(false);
                }
            }

            int diff1 = values[1] - values[0];
            int diff2 = values[2] - values[1];

            int diff3 = values[4] - values[3];
            int diff4 = values[5] - values[4];

            if (diff1 == diff2 && diff1 == diff3 && diff1 == diff4)
            {
                xmlNode.InnerText = "{0}";
                ValExpUnitPutCommand command = new ValExpUnitPutCommand();
                command.CommandString = xmlNode.OwnerDocument.OuterXml;
                command.Step          = diff1;
                command.Min           = values[0];
                command.Max           = values[5];
                command.Unit          = "";
                command.Exp           = 0;

                Put_AddValExpUnitCommand(xmlNode.OwnerDocument, command);
                return(true);
            }

            return(false);
        }
コード例 #5
0
 public void AddValExpUnitPutCommand(ValExpUnitPutCommand command)
 {
     valExpUnitPutCommand = command;
     putCommand           = command.CommandString;
 }