Ejemplo n.º 1
0
 public void traceGeneratedHandler(AnotoInkTrace generatedTrace)
 {
     if (!generatedTrace.isComplete())
     {
         return;
     }
     // TODO Auto-generated method stub
     if (generatedTrace.isPotentialAssignGesture())
     {
         //if the ID of the paper outside the note is not the wallpaper
         //then it is not "assign" gesture
         if (generatedTrace.InkDots[0].PaperNoteID != wallPaperID)
         {
             processMultipleIDsTrace(generatedTrace);
         }
         else
         {
             //add new PostIt from buffered traces
             //first get the ID of the note to be created
             // it should be different from the wallpaper
             int postItID = 0;
             foreach (AnotoInkDot inkDot in generatedTrace.InkDots)
             {
                 if (inkDot.PaperNoteID != wallPaperID)
                 {
                     postItID = inkDot.PaperNoteID;
                     break;
                 }
             }
             AnotoPostIt newPostIt = createNewPostItWithNoteID(postItID);
             if (newPostIt != null)
             {
                 newPostIt.extractPositionFromAssigningTrace(generatedTrace);
                 newPostIt.postItRemovedHandler  += new AnotoPostIt.DrawablePostItRemoved(newPostIt_postItRemovedHandler);
                 newPostIt.contentUpdatedHandler += new AnotoPostIt.DrawableContentUpdated(newPostIt_contentUpdatedHandler);
                 anotoNotes.Add(newPostIt);
                 if (newNoteAddedHandler != null)
                 {
                     newNoteAddedHandler(newPostIt);
                 }
             }
             else
             {
                 processMultipleIDsTrace(generatedTrace);
             }
         }
     }
     else
     {
         if (generatedTrace.isMultiIDTrace())
         {
             processMultipleIDsTrace(generatedTrace);
         }
         else
         {
             processSingleIDTrace(generatedTrace);
         }
     }
 }
Ejemplo n.º 2
0
        private bool containRemoveGesture()
        {
            //remove gesture is 2 crossing lines
            // each goes from a corner to the opposite one of the note
            //just check the two latest note
            List <AnotoInkTrace> traces = (List <AnotoInkTrace>)_content;

            if (traces.Count < 2)
            {
                return(false);
            }
            AnotoInkTrace trace_1 = traces[traces.Count - 1];

            /*if(!trace_1.isInNoteTrace()){
             *  return false;
             * }*/
            AnotoInkTrace trace_2 = traces[traces.Count - 2];

            /*if(!trace_2.isInNoteTrace()){
             *  return false;
             * }*/
            if (!trace_1.isStraightLine())
            {
                return(false);
            }
            if (!trace_2.isStraightLine())
            {
                return(false);
            }
            //if both two lines do not start near (0,0)
            // then this should not be remove gestures

            if (trace_1.getLeftEndPoint().X > 50 &&
                trace_2.getLeftEndPoint().X > 50 &&
                trace_1.getLeftEndPoint().Y > 50 &&
                trace_2.getLeftEndPoint().Y > 50)
            {
                return(false);
            }
            AnotoInkTrace updownTrace = null;

            updownTrace = trace_1.getLeftEndPoint().Y < trace_2.getLeftEndPoint().Y ? trace_1 : trace_2;
            AnotoInkTrace downupTrace = null;

            downupTrace = trace_1.getLeftEndPoint().Y > trace_2.getLeftEndPoint().Y ? trace_1 : trace_2;
            float leftDif   = Math.Abs(updownTrace.getLeftEndPoint().X - downupTrace.getLeftEndPoint().X);
            float topDif    = Math.Abs(updownTrace.getLeftEndPoint().Y - downupTrace.getRightEndPoint().Y);
            float rightDif  = Math.Abs(updownTrace.getRightEndPoint().X - downupTrace.getRightEndPoint().X);
            float bottomDif = Math.Abs(updownTrace.getRightEndPoint().Y - downupTrace.getLeftEndPoint().Y);
            int   MAX_DIF   = 50;

            if (leftDif > MAX_DIF || topDif > MAX_DIF || rightDif > MAX_DIF || bottomDif > MAX_DIF)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public void processMultipleIDsTrace(AnotoInkTrace multiIDTrace)
        {
            List <AnotoInkTrace> singleIDTraces = multiIDTrace.splitToSingleIDTraces();

            foreach (AnotoInkTrace trace in singleIDTraces)
            {
                processSingleIDTrace(trace);
            }
        }
Ejemplo n.º 4
0
        public void extractPositionFromAssigningTrace(AnotoInkTrace trace)
        {
            PointF      outBorder1 = new PointF();
            PointF      inBorder1  = new PointF();
            PointF      inBorder2  = new PointF();
            PointF      outBorder2 = new PointF();
            AnotoInkDot prevDot    = trace.InkDots[0];
            int         curIndex   = 0;

            for (; curIndex < trace.InkDots.Count; curIndex++)
            {
                AnotoInkDot curDot = trace.InkDots[curIndex];
                if (curDot.PaperNoteID != prevDot.PaperNoteID)
                {
                    //move from main canvas to current PostIt
                    if (curDot.PaperNoteID == this.Id)
                    {
                        //then the point right outside the PostIt is prevDot
                        outBorder1.X = prevDot.X;
                        outBorder1.Y = prevDot.Y;
                        //the first point right inside the PostIt is curDot
                        inBorder1.X = curDot.X;
                        inBorder1.Y = curDot.Y;
                    }
                    else
                    {
                        //move from current PostIt back to the main canvas
                        //then prevDot is the last point inside the PostIt
                        inBorder2.X = prevDot.X;
                        inBorder2.Y = prevDot.Y;
                        //the next dot (curDot) lies outside
                        outBorder2.X = curDot.X;
                        outBorder2.Y = curDot.Y;
                    }
                }
                prevDot = curDot;
            }
            //swapping if trace drawn down-to-top
            if (outBorder2.X < outBorder1.X ||
                outBorder2.Y < outBorder1.Y)
            {
                PointF temp = outBorder2;
                outBorder2 = outBorder1;
                outBorder1 = temp;

                temp      = inBorder2;
                inBorder2 = inBorder1;
                inBorder1 = temp;
            }
            //interpolate PostIt's position on the main canvas
            //assume outBorder1 and inBorder are very close
            //there is no much difference between two points
            _centerX = outBorder1.X - inBorder1.X;
            _centerY = outBorder1.Y - inBorder1.Y;
        }
Ejemplo n.º 5
0
        public void processSingleIDTrace(AnotoInkTrace trace)
        {
            AnotoPostIt postIt = getPostItWithID(trace.InkDots[0].PaperNoteID);

            if (postIt == null)
            {
                bufferedTraces.Add(trace);
            }
            else
            {
                if (postIt.IsAvailable)
                {
                    postIt.updateContent(trace);
                }
            }
        }