예제 #1
0
        void annotoPenReceiver_PenDown(object sender, AnnotoPenMotionEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)delegate()
            {
                StylusPoint pt = new StylusPoint((e.X - 5.0) / 204.0 * 363.0, (e.Y - 5.0) / 173.0 * 309.0, e.Force / 256.0f);
                //currentPts.Add(pt);

                if (currentStroke == null)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    pts.Add(pt);

                    DrawingAttributes attr = new DrawingAttributes()
                    {
                        Color = Colors.White, 
                    };

                    currentStroke = new Stroke(pts, attr);
                    inkCanvas.Strokes.Add(currentStroke);
                }
                else
                {
                    currentStroke.StylusPoints.Add(pt);
                }
                //Trace.WriteLine("Pen Down");
            }, null);
        }
예제 #2
0
        void annotoPenReceiver_PenUp(object sender, AnnotoPenMotionEventArgs e)
        {
            Dispatcher.BeginInvoke((Action)delegate()
            {
                /*if (currentPts == null || currentPts.Count == 0)
                {
                    return;
                }

                inkCanvas.Strokes.Add(new Stroke(currentPts));
                currentPts = new StylusPointCollection();*/
                currentStroke = null;
                Trace.WriteLine("Pen Up");
            }, null);
        }
예제 #3
0
        void annotoPenReceiver_PenMove(object sender, AnnotoPenMotionEventArgs e)
        {

        }
예제 #4
0
        private void clientThreadWorker()
        {
            while (client != null && client.Connected)
            {
                if (isCloseRequested)
                {
                    client.Close();
                }

                int msgSize = 0;

                try
                {
                    codedStream.ReadInt32(ref msgSize);
                }
                catch (Exception)   //SocketException, InvalidProtocolBufferException
                {
                    Trace.WriteLine("AnnotoPen connection lost");
                    break;
                }

                int oldLimit = codedStream.PushLimit(msgSize);
                Message msg = Message.ParseFrom(codedStream);
                codedStream.PopLimit(oldLimit);

                if (msg.Type == MessageType.Motion)
                {
                    AnnotoPenMotionEventArgs e = new AnnotoPenMotionEventArgs(msg.Motion.X, msg.Motion.Y, msg.Motion.Timestamp, msg.Motion.Force, msg.Motion.Document, msg.Motion.Page);
                    if (msg.Motion.Motion == MotionCode.PenDown && PenDown != null)
                    {
                        PenDown(this, e);
                    }
                    else if (msg.Motion.Motion == MotionCode.PenUp && PenUp != null)
                    {
                        PenUp(this, e);
                    }
                    else if (msg.Motion.Motion == MotionCode.PenMove && PenMove != null)
                    {
                        PenMove(this, e);
                    }
                }

                //Console.WriteLine(msg.ToString());
            }
        }