예제 #1
0
        public void CaptureSnapshot(TestObjectNurse nurseObject)
        {
            string token = null;

            UIATestObject testObject = nurseObject.TestObject as UIATestObject;

            if (testObject == null)
            {
                return;                     //not the UIA object
            }
            AutomationElement element = testObject.AutomationElement;

            if (SpySettings.CaptureSnapshots)
            {
                try
                {
                    //capture snapshot of clicked area
                    SnapshotHelper.CaptureTempSnapshot(element, out token);
                }
                catch (ElementNotAvailableException)
                {
                    MessageBox.Show(StringResources.LPSpy_SpyMainWindow_CannotFindObjectMsg);
                }
                catch (ApplicationException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            nurseObject.ImageFile = SnapshotHelper.GetCachedSnapshot(token, nurseObject.ImageFile);


            AppEnvironment.SetModelChanged(true);
        }
예제 #2
0
        private void btnAddObject_Click(object sender, EventArgs e)
        {
            this.Visible        = false;
            this._owner.Visible = true;

            if (this._modeType == AddObjWndModeType.Normal && this.UpdateSelectedTree != null)
            {
                TestObjectNurse selfNurse = GetNurseObjectsLine(objectTree);

                TestObjectNurse leftNurse = null, rightNurse = null;

                if (_leftElement != null)
                {
                    TreeNode node = _leftElement.GetContext <TreeNode>();
                    if (node.Checked)
                    {
                        leftNurse = _leftElement.ToNurseObject();
                    }
                }
                if (_rightElement != null)
                {
                    TreeNode node = _rightElement.GetContext <TreeNode>();
                    if (node.Checked)
                    {
                        rightNurse = _rightElement.ToNurseObject();
                    }
                }

                selfNurse.ImageFile = SnapshotHelper.GetCachedSnapshot(_token);

                TestObjectNurse rootNurse;
                TestObjectNurse temp;
                temp = selfNurse;
                do
                {
                    rootNurse = temp;
                    temp      = rootNurse.ParentNurse;
                } while (temp != null);

                UpdateSelectedTree(rootNurse, selfNurse, leftNurse, rightNurse);
            }

            if (this._modeType == AddObjWndModeType.UpdateProperties && this.UpdateSelectedNode != null)
            {
                ElementProperties elementProperties = null;
                if (this.objectTree.SelectedNode != null &&
                    null != (elementProperties = objectTree.SelectedNode.Tag as ElementProperties))
                {
                    if (SpySettings.CaptureSnapshots)
                    {
                        //capture snapshot of clicked area
                        SnapshotHelper.CaptureTempSnapshot(elementProperties.AutomationElement, out _token);
                    }
                    UpdateSelectedNode(elementProperties, SnapshotHelper.GetCachedSnapshot(_token));
                }
                else
                {
                    UpdateSelectedNode(_selfElement, SnapshotHelper.GetCachedSnapshot(_token));
                }
            }


            this.Dispose();
        }