Xamarin.Android. Setting time for LongClick event - c#

Is it possible in Xamarin.Android to set event LongClick click time or something similar? The click time as it is, is too short for me.

LongClick timing is managed by the Android OS, so it cannot be directly modified. However, you could go around the problem by handling everything by yourself.
Create a touch listener.
In the OnTouch event, detect if the touch action is MotionEventActions.Down and get the current time in milliseconds by using CurrentTimeMillis method.
Have another check for MotionEventActions.Up to detect when the user lifts the finger. Calculate the time difference between touch up and touch down events and if it's long enough, do something.
Here's some code samples related to touch events. It shows how to create the touch listener and react to touch events.

Related

How to detect whether user is on the desktop C# winforms

I was making a program that changes the desktop background, but there is no need to do this when the user is not on the desktop.
I was wondering if there was a way to detect if the user was on the desktop.
I was also thinking an alternative could be checking whether the user is on any other processes, but I don't know how to do this either.
(I would happily provide my code if necessary)
I'm sorry for posting such a broad question, I hope there is a way to do this though.
Thanks to anyone who can help!
If you want to check application in idle condition then you have to do below:
Add a timer control to your application.
Subscribe to mouseover and keydown events - when they fire, reset the timer.
When the timer fires (ie mouse hasn't moved and key's haven't been pressed for x amount of time), write your logic.
And If want to check idle condition of desktop then below references will be useful for you:
Detecting that the user is away from the PC with .NET
Detecting that the user is away from the PC with .NET
http://www.codeproject.com/KB/cs/ApplicationIdle.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.idle.aspx
http://ellisweb.net/2008/02/detecting-application-idle-state-in-windows-forms/

Is there a way to get rid of the short pause in reaction after you press a key for the first time and hold it down?

I'm trying to make a game in WPF, C# where it would be crucial to have quick movements with the keyboard. Does anyone know how to get rid of the said phenomena?
What you are likely seeing in terms of a 'delay' is the keyboard repeat delay, which is controlled by the operation system (see Control Panel -> Keyboard).
You will probably have better luck working with the KeyDown and KeyUp attached events. https://msdn.microsoft.com/en-us/library/system.windows.input.keyboard.keydown(v=vs.110).aspx
By handing these events, you can handle repeating the functionality as frequently as you want until the KeyUp event is received.

KinectSDK poll after using events

I have two sections of a Kinect app I'm making. There's a WPF menu which eventually directs the user to an XNA Game.
The problem is the WPF controls I'm using (like KinectRegion) are adding event listeners to things like AllFramesReady on the KinectSensor object. And as soon as I try to poll for skeleton data in my XNA game, I get the following error:
This API cannot be called when an event listener has been set
My question: How can I reset everything in the KinectSDK so I have a clean slate when starting my XNA game? Or at the very least, get it into a state where I can poll for skeleton data successfully.
I don't know what methods the WPF controls are attaching to handle the events, so I can't explicitly remove them from the event.
Similar issue: Get color Image not in the frame ready event
You are not able to use event handler and polling method at one time. Kinect API won't support that. better way is to use global variable for your polling method and use it on anywhere that you want.

Long click event doesn't fire when also listening for touch

Is there a good way to listen for both Touch and LongClick events?
When my touch event fires, the resulting actions are all in a different thread, so code isn't running in the UI thread, but the long click event still doesn't seem to fire. This is in Xamarin, if that makes a difference.
Documentation for OnTouchListener and for OnLongClickListener
Is there a workaround for this?

How to efficiently react to touch events in Windows RT

This might be a dumb question but I'm not familiar with XAML.
I'm implementing a RTP-MIDI client Library for Windows Store Apps and would like to investigate and troubleshoot potential latency and performance problems.
I've written a quick dummy application with a couple of buttons to send MIDI events to an musical instrument over the network using my Library. In that scenario, I find that my Library is able to process a single basic MIDI event in under 10ms over the network, but I find that the delay between the time I press a button on the UI and the time where my Library is instructed to send an event is very high.
Ideally, I would like to react to a "touch pressed" event and instantly send a MIDI event as well as a "touch released" event and instantly send the corresponding MIDI event.
I could not find such events on the regular button controls. Ideally, I would like to achieve the highest performance possible from the UI, even with a single button, in order to eliminate this source of problems in my performance assessment.
Is there a way I could react to the screen being touched "in real time" like a game, for instance?
The most basic access to various pointer events (such as tapping, clicking) are available through a series of lower level events, with these being directly related to your question:
PointerPressed
PointerReleased
PointerPressed should be the equivalent of MouseDown for example in a traditional application as it fires early, and before any translation into a higher level event (such as Click) has occurred.
The PointerReleased would be the equivalent of MouseUp. If you're relying on the PointerReleased event, you'll want to take note of the fact that the event isn't necessarily fired as a pair with the PointerPressed event, as there are a number of conditions where it may not fire. The documentation has the details.

Categories

Resources