View gist:01664dc7ee576f69042c
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Runtime.InteropServices; | |
using System.IO; | |
namespace WiredPrairie.Samples | |
{ | |
public static class Pathing |
View acc.cs
private Accessible GetFocused(Accessible objParent) | |
{ | |
Accessible objToReturn = default(Accessible); | |
if (objParent != null) | |
{ | |
Accessible[] children = null; | |
objParent.Children(out children); | |
if (children != null) | |
{ | |
foreach (var accessible in children) |
View gist:f2e77c771b6b816bdea0
public static string GetText() | |
{ | |
try | |
{ | |
var element = AutomationElement.FocusedElement; | |
if (element != null) | |
{ | |
object pattern; | |
if (element.TryGetCurrentPattern(TextPattern.Pattern, out pattern)) | |
{ |
View gist:8f474733daa8741af061
class ImageOpacity | |
{ | |
private const int bytesPerPixel = 4; | |
/// <summary> | |
/// Change the opacity of an image | |
/// </summary> | |
/// <param name="originalImage">The original image</param> | |
/// <param name="opacity">Opacity, where 1.0 is no opacity, 0.0 is full transparency</param> | |
/// <returns>The changed image</returns> |
View gist:a7d9a456156c386149d8
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, | |
out ulong lpFreeBytesAvailable, | |
out ulong lpTotalNumberOfBytes, | |
out ulong lpTotalNumberOfFreeBytes); | |
ulong FreeBytesAvailable; | |
ulong TotalNumberOfBytes; | |
ulong TotalNumberOfFreeBytes; |
View gist:dc32cbe0dd47470801d4
var start = reachTextBox.Document.ContentStart; | |
var textrange = new TextRange(GetPoint(start, pos), GetPoint(start, pos + len)); | |
private TextPointer GetPoint(TextPointer start, int x) | |
{ | |
var ret = start; | |
var i = 0; | |
while (true) | |
{ | |
string stringSoFar = new TextRange(ret, ret.GetPositionAtOffset(i, LogicalDirection.Forward)).Text; |