public override void Initialize(GameContext <AndroidXenkoGameView> gameContext) { var viewListener = new ViewListener(this); Control = gameContext.Control; Control.SetOnTouchListener(viewListener); Control.SetOnKeyListener(viewListener); Control.Resize += GameViewOnResize; GameViewOnResize(null, EventArgs.Empty); // Get the android sensors sensorManager = (SensorManager)PlatformAndroid.Context.GetSystemService(Context.SensorService); androidAccelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer); androidGyroscope = sensorManager.GetDefaultSensor(SensorType.Gyroscope); androidUserAcceleration = sensorManager.GetDefaultSensor(SensorType.LinearAcceleration); androidGravity = sensorManager.GetDefaultSensor(SensorType.Gravity); androidRotationVector = sensorManager.GetDefaultSensor(SensorType.RotationVector); // Determine which sensor is available on the device Accelerometer.IsSupported = androidAccelerometer != null; Compass.IsSupported = androidRotationVector != null; Gyroscope.IsSupported = androidGyroscope != null; UserAcceleration.IsSupported = androidUserAcceleration != null; Gravity.IsSupported = androidGravity != null; Orientation.IsSupported = androidRotationVector != null; }
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 override void Initialize() { base.Initialize(); var viewListener = new ViewListener(this); gameView = Game.Context.Control; gameView.SetOnTouchListener(viewListener); gameView.SetOnKeyListener(viewListener); gameView.Resize += GameViewOnResize; GameViewOnResize(null, EventArgs.Empty); // Get the android sensors sensorManager = (SensorManager)PlatformAndroid.Context.GetSystemService(Context.SensorService); androidAccelerometer = sensorManager.GetDefaultSensor(SensorType.Accelerometer); androidGyroscope = sensorManager.GetDefaultSensor(SensorType.Gyroscope); androidUserAcceleration = sensorManager.GetDefaultSensor(SensorType.LinearAcceleration); androidGravity = sensorManager.GetDefaultSensor(SensorType.Gravity); androidRotationVector = sensorManager.GetDefaultSensor(SensorType.RotationVector); // Determine which sensor is available on the device Accelerometer.IsSupported = androidAccelerometer != null; Compass.IsSupported = androidRotationVector != null; Gyroscope.IsSupported = androidGyroscope != null; UserAcceleration.IsSupported = androidUserAcceleration != null; Gravity.IsSupported = androidGravity != null; Orientation.IsSupported = androidRotationVector != null; }
public override void Initialize() { var viewListener = new ViewListener(this); gameView = Game.Context.Control; gameView.SetOnTouchListener(viewListener); gameView.SetOnKeyListener(viewListener); gameView.Resize += GameViewOnResize; GameViewOnResize(null, EventArgs.Empty); }
//遍历view,但是C#没有匿名内部类?不多做研究 private void forEachView(Control view, ViewListener listener) { if (view is GroupBox || view is Form) { listener.each(this); foreach (Control v in view.Controls) { forEachView(v, listener); } } else { listener.each(view); } }