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; } } } }
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)); } }
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); } } }
public static void DumpRecyclingBin(TestObjectNurse nurse) { TestObjectNurse.CleanupDeletedItems(nurse, (imageFilePath) => { File.Delete(AppEnvironment.GetModelResourceFilePath(imageFilePath)); }); }