protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.main); mViewListener = new ViewListener(this); mCaptureCallback = new CaptureCallback(this); rootView = FindViewById(Resource.Id.panels); mPreviewView = (PreviewView)FindViewById(Resource.Id.preview); mPreviewView.SetImplementationMode(PreviewView.ImplementationMode.Compatible); mPreviewView.SetScaleType(PreviewView.ScaleType.FitCenter); mPreviewView.SetOnTouchListener(this); mGestureDetector = new GestureDetector(this, mViewListener); Button helpButton = (Button)FindViewById(Resource.Id.help_button); helpButton.SetOnClickListener(this); mModeText = (TextView)FindViewById(Resource.Id.mode_label); mEvenExposureText = (TextView)FindViewById(Resource.Id.even_exposure); mOddExposureText = (TextView)FindViewById(Resource.Id.odd_exposure); mAutoExposureText = (TextView)FindViewById(Resource.Id.auto_exposure); mExecutor = Executors.NewSingleThreadExecutor(); mRS = RenderScript.Create(this); }
public void RegisterCaptureCallback(CaptureCallback cb) { if (cb == null) { mNativeCaptureCallback = null; mCaptureCallback = null; WasapiIO_RegisterCaptureCallback(mId, null); return; } mNativeCaptureCallback = new NativeCaptureCallback(NativeCaptureCallbackImpl); mCaptureCallback = cb; WasapiIO_RegisterCaptureCallback(mId, mNativeCaptureCallback); }
///<summary>Called when the entire sequence of image captures is complete (possibly because of failure, or a full mount among other things).</summary> private void OnCaptureFinalize(object sender,EventArgs e) { if(this.InvokeRequired) { CaptureCallback c=new CaptureCallback(OnCaptureFinalize); Invoke(c,new object[] { sender,e }); return; } ToolBarMain.Buttons["Capture"].Pushed=false; ToolBarMain.Invalidate(); EnableAllTools(true); if(IdxSelectedInMount>0 && DocsInMount[IdxSelectedInMount]!=null) {//The capture finished in a state where a mount item is selected. EnableTreeItemTools(true,true,false,true,false,true,false,true,true,true,true,true,true,true); } else {//The capture finished without a mount item selected (so the mount itself is considered to be selected). EnableTreeItemTools(true,true,true,true,false,false,false,true,true,true,false,false,false,true); } }
///<summary>Called on successful capture of image.</summary> private void OnCaptureComplete(object sender,EventArgs e) { if(this.InvokeRequired) { CaptureCallback c=new CaptureCallback(OnCaptureComplete); Invoke(c,new object[] { sender,e }); return; } if(IdxSelectedInMount<0 || DocsInMount[IdxSelectedInMount]!=null) {//Mount is full. xRayImageController.KillXRayThread(); return; } //Depending on the device being captured from, we need to rotate the images returned from the device by a certain //angle, and we need to place the returned images in a specific order within the mount slots. Later, we will allow //the user to define the rotations and slot orders, but for now, they will be hard-coded. short rotationAngle=0; switch(IdxSelectedInMount) { case (0): rotationAngle=90; break; case (1): rotationAngle=90; break; case (2): rotationAngle=270; break; default://3 rotationAngle=270; break; } //Create the document object in the database for this mount image. Bitmap capturedImage=xRayImageController.capturedImage; Document doc=ImageStore.ImportImageToMount(capturedImage,rotationAngle,MountItemsForSelected[IdxSelectedInMount].MountItemNum,GetCurrentCategory(),PatCur); ImagesCur[IdxSelectedInMount]=capturedImage; WidthsImagesCur[IdxSelectedInMount]=capturedImage.Width; HeightsImagesCur[IdxSelectedInMount]=capturedImage.Height; DocsInMount[IdxSelectedInMount]=doc; DocSelected=doc; SetBrightnessAndContrast(); //Refresh image in in picture box. InvalidateSettings(ImageSettingFlags.ALL,false); //This capture was successful. Keep capturing more images until the capture is manually aborted. //This will cause calls to OnCaptureBegin(), then OnCaptureFinalize(). xRayImageController.CaptureXRay(); }
public void Term() { WasapiIO_Term(mId); mNativeCaptureCallback = null; mCaptureCallback = null; }
public void CancelCapture() { capture = null; }
public void CaptureNext(CaptureCallback c) { capture = c; }
public void Reset() { A = new ButtonActions(Core, true, VirtualController.Button.A); B = new ButtonActions(Core, true, VirtualController.Button.B); X = new ButtonActions(Core, true, VirtualController.Button.X); Y = new ButtonActions(Core, true, VirtualController.Button.Y); Br = new ButtonActions(Core, true, VirtualController.Button.Br); Bl = new ButtonActions(Core, true, VirtualController.Button.Bl); Tl = new ButtonActions(Core, true, VirtualController.Button.Tl); Tr = new ButtonActions(Core, true, VirtualController.Button.Tr); Back = new ButtonActions(Core, true, VirtualController.Button.Back); Start = new ButtonActions(Core, true, VirtualController.Button.Start); System = new ButtonActions(Core, true, VirtualController.Button.System); LeftAnalogButton = new ButtonActions(Core, true, VirtualController.Button.LeftAnalog); RightAnalogButton = new ButtonActions(Core, true, VirtualController.Button.RightAnalog); bool needsCapture = (LeftXAxis == null); LeftXAxis = new AxisActions(Core, true, LeftXAxis, VirtualController.Axis.LeftX); LeftYAxis = new AxisActions(Core, true, LeftYAxis, VirtualController.Axis.LeftY); RightXAxis = new AxisActions(Core, true, RightXAxis, VirtualController.Axis.RightX); RightYAxis = new AxisActions(Core, true, RightYAxis, VirtualController.Axis.RightY); DigitalXAxis = new AxisActions(Core, true, DigitalXAxis, VirtualController.Axis.DigitalX); DigitalYAxis = new AxisActions(Core, true, DigitalYAxis, VirtualController.Axis.DigitalY); Trigger = new AxisActions(Core, true, Trigger, VirtualController.Axis.Trigger); if (needsCapture) { LeftXAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.LeftX, true)); capture = null; } }; LeftXAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.LeftX, false)); capture = null; } }; LeftYAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.LeftY, true)); capture = null; } }; LeftYAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.LeftY, false)); capture = null; } }; RightXAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.RightX, true)); capture = null; } }; RightXAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.RightX, false)); capture = null; } }; RightYAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.RightY, true)); capture = null; } }; RightYAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.RightY, false)); capture = null; } }; DigitalXAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.DigitalX, true)); capture = null; } }; DigitalXAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.DigitalX, false)); capture = null; } }; DigitalYAxis.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.DigitalY, true)); capture = null; } }; DigitalYAxis.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.DigitalY, false)); capture = null; } }; Trigger.PositiveRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.Trigger, true)); capture = null; } }; Trigger.NegativeRelease += delegate(object sender, EventArgs e) { if (capture != null) { capture(new CapturedInput(Axis.Trigger, false)); capture = null; } }; } }