private void Start() { state = State.NORMAL; Instance = this; ShowSave(false); ShowDefense(false); }
public void PushNullStringToClipboardIsntAllowed() { var result = Clippy.PushStringToClipboard(null); Assert.IsNotNull(result); Assert.AreEqual(Clippy.ResultCode.ErrorInvalidArgs, result.ResultCode); Assert.IsTrue(IsClipboardEmpty()); }
public void PushHugeStringToClipboardDoesntBomb() { var stuff = "1234567890"; for (var i = 0; i < 99; ++i) { var outOfMemory = false; try { stuff += stuff; } catch (OutOfMemoryException) { outOfMemory = true; } var result = Clippy.PushStringToClipboard(stuff); Assert.IsNotNull(result); switch (result.ResultCode) { case Clippy.ResultCode.Success: break; case Clippy.ResultCode.ErrorGlobalAlloc: Assert.AreEqual(WindowsErrorCodes.ErrorNotEnoughMemory, (WindowsErrorCodes)result.LastError); Assert.IsFalse(Clipboard.GetText() == stuff); break; case Clippy.ResultCode.ErrorOutOfMemoryException: Assert.AreEqual(WindowsErrorCodes.Success, (WindowsErrorCodes)result.LastError); Assert.IsFalse(Clipboard.GetText() == stuff); break; default: Assert.Fail("Unexpected result code ({0}) and windows error ({1})", result.ResultCode, result.LastError); break; } if (outOfMemory) { Assert.IsFalse(result.OK); } else { if (result.OK) { Assert.IsTrue(Clipboard.ContainsData(DataFormats.UnicodeText)); Assert.IsTrue(Clipboard.GetText() == stuff); } else { Assert.IsFalse(Clipboard.GetText() == stuff); return; } } } Assert.Inconclusive(); }
public override void SetClipboard(string value) { if (value == null) { return; } var r = Clippy.PushStringToClipboard(value); }
public void PushEmptyStringToClipboardDoesntBomb() { const string p = ""; var result = Clippy.PushStringToClipboard(p); Assert.IsNotNull(result); Assert.IsTrue(result.OK); Assert.IsTrue(Clipboard.ContainsData(DataFormats.UnicodeText)); Assert.IsTrue(Clipboard.GetText() == p); }
public void PushNonAsciiStringToClipboardWillBeUnicode() { var p = "áéíóúýðæö"; var result = Clippy.PushStringToClipboard(p); Assert.IsNotNull(result); Assert.IsTrue(result.OK); Assert.IsTrue(Clipboard.ContainsData(DataFormats.UnicodeText)); Assert.IsTrue(Clipboard.GetText() == p); }
public void PushAsciiStringToClipboardWillBeAscii() { var p = "asdf"; var result = Clippy.PushStringToClipboard(p); Assert.IsNotNull(result); Assert.IsTrue(result.OK); Assert.IsTrue(Clipboard.ContainsData(DataFormats.Text)); Assert.IsTrue(Clipboard.GetText() == p); }
static void Main(string[] args) { if (args.Length > 0) { Clippy.PushStringToClipboard(args[0]); System.Console.WriteLine("pushed \"{0}\" to the clipboard.", args[0]); } else { System.Console.WriteLine("usage: sample.exe \"<message>\""); System.Console.WriteLine(" pushes the message <message> onto the clipboard."); } }
/// <summary> /// This is the tools main sequence. /// </summary> /// <param name="args"></param> static void Main() { // The title of the console window. Console.Title = "Quick Access Junction Tool"; // The destination where I keep all junction points relative to Quick Access stored. string qAccess = "E:\\Desktop\\Quick Access Shortcuts\\"; string jLink; string dLink; string errorMessage = "Seems like an error occurred... Sorry about that."; // The prompt that requests what you'd like to name the junction point. Console.WriteLine("Please enter the desired name of your Junction Point."); Spacer(); jLink = qAccess + Console.ReadLine(); Spacer(); // The prompt that requests the path to the folder that the junction will point towards. Console.WriteLine("Please enter the path of the folder that the Junction will point towards."); Spacer(); dLink = Console.ReadLine(); Spacer(); try { Console.WriteLine("Here's the command to create your junction point. This has also been copied to your clipboard."); Spacer(); Console.WriteLine(Final(jLink, dLink)); Spacer(); // Copies the final outcome to the clipboard to allow for easy entry in the command prompt. Clippy.PushUnicodeStringToClipboard(Final(jLink, dLink)); } catch (Exception e) { errorMessage = e.Message; Console.WriteLine(errorMessage); Spacer(); } Toggle(); }
/// <summary> /// Initializes a new instance of the <see cref="ClippyContentCard"/> class. /// </summary> /// <param name="clippy">The <see cref="Clippy"/> for this card.</param> public ClippyContentCard(Clippy clippy) { this.clippy = clippy ?? throw new ArgumentNullException(nameof(clippy)); }