Example #1
0
        private void btnAddProperty_Click(object sender, EventArgs e)
        {
            if (_nurseObject == null)
            {
                MessageBox.Show(StringResources.LPSpy_SpyMainWindow_SelectobjMsg);
                return;
            }

            addPropertyWindow = new AddPropertiesWindow();

            addPropertyWindow.Tag   = _nurseObject.TreeNode;
            addPropertyWindow.Owner = this.ParentForm;

            if (addPropertyWindow.EndUpdating == null)
            {
                addPropertyWindow.EndUpdating = new AddPropertiesWindow.EndAddingProperty(
                    nurseObject =>
                {
                    propertyGrid.SetTestObject(nurseObject);
                    AppEnvironment.SetModelChanged(true);
                }
                    );
            }

            addPropertyWindow.ShowDialog();
        }
Example #2
0
        private void LoadImage(TestObjectNurse testNurse)
        {
            if (testNurse == null /* || testNurse.ImageFile == null*/)
            {
                snapshotBox.Image       = null;
                snapshotBox2.TestObject = null;
                return;
            }

            snapshotBox.TestObject = snapshotBox2.TestObject = testNurse;

            string imageFile = testNurse.ImageFile;

            if (imageFile != null)
            {
                string path = AppEnvironment.GetModelResourceFilePath(imageFile);

                Image image = snapshotBox.Image;
                if (image != null)
                {
                    if (image.Height > snapshotBox.Height || image.Width > snapshotBox.Width)
                    {
                        snapshotBox.SizeMode = PictureBoxSizeMode.Zoom;
                    }
                    else
                    {
                        snapshotBox.SizeMode = PictureBoxSizeMode.Normal;
                    }
                }
            }
        }
        public static bool SaveToModelFile(TestObjectNurse rootNurse)
        {
            string filePath = AppEnvironment.CurrentModelPath;
            bool   ret      = SaveToModelFile(rootNurse, filePath);

            AppEnvironment.DumpRecyclingBin(rootNurse);
            return(ret);
        }
        /// <summary>
        /// create a new empty model
        /// </summary>
        /// <param name="filePath"></param>
        internal void NewModel(string filePath)
        {
            RootNurseObject.Clear();

            _nodeView.NodeChanged(null);

            AppEnvironment.CurrentModelPath = filePath;
            AppEnvironment.SetModelChanged(false);
        }
Example #5
0
        public static bool Save(TestObjectNurse rootNurseObject)
        {
            bool succeed = ModelFileHandler.SaveToModelFile(rootNurseObject);

            if (succeed)
            {
                AppEnvironment.SetModelChanged(false);
            }

            SpySettings.Persist();
            return(succeed);
        }
Example #6
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 UpdateNodePropertyCompleteHandler(ResultType result)
        {
            if (ResultType.OK == result)
            {
                AppEnvironment.SetModelChanged(true);

                //TODO Is this necessary?
                //SelectedNodesChanged(_selectedNode);
            }
            else if (ResultType.NotSameControlType == result)
            {
                MessageBox.Show(StringResources.LPSpy_SpyMainWindow_RefreshobjNotMatchWarningMsg,
                                StringResources.LPSpy_SpyMainWindow_RefreshobjWarningTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #8
0
        private void ReadImageFile(string imageFile)
        {
            int margin = Snapshot.Margin;

            string path = AppEnvironment.GetModelResourceFilePath(imageFile);

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                this.Image = System.Drawing.Image.FromStream(fs);

                Debug.Assert(this.Image == null || this.Image.Width >= margin);
                Debug.Assert(this.Image == null || this.Image.Height >= margin);
                _borderRect = new Rectangle(margin, margin,
                                            Math.Max(0, this.Image.Width - 2 * margin),
                                            Math.Max(0, this.Image.Height - 2 * margin));
            }
        }
Example #9
0
        public void SetTestObject(TestObjectNurse testNurse)
        {
            if (testNurse == null)
            {
                this.SelectedObject = null;
                return;
            }
            TestObjectPropertyBag propertyBag = this.SelectedObject as TestObjectPropertyBag;
            if (propertyBag != null)
            {
                //dispose the old object
                propertyBag.Dispose();
            }
            propertyBag = new TestObjectPropertyBag(testNurse);
            propertyBag.PropertyChanged += () => { AppEnvironment.SetModelChanged(true); };
            this.SelectedObject = propertyBag;
            this.Tag = testNurse; //cache5 it for use later (editing properties)

        }
Example #10
0
        internal void EditVirtualControl(TestObjectNurse nurseObject)
        {
            if (nurseObject.ControlTypeString == NodeType.VirtualControl)
            {
                nurseObject = nurseObject.ParentNurse;

                Debug.Assert(nurseObject.TestObject is UIATestObject);
            }

            if (nurseObject.ImageFile == null)
            {
                //"Please capture the screen shot of the control before editing virtual controls"
                MessageBox.Show(StringResources.LPSpy_SpyMainWindow_CaptureSnapshotFirst);
                return;
            }

            string imagePath = AppEnvironment.GetModelResourceFilePath(nurseObject.ImageFile);

            VirtualTestObject[] virtualControls = VirtualControlHelper.GetVirtualControls(nurseObject.TestObject);

            System.Drawing.Image controlImage = System.Drawing.Image.FromFile(imagePath);

            UIATestObject testObject = (UIATestObject)nurseObject.TestObject;

            bool changed = VirtualControlHelper.EditVirtualControls(testObject, controlImage, ref virtualControls);

            if (changed)
            {
                VirtualTestObject[] updatedControls = virtualControls;

                bool different = TreeNodeHelper.MergeVirtualControlsToTree(updatedControls, nurseObject.TreeNode);

                nurseObject.TreeNode.Expand();

                if (different)
                {
                    AppEnvironment.SetModelChanged(true);
                }
            }
        }
Example #11
0
 public static void DumpRecyclingBin(TestObjectNurse nurse)
 {
     TestObjectNurse.CleanupDeletedItems(nurse,
                                         (imageFilePath) => { File.Delete(AppEnvironment.GetModelResourceFilePath(imageFilePath)); });
 }