private void WritePathElement(XmlWriter xmlwriter, JavaWindow javawin)
 {
     if (javawin.Parent == null)
     {
         return; // don't create an element for the top level window
     }
     /// Don't use name...
     /// Reason #1: The name of a textbox is the text in the box and changes frequently
     /// Reason #2: While the name of a button may not change, it is definitely not unique and could also change.  For example an OK button might exist all over.
     ///
     //if (!String.IsNullOrEmpty(javawin.Name))
     //{
     //    if (javawin.Parent != null)
     //        WritePathElement(xmlwriter, javawin.Parent);
     //    xmlwriter.WriteStartElement("NextName");
     //    xmlwriter.WriteAttributeString("offset", "0");
     //    xmlwriter.WriteString(javawin.Name);
     //    xmlwriter.WriteEndElement();
     //}
     //else
     {
         if (javawin.Parent != null)
         {
             WritePathElement(xmlwriter, javawin.Parent);
         }
         xmlwriter.WriteStartElement("NextRole");
         xmlwriter.WriteAttributeString("offset", GetOffset(javawin, javawin.Role).ToString());
         xmlwriter.WriteString(javawin.Role);
         xmlwriter.WriteEndElement();
     }
 }
Beispiel #2
0
        private JavaWindowViewModel(JavaWindow win, JavaWindowViewModel parent)
        {
            _win    = win;
            _parent = parent;

            _children = new ReadOnlyCollection <JavaWindowViewModel>(
                (from child in _win.Children
                 select new JavaWindowViewModel(child, this))
                .ToList <JavaWindowViewModel>());
        }
        public JavaWindow(JavaWindow parent, IntPtr javaWin, int vmId)
        {
            _parent = parent;
            if (javaWin == IntPtr.Zero)
            {
                return;
            }
            _vmId    = vmId;
            _javaWin = javaWin;

            LoadData();
        }
        private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            try
            {
                jw = (e.NewValue as JavaWindowViewModel).Win;
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Role:" + jw.Role);
                sb.AppendLine("Name:" + jw.Name);
                sb.AppendLine("IndexInParent:" + jw.IndexInParent);
                sb.AppendLine("AccessibleAction:" + jw.AccessibleAction);
                sb.AppendLine("AccessibleComponent:" + jw.AccessibleComponent);
                sb.AppendLine("AccessibleInterfaces:" + jw.AccessibleInterfaces);
                sb.AppendLine("AccessibleSelection:" + jw.AccessibleSelection);
                sb.AppendLine("AccessibleText:" + jw.AccessibleText);
                sb.AppendLine("ChildrenCount:" + jw.ChildrenCount.ToString());
                sb.AppendLine("Description:" + jw.Description);
                sb.AppendLine("X:" + jw.X);
                sb.AppendLine("Y:" + jw.Y);
                sb.AppendLine("Width:" + jw.Width);
                sb.AppendLine("Height:" + jw.Height);
                sb.AppendLine("Role_en_US:" + jw.Role_en_US);
                sb.AppendLine("States:" + jw.States);
                sb.AppendLine("States_en_US:" + jw.States_en_US);
                sb.AppendLine("");
                sb.AppendLine("");
                sb.AppendLine("XML");
                sb.AppendLine("---------");
                sb.AppendLine(jw.SuggestedXml);
                displayOutput.Text = sb.ToString();
                ddaActionPanel.Items.Clear();
                foreach (string s in jw.javaactions)
                {
                    Button b = new Button();
                    b.Content = s;
                    b.Margin  = new Thickness(1);
                    b.Padding = new Thickness(3);
                    b.Click  += DDAAction_Click;
                    ddaActionPanel.Items.Add(b);

                    Button b2 = new Button();
                    b2.Content = s;
                    b2.Margin  = new Thickness(1);
                    b2.Padding = new Thickness(3);
                    b2.Click  += JABAction_Click;
                    directActionPanel.Items.Add(b2);
                }
            }
            catch
            { }
        }
        private int GetOffset(JavaWindow javawin, string role)
        {
            JavaWindow parent = javawin.Parent;

            if (parent == null)
            {
                return(0);
            }
            int ioffset = 0;

            for (int i = 0; i < parent.Children.Count(); i++)
            {
                if (parent.Children[i] == javawin)
                {
                    return(ioffset);
                }
                if (parent.Children[i].Role == role)
                {
                    ioffset++;
                }
            }
            return(0);
        }
Beispiel #6
0
 public JavaWindowViewModel(JavaWindow win)
     : this(win, null)
 {
 }
Beispiel #7
0
 public JavaTreeViewModel(JavaWindow rootWindow)
 {
     _rootWindow      = new JavaWindowViewModel(rootWindow);
     _firstGeneration = new ReadOnlyCollection <JavaWindowViewModel>(new JavaWindowViewModel[] { _rootWindow });
 }