Example #1
0
        // Invoked every time the app receives focus.
        void PasteFromClipboard()
        {
            // Get text from the clipboard.
            // Replace , with . and − with - so the string can be properly read as a number.
            string latestText = Clipboard.GetText();

            latestText = latestText.Replace(Constants.Comma, Constants.DecimalSeparator);
            latestText = latestText.Replace(Constants.Minus, Constants.Negative);

            // If the clipboard text is a number, and it's a new number (not pasted just earlier).
            // Then pass the number to the display and show a message that a number has been pasted.
            if (double.TryParse(latestText, out double number) &&
                !latestText.Equals(lastPastedValue))
            {
                InputEvents.ClipboardTextPasted(latestText);

                //InputEvents.NumberEntered(latestText);

                //OutputEvents.UpdateClipboardMessage(String.Format(Constants.PasteFromClipboard, latestText));
            }
        }