Пример #1
0
        private void OnMruFile(int number, String filename)
        {
            bool loadSuccessful = false;

            try
            {
                SpyWindowHelper.WantToSave(_rootNurseObject);
                loadSuccessful = ModelFileHandler.LoadRecentModelFile(filename, _presenterModel.GetTreeView());
            }
            catch (Exception ex)
            {
                //"Invalid file format, please check log files for more details"
                MessageBox.Show(StringResources.LPSpy_SpyMainWindow_InvalidFileFormat);
                //TODO: log message
                MessageBox.Show(ex.ToString());
            }

            if (loadSuccessful)
            {
                mruMenu.SetFirstFile(number);
            }
            else
            {
                //The file '{0}' cannot be opened and will be removed from the Recent list(s)
                string message = StringResources.LPSpy_SpyMainWindow_FileRemovedFromRecentList;
                MessageBox.Show(string.Format(message, filename)
                                , ""
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Error);
                mruMenu.RemoveFile(number);
            }
        }
Пример #2
0
 private void chineseMenuItem_Click(object sender, EventArgs e)
 {
     if (SpySettings.Language == AppLanguageEnum.English)
     {
         SpyWindowHelper.SwitchLanguage(AppLanguageEnum.Chinese, () => { SpyWindowHelper.WantToSave(_rootNurseObject); });
     }
 }
Пример #3
0
        private void SpyMainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            //check whether need to save before exit
            SpyWindowHelper.WantToSave(_rootNurseObject);

            SpySettings.SaveUserSettings();
            mruMenu.SaveToRegistry();
            mruMenu.BuildJumpList();
        }
Пример #4
0
        //menu -> new
        private void newMenuItem_Click(object sender, EventArgs e)
        {
            SpyWindowHelper.WantToSave(_rootNurseObject);

            string filePath = null;

            if (ModelFileHandler.DlgNewModelFile(out filePath))
            {
                _presenterModel.NewModel(filePath);
            }
        }
Пример #5
0
        public void mnuPropertyRemove_Click(object sender, EventArgs e)
        {
            string key = this.SelectedGridItem.PropertyDescriptor.Name;
            TestObjectNurse nurseObject = (TestObjectNurse)this.Tag;
            if (SpyWindowHelper.DeleteSelectedProperties(key, nurseObject.TestObject))
            {
                SetTestObject(nurseObject);

                AppEnvironment.SetModelChanged(true);
            }

        }
        private void AddButton_Click(object sender, EventArgs e)
        {
            TestObjectNurse nurseObject = TestObjectNurse.FromTreeNode((TreeNode)this.Tag);

            SpyWindowHelper.AddSelectedProperty(propertyGrid, nurseObject);

            if (EndUpdating != null)
            {
                EndUpdating(nurseObject);
            }
            this.Dispose();

        }
Пример #7
0
        //menu -> open
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            SpyWindowHelper.WantToSave(_rootNurseObject);
            try
            {
                if (_presenterModel.DlgOpenModelFile())
                {
                    mruMenu.AddFile(AppEnvironment.CurrentModelPath);
                }
            }
            catch (Newtonsoft.Json.JsonReaderException ex)
            {
                //Invalid file format, please check log files for more detail
                MessageBox.Show(StringResources.LPSpy_SpyMainWindow_InvalidFileFormat);

                _Logger.WriteWarning(ex.ToString());
            }
        }
Пример #8
0
 private void documentsMenuItem_Click(object sender, EventArgs e)
 {
     SpyWindowHelper.ShowHelp();
 }
Пример #9
0
        private bool MergeObjectsToMainTree(TestObjectNurse repoNurseNode, IEnumerable <ITestObject> testObjectNodes) //addCollection
        {
            bool found;
            bool changed = false;
            bool web     = false;

            foreach (TestObjectNurse testObjectNurse in testObjectNodes)
            {
                found = false;
                ITestObject testobject = testObjectNurse.TestObject;
                web = testobject.ControlTypeString.StartsWith("Web");

                //if ( null == (repoNurseNode.TestObject as UIATestObject ))
                //{

                //    TestObjectNurse newTestNurse = new TestObjectNurse(testObjectNurse.TestObject);

                //    newTestNurse.NodeName = testObjectNurse.TestObject.NodeName;

                //    repoNurseNode.AddChild(newTestNurse);

                //    TreeNode node = newTestNurse.TreeNode;

                //    changed = true;

                //    TreeNodeHelper.FixTreeNodeImage(node, "Button");

                //    MergeObjectsToMainTree(newTestNurse, testObjectNurse.Children);
                //   // NeighbourChecker(newTestNurse, testObjectNurse);

                //    RaiseMergeCompleteEvent(true);
                //    continue;
                //}
                ////UIACondition fromNodeCondition = (UIACondition)fromNode.Tag;
                TestObjectNurse repoNode = FindMatchingNode(repoNurseNode, testObjectNurse);

                if (repoNode != null)
                {
                    changed |= MergeObjectsToMainTree(repoNode, testObjectNurse.Children);
                    changed |= NeighbourChecker(repoNode, testObjectNurse);
                    repoNode.TreeNode.Expand();
                    found = true;
                }



                if (!found)
                {
                    TestObjectNurse newTestNurse = new TestObjectNurse(testObjectNurse.TestObject);
                    TreeNode        node         = newTestNurse.TreeNode;
                    if (web)
                    {
                        newTestNurse.NodeName = testObjectNurse.TestObject.NodeName;

                        repoNurseNode.AddChild(newTestNurse);

                        changed = true;

                        TreeNodeHelper.FixTreeNodeImage(node, testObjectNurse.TestObject.ControlTypeString);

                        MergeObjectsToMainTree(newTestNurse, testObjectNurse.Children);
                        // NeighbourChecker(newTestNurse, testObjectNurse);

                        RaiseMergeCompleteEvent(true);
                        continue;
                    }
                    UIATestObject     uiaTestObject = (UIATestObject)testObjectNurse.TestObject;
                    AutomationElement addedElement  = uiaTestObject.AutomationElement;

                    string nodeName;

                    // if Element not exist, use the default condition, if exist, create new condition, because this can create index for object.
                    bool elementExist = (!addedElement.Current.BoundingRectangle.IsEmpty);
                    if (!elementExist)
                    {
                        string tempNewName;

                        if (!string.IsNullOrEmpty(uiaTestObject.ControlName))
                        {
                            tempNewName = uiaTestObject.ControlName;
                        }
                        else
                        {
                            tempNewName = uiaTestObject.ControlTypeString;
                        }

                        nodeName = SpyWindowHelper.DeriveControlName(repoNurseNode, tempNewName);
                    }
                    else
                    {
                        nodeName = SpyWindowHelper.DeriveControlName(repoNurseNode, addedElement);
                        //TODO should use the following logic
                        //newCondition = new UIACondition(fromNode, nodeName);
                    }

                    string nodeText = testObjectNurse.NodeName = nodeName;

                    //TestObjectNurse newTestNurse = new TestObjectNurse(uiaTestObject);

                    newTestNurse.NodeName = nodeText;

                    repoNurseNode.AddChild(newTestNurse);

                    // TreeNode node = newTestNurse.TreeNode;

                    changed = true;

                    TreeNodeHelper.FixTreeNodeImage(node, uiaTestObject.ControlTypeString);

                    MergeObjectsToMainTree(newTestNurse, testObjectNurse.Children);
                    NeighbourChecker(newTestNurse, testObjectNurse);

                    node.Expand();
                    RaiseMergeCompleteEvent(true);
                }
            }

            return(changed);
        }
Пример #10
0
 internal bool SaveModel()
 {
     return(SpyWindowHelper.Save(RootNurseObject));
 }