示例#1
0
        void processDot(Dot dot)
        {
            // 필터링 된 필압
            dot.force = mFilter.Filter(dot.force);

            // TODO: Drawing sample code
            if (dot.type == DotType.PEN_DOWN)
            {
                stroke = new Stroke(dot.sectionId, dot.ownerId, dot.noteId, dot.pageId);
                stroke.Add(dot);
            }
            else if (dot.type == DotType.PEN_MOVE)
            {
                stroke.Add(dot);
            }
            else if (dot.type == DotType.PEN_UP)
            {
                stroke.Add(dot);

                drawStroke(stroke);

                mFilter.Reset();
            }

            this.BeginInvoke(new MethodInvoker(delegate()
            {
                if (dot.type == DotType.PEN_DOWN)
                {
                    txtPacket.Text          += Time.GetDateTime(dot.timeLong).ToString() + " ";
                    txtPacket.Text          += dot.ToString() + "\r\n";
                    txtPacket.SelectionStart = txtPacket.TextLength;
                    txtPacket.ScrollToCaret();
                }
            }));
        }
示例#2
0
        private void ProcessDot(Dot dot)
        {
            dot.Force = mFilter.Filter(dot.Force);

            // TODO: Drawing sample code
            if (dot.DotType == DotTypes.PEN_DOWN)
            {
                mStroke = new Stroke(dot.Section, dot.Owner, dot.Note, dot.Page);
                mStroke.Add(dot);
                printDot(dot);
            }
            else if (dot.DotType == DotTypes.PEN_MOVE)
            {
                mStroke.Add(dot);
            }
            else if (dot.DotType == DotTypes.PEN_UP)
            {
                mStroke.Add(dot);

                //DrawStroke(mStroke);

                mSig.Add(mStroke);

                ClearImage();

                DrawSignature();

                //Debug.WriteLine("Number of lines: " + mSig.Count);

                mFilter.Reset();

                //saveImage();
            }
        }
示例#3
0
 public void DrawSegment(int x, int y)
 {
     current.Add(x, y);
     if (NewSegment != null)
     {
         int cnt = current.Count;
         NewSegment(current.GetPoint(cnt - 2).X, current.GetPoint(cnt - 2).Y, x, y);
     }
 }
示例#4
0
        public void TestOpenSaveStroke()
        {
            var stroke = new Stroke();
            stroke.Add(new Point(1, 2));
            stroke.Add(new Point(3, 4));
            var mem = new System.IO.MemoryStream();
            var f = Obf.OpenBinaryFormat.ToMemory(mem);
            stroke.Save(f, 1);
            var bytes = mem.ToArray();
            f.Close();

            f = Obf.OpenBinaryFormat.FromBytes(bytes);
            var newStroke = new Stroke();
            newStroke.Read(f);
            Assert.True(newStroke.Count == 2);
            Assert.True(newStroke[0].X == 1);
            Assert.True(newStroke[0].Y == 2);
            Assert.True(newStroke[1].X == 3);
            Assert.True(newStroke[1].Y == 4);
        }
示例#5
0
    void TryStartGesture(Touch2 touch)
    {
        if (!IsOnCanvas(touch))
        {
            return;
        }

        _isDrawing     = true;
        _currentStroke = CreateStroke();
        _currentStroke.Add(Utilities.GetNormalizedWorldCoordinates(_camera, touch));
    }
示例#6
0
 private void ProcessDot(Dot dot)
 {
     if (session != null)
     {
         dot.Force = mFilter.Filter(dot.Force);
         if (dot.DotType == DotTypes.PEN_DOWN)
         {
             mStroke = new Stroke(dot.Section, dot.Owner, dot.Note, dot.Page);
             mStroke.Add(dot);
         }
         else if (dot.DotType == DotTypes.PEN_MOVE)
         {
             mStroke.Add(dot);
         }
         else if (dot.DotType == DotTypes.PEN_UP)
         {
             mStroke.Add(dot);
             ProcessStroke(mStroke);
             DrawStroke(mStroke);
             mFilter.Reset();
         }
     }
 }
示例#7
0
    void TryAddStroke(Touch2 touch)
    {
        if (!_isDrawing)
        {
            return;
        }

        if (!IsOnCanvas(touch))
        {
            return;
        }

        _currentStroke.Add(Utilities.GetNormalizedWorldCoordinates(_camera, touch));
    }
示例#8
0
        public void TestOpenSaveFrameData()
        {
            var frameData = new FrameData();
            var frame = new Frame();
            frameData.Frames.Add(frame);
            var stroke = new Stroke();
            stroke.Add(new Point(0, 0));
            stroke.Add(new Point(100, 100));
            frame.Strokes.Add(stroke);

            System.IO.MemoryStream mem = new System.IO.MemoryStream();
            Obf.OpenBinaryFormat f = Obf.OpenBinaryFormat.ToMemory(mem);
            frameData.Save(f);

            var bytes = mem.ToArray();
            f.Close();

            f = Obf.OpenBinaryFormat.FromBytes(bytes);

            var newFrameData = new FrameData();
            newFrameData.Read(f);

            f.Close();

            Assert.True(newFrameData.Frames.Count == 1);
            frame = newFrameData.Frames[0];
            Assert.True(frame.Strokes.Count == 1);
            stroke = frame.Strokes[0];
            Assert.True(stroke.Count == 2);
            var p1 = stroke[0];
            Assert.True(p1.X == 0);
            Assert.True(p1.Y == 0);
            var p2 = stroke[1];
            Assert.True(p2.X == 100);
            Assert.True(p2.Y == 100);
        }
示例#9
0
        private void ProcessDot(Dot dot)
        {
            // Filtered pressure
            dot.Force = mFilter.Filter(dot.Force);

            // TODO: Drawing sample code
            if (dot.DotType == DotTypes.PEN_DOWN)
            {
                mStroke = new Stroke(dot.Section, dot.Owner, dot.Note, dot.Page);
                mStroke.Add(dot);
            }
            else if (dot.DotType == DotTypes.PEN_MOVE)
            {
                mStroke.Add(dot);
            }
            else if (dot.DotType == DotTypes.PEN_UP)
            {
                mStroke.Add(dot);

                DrawStroke(mStroke);

                mFilter.Reset();
            }
        }
        private void SendDotReceiveEvent(Dot dot, object obj)
        {
            if (curStroke == null || dot.DotType == DotTypes.PEN_DOWN)
            {
                curStroke = new Stroke(dot.Section, dot.Owner, dot.Note, dot.Page);
            }

            curStroke.Add(dot);

            Callback.onReceiveDot(this, dot);

            if (dot.DotType == DotTypes.PEN_UP && MetadataManager != null)
            {
                var symbols = MetadataManager.FindApplicableSymbols(curStroke);

                if (symbols != null && symbols.Count > 0)
                {
                    Callback.onSymbolDetected(this, symbols);
                }
            }
        }
		void Collect (Stroke stroke, UITouch touch, UIView view, bool coalesced, bool predicted)
		{
			if (view == null)
				throw new ArgumentNullException ();

			// Only collect samples that actually moved in 2D space.
			var location = touch.GetPreciseLocation (view);
			var previousSample = stroke.Samples.LastOrDefault ();
			if (Distance (previousSample?.Location, location) < 0.003)
				return;

			var sample = new StrokeSample {
				Timestamp = touch.Timestamp,
				Location = location,
				Coalesced = coalesced,
				Predicted = predicted
			};
			bool collectForce = touch.Type == UITouchType.Stylus || view.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available;
			if (collectForce)
				sample.Force = touch.Force;

			if (touch.Type == UITouchType.Stylus) {
				var estimatedProperties = touch.EstimatedProperties;
				sample.EstimatedProperties = estimatedProperties;
				sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates;
				sample.Altitude = touch.AltitudeAngle;
				sample.Azimuth = touch.GetAzimuthAngle (view);

				if (stroke.Samples.Count == 0 && estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					stroke.ExpectsAltitudeAzimuthBackfill = true;
				} else if (stroke.ExpectsAltitudeAzimuthBackfill &&
						   !estimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
					for (int index = 0; index < stroke.Samples.Count; index++) {
						var priorSample = stroke.Samples [index];
						var updatedSample = priorSample;

						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Altitude)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Altitude;
							updatedSample.Altitude = sample.Altitude;
						}
						if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Azimuth)) {
							updatedSample.EstimatedProperties &= ~UITouchProperties.Azimuth;
							updatedSample.Azimuth = sample.Azimuth;
						}
						stroke.Update (updatedSample, index);
					}
					stroke.ExpectsAltitudeAzimuthBackfill = false;
				}
			}

			if (predicted) {
				stroke.AddPredicted (sample);
			} else {
				var index = stroke.Add (sample);
				if (touch.EstimatedPropertiesExpectingUpdates != 0) {
					outstandingUpdateIndexes [touch.EstimationUpdateIndex] = new StrokeIndex {
						Stroke = stroke,
						Index = index
					};
				}
			}
		}
示例#12
0
 public void AddStroke(string catagory, int stroke)
 {
     Stroke.Add(catagory, stroke);
 }