public ScanningPoint() { float secondsPerCol = ScanPeriod / (float)xRes; this.timerPeriod = (long)(500000 * secondsPerCol); this.ticksPerFrame = (long)(ScanPeriod * TimeSpan.TicksPerSecond); this.p = new ProportionPoint(0f, 0.5f); }
private void backgroundReceiver_Work(object sender, DoWorkEventArgs e) { string latest; while (true) { latest = this.ReceiveString(); //Console.Write(latest); if (latest.Contains(";")) { float[] coords = ExtractCoords(latest); this.p = new ProportionPoint(coords); if (this.Mode == ModuleMode.Active) { NewPosition(this, new NewPositionEventArgs(this.p)); } if (this.pointerDown == false) { this.pointerDown = true; if (this.Mode == ModuleMode.Active) { //PointerStateChange(this, new PointerStateChangeEventArgs(this.pointerDown)); } } } else { // if there isn't a semi-colon, not coordinates // most likely "finger___up" (could be some other, yet to be implemented, message) if(latest=="finger___up") { this.pointerDown = false; if (this.Mode == ModuleMode.Active) { //PointerStateChange(this,new PointerStateChangeEventArgs(this.pointerDown)); } } } } }
public CentrePoint() { this.p = new ProportionPoint(0.5f, 0.5f); }
private void PointerModule_NewPosition(object sender, NewPositionEventArgs e) { this.p = e.Position; int col = (int)Math.Round((double)(p.x * (float)xRes)); // Do we need a new image? if ((col < this.lastCol)||(this.bmdb==null)) { try { // Get a new image Bitmap orig = this.AcquisitionModule.GetImage(); // Now resize it so that it's height is equal to yRes Bitmap resized = this.ResizeBitmap(orig); Bitmap greyscale = this.ToGreyscale(resized); // Save this resized bitmap for posterity //string tmpPath = Path.GetTempFileName(); //resized.Save(tmpPath); //Console.WriteLine("frame saved to {0}", tmpPath); //this.bm = resized; this.bmdb = this.ImageToBytes(greyscale); } catch (NoDataYetException ndye) { Console.Write(ndye.Message); } } if ((this.bmdb != null)&&(this.lastCol!=col)) { // Now read a column //for (int i = 0; i < yRes; i++) //{ // byte[] pixel = new byte[2]; // pixel[0] = this.bmdb[0, col, i]; // pixel[1] = this.bmdb[1, col, i]; // int pixelVal = BitConverter.ToInt16(pixel, 0); // float pixelValProp = (float)pixelVal / 256f; // this.Outputs[i].Amplitude = pixelValProp; //} } this.lastCol = col; }