Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="ParsedMessage"/> event.
        /// </summary>
        /// <param name="e">Event arguments for the event.</param>
        protected virtual void OnParsedMessage(ParsedMessageArgs e)
        {
            EventHandler <ParsedMessageArgs> handler = ParsedMessage;

            if (handler != null)
            {
                handler(null, e);
            }
        }
Ejemplo n.º 2
0
        private void MessageParsed(object sender, ParsedMessageArgs e)
        {
            string fmtString = "{0}: {1} {2}";

            textClip.Text += String.Format(fmtString, e.action, e.path, e.message) + Environment.NewLine;
        }
Ejemplo n.º 3
0
        public void parseMessage(String incomingData)
        {
            if (incomingData == null || !incomingData.StartsWith(TOKEN))
            {
                // No logging/error this is just a regular copy we don't care about.
                return;
            }
            string[] segments = incomingData.Split(SEPERATOR, StringSplitOptions.RemoveEmptyEntries);
            if (segments.Length < 3 && segments[1] != "Init")
            {
                Debug.WriteLine("Failed to parse tokenized clipboard content: " + incomingData);
                return;
            }
            switch (segments[1])
            {
            case "Init":
                initGeminiScanner();
                break;

            case "OpenFile":
                openOutputFile(segments[2], false);
                break;

            case "OpenFileAppend":
                openOutputFile(segments[2], true);
                break;

            case "CloseFile":
                closeOutputFile(segments[2]);
                break;

            case "WriteToFile":
                if (segments.Length < 4)
                {
                    return;
                }
                writeContent(segments[2], segments[3]);
                break;

            default:
                Debug.WriteLine("Unknown MessageType Segment: " + segments[1]);
                return;
            }
            ParsedMessageArgs e = new ParsedMessageArgs();

            e.action = segments[1];
            if (segments.Length >= 3)
            {
                e.path = segments[2];
            }
            else
            {
                e.path = "";
            }
            if (segments.Length >= 4)
            {
                e.message = segments[3];
            }
            else
            {
                e.message = "";
            }
            OnParsedMessage(e);
        }