private void OnNewRawInkSample(RawInkSample raw) { //checking for duplicate times if (_CapturedPackets.Count > 0 && _CapturedPackets[_CapturedPackets.Count - 1].Time == raw.Time) { return; } //calibrate the ink sample CalibratedInkSample cal; using (Graphics g = _Overlay.AttachedControl.CreateGraphics()) { cal = InkCalibration.Current.RawToCalibrated(g, raw, _Overlay.AttachedControl.Size); } #if (DEBUG) Console.WriteLine(cal); #endif //store the sample _CapturedPackets.Add(cal); if (NewInkSample != null) { NewInkSample(cal); } }
public override bool Equals(object obj) { RawInkSample raw = (RawInkSample)obj; return(raw.Time == Time && raw.X == X && raw.Y == Y && raw.Pressure == Pressure); }
private void Overlay_NewPackets(object sender, InkCollectorNewPacketsEventArgs e) { /*** THIS ROUTINE MUST BE EXTREMELY FAST ***/ /* * Since we are handling a flurry of packet * data, this routine should not perform any * significant processing, just data recording. * * Asynchronous invocation on the windows forms * thread is used to delay as much sample * processing as possible. */ //go over the packet data and store InkSamples int[] PacketData = e.PacketData; if (PacketData[2] == 0) //new stroke since timer is 0; use the internal timer to compute the time of the first packet { //check if the packets have pressure data Tablet CurrentTablet = e.Cursor.Tablet; Overlay_NewPackets_PacketsHavePressure = CurrentTablet != null && CurrentTablet.IsPacketPropertySupported(PacketProperty.NormalPressure); //raise the NewInkSample event with an invalid ink sample to signal a new stroke to listeners _Overlay.AttachedControl.BeginInvoke(new NewRawInkSampleHandler(OnNewRawInkSample), new RawInkSample(_Timer.Now())); } for (int i = 0; i < PacketData.Length;) { RawInkSample s = new RawInkSample(); s.Time = _Timer.Now(); s.X = PacketData[i++]; s.Y = PacketData[i++]; i++; //skip the timer sample s.Pressure = Overlay_NewPackets_PacketsHavePressure ? PacketData[i++] : 0; //have the form thread raise the NewInkSample event at its convenience _Overlay.AttachedControl.BeginInvoke(new NewRawInkSampleHandler(OnNewRawInkSample), s); } }
private void Overlay_NewPackets(object sender, InkCollectorNewPacketsEventArgs e) { /*** THIS ROUTINE MUST BE EXTREMELY FAST ***/ /* * Since we are handling a flurry of packet * data, this routine should not perform any * significant processing, just data recording. * * Asynchronous invocation on the windows forms * thread is used to delay as much sample * processing as possible. */ //go over the packet data and store InkSamples int[] PacketData = e.PacketData; if(PacketData[2] == 0) //new stroke since timer is 0; use the internal timer to compute the time of the first packet { //check if the packets have pressure data Tablet CurrentTablet = e.Cursor.Tablet; Overlay_NewPackets_PacketsHavePressure = CurrentTablet != null && CurrentTablet.IsPacketPropertySupported(PacketProperty.NormalPressure); //raise the NewInkSample event with an invalid ink sample to signal a new stroke to listeners _Overlay.AttachedControl.BeginInvoke(new NewRawInkSampleHandler(OnNewRawInkSample), new RawInkSample(_Timer.Now())); } for(int i = 0; i < PacketData.Length; ) { RawInkSample s = new RawInkSample(); s.Time = _Timer.Now(); s.X = PacketData[i++]; s.Y = PacketData[i++]; i++; //skip the timer sample s.Pressure = Overlay_NewPackets_PacketsHavePressure ? PacketData[i++] : 0; //have the form thread raise the NewInkSample event at its convenience _Overlay.AttachedControl.BeginInvoke(new NewRawInkSampleHandler(OnNewRawInkSample), s); } }
private void OnNewRawInkSample(RawInkSample raw) { //checking for duplicate times if (_CapturedPackets.Count > 0 && _CapturedPackets[_CapturedPackets.Count - 1].Time == raw.Time) return; //calibrate the ink sample CalibratedInkSample cal; using (Graphics g = _Overlay.AttachedControl.CreateGraphics()) { cal = InkCalibration.Current.RawToCalibrated(g, raw, _Overlay.AttachedControl.Size); } #if(DEBUG) Console.WriteLine(cal); #endif //store the sample _CapturedPackets.Add(cal); if(NewInkSample != null) NewInkSample(cal); }