Ejemplo n.º 1
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();
        }