Exemplo n.º 1
0
        private AccNode parseLines(ArrayList accLines)
        {
            AccNode     parent = null;
            IEnumerator it     = accLines.GetEnumerator();
            AccNode     an     = BuildNode(parent, ref it, 0);

            return(an);
        }
Exemplo n.º 2
0
        public bool go()
        {
            ArrayList nodes   = readAccExplorerText();
            AccNode   ansRoot = parseLines(nodes);

            writeModel(ansRoot);
            return(true);
        }
Exemplo n.º 3
0
        private bool writeModel(AccNode root)
        {
            StreamWriter sw = File.CreateText(m_Target);
            sw.WriteLine (@"<?xml version=""1.0"" encoding=""UTF-8""?>");
            sw.WriteLine (@"<?xml-stylesheet type=""text/xsl"" href=""Convert.xsl""?>");

            sw.WriteLine (@"<gui-tree>");
            writeNode(sw, root, 0);
            sw.WriteLine (@"</gui-tree>");

            sw.Close();
            return true;
        }
Exemplo n.º 4
0
        private bool writeModel(AccNode root)
        {
            StreamWriter sw = File.CreateText(m_Target);

            sw.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
            sw.WriteLine(@"<?xml-stylesheet type=""text/xsl"" href=""Convert.xsl""?>");

            sw.WriteLine(@"<gui-tree>");
            writeNode(sw, root, 0);
            sw.WriteLine(@"</gui-tree>");

            sw.Close();
            return(true);
        }
Exemplo n.º 5
0
 private AccNode BuildNode(AccNode parent, ref IEnumerator it, int sib)
 {
     AccNode an = null;
     if (!it.MoveNext()) return an; // end of data lines
     an = AccNode.parseNCreate(parent, sib, ref it);
     if (an.NumChildren > 0)
     { // this is a child of parent
         AccNode child = null;
         for (int i = 0; i < an.NumChildren; i++)
         {
             child = BuildNode(an, ref it, i);
             an.addChild(child);
         }
     }
     return an;
 }
Exemplo n.º 6
0
        private AccNode BuildNode(AccNode parent, ref IEnumerator it, int sib)
        {
            AccNode an = null;

            if (!it.MoveNext())
            {
                return(an);                            // end of data lines
            }
            an = AccNode.parseNCreate(parent, sib, ref it);
            if (an.NumChildren > 0)
            {             // this is a child of parent
                AccNode child = null;
                for (int i = 0; i < an.NumChildren; i++)
                {
                    child = BuildNode(an, ref it, i);
                    an.addChild(child);
                }
            }
            return(an);
        }
Exemplo n.º 7
0
        public static AccNode parseNCreate(AccNode parent, int sibNum, ref IEnumerator it)
        {
            string image  = (string)it.Current;
            int    before = skipLeveling(image);            // skip the | '--- stuff
            int    after  = -1;

            // rs.ReadLine breaks lines at \r which can be data
            // So, if the cue isn't found, tack the next line to the image.
            while ((after = image.IndexOf("[")) == -1)
            {
                image = fixLine(image, ref it);
            }
            string  name = image.Substring(before, after - before);
            string  role = getValueFromLine(", Role: ", ", State:", image, ref it);
            AccNode node = new AccNode(parent, name, role);

            node.Level   = (int)Math.Ceiling((before - 1.0) / 6.0);             // not a bad estimate
            node.Sibling = sibNum;

            node.Action      = getValueFromLine("] {Action: ", ", Description:", image, ref it);
            node.Description = getValueFromLine(", Description: ", ", Help:", image, ref it);
            node.Help        = getValueFromLine(", Help: ", ", Help Topic:", image, ref it);
            node.HelpTopic   = getValueFromLine(", Help Topic: ", ", Shortcut:", image, ref it);
            node.Shortcut    = getValueFromLine(", Shortcut: ", ", Location:", image, ref it);
            string loc = getValueFromLine(", Location: ", ", Num Children:", image, ref it);
            int    x = 0, y = 0, w = 0, h = 0;

            if (loc != null)
            {
                getLocFromValue(loc, out x, out y, out h, out w);
            }
            node.LocationX   = x;             // can't set a property as an out parameter!
            node.LocationY   = y;
            node.LocationH   = h;
            node.LocationW   = w;
            node.NumChildren = getIntFromLine(", Num Children: ", ", Role:", image);
            node.State       = getValueFromLine(", State: ", ", Value:", image, ref it);
            node.Value       = getValueFromLine(", Value: ", null, image, ref it);
            return(node);
        }
Exemplo n.º 8
0
 public AccNode(AccNode parent, string name, string role)
 {
     m_Parent = parent;
     m_Name = name;
     m_Role = role;
 }
Exemplo n.º 9
0
 public void addChild(AccNode child)
 {
     m_Children.Add(child);
 }
Exemplo n.º 10
0
        public static AccNode parseNCreate(AccNode parent, int sibNum, ref IEnumerator it)
        {
            string image = (string)it.Current;
            int before   = skipLeveling(image); // skip the | '--- stuff
            int after    = -1;
            // rs.ReadLine breaks lines at \r which can be data
            // So, if the cue isn't found, tack the next line to the image.
            while ((after = image.IndexOf("[")) == -1)
                image = fixLine(image, ref it);
            string name  = image.Substring(before, after-before);
            string role  = getValueFromLine(", Role: ", ", State:", image, ref it);
            AccNode node = new AccNode(parent, name, role);

            node.Level       = (int)Math.Ceiling((before-1.0)/6.0); // not a bad estimate
            node.Sibling     = sibNum;

            node.Action      = getValueFromLine("] {Action: ", ", Description:", image, ref it);
            node.Description = getValueFromLine(", Description: ", ", Help:", image, ref it);
            node.Help        = getValueFromLine(", Help: ", ", Help Topic:", image, ref it);
            node.HelpTopic   = getValueFromLine(", Help Topic: ", ", Shortcut:", image, ref it);
            node.Shortcut    = getValueFromLine(", Shortcut: ", ", Location:", image, ref it);
            string loc       = getValueFromLine(", Location: ", ", Num Children:", image, ref it);
            int x = 0, y = 0, w = 0, h = 0;
            if (loc != null) getLocFromValue(loc, out x, out y, out h, out w);
            node.LocationX   = x; // can't set a property as an out parameter!
            node.LocationY   = y;
            node.LocationH   = h;
            node.LocationW   = w;
            node.NumChildren = getIntFromLine(", Num Children: ", ", Role:", image);
            node.State       = getValueFromLine(", State: ", ", Value:", image, ref it);
            node.Value       = getValueFromLine(", Value: ", null, image, ref it);
            return node;
        }
Exemplo n.º 11
0
        private bool writeNode(StreamWriter sw, AccNode node, int level)
        {
            string role = (node.Role).Replace(' ','-');
            sw.Write (@"<{0}",role);
            sw.Write (@" name=""{0}""",node.Name);
            sw.Write (@" lev=""{0}""",level); // not node.Level
            sw.Write (@" sib=""{0}""",node.Sibling);
            if (node.Shortcut != null)		sw.Write (@" sc=""{0}""",node.Shortcut);
            if (node.State != null)			sw.Write (@" st=""{0}""",node.State);
            if (node.Description != null)	sw.Write (@" desc=""{0}""",(node.Description).Replace("<","&lt;"));
            if (node.Action != null)		sw.Write (@" act=""{0}""",node.Action);
            if (node.Help != null)			sw.Write (@" help=""{0}""",node.Help);
            if (node.HelpTopic != null)		sw.Write (@" htop=""{0}""",node.HelpTopic);
            if (node.LocationX != 0)		sw.Write (@" locX=""{0}""",node.LocationX);
            if (node.LocationY != 0)		sw.Write (@" locY=""{0}""",node.LocationY);
            if (node.LocationH != 0)		sw.Write (@" locH=""{0}""",node.LocationH);
            if (node.LocationW != 0)		sw.Write (@" locW=""{0}""",node.LocationW);
            if (node.NumChildren != 0)	    sw.Write (@" child=""{0}""",node.NumChildren);
            if (node.Value != null)			sw.Write (@" value=""{0}""",node.Value);

            IEnumerator it = node.getChildren();
            if (!it.MoveNext()) sw.WriteLine (@"/>");
            else
            {
                it.Reset();
                sw.WriteLine (@">");
                while (it.MoveNext() && it.Current != null) // shouldn't be null!
                    writeNode(sw,(AccNode)it.Current,level+1);
                sw.WriteLine (@"</{0}>",role);
            }
            return true;
        }
Exemplo n.º 12
0
        private bool writeNode(StreamWriter sw, AccNode node, int level)
        {
            string role = (node.Role).Replace(' ', '-');

            sw.Write(@"<{0}", role);
            sw.Write(@" name=""{0}""", node.Name);
            sw.Write(@" lev=""{0}""", level);             // not node.Level
            sw.Write(@" sib=""{0}""", node.Sibling);
            if (node.Shortcut != null)
            {
                sw.Write(@" sc=""{0}""", node.Shortcut);
            }
            if (node.State != null)
            {
                sw.Write(@" st=""{0}""", node.State);
            }
            if (node.Description != null)
            {
                sw.Write(@" desc=""{0}""", (node.Description).Replace("<", "&lt;"));
            }
            if (node.Action != null)
            {
                sw.Write(@" act=""{0}""", node.Action);
            }
            if (node.Help != null)
            {
                sw.Write(@" help=""{0}""", node.Help);
            }
            if (node.HelpTopic != null)
            {
                sw.Write(@" htop=""{0}""", node.HelpTopic);
            }
            if (node.LocationX != 0)
            {
                sw.Write(@" locX=""{0}""", node.LocationX);
            }
            if (node.LocationY != 0)
            {
                sw.Write(@" locY=""{0}""", node.LocationY);
            }
            if (node.LocationH != 0)
            {
                sw.Write(@" locH=""{0}""", node.LocationH);
            }
            if (node.LocationW != 0)
            {
                sw.Write(@" locW=""{0}""", node.LocationW);
            }
            if (node.NumChildren != 0)
            {
                sw.Write(@" child=""{0}""", node.NumChildren);
            }
            if (node.Value != null)
            {
                sw.Write(@" value=""{0}""", node.Value);
            }

            IEnumerator it = node.getChildren();

            if (!it.MoveNext())
            {
                sw.WriteLine(@"/>");
            }
            else
            {
                it.Reset();
                sw.WriteLine(@">");
                while (it.MoveNext() && it.Current != null)                 // shouldn't be null!
                {
                    writeNode(sw, (AccNode)it.Current, level + 1);
                }
                sw.WriteLine(@"</{0}>", role);
            }
            return(true);
        }
Exemplo n.º 13
0
 public AccNode(AccNode parent, string name, string role)
 {
     m_Parent = parent;
     m_Name   = name;
     m_Role   = role;
 }
Exemplo n.º 14
0
 public void addChild(AccNode child)
 {
     m_Children.Add(child);
 }