Improved the support for dragging and dropping images from a website, now also parsing HTML img src information, to be able to download that image. For this we need the HtmlAgilityPack.dll (#294)

Removed a lot of dead code, and remove the old OCR code as we don't even know if it still works.
This commit is contained in:
Robin Krom 2021-03-21 22:34:17 +01:00 committed by GitHub
commit 26fe579d31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
151 changed files with 1138 additions and 8174 deletions

View file

@ -298,17 +298,6 @@ namespace GreenshotPlugin.Core
return null;
}
/// <summary>
/// Retrieve the children with matching classname
/// </summary>
public IEnumerable<WindowDetails> GetChilden(string childClassname) {
foreach (var child in Children) {
if (childClassname.Equals(child.ClassName)) {
yield return child;
}
}
}
public IntPtr ParentHandle {
get {
if (_parentHandle == IntPtr.Zero) {
@ -379,92 +368,6 @@ namespace GreenshotPlugin.Core
return FindWindow(Children, titlePattern, classnamePattern);
}
/// <summary>
/// Recurse-ing helper method for the FindPath
/// </summary>
/// <param name="classNames">List string with classNames</param>
/// <param name="index">The index in the list to look for</param>
/// <returns>WindowDetails if a match was found</returns>
private WindowDetails FindPath(IList<string> classNames, int index) {
if (index == classNames.Count - 1) {
foreach (var foundWindow in FindChildren(null, classNames[index]))
{
return foundWindow;
}
} else {
foreach(var foundWindow in FindChildren(null, classNames[index]))
{
var resultWindow = foundWindow.FindPath(classNames, index+1);
if (resultWindow != null)
{
return resultWindow;
}
}
}
return null;
}
/// <summary>
/// This method will find the child window according to a path of classNames.
/// Usually used for finding a certain "content" window like for the IE Browser
/// </summary>
/// <param name="classNames">List of string with classname "path"</param>
/// <param name="allowSkip">true allows the search to skip a classname of the path</param>
/// <returns>WindowDetails if found</returns>
public WindowDetails FindPath(IList<string> classNames, bool allowSkip) {
int index = 0;
var resultWindow = FindPath(classNames, index++);
if (resultWindow == null && allowSkip) {
while(resultWindow == null && index < classNames.Count) {
resultWindow = FindPath(classNames, index);
}
}
return resultWindow;
}
/// <summary>
/// Deep scan for a certain classname pattern
/// </summary>
/// <param name="windowDetails">Window to scan into</param>
/// <param name="classnamePattern">Classname regexp pattern</param>
/// <returns>The first WindowDetails found</returns>
public static WindowDetails DeepScan(WindowDetails windowDetails, Regex classnamePattern) {
if (classnamePattern.IsMatch(windowDetails.ClassName)) {
return windowDetails;
}
// First loop through this level
foreach(var child in windowDetails.Children) {
if (classnamePattern.IsMatch(child.ClassName)) {
return child;
}
}
// Go into all children
foreach(var child in windowDetails.Children) {
var deepWindow = DeepScan(child, classnamePattern);
if (deepWindow != null) {
return deepWindow;
}
}
return null;
}
/// <summary>
/// GetWindow
/// </summary>
/// <param name="gwCommand">The GetWindowCommand to use</param>
/// <returns>null if nothing found, otherwise the WindowDetails instance of the "child"</returns>
public WindowDetails GetWindow(GetWindowCommand gwCommand) {
var tmphWnd = User32.GetWindow(Handle, gwCommand);
if (IntPtr.Zero == tmphWnd) {
return null;
}
var windowDetails = new WindowDetails(tmphWnd)
{
_parent = this
};
return windowDetails;
}
/// <summary>
/// Gets the window's handle
/// </summary>
@ -512,7 +415,7 @@ namespace GreenshotPlugin.Core
}
/// <summary>
/// Gets/Sets whether the window is maximised or not.
/// Gets/Sets whether the window is maximized or not.
/// </summary>
public bool Maximised {
get {
@ -541,13 +444,6 @@ namespace GreenshotPlugin.Core
}
}
/// <summary>
/// This doesn't work as good as is should, but does move the App out of the way...
/// </summary>
public void HideApp() {
User32.ShowWindow(Handle, ShowWindowCommand.Hide);
}
/// <summary>
/// Returns if this window is cloaked
/// </summary>
@ -627,13 +523,6 @@ namespace GreenshotPlugin.Core
}
}
/// <summary>
/// Make sure the next call of a cached value is guaranteed the real value
/// </summary>
public void Reset() {
_previousWindowRectangle = Rectangle.Empty;
}
private Rectangle _previousWindowRectangle = Rectangle.Empty;
private long _lastWindowRectangleRetrieveTime;
private const long CacheTime = TimeSpan.TicksPerSecond * 2;
@ -1354,24 +1243,6 @@ namespace GreenshotPlugin.Core
return null;
}
/// <summary>
/// Check if this window is Greenshot
/// </summary>
public bool IsGreenshot {
get {
try {
if (!IsMetroApp)
{
using Process thisWindowProcess = Process;
return "Greenshot".Equals(thisWindowProcess.MainModule.FileVersionInfo.ProductName);
}
} catch (Exception ex) {
Log.Warn(ex);
}
return false;
}
}
/// <summary>
/// Gets the Desktop window
/// </summary>