예제 #1
0
파일: Clippy.cs 프로젝트: Etiouse/GMTK-20
 private void Start()
 {
     state    = State.NORMAL;
     Instance = this;
     ShowSave(false);
     ShowDefense(false);
 }
예제 #2
0
        public void PushNullStringToClipboardIsntAllowed()
        {
            var result = Clippy.PushStringToClipboard(null);

            Assert.IsNotNull(result);
            Assert.AreEqual(Clippy.ResultCode.ErrorInvalidArgs, result.ResultCode);
            Assert.IsTrue(IsClipboardEmpty());
        }
예제 #3
0
        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();
        }
예제 #4
0
        public override void SetClipboard(string value)
        {
            if (value == null)
            {
                return;
            }

            var r = Clippy.PushStringToClipboard(value);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
 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.");
     }
 }
예제 #9
0
        /// <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();
        }
예제 #10
0
 /// <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));
 }