How can a C# Windows Console application tell if it is run interactively

[EDIT: 4/2021 – new answer…] Due to a recent change in the Visual Studio debugger, my original answer stopped working correctly when debugging. To remedy this, I’m providing an entirely different approach. The text of the original answer is included at the bottom. 1. Just the code, please… To determine if a .NET application is … Read more

How to disable touch input to all views except the top-most view?

Hope this help… [[yourSuperView subviews] makeObjectsPerformSelector:@selector(setUserInteractionEnabled:) withObject:[NSNumber numberWithBool:FALSE]]; which will disable userInteraction of a view’s immediate subviews..Then give userInteraction to the only view you wanted yourTouchableView.setUserInteraction = TRUE; EDIT: It seems in iOS disabling userInteraction on a parent view doesn’t disable userInteraction on its childs.. So the code above (I mean the one with makeObjectsPerformSelector:)will … Read more

How to create a resizable rectangle with user touch events on Android?

Chintan Rathod’s answer was great solution but there are something wrong when He draws the rectangle. I just edit some lines of code to make it works correctly with user touch event. Now, you can add this view to your layout then touch to draw. import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; … Read more

How to detect swipe direction between left/right and up/down

I wrote a simple class for this: it’s well documented so I wont explain it here public class OnSwipeListener extends GestureDetector.SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // Grab two events located on the plane at e1=(x1, y1) and e2=(x2, y2) // Let e1 be the initial event … Read more