public void CreateLogItem(LogItemCategory logItemCategory, string description, Screenshot screenshot = null) { LogItem logItem = new LogItem(); logItem.StartTime = DateTime.Now; logItem.Description = description; logItem.Category = logItemCategory; logItem.Screenshot = screenshot; currentLogItems.Add(logItem); }
public Point GetClickPoint(Screenshot tempScreenshot) { string text = textParam.GetValue(); Point clickPoint = new Point(int.Parse(clickXParam.GetValue()), int.Parse(clickYParam.GetValue())); if (string.IsNullOrEmpty(text) && string.IsNullOrEmpty(imageParam.GetValue())) { return clickPoint; } if (!string.IsNullOrEmpty(text)) { OcrAnalyzer analyzer = new OcrAnalyzer(Camera.Capture()); OcrData deserializedData = Serializer.DeSerialize(File.ReadAllBytes(@"..\..\..\..\LearningOcr\LearningOcr\bin\Debug\TestFffff.ocr")) as OcrData; deserializedData.Analyze(); IEnumerable<FoundTextData> foundTextDatas = analyzer.FindText(text, deserializedData, 0.8f); FoundTextData foundText = foundTextDatas.FirstOrDefault(); if (foundText == null) return clickPoint; return new Point(foundText.Bounds.Left + foundText.Bounds.Width / 2, foundText.Bounds.Top + foundText.Bounds.Height / 2); } Bitmap bitmap = imageParam.Value as Bitmap; if (bitmap != null) { Rectangle rect = SearchBitmap(bitmap, tempScreenshot.Image, 0); return new Point(rect.Left + rect.Width/2, rect.Top + rect.Height/2); } throw new Exception("Could not get a clickpoint"); }
protected Screenshot CreateScreenshot(Log log, int handle=0, bool save=true) { Bitmap bitmap = Camera.Capture(handle); Screenshot screenshot = new Screenshot(); DateTime dateTime = DateTime.Now; string screenshotName = "ghscn_" + dateTime.Ticks + ".bmp"; screenshot.ImageFile = screenshotName; screenshot.DateTime = dateTime; if (save) { bitmap.Save(Path.Combine(ProjectSuiteManager.GetScreenshotsFolder(log), screenshotName)); } else { screenshot.Image = bitmap; } return screenshot; }
private Screenshot CreateScreenshotFromCurrentBitmap() { Screenshot screenshot = new Screenshot(); string screenshotName = "ghscn_" + currentBitmapDateTime.Ticks + ".bmp"; screenshot.ImageFile = screenshotName; screenshot.DateTime = currentBitmapDateTime; currentBitmap.Save(Path.Combine(ProjectSuiteManager.GetScreenshotsFolder(test), screenshotName)); return screenshot; }