Changes recommended by Rider/Resharper

This commit is contained in:
2022-04-09 00:55:02 +02:00
parent 73e7fe89f1
commit fc5b81014b
28 changed files with 982 additions and 790 deletions

13
.idea/.idea.VAR.ScreenAutomation/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/projectSettingsUpdater.xml
/.idea.VAR.ScreenAutomation.iml
/contentModel.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,60 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">NotRequired</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_MULTILINE_LISTS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_SINGLELINE_LISTS/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_BLOCK_ARRANGEMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_BLOCK_ON_SAME_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ALLOW_FAR_ALIGNMENT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/NormalizeTagNames/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/ProcessingInstructionAttributeIndenting/@EntryValue">OneStep</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagAttributeIndenting/@EntryValue">OneStep</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/HtmlFormatter/TagSpaceBeforeHeaderEnd1/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseVarWhenEvident</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AES/@EntryIndexedValue">AES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AM/@EntryIndexedValue">AM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AUX/@EntryIndexedValue">AUX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BPP/@EntryIndexedValue">BPP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CYC/@EntryIndexedValue">CYC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DES/@EntryIndexedValue">DES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EPM/@EntryIndexedValue">EPM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GDI/@EntryIndexedValue">GDI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RECT/@EntryIndexedValue">RECT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SCART/@EntryIndexedValue">SCART</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SPDIF/@EntryIndexedValue">SPDIF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQL/@EntryIndexedValue">SQL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SRCCOPY/@EntryIndexedValue">SRCCOPY</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TCP/@EntryIndexedValue">TCP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=USB/@EntryIndexedValue">USB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VAR/@EntryIndexedValue">VAR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WMIC/@EntryIndexedValue">WMIC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=YRYBY/@EntryIndexedValue">YRYBY</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Constants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=EnumMember/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb"&gt;&lt;ExtraRule Prefix="T" Suffix="" Style="AaBb_AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Interfaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=LocalConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Locals/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Method/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Parameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Property/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PublicFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypesAndNamespaces/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
</wpf:ResourceDictionary>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup> </startup>
</configuration> </configuration>

View File

@@ -29,4 +29,4 @@ namespace VAR.ScreenAutomation.Bots
return string.Empty; return string.Empty;
} }
} }
} }

View File

@@ -17,12 +17,12 @@ namespace VAR.ScreenAutomation.Bots
private TetrisGrid _workGrid1; private TetrisGrid _workGrid1;
private double[] _columnEvaluation; private double[] _columnEvaluation;
private bool _shapeFound = false; private bool _shapeFound;
private int _shapeX; private int _shapeX;
private int _shapeY; private int _shapeY;
private double _bestEvaluation = double.MinValue; private double _bestEvaluation = double.MinValue;
private int _bestXOffset = 0; private int _bestXOffset;
private int _bestRotation = 0; private int _bestRotation;
public string Name => "Tetris"; public string Name => "Tetris";
@@ -57,7 +57,7 @@ namespace VAR.ScreenAutomation.Bots
new TetrisShape(), new TetrisShape(),
}; };
output.Clean(); output.Clean();
output.AddLine(string.Format("TetrisBot: Starting {0}", DateTime.UtcNow.ToString("s"))); output.AddLine($"TetrisBot: Starting {DateTime.UtcNow:s}");
} }
public Bitmap Process(Bitmap bmpInput, IOutputHandler output) public Bitmap Process(Bitmap bmpInput, IOutputHandler output)
@@ -74,6 +74,7 @@ namespace VAR.ScreenAutomation.Bots
_currentShape[_bestRotation].Drop(_workGrid0, _shapeX + _bestXOffset, _shapeY, TetrisGrid.CellShapeA); _currentShape[_bestRotation].Drop(_workGrid0, _shapeX + _bestXOffset, _shapeY, TetrisGrid.CellShapeA);
_currentShape[0].PutOnGrid(_workGrid0, _shapeX, _shapeY, TetrisGrid.CellShapeB); _currentShape[0].PutOnGrid(_workGrid0, _shapeX, _shapeY, TetrisGrid.CellShapeB);
} }
_workGrid0.Draw(bmpInput, 0.75f); _workGrid0.Draw(bmpInput, 0.75f);
_workGrid0.SampleOther(_grid, TetrisGrid.CellSolid, TetrisGrid.CellSolid); _workGrid0.SampleOther(_grid, TetrisGrid.CellSolid, TetrisGrid.CellSolid);
_workGrid0.RemoveGround(); _workGrid0.RemoveGround();
@@ -91,7 +92,8 @@ namespace VAR.ScreenAutomation.Bots
{ {
for (int x = 0; x < _grid.Width; x++) for (int x = 0; x < _grid.Width; x++)
{ {
TetrisShape matchedShape = TetrisShape.DefaultShapes.FirstOrDefault(s => s.MatchOnGrid(_workGrid0, x, y)); TetrisShape matchedShape =
TetrisShape.DefaultShapes.FirstOrDefault(s => s.MatchOnGrid(_workGrid0, x, y));
if (matchedShape != null) if (matchedShape != null)
{ {
_workGrid1.SampleOther(_workGrid0, TetrisGrid.CellSolid, TetrisGrid.CellSolid); _workGrid1.SampleOther(_workGrid0, TetrisGrid.CellSolid, TetrisGrid.CellSolid);
@@ -102,14 +104,16 @@ namespace VAR.ScreenAutomation.Bots
_currentShape[0].Copy(matchedShape); _currentShape[0].Copy(matchedShape);
for (int i = 1; i < 4; i++) for (int i = 1; i < 4; i++)
{ {
_currentShape[i].RotateCW(_currentShape[i - 1]); _currentShape[i].RotateClockWise(_currentShape[i - 1]);
} }
_shapeX = x; _shapeX = x;
_shapeY = y; _shapeY = y;
_shapeFound = true; _shapeFound = true;
break; break;
} }
} }
if (_shapeFound) { break; } if (_shapeFound) { break; }
} }
} }
@@ -147,9 +151,11 @@ namespace VAR.ScreenAutomation.Bots
// Search valid X range // Search valid X range
int minX = _shapeX; int minX = _shapeX;
while (minX >= 0 && _columnEvaluation[minX] > double.MinValue) { minX--; } while (minX >= 0 && _columnEvaluation[minX] > double.MinValue) { minX--; }
minX++; minX++;
int maxX = _shapeX; int maxX = _shapeX;
while (maxX < _grid.Width && _columnEvaluation[maxX] > double.MinValue) { maxX++; } while (maxX < _grid.Width && _columnEvaluation[maxX] > double.MinValue) { maxX++; }
maxX--; maxX--;
// Apply best value inside valid X range // Apply best value inside valid X range
@@ -165,8 +171,8 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
private int _shotCooldownFrames = 0; private int _shotCooldownFrames;
private int _shotCooldown = 0; private int _shotCooldown;
public string ResponseKeys() public string ResponseKeys()
{ {
@@ -189,9 +195,13 @@ namespace VAR.ScreenAutomation.Bots
_shotCooldown = _shotCooldownFrames; _shotCooldown = _shotCooldownFrames;
if (_bestRotation != 0 && _bestXOffset < 0) { return "{UP}{LEFT}"; } if (_bestRotation != 0 && _bestXOffset < 0) { return "{UP}{LEFT}"; }
if (_bestRotation != 0 && _bestXOffset > 0) { return "{UP}{RIGHT}"; } if (_bestRotation != 0 && _bestXOffset > 0) { return "{UP}{RIGHT}"; }
if (_bestRotation != 0) { return "{UP}"; } if (_bestRotation != 0) { return "{UP}"; }
if (_bestXOffset < 0) { return "{LEFT}"; } if (_bestXOffset < 0) { return "{LEFT}"; }
if (_bestXOffset > 0) { return "{RIGHT}"; } if (_bestXOffset > 0) { return "{RIGHT}"; }
return string.Empty; return string.Empty;
@@ -200,11 +210,11 @@ namespace VAR.ScreenAutomation.Bots
public class TetrisShape public class TetrisShape
{ {
public const int ShapeSize = 4; private const int ShapeSize = 4;
private byte[][] _cells = null; private readonly byte[][] _cells;
private int _count = 0; private int _count;
public TetrisShape(byte[][] cells = null) public TetrisShape(byte[][] cells = null)
{ {
@@ -220,9 +230,11 @@ namespace VAR.ScreenAutomation.Bots
for (int j = 0; j < ShapeSize; j++) for (int j = 0; j < ShapeSize; j++)
{ {
if (j >= cells.Length) { break; } if (j >= cells.Length) { break; }
for (int i = 0; i < ShapeSize; i++) for (int i = 0; i < ShapeSize; i++)
{ {
if (i >= cells[j].Length) { break; } if (i >= cells[j].Length) { break; }
_cells[j][i] = cells[j][i]; _cells[j][i] = cells[j][i];
if (_cells[j][i] != 0) { _count++; } if (_cells[j][i] != 0) { _count++; }
} }
@@ -235,124 +247,140 @@ namespace VAR.ScreenAutomation.Bots
return _count; return _count;
} }
private static List<TetrisShape> _defaultShapes = null; private static List<TetrisShape> _defaultShapes;
public static List<TetrisShape> DefaultShapes public static List<TetrisShape> DefaultShapes
{ {
get get
{ {
if (_defaultShapes == null) return _defaultShapes ?? (_defaultShapes = new List<TetrisShape>
{ {
_defaultShapes = new List<TetrisShape> // I
new TetrisShape(new[]
{ {
// I new byte[] { 1, 1, 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 1, 1, 1, 1, }, new TetrisShape(new[]
}), {
new TetrisShape(new byte[][]{ new byte[] { 1, },
new byte[]{ 1, }, new byte[] { 1, },
new byte[]{ 1, }, new byte[] { 1, },
new byte[]{ 1, }, new byte[] { 1, },
new byte[]{ 1, }, }),
}),
// J // J
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 1, }, {
new byte[]{ 1, 1, 1, }, new byte[] { 1, },
}), new byte[] { 1, 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 1, 1, }, new TetrisShape(new[]
new byte[]{ 1, }, {
new byte[]{ 1, }, new byte[] { 1, 1, },
}), new byte[] { 1, },
new TetrisShape(new byte[][]{ new byte[] { 1, },
new byte[]{ 1, 1, 1, }, }),
new byte[]{ 0, 0, 1, }, new TetrisShape(new[]
}), {
new TetrisShape(new byte[][]{ new byte[] { 1, 1, 1, },
new byte[]{ 0, 1, }, new byte[] { 0, 0, 1, },
new byte[]{ 0, 1, }, }),
new byte[]{ 1, 1, }, new TetrisShape(new[]
}), {
new byte[] { 0, 1, },
new byte[] { 0, 1, },
new byte[] { 1, 1, },
}),
// L // L
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 0, 0, 1, }, {
new byte[]{ 1, 1, 1, }, new byte[] { 0, 0, 1, },
}), new byte[] { 1, 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 1, }, new TetrisShape(new[]
new byte[]{ 1, }, {
new byte[]{ 1, 1, }, new byte[] { 1, },
}), new byte[] { 1, },
new TetrisShape(new byte[][]{ new byte[] { 1, 1, },
new byte[]{ 1, 1, 1, }, }),
new byte[]{ 1, }, new TetrisShape(new[]
}), {
new TetrisShape(new byte[][]{ new byte[] { 1, 1, 1, },
new byte[]{ 1, 1, }, new byte[] { 1, },
new byte[]{ 0, 1, }, }),
new byte[]{ 0, 1, }, new TetrisShape(new[]
}), {
new byte[] { 1, 1, },
new byte[] { 0, 1, },
new byte[] { 0, 1, },
}),
// S // S
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 0, 1, 1, }, {
new byte[]{ 1, 1, }, new byte[] { 0, 1, 1, },
}), new byte[] { 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 1, }, new TetrisShape(new[]
new byte[]{ 1, 1, }, {
new byte[]{ 0, 1, }, new byte[] { 1, },
}), new byte[] { 1, 1, },
new byte[] { 0, 1, },
}),
// T // T
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 0, 1, }, {
new byte[]{ 1, 1, 1, }, new byte[] { 0, 1, },
}), new byte[] { 1, 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 1, }, new TetrisShape(new[]
new byte[]{ 1, 1, }, {
new byte[]{ 1, }, new byte[] { 1, },
}), new byte[] { 1, 1, },
new TetrisShape(new byte[][]{ new byte[] { 1, },
new byte[]{ 1, 1, 1, }, }),
new byte[]{ 0, 1, }, new TetrisShape(new[]
}), {
new TetrisShape(new byte[][]{ new byte[] { 1, 1, 1, },
new byte[]{ 0, 1, }, new byte[] { 0, 1, },
new byte[]{ 1, 1, }, }),
new byte[]{ 0, 1, }, new TetrisShape(new[]
}), {
new byte[] { 0, 1, },
new byte[] { 1, 1, },
new byte[] { 0, 1, },
}),
// Z // Z
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 1, 1, }, {
new byte[]{ 0, 1, 1, }, new byte[] { 1, 1, },
}), new byte[] { 0, 1, 1, },
new TetrisShape(new byte[][]{ }),
new byte[]{ 0, 1, }, new TetrisShape(new[]
new byte[]{ 1, 1, }, {
new byte[]{ 1, }, new byte[] { 0, 1, },
}), new byte[] { 1, 1, },
new byte[] { 1, },
}),
// O // O
new TetrisShape(new byte[][]{ new TetrisShape(new[]
new byte[]{ 1, 1, }, {
new byte[]{ 1, 1, }, new byte[] { 1, 1, },
}) new byte[] { 1, 1, },
}; })
} });
return _defaultShapes;
} }
} }
public bool IsValid() public bool IsValid()
{ {
if (_count != 4) { return false; } if (_count != 4) { return false; }
bool matchesAnyDefault = DefaultShapes.Any(ts => CompareShape(ts));
bool matchesAnyDefault = DefaultShapes.Any(CompareShape);
return matchesAnyDefault; return matchesAnyDefault;
} }
@@ -368,7 +396,7 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
public bool CompareShape(TetrisShape shape) private bool CompareShape(TetrisShape shape)
{ {
for (int j = 0; j < ShapeSize; j++) for (int j = 0; j < ShapeSize; j++)
{ {
@@ -380,6 +408,7 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
return true; return true;
} }
@@ -410,6 +439,7 @@ namespace VAR.ScreenAutomation.Bots
for (int i = 0; i < ShapeSize; i++) for (int i = 0; i < ShapeSize; i++)
{ {
if (_cells[j][i] == 0) { continue; } if (_cells[j][i] == 0) { continue; }
grid.Set(x + i, y + j, value); grid.Set(x + i, y + j, value);
} }
} }
@@ -422,27 +452,31 @@ namespace VAR.ScreenAutomation.Bots
for (int i = 0; i < ShapeSize; i++) for (int i = 0; i < ShapeSize; i++)
{ {
if (_cells[j][i] == 0) { continue; } if (_cells[j][i] == 0) { continue; }
if (grid.Get(x + i, y + j) != 0) if (grid.Get(x + i, y + j) != 0)
{ {
return true; return true;
} }
} }
} }
return false; return false;
} }
public bool Drop(TetrisGrid grid, int x, int y, byte value) public bool Drop(TetrisGrid grid, int x, int y, byte value)
{ {
if (CheckIntersection(grid, x, y)) { return false; } if (CheckIntersection(grid, x, y)) { return false; }
while (CheckIntersection(grid, x, y + 1) == false) while (CheckIntersection(grid, x, y + 1) == false)
{ {
y++; y++;
} }
PutOnGrid(grid, x, y, value); PutOnGrid(grid, x, y, value);
return true; return true;
} }
public bool SearchFirstCell(byte value, out int x, out int y) private bool SearchFirstCell(byte value, out int x, out int y)
{ {
x = -1; x = -1;
y = -1; y = -1;
@@ -456,7 +490,9 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
if (y == -1) { return false; } if (y == -1) { return false; }
for (int i = 0; i < ShapeSize && x == -1; i++) for (int i = 0; i < ShapeSize && x == -1; i++)
{ {
for (int j = 0; j < ShapeSize && x == -1; j++) for (int j = 0; j < ShapeSize && x == -1; j++)
@@ -467,11 +503,13 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
if (x == -1) { return false; } if (x == -1) { return false; }
return true; return true;
} }
public void Offset(int x, int y) private void Offset(int x, int y)
{ {
_count = 0; _count = 0;
for (int j = 0; j < ShapeSize; j++) for (int j = 0; j < ShapeSize; j++)
@@ -494,7 +532,7 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
public void RotateCW(TetrisShape shape) public void RotateClockWise(TetrisShape shape)
{ {
for (int j = 0; j < ShapeSize; j++) for (int j = 0; j < ShapeSize; j++)
{ {
@@ -503,6 +541,7 @@ namespace VAR.ScreenAutomation.Bots
_cells[i][ShapeSize - (j + 1)] = shape._cells[j][i]; _cells[i][ShapeSize - (j + 1)] = shape._cells[j][i];
} }
} }
_count = shape._count; _count = shape._count;
if (SearchFirstCell(1, out int offsetX, out int offsetY)) if (SearchFirstCell(1, out int offsetX, out int offsetY))
@@ -518,15 +557,9 @@ namespace VAR.ScreenAutomation.Bots
StringBuilder sbLine = new StringBuilder(); StringBuilder sbLine = new StringBuilder();
for (int x = 0; x < ShapeSize; x++) for (int x = 0; x < ShapeSize; x++)
{ {
if (_cells[y][x] == 0) sbLine.Append(_cells[y][x] == 0 ? ".." : "[]");
{
sbLine.Append("..");
}
else
{
sbLine.Append("[]");
}
} }
output.AddLine(sbLine.ToString()); output.AddLine(sbLine.ToString());
} }
} }
@@ -554,6 +587,7 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
return true; return true;
} }
} }
@@ -565,15 +599,15 @@ namespace VAR.ScreenAutomation.Bots
public const byte CellShapeA = 2; public const byte CellShapeA = 2;
public const byte CellShapeB = 3; public const byte CellShapeB = 3;
private int _gridWidth; private readonly int _gridWidth;
private int _gridHeight; private readonly int _gridHeight;
public int Width { get { return _gridWidth; } } public int Width => _gridWidth;
public int Height { get { return _gridHeight; } } public int Height => _gridHeight;
private byte[][] _grid = null; private readonly byte[][] _grid;
private int[] _heights = null; private readonly int[] _heights;
public TetrisGrid(int gridWidth, int gridHeight) public TetrisGrid(int gridWidth, int gridHeight)
{ {
@@ -584,27 +618,32 @@ namespace VAR.ScreenAutomation.Bots
{ {
_grid[y] = new byte[_gridWidth]; _grid[y] = new byte[_gridWidth];
} }
_heights = new int[_gridWidth]; _heights = new int[_gridWidth];
} }
public byte Get(int x, int y) public byte Get(int x, int y)
{ {
if (x >= _gridWidth || x < 0) { return 0xFF; } if (x >= _gridWidth || x < 0) { return 0xFF; }
if (y >= _gridHeight || y < 0) { return 0xFF; } if (y >= _gridHeight || y < 0) { return 0xFF; }
return _grid[y][x]; return _grid[y][x];
} }
public void Set(int x, int y, byte value) public void Set(int x, int y, byte value)
{ {
if (x >= _gridWidth || x < 0) { return; } if (x >= _gridWidth || x < 0) { return; }
if (y >= _gridHeight || y < 0) { return; } if (y >= _gridHeight || y < 0) { return; }
_grid[y][x] = value; _grid[y][x] = value;
} }
public void SampleFromBitmap(Bitmap bmp) public void SampleFromBitmap(Bitmap bmp)
{ {
float xStep = bmp.Width / _gridWidth; float xStep = bmp.Width / (float)_gridWidth;
float yStep = bmp.Height / _gridHeight; float yStep = bmp.Height / (float)_gridHeight;
float xOff0 = xStep / 2; float xOff0 = xStep / 2;
float xOff1 = xOff0 / 2; float xOff1 = xOff0 / 2;
float xOff2 = xOff0 + xOff1; float xOff2 = xOff0 + xOff1;
@@ -665,11 +704,14 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
public void FloodFill(int x, int y, byte expectedValue, byte fillValue) private void FloodFill(int x, int y, byte expectedValue, byte fillValue)
{ {
if (x >= _gridWidth || x < 0) { return; } if (x >= _gridWidth || x < 0) { return; }
if (y >= _gridHeight || y < 0) { return; } if (y >= _gridHeight || y < 0) { return; }
if (_grid[y][x] != expectedValue) { return; } if (_grid[y][x] != expectedValue) { return; }
_grid[y][x] = fillValue; _grid[y][x] = fillValue;
FloodFill(x - 1, y - 1, expectedValue, fillValue); FloodFill(x - 1, y - 1, expectedValue, fillValue);
FloodFill(x - 1, y + 0, expectedValue, fillValue); FloodFill(x - 1, y + 0, expectedValue, fillValue);
@@ -681,7 +723,7 @@ namespace VAR.ScreenAutomation.Bots
FloodFill(x + 1, y + 1, expectedValue, fillValue); FloodFill(x + 1, y + 1, expectedValue, fillValue);
} }
public void SampleOther(TetrisGrid grid, byte value, byte setValue = 1) public void SampleOther(TetrisGrid grid, byte value, byte setValue)
{ {
for (int y = 0; y < _gridHeight; y++) for (int y = 0; y < _gridHeight; y++)
{ {
@@ -713,7 +755,9 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
if (y == -1) { return false; } if (y == -1) { return false; }
for (int i = 0; i < _gridWidth && x == -1; i++) for (int i = 0; i < _gridWidth && x == -1; i++)
{ {
for (int j = 0; j < _gridHeight && x == -1; j++) for (int j = 0; j < _gridHeight && x == -1; j++)
@@ -724,11 +768,13 @@ namespace VAR.ScreenAutomation.Bots
} }
} }
} }
if (x == -1) { return false; } if (x == -1) { return false; }
return true; return true;
} }
public bool IsCompleteLine(int y) private bool IsCompleteLine(int y)
{ {
bool complete = true; bool complete = true;
for (int x = 0; x < _gridWidth; x++) for (int x = 0; x < _gridWidth; x++)
@@ -739,6 +785,7 @@ namespace VAR.ScreenAutomation.Bots
break; break;
} }
} }
return complete; return complete;
} }
@@ -748,14 +795,16 @@ namespace VAR.ScreenAutomation.Bots
double holesWeight = -0.35663, double holesWeight = -0.35663,
double bumpinessWeight = -0.184483) double bumpinessWeight = -0.184483)
{ {
// Calculte aggregate height // Calculate aggregate height
for (int i = 0; i < _gridWidth; i++) for (int i = 0; i < _gridWidth; i++)
{ {
int j = 0; int j = 0;
while (j < _gridHeight && _grid[j][i] == CellEmpty) { j++; } while (j < _gridHeight && _grid[j][i] == CellEmpty) { j++; }
_heights[i] = _gridHeight - j; _heights[i] = _gridHeight - j;
} }
double agregateHeight = _heights.Sum();
double aggregateHeight = _heights.Sum();
// Calculate complete lines // Calculate complete lines
int completeLines = 0; int completeLines = 0;
@@ -783,18 +832,18 @@ namespace VAR.ScreenAutomation.Bots
} }
// Calculate bumpiness // Calculate bumpiness
int bumpines = 0; int bumpiness = 0;
for (int i = 1; i < _gridWidth; i++) for (int i = 1; i < _gridWidth; i++)
{ {
bumpines += Math.Abs(_heights[i] - _heights[i - 1]); bumpiness += Math.Abs(_heights[i] - _heights[i - 1]);
} }
// Evaluate formula // Evaluate formula
double evaluationValue = double evaluationValue =
aggregateHeightWeight * agregateHeight + aggregateHeightWeight * aggregateHeight +
completeLinesWeight * completeLines + completeLinesWeight * completeLines +
holesWeight * holes + holesWeight * holes +
bumpinessWeight * bumpines + bumpinessWeight * bumpiness +
0; 0;
return evaluationValue; return evaluationValue;
} }
@@ -832,13 +881,15 @@ namespace VAR.ScreenAutomation.Bots
{ {
br = Brushes.Green; br = Brushes.Green;
} }
if (br == null) { continue; } if (br == null) { continue; }
g.DrawRectangle(borderPen, (xStep * x) + offX - 1, (yStep * y) + offY - 1, halfXStep + 2, halfYStep + 2); g.DrawRectangle(borderPen, (xStep * x) + offX - 1, (yStep * y) + offY - 1, halfXStep + 2,
halfYStep + 2);
g.FillRectangle(br, (xStep * x) + offX, (yStep * y) + offY, halfXStep, halfYStep); g.FillRectangle(br, (xStep * x) + offX, (yStep * y) + offY, halfXStep, halfYStep);
} }
} }
} }
} }
} }
} }

View File

@@ -6,9 +6,9 @@ using VAR.ScreenAutomation.Interfaces;
namespace VAR.ScreenAutomation.Code namespace VAR.ScreenAutomation.Code
{ {
public class AutomationBotFactory public static class AutomationBotFactory
{ {
private static Dictionary<string, Type> _dictAutomationBots = null; private static Dictionary<string, Type> _dictAutomationBots;
private static Dictionary<string, Type> GetDict() private static Dictionary<string, Type> GetDict()
{ {
@@ -28,8 +28,9 @@ namespace VAR.ScreenAutomation.Code
true); true);
_dictAutomationBots = automationBotTypes.ToDictionary(t => _dictAutomationBots = automationBotTypes.ToDictionary(t =>
{ {
IAutomationBot automationBot = System.Runtime.Serialization.FormatterServices.GetUninitializedObject(t) as IAutomationBot; IAutomationBot automationBot =
return automationBot.Name; System.Runtime.Serialization.FormatterServices.GetUninitializedObject(t) as IAutomationBot;
return automationBot?.Name ?? t.Name;
}); });
return _dictAutomationBots; return _dictAutomationBots;
@@ -39,7 +40,7 @@ namespace VAR.ScreenAutomation.Code
{ {
Dictionary<string, Type> dict = GetDict(); Dictionary<string, Type> dict = GetDict();
string[] allAutomationBots = dict.Select(p => p.Key).ToArray(); string[] allAutomationBots = dict.Select(p => p.Key).ToArray();
return allAutomationBots; return allAutomationBots.ToArray<object>();
} }
public static IAutomationBot CreateFromName(string name) public static IAutomationBot CreateFromName(string name)
@@ -49,10 +50,12 @@ namespace VAR.ScreenAutomation.Code
{ {
return new DummyBot(); return new DummyBot();
} }
if (dict.ContainsKey(name) == false) if (dict.ContainsKey(name) == false)
{ {
throw new NotImplementedException(string.Format("Can't create IAutomationBot with this name: {0}", name)); throw new NotImplementedException($"Can't create IAutomationBot with this name: {name}");
} }
Type proxyCmdExecutorType = dict[name]; Type proxyCmdExecutorType = dict[name];
IAutomationBot automationBot = Activator.CreateInstance(proxyCmdExecutorType) as IAutomationBot; IAutomationBot automationBot = Activator.CreateInstance(proxyCmdExecutorType) as IAutomationBot;
@@ -60,4 +63,4 @@ namespace VAR.ScreenAutomation.Code
return automationBot; return automationBot;
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using VAR.ScreenAutomation.Interfaces; using VAR.ScreenAutomation.Interfaces;
@@ -7,9 +8,9 @@ namespace VAR.ScreenAutomation.Code
{ {
public class FileBackedConfiguration : IConfiguration public class FileBackedConfiguration : IConfiguration
{ {
private MemoryBackedConfiguration _config = new MemoryBackedConfiguration(); private readonly MemoryBackedConfiguration _config = new MemoryBackedConfiguration();
private string _name = null; private readonly string _name;
public FileBackedConfiguration(string name = null) public FileBackedConfiguration(string name = null)
{ {
@@ -18,33 +19,22 @@ namespace VAR.ScreenAutomation.Code
private static string GetConfigFileName(string name = null) private static string GetConfigFileName(string name = null)
{ {
string location = System.Reflection.Assembly.GetEntryAssembly().Location; string location = System.Reflection.Assembly.GetEntryAssembly()?.Location;
string path = Path.GetDirectoryName(location); string path = Path.GetDirectoryName(location);
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(location); string filenameWithoutExtension = Path.GetFileNameWithoutExtension(location);
string configFile; string configFile = string.IsNullOrEmpty(name)
if (string.IsNullOrEmpty(name)) ? $"{path}/{filenameWithoutExtension}.cfg"
{ : $"{path}/{filenameWithoutExtension}_{name}.cfg";
configFile = string.Format("{0}/{1}.cfg", path, filenameWithoutExtension);
}
else
{
configFile = string.Format("{0}/{1}_{2}.cfg", path, filenameWithoutExtension, name);
}
return configFile; return configFile;
} }
private static string[] GetConfigurationLines(string name = null) private static string[] GetConfigurationLines(string name = null)
{ {
string configFile = GetConfigFileName(name); string configFile = GetConfigFileName(name);
string[] config; string[] config = File.Exists(configFile) == false
if (File.Exists(configFile) == false) ? Array.Empty<string>()
{ : File.ReadAllLines(configFile);
config = new string[0];
}
else
{
config = File.ReadAllLines(configFile);
}
return config; return config;
} }
@@ -58,11 +48,13 @@ namespace VAR.ScreenAutomation.Code
_config.Set(key, other.Get(key, null)); _config.Set(key, other.Get(key, null));
} }
} }
string[] configLines = GetConfigurationLines(_name); string[] configLines = GetConfigurationLines(_name);
foreach (string configLine in configLines) foreach (string configLine in configLines)
{ {
int idxSplit = configLine.IndexOf('|'); int idxSplit = configLine.IndexOf('|');
if (idxSplit < 0) { continue; } if (idxSplit < 0) { continue; }
string configName = configLine.Substring(0, idxSplit); string configName = configLine.Substring(0, idxSplit);
string configData = configLine.Substring(idxSplit + 1); string configData = configLine.Substring(idxSplit + 1);
@@ -77,6 +69,7 @@ namespace VAR.ScreenAutomation.Code
{ {
sbConfig.AppendFormat("{0}|{1}\n", key, _config.Get(key, string.Empty)); sbConfig.AppendFormat("{0}|{1}\n", key, _config.Get(key, string.Empty));
} }
string configFileName = GetConfigFileName(_name); string configFileName = GetConfigFileName(_name);
File.WriteAllText(configFileName, sbConfig.ToString()); File.WriteAllText(configFileName, sbConfig.ToString());
} }
@@ -120,6 +113,5 @@ namespace VAR.ScreenAutomation.Code
{ {
_config.Set(key, value); _config.Set(key, value);
} }
} }
} }

View File

@@ -7,12 +7,13 @@ namespace VAR.ScreenAutomation.Code
{ {
public class MemoryBackedConfiguration : IConfiguration public class MemoryBackedConfiguration : IConfiguration
{ {
private Dictionary<string, string> _configItems = new Dictionary<string, string>(); private readonly Dictionary<string, string> _configItems = new Dictionary<string, string>();
public IEnumerable<string> GetKeys() public IEnumerable<string> GetKeys()
{ {
if (_configItems == null) { return new List<string>(); } return _configItems == null
return _configItems.Select(p => p.Key); ? new List<string>()
: _configItems.Select(p => p.Key);
} }
public void Clear() public void Clear()
@@ -23,41 +24,44 @@ namespace VAR.ScreenAutomation.Code
public string Get(string key, string defaultValue) public string Get(string key, string defaultValue)
{ {
if (_configItems == null) { return defaultValue; } if (_configItems == null) { return defaultValue; }
if (_configItems.ContainsKey(key))
{ return _configItems.ContainsKey(key) ? _configItems[key] : defaultValue;
return _configItems[key];
}
return defaultValue;
} }
public int Get(string key, int defaultValue) public int Get(string key, int defaultValue)
{ {
if (_configItems == null) { return defaultValue; } if (_configItems == null) { return defaultValue; }
if (_configItems.ContainsKey(key)) if (_configItems.ContainsKey(key))
{ {
if (int.TryParse(_configItems[key], out int value)) if (int.TryParse(_configItems[key], out int value))
{ {
return value; return value;
} }
return defaultValue; return defaultValue;
} }
return defaultValue; return defaultValue;
} }
public bool Get(string key, bool defaultValue) public bool Get(string key, bool defaultValue)
{ {
if (_configItems == null) { return defaultValue; } if (_configItems == null) { return defaultValue; }
if (_configItems.ContainsKey(key)) if (_configItems.ContainsKey(key))
{ {
string value = _configItems[key]; string value = _configItems[key];
return (value == "true"); return (value == "true");
} }
return defaultValue; return defaultValue;
} }
public void Set(string key, string value) public void Set(string key, string value)
{ {
if (_configItems == null) { return; } if (_configItems == null) { return; }
if (_configItems.ContainsKey(key)) if (_configItems.ContainsKey(key))
{ {
_configItems[key] = value; _configItems[key] = value;
@@ -71,6 +75,7 @@ namespace VAR.ScreenAutomation.Code
public void Set(string key, int value) public void Set(string key, int value)
{ {
if (_configItems == null) { return; } if (_configItems == null) { return; }
if (_configItems.ContainsKey(key)) if (_configItems.ContainsKey(key))
{ {
_configItems[key] = Convert.ToString(value); _configItems[key] = Convert.ToString(value);
@@ -84,6 +89,7 @@ namespace VAR.ScreenAutomation.Code
public void Set(string key, bool value) public void Set(string key, bool value)
{ {
if (_configItems == null) { return; } if (_configItems == null) { return; }
if (_configItems.ContainsKey(key)) if (_configItems.ContainsKey(key))
{ {
_configItems[key] = value ? "true" : "false"; _configItems[key] = value ? "true" : "false";
@@ -93,6 +99,5 @@ namespace VAR.ScreenAutomation.Code
_configItems.Add(key, value ? "true" : "false"); _configItems.Add(key, value ? "true" : "false");
} }
} }
} }
} }

View File

@@ -1,9 +1,11 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace VAR.ScreenAutomation.Code namespace VAR.ScreenAutomation.Code
{ {
public class Mouse public static class Mouse
{ {
public enum MouseButtons public enum MouseButtons
{ {
@@ -24,14 +26,17 @@ namespace VAR.ScreenAutomation.Code
{ {
input.Data.Mouse.Flags = down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; input.Data.Mouse.Flags = down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
} }
if (button == MouseButtons.Middle) if (button == MouseButtons.Middle)
{ {
input.Data.Mouse.Flags = down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP; input.Data.Mouse.Flags = down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
} }
if (button == MouseButtons.Right) if (button == MouseButtons.Right)
{ {
input.Data.Mouse.Flags = down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP; input.Data.Mouse.Flags = down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
} }
INPUT[] inputs = new INPUT[] { input }; INPUT[] inputs = new INPUT[] { input };
if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0) if (SendInput(1, inputs, Marshal.SizeOf(typeof(INPUT))) == 0)
throw new Exception(); throw new Exception();
@@ -73,14 +78,11 @@ namespace VAR.ScreenAutomation.Code
[StructLayout(LayoutKind.Explicit)] [StructLayout(LayoutKind.Explicit)]
public struct MOUSEKEYBDHARDWAREINPUT public struct MOUSEKEYBDHARDWAREINPUT
{ {
[FieldOffset(0)] [FieldOffset(0)] public HARDWAREINPUT Hardware;
public HARDWAREINPUT Hardware;
[FieldOffset(0)] [FieldOffset(0)] public KEYBDINPUT Keyboard;
public KEYBDINPUT Keyboard;
[FieldOffset(0)] [FieldOffset(0)] public MOUSEINPUT Mouse;
public MOUSEINPUT Mouse;
} }
/// <summary> /// <summary>
@@ -144,7 +146,6 @@ namespace VAR.ScreenAutomation.Code
public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize); public static extern int SendInput(int nInputs, INPUT[] pInputs, int cbSize);
/// <summary> /// <summary>
/// Struct representing a point. /// Struct representing a point.
/// </summary> /// </summary>
@@ -163,7 +164,6 @@ namespace VAR.ScreenAutomation.Code
public static extern bool GetCursorPos(out POINT lpPoint); public static extern bool GetCursorPos(out POINT lpPoint);
[DllImport("User32.dll")] [DllImport("User32.dll")]
public static extern Boolean SetCursorPos(UInt32 X, UInt32 Y); public static extern Boolean SetCursorPos(UInt32 x, UInt32 y);
} }
} }

View File

@@ -4,17 +4,19 @@ using System.Windows.Forms;
namespace VAR.ScreenAutomation.Code namespace VAR.ScreenAutomation.Code
{ {
public class Screenshoter public static class Screenshoter
{ {
public static Bitmap CaptureControl(Control ctrl, Bitmap bmp = null) public static Bitmap CaptureControl(Control ctrl, Bitmap bmp = null)
{ {
if (ctrl == null) { return bmp; } if (ctrl == null) { return bmp; }
Point picCapturerOrigin = ctrl.PointToScreen(new Point(0, 0)); Point picCapturerOrigin = ctrl.PointToScreen(new Point(0, 0));
bmp = CaptureScreen(bmp, picCapturerOrigin.X, picCapturerOrigin.Y, ctrl.Width, ctrl.Height); bmp = CaptureScreen(bmp, picCapturerOrigin.X, picCapturerOrigin.Y, ctrl.Width, ctrl.Height);
return bmp; return bmp;
} }
public static Bitmap CaptureScreen(Bitmap bmp = null, int? left = null, int? top = null, int? width = null, int? height = null) private static Bitmap CaptureScreen(Bitmap bmp = null, int? left = null, int? top = null, int? width = null,
int? height = null)
{ {
if (width <= 0 || height <= 0) { return bmp; } if (width <= 0 || height <= 0) { return bmp; }
@@ -25,9 +27,9 @@ namespace VAR.ScreenAutomation.Code
height = height ?? SystemInformation.VirtualScreen.Height; height = height ?? SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the screenshot. // Create a bitmap of the appropriate size to receive the screenshot.
if (bmp == null || bmp?.Width != width || bmp?.Height != height) if (bmp == null || bmp.Width != width || bmp.Height != height)
{ {
bmp = new Bitmap(width ?? 0, height ?? 0); bmp = new Bitmap((int)width, (int)height);
} }
try try
@@ -35,11 +37,15 @@ namespace VAR.ScreenAutomation.Code
// Draw the screenshot into our bitmap. // Draw the screenshot into our bitmap.
using (Graphics g = Graphics.FromImage(bmp)) using (Graphics g = Graphics.FromImage(bmp))
{ {
g.CopyFromScreen(left ?? 0, top ?? 0, 0, 0, bmp.Size); g.CopyFromScreen((int)left, (int)top, 0, 0, bmp.Size);
} }
} }
catch (Exception) { /* Nom Nom Nom */} catch (Exception)
{
/* Nom Nom Nom */
}
return bmp; return bmp;
} }
} }
} }

View File

@@ -3,9 +3,11 @@ using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
// ReSharper disable InconsistentNaming
namespace VAR.ScreenAutomation.Code namespace VAR.ScreenAutomation.Code
{ {
public class WindowHandling public static class WindowHandling
{ {
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
@@ -15,18 +17,15 @@ namespace VAR.ScreenAutomation.Code
[DllImport("user32.dll")] [DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy,
uint uFlags);
public static void WindowSetTopLevel(Form form, bool top = true) public static void WindowSetTopLevel(Form form, bool top = true)
{ {
if (top) SetWindowPos(form.Handle, top
{ ? HWND_TOPMOST
SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); : HWND_NOTOPMOST,
} 0, 0, 0, 0, TOPMOST_FLAGS);
else
{
SetWindowPos(form.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}
} }
public static bool ApplicationIsActivated() public static bool ApplicationIsActivated()
@@ -48,4 +47,4 @@ namespace VAR.ScreenAutomation.Code
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int GetWindowThreadProcessId(IntPtr handle, out int processId); private static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
} }
} }

View File

@@ -8,7 +8,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
#region Declarations #region Declarations
private Image _imageShow = null; private Image _imageShow;
#endregion #endregion
@@ -16,7 +16,8 @@ namespace VAR.ScreenAutomation.Controls
public Image ImageShow public Image ImageShow
{ {
get { return _imageShow; } // ReSharper disable once InconsistentlySynchronizedField
get => _imageShow;
set set
{ {
lock (this) lock (this)
@@ -32,6 +33,11 @@ namespace VAR.ScreenAutomation.Controls
#region Control life cycle #region Control life cycle
public CtrImageViewer() public CtrImageViewer()
{
InitializeComponent();
}
private void InitializeComponent()
{ {
BackColor = Color.Black; BackColor = Color.Black;
} }
@@ -59,6 +65,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
return; return;
} }
lock (_imageShow) lock (_imageShow)
{ {
if (graph == null) if (graph == null)
@@ -71,7 +78,7 @@ namespace VAR.ScreenAutomation.Controls
int imgDrawHeight; int imgDrawHeight;
float imgDrawX = 0; float imgDrawX = 0;
float imgDrawY = 0; float imgDrawY = 0;
float relation = (float)_imageShow.Width / (float)_imageShow.Height; float relation = _imageShow.Width / (float)_imageShow.Height;
if (relation > 0) if (relation > 0)
{ {
// Imagen mas ancha que alta // Imagen mas ancha que alta
@@ -110,6 +117,5 @@ namespace VAR.ScreenAutomation.Controls
} }
#endregion #endregion
} }
} }

View File

@@ -6,6 +6,8 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VAR.ScreenAutomation.Interfaces; using VAR.ScreenAutomation.Interfaces;
// ReSharper disable InconsistentNaming
namespace VAR.ScreenAutomation.Controls namespace VAR.ScreenAutomation.Controls
{ {
public class CtrOutput : Control, IOutputHandler public class CtrOutput : Control, IOutputHandler
@@ -18,6 +20,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
public string Text { get; set; } public string Text { get; set; }
public object Data { get; set; } public object Data { get; set; }
public override string ToString() public override string ToString()
{ {
return Text; return Text;
@@ -37,7 +40,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
Dock = DockStyle.Fill, Dock = DockStyle.Fill,
FormattingEnabled = true, FormattingEnabled = true,
Font = new System.Drawing.Font("Consolas", 9), Font = new Font("Consolas", 9),
BackColor = Color.Black, BackColor = Color.Black,
ForeColor = Color.Gray, ForeColor = Color.Gray,
SelectionMode = SelectionMode.MultiExtended, SelectionMode = SelectionMode.MultiExtended,
@@ -69,6 +72,7 @@ namespace VAR.ScreenAutomation.Controls
CopyToClipboard(); CopyToClipboard();
return true; return true;
} }
return base.ProcessCmdKey(ref msg, keyData); return base.ProcessCmdKey(ref msg, keyData);
} }
@@ -87,6 +91,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
sbText.AppendLine(item.Text); sbText.AppendLine(item.Text);
} }
if (sbText.Length > 0) if (sbText.Length > 0)
{ {
Clipboard.SetText(sbText.ToString()); Clipboard.SetText(sbText.ToString());
@@ -106,7 +111,7 @@ namespace VAR.ScreenAutomation.Controls
} }
} }
private bool _updated = false; private bool _updated;
private readonly List<OutputItem> _pendingOutput = new List<OutputItem>(); private readonly List<OutputItem> _pendingOutput = new List<OutputItem>();
private void UpdatePosition() private void UpdatePosition()
@@ -119,6 +124,7 @@ namespace VAR.ScreenAutomation.Controls
{ {
_listBox.Items.Add(item); _listBox.Items.Add(item);
} }
_pendingOutput.Clear(); _pendingOutput.Clear();
_listBox.ResumeLayout(); _listBox.ResumeLayout();
@@ -131,7 +137,7 @@ namespace VAR.ScreenAutomation.Controls
} }
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessage(HandleRef hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); private static extern IntPtr SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam);
private static void EnableRepaint(HandleRef handle, bool enable) private static void EnableRepaint(HandleRef handle, bool enable)
{ {
@@ -168,6 +174,7 @@ namespace VAR.ScreenAutomation.Controls
public string GetCurrentText() public string GetCurrentText()
{ {
if (_listBox.SelectedItems.Count == 0) { return null; } if (_listBox.SelectedItems.Count == 0) { return null; }
OutputItem item = (OutputItem)_listBox.SelectedItems[0]; OutputItem item = (OutputItem)_listBox.SelectedItems[0];
return item?.Text; return item?.Text;
} }
@@ -175,8 +182,9 @@ namespace VAR.ScreenAutomation.Controls
public object GetCurrentData() public object GetCurrentData()
{ {
if (_listBox.SelectedItems.Count == 0) { return null; } if (_listBox.SelectedItems.Count == 0) { return null; }
OutputItem item = (OutputItem)_listBox.SelectedItems[0]; OutputItem item = (OutputItem)_listBox.SelectedItems[0];
return item?.Data; return item?.Data;
} }
} }
} }

View File

@@ -9,11 +9,11 @@ namespace VAR.ScreenAutomation
{ {
public partial class FrmAutomationBotParams : Form public partial class FrmAutomationBotParams : Form
{ {
private FileBackedConfiguration _config = null; private readonly FileBackedConfiguration _config;
private BindingList<Pair> pairs = null; private BindingList<Pair> _pairs;
private DataGridView dgvParams = null; private DataGridView _dgvParams;
public FrmAutomationBotParams(FileBackedConfiguration config) public FrmAutomationBotParams(FileBackedConfiguration config)
{ {
@@ -24,32 +24,34 @@ namespace VAR.ScreenAutomation
private void FrmAutomationBotParams_Load(object sender, EventArgs e) private void FrmAutomationBotParams_Load(object sender, EventArgs e)
{ {
pairs = new BindingList<Pair>(); _pairs = new BindingList<Pair>();
foreach (string key in _config.GetKeys()) foreach (string key in _config.GetKeys())
{ {
pairs.Add(new Pair { Key = key, Value = _config.Get(key, string.Empty), }); _pairs.Add(new Pair { Key = key, Value = _config.Get(key, string.Empty), });
} }
pairs.AddingNew += (s, a) =>
_pairs.AddingNew += (s, a) =>
{ {
a.NewObject = new Pair { Parent = pairs }; a.NewObject = new Pair { Parent = _pairs };
}; };
dgvParams = new DataGridView _dgvParams = new DataGridView
{ {
Dock = DockStyle.Fill, Dock = DockStyle.Fill,
DataSource = pairs DataSource = _pairs
}; };
Controls.Add(dgvParams); Controls.Add(_dgvParams);
} }
private void FrmAutomationBotParams_FormClosing(object sender, FormClosingEventArgs e) private void FrmAutomationBotParams_FormClosing(object sender, FormClosingEventArgs e)
{ {
var parms = new Dictionary<string, string>(); foreach (Pair pair in _pairs)
foreach (Pair pair in pairs)
{ {
if (string.IsNullOrEmpty(pair.Key)) { continue; } if (string.IsNullOrEmpty(pair.Key)) { continue; }
_config.Set(pair.Key, pair.Value); _config.Set(pair.Key, pair.Value);
} }
_config.Save(); _config.Save();
} }
@@ -59,23 +61,21 @@ namespace VAR.ScreenAutomation
public string Key { get; set; } public string Key { get; set; }
public string Value { get; set; } public string Value { get; set; }
string IDataErrorInfo.Error string IDataErrorInfo.Error => string.Empty;
{
get { return string.Empty; }
}
string IDataErrorInfo.this[string columnName] string IDataErrorInfo.this[string columnName]
{ {
get get
{ {
if (columnName == "Key" && Parent != null && Parent.Any( if (columnName == "Key" && Parent != null && Parent.Any(
x => x.Key == this.Key && !ReferenceEquals(x, this))) x => x.Key == this.Key && !ReferenceEquals(x, this)))
{ {
return "duplicate key"; return "duplicate key";
} }
return string.Empty; return string.Empty;
} }
} }
} }
} }
} }

View File

@@ -1,120 +1,125 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:complexType> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:choice maxOccurs="unbounded">
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="metadata">
</xsd:sequence> <xsd:complexType>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:sequence>
<xsd:attribute name="type" type="xsd:string" /> <xsd:element name="value" type="xsd:string" minOccurs="0"/>
<xsd:attribute name="mimetype" type="xsd:string" /> </xsd:sequence>
<xsd:attribute ref="xml:space" /> <xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> </xsd:schema>
<xsd:complexType> <resheader name="resmimetype">
<xsd:attribute name="alias" type="xsd:string" /> <value>text/microsoft-resx</value>
<xsd:attribute name="name" type="xsd:string" /> </resheader>
</xsd:complexType> <resheader name="version">
</xsd:element> <value>2.0</value>
<xsd:element name="data"> </resheader>
<xsd:complexType> <resheader name="reader">
<xsd:sequence> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> PublicKeyToken=b77a5c561934e089
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </value>
</xsd:sequence> </resheader>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <resheader name="writer">
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> PublicKeyToken=b77a5c561934e089
<xsd:attribute ref="xml:space" /> </value>
</xsd:complexType> </resheader>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root> </root>

View File

@@ -5,23 +5,31 @@ using System.Windows.Forms;
using VAR.ScreenAutomation.Code; using VAR.ScreenAutomation.Code;
using VAR.ScreenAutomation.Interfaces; using VAR.ScreenAutomation.Interfaces;
// ReSharper disable LocalizableElement
namespace VAR.ScreenAutomation namespace VAR.ScreenAutomation
{ {
public partial class FrmScreenAutomation : Form public partial class FrmScreenAutomation : Form
{ {
private bool _running = false; private bool _running;
private IAutomationBot _automationBot = null; private IAutomationBot _automationBot;
private Timer timTicker; private Timer _timTicker;
private Bitmap bmpScreen = null; private Bitmap _bmpScreen;
public FrmScreenAutomation() public FrmScreenAutomation()
{ {
AutoScaleMode = AutoScaleMode.None; PreInitializeComponent();
Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);
InitializeComponent(); InitializeComponent();
} }
private void PreInitializeComponent()
{
AutoScaleMode = AutoScaleMode.None;
Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet,
Font.GdiVerticalFont);
}
private void FrmScreenAutomation_Load(object sender, EventArgs e) private void FrmScreenAutomation_Load(object sender, EventArgs e)
{ {
var configuration = new FileBackedConfiguration(); var configuration = new FileBackedConfiguration();
@@ -31,7 +39,8 @@ namespace VAR.ScreenAutomation
Width = configuration.Get("Width", Width); Width = configuration.Get("Width", Width);
Height = configuration.Get("Height", Height); Height = configuration.Get("Height", Height);
splitMain.SplitterDistance = configuration.Get("splitMain.SplitterDistance", splitMain.SplitterDistance); splitMain.SplitterDistance = configuration.Get("splitMain.SplitterDistance", splitMain.SplitterDistance);
splitOutput.SplitterDistance = configuration.Get("splitOutput.SplitterDistance", splitOutput.SplitterDistance); splitOutput.SplitterDistance =
configuration.Get("splitOutput.SplitterDistance", splitOutput.SplitterDistance);
SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
@@ -40,7 +49,8 @@ namespace VAR.ScreenAutomation
picCapturer.BackColor = Color.LimeGreen; picCapturer.BackColor = Color.LimeGreen;
ddlAutomationBot.Items.AddRange(AutomationBotFactory.GetAllAutomationBots()); ddlAutomationBot.Items.AddRange(AutomationBotFactory.GetAllAutomationBots());
ddlAutomationBot.SelectedItem = configuration.Get("ddlAutomationBot", (string)ddlAutomationBot.SelectedItem); ddlAutomationBot.SelectedItem =
configuration.Get("ddlAutomationBot", (string)ddlAutomationBot.SelectedItem);
if (ddlAutomationBot.SelectedIndex < 0) if (ddlAutomationBot.SelectedIndex < 0)
{ {
ddlAutomationBot.SelectedIndex = 0; ddlAutomationBot.SelectedIndex = 0;
@@ -52,14 +62,14 @@ namespace VAR.ScreenAutomation
chkClick.Checked = configuration.Get("chkClick", chkClick.Checked); chkClick.Checked = configuration.Get("chkClick", chkClick.Checked);
if (components == null) { components = new Container(); } if (components == null) { components = new Container(); }
timTicker = new Timer(components)
_timTicker = new Timer(components)
{ {
Interval = Convert.ToInt32(1000 / numFPS.Value), Interval = Convert.ToInt32(1000 / numFPS.Value),
}; };
timTicker.Tick += TimTicker_Tick; _timTicker.Tick += TimTicker_Tick;
timTicker.Enabled = true; _timTicker.Enabled = true;
timTicker.Start(); _timTicker.Start();
} }
private void FrmScreenAutomation_FormClosing(object sender, FormClosingEventArgs e) private void FrmScreenAutomation_FormClosing(object sender, FormClosingEventArgs e)
@@ -80,14 +90,14 @@ namespace VAR.ScreenAutomation
private void TimTicker_Tick(object sender, EventArgs e) private void TimTicker_Tick(object sender, EventArgs e)
{ {
timTicker.Enabled = false; _timTicker.Enabled = false;
timTicker.Stop(); _timTicker.Stop();
bmpScreen = Screenshoter.CaptureControl(picCapturer, bmpScreen); _bmpScreen = Screenshoter.CaptureControl(picCapturer, _bmpScreen);
if (_automationBot != null) if (_automationBot != null)
{ {
bmpScreen = _automationBot.Process(bmpScreen, ctrOutput); _bmpScreen = _automationBot.Process(_bmpScreen, ctrOutput);
if (_running) if (_running)
{ {
string responseKeys = _automationBot.ResponseKeys(); string responseKeys = _automationBot.ResponseKeys();
@@ -97,11 +107,12 @@ namespace VAR.ScreenAutomation
} }
} }
} }
picPreview.ImageShow = bmpScreen;
timTicker.Interval = Convert.ToInt32(1000 / numFPS.Value); picPreview.ImageShow = _bmpScreen;
timTicker.Enabled = true;
timTicker.Start(); _timTicker.Interval = Convert.ToInt32(1000 / numFPS.Value);
_timTicker.Enabled = true;
_timTicker.Start();
} }
private void BtnStartEnd_Click(object sender, EventArgs e) private void BtnStartEnd_Click(object sender, EventArgs e)
@@ -124,6 +135,7 @@ namespace VAR.ScreenAutomation
private void BtnAutomationBotConfig_Click(object sender, EventArgs e) private void BtnAutomationBotConfig_Click(object sender, EventArgs e)
{ {
if (_automationBot == null) { return; } if (_automationBot == null) { return; }
IConfiguration defaultConfig = _automationBot.GetDefaultConfiguration(); IConfiguration defaultConfig = _automationBot.GetDefaultConfiguration();
var config = new FileBackedConfiguration(_automationBot.Name); var config = new FileBackedConfiguration(_automationBot.Name);
config.Load(defaultConfig); config.Load(defaultConfig);
@@ -135,6 +147,7 @@ namespace VAR.ScreenAutomation
{ {
WindowHandling.WindowSetTopLevel(this, false); WindowHandling.WindowSetTopLevel(this, false);
} }
frmAutomationBotParameters.ShowDialog(); frmAutomationBotParameters.ShowDialog();
InitBot(_automationBot.Name); InitBot(_automationBot.Name);
if (_isToplevel) if (_isToplevel)
@@ -146,20 +159,22 @@ namespace VAR.ScreenAutomation
private void Start() private void Start()
{ {
if (_running) { return; } if (_running) { return; }
_running = true; _running = true;
btnStartEnd.Text = "End"; btnStartEnd.Text = "End";
InitBot((string)ddlAutomationBot.SelectedItem); InitBot((string)ddlAutomationBot.SelectedItem);
if (chkClick.Checked) if (!chkClick.Checked) { return; }
{
Point pointCapturerCenter = picCapturer.PointToScreen(new Point(picCapturer.Width / 2, picCapturer.Height / 2)); Point pointCapturerCenter =
Mouse.SetPosition((uint)pointCapturerCenter.X, (uint)pointCapturerCenter.Y); picCapturer.PointToScreen(new Point(picCapturer.Width / 2, picCapturer.Height / 2));
Mouse.Click(Mouse.MouseButtons.Left); Mouse.SetPosition((uint)pointCapturerCenter.X, (uint)pointCapturerCenter.Y);
} Mouse.Click(Mouse.MouseButtons.Left);
} }
private void End() private void End()
{ {
if (_running == false) { return; } if (_running == false) { return; }
_running = false; _running = false;
btnStartEnd.Text = "Start"; btnStartEnd.Text = "Start";
} }
@@ -177,22 +192,24 @@ namespace VAR.ScreenAutomation
WindowSetTopLevel(chkKeepToplevel.Checked); WindowSetTopLevel(chkKeepToplevel.Checked);
} }
private bool _isToplevel = false; private bool _isToplevel;
private void WindowSetTopLevel(bool toplevel) private void WindowSetTopLevel(bool toplevel)
{ {
if (toplevel) if (toplevel)
{ {
if (_isToplevel) { return; } if (_isToplevel) { return; }
WindowHandling.WindowSetTopLevel(this); WindowHandling.WindowSetTopLevel(this);
_isToplevel = true; _isToplevel = true;
} }
else else
{ {
if (_isToplevel == false) { return; } if (_isToplevel == false) { return; }
WindowHandling.WindowSetTopLevel(this, false); WindowHandling.WindowSetTopLevel(this, false);
_isToplevel = false; _isToplevel = false;
} }
} }
} }
} }

View File

@@ -1,120 +1,125 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:complexType> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:choice maxOccurs="unbounded">
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="metadata">
</xsd:sequence> <xsd:complexType>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:sequence>
<xsd:attribute name="type" type="xsd:string" /> <xsd:element name="value" type="xsd:string" minOccurs="0"/>
<xsd:attribute name="mimetype" type="xsd:string" /> </xsd:sequence>
<xsd:attribute ref="xml:space" /> <xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
<xsd:attribute ref="xml:space"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> </xsd:schema>
<xsd:complexType> <resheader name="resmimetype">
<xsd:attribute name="alias" type="xsd:string" /> <value>text/microsoft-resx</value>
<xsd:attribute name="name" type="xsd:string" /> </resheader>
</xsd:complexType> <resheader name="version">
</xsd:element> <value>2.0</value>
<xsd:element name="data"> </resheader>
<xsd:complexType> <resheader name="reader">
<xsd:sequence> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> PublicKeyToken=b77a5c561934e089
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </value>
</xsd:sequence> </resheader>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <resheader name="writer">
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> PublicKeyToken=b77a5c561934e089
<xsd:attribute ref="xml:space" /> </value>
</xsd:complexType> </resheader>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root> </root>

View File

@@ -10,4 +10,4 @@ namespace VAR.ScreenAutomation.Interfaces
Bitmap Process(Bitmap bmpInput, IOutputHandler output); Bitmap Process(Bitmap bmpInput, IOutputHandler output);
string ResponseKeys(); string ResponseKeys();
} }
} }

View File

@@ -5,4 +5,4 @@
void Clean(); void Clean();
void AddLine(string line, object data = null); void AddLine(string line, object data = null);
} }
} }

View File

@@ -16,4 +16,4 @@ namespace VAR.ScreenAutomation
Application.Run(new FrmScreenAutomation()); Application.Run(new FrmScreenAutomation());
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,117 +1,122 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
<xsd:element name="root" msdata:IsDataSet="true"> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:complexType> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:choice maxOccurs="unbounded">
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="metadata">
</xsd:sequence> <xsd:complexType>
<xsd:attribute name="name" type="xsd:string" /> <xsd:sequence>
<xsd:attribute name="type" type="xsd:string" /> <xsd:element name="value" type="xsd:string" minOccurs="0"/>
<xsd:attribute name="mimetype" type="xsd:string" /> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
<xsd:attribute name="mimetype" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1"/>
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"/>
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> </xsd:schema>
<xsd:complexType> <resheader name="resmimetype">
<xsd:attribute name="alias" type="xsd:string" /> <value>text/microsoft-resx</value>
<xsd:attribute name="name" type="xsd:string" /> </resheader>
</xsd:complexType> <resheader name="version">
</xsd:element> <value>2.0</value>
<xsd:element name="data"> </resheader>
<xsd:complexType> <resheader name="reader">
<xsd:sequence> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> PublicKeyToken=b77a5c561934e089
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </value>
</xsd:sequence> </resheader>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <resheader name="writer">
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> PublicKeyToken=b77a5c561934e089
</xsd:complexType> </value>
</xsd:element> </resheader>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root> </root>

View File

@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles> <Profiles>
<Profile Name="(Default)" /> <Profile Name="(Default)"/>
</Profiles> </Profiles>
<Settings /> <Settings/>
</SettingsFile> </SettingsFile>

View File

@@ -1,113 +1,113 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}</ProjectGuid> <ProjectGuid>{E2BE8E2A-3422-42A6-82FA-5E0CCDC42032}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>VAR.ScreenAutomation</RootNamespace> <RootNamespace>VAR.ScreenAutomation</RootNamespace>
<AssemblyName>VAR.ScreenAutomation</AssemblyName> <AssemblyName>VAR.ScreenAutomation</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System"/>
<Reference Include="System.Core" /> <Reference Include="System.Core"/>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq"/>
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions"/>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp"/>
<Reference Include="System.Data" /> <Reference Include="System.Data"/>
<Reference Include="System.Deployment" /> <Reference Include="System.Deployment"/>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing"/>
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http"/>
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms"/>
<Reference Include="System.Xml" /> <Reference Include="System.Xml"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Bots\DummyBot.cs" /> <Compile Include="Bots\DummyBot.cs"/>
<Compile Include="Bots\TetrisBot.cs" /> <Compile Include="Bots\TetrisBot.cs"/>
<Compile Include="Code\AutomationBotFactory.cs" /> <Compile Include="Code\AutomationBotFactory.cs"/>
<Compile Include="Code\FileBackedConfiguration.cs" /> <Compile Include="Code\FileBackedConfiguration.cs"/>
<Compile Include="Code\MemoryBackedConfiguration.cs" /> <Compile Include="Code\MemoryBackedConfiguration.cs"/>
<Compile Include="FrmAutomationBotParams.cs"> <Compile Include="FrmAutomationBotParams.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="FrmAutomationBotParams.Designer.cs"> <Compile Include="FrmAutomationBotParams.Designer.cs">
<DependentUpon>FrmAutomationBotParams.cs</DependentUpon> <DependentUpon>FrmAutomationBotParams.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Interfaces\IConfiguration.cs" /> <Compile Include="Interfaces\IConfiguration.cs"/>
<Compile Include="Code\Mouse.cs" /> <Compile Include="Code\Mouse.cs"/>
<Compile Include="Code\Screenshoter.cs" /> <Compile Include="Code\Screenshoter.cs"/>
<Compile Include="Code\WindowHandling.cs" /> <Compile Include="Code\WindowHandling.cs"/>
<Compile Include="Controls\CtrImageViewer.cs"> <Compile Include="Controls\CtrImageViewer.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Controls\CtrOutput.cs"> <Compile Include="Controls\CtrOutput.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="FrmScreenAutomation.cs"> <Compile Include="FrmScreenAutomation.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="FrmScreenAutomation.Designer.cs"> <Compile Include="FrmScreenAutomation.Designer.cs">
<DependentUpon>FrmScreenAutomation.cs</DependentUpon> <DependentUpon>FrmScreenAutomation.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Interfaces\IAutomationBot.cs" /> <Compile Include="Interfaces\IAutomationBot.cs"/>
<Compile Include="Interfaces\IOutputHandler.cs" /> <Compile Include="Interfaces\IOutputHandler.cs"/>
<Compile Include="Program.cs" /> <Compile Include="Program.cs"/>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs"/>
<EmbeddedResource Include="FrmAutomationBotParams.resx"> <EmbeddedResource Include="FrmAutomationBotParams.resx">
<DependentUpon>FrmAutomationBotParams.cs</DependentUpon> <DependentUpon>FrmAutomationBotParams.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmScreenAutomation.resx"> <EmbeddedResource Include="FrmScreenAutomation.resx">
<DependentUpon>FrmScreenAutomation.cs</DependentUpon> <DependentUpon>FrmScreenAutomation.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<None Include="app.manifest" /> <None Include="app.manifest"/>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<Compile Include="Properties\Settings.Designer.cs"> <Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config"/>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project> </Project>

View File

@@ -1,76 +1,76 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security> <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options <!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following. requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <application>
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> <!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
Specifying requestedExecutionLevel element will disable file and registry virtualization. <!-- Windows Vista -->
Remove this element if your application requires this virtualization for backwards <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <!-- Windows 7 -->
<application> <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista --> <!-- Windows 8 -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 7 --> <!-- Windows 8.1 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 8 --> <!-- Windows 10 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
<!-- Windows 8.1 --> </application>
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> </compatibility>
<!-- Windows 10 --> <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application> </application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <!--
<dependency> <dependency>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity <assemblyIdentity
type="win32" type="win32"
name="Microsoft.Windows.Common-Controls" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" version="6.0.0.0"
processorArchitecture="*" processorArchitecture="*"
publicKeyToken="6595b64144ccf1df" publicKeyToken="6595b64144ccf1df"
language="*" language="*"
/> />
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
--> -->
</assembly> </assembly>