public VisualButton AddVisualButton(string name, Rectangle rectangle) { var visualButton = new VisualButton(rectangle); this.visualButtons.Add(name, visualButton); return visualButton; }
protected override InputConfiguration CreateInputConfiguration() { var inputConfiguration = new InputConfiguration(); inputConfiguration.AddDigitalButton("Back").Assign(KeyboardKeys.Escape) .MapClickTo(gt => this.screenNavigation.NavigateBack()); //inputConfiguration.AddTouchTracking(this.Camera).OnTouch((ts, gt) => this.touchState = ts); inputConfiguration.AddEvent("Tap").Assign(TouchGestureType.Tap).MapTo(gt => this.tapCount++); inputConfiguration.AddEvent("Hold").Assign(TouchGestureType.Hold).MapTo(gt => this.holdCount++); inputConfiguration.AddEvent("DoubleTap").Assign(TouchGestureType.DoubleTap).MapTo(gt => this.doubleTapCount++); inputConfiguration.AddEvent("DragComplete").Assign(TouchGestureType.DragComplete).MapTo(gt => this.dragCompleteCount++); inputConfiguration.AddEvent("Flick").Assign(TouchGestureType.Flick).MapTo(gt => this.flickCount++); inputConfiguration.AddEvent("FreeDrag").Assign(TouchGestureType.FreeDrag).MapTo(gt => this.freeDragCount++); inputConfiguration.AddEvent("HorizontalDrag").Assign(TouchGestureType.HorizontalDrag).MapTo(gt => this.horizontalDragCount++); inputConfiguration.AddEvent("Pinch").Assign(TouchGestureType.Pinch).MapTo(gt => this.pinchCount++); inputConfiguration.AddEvent("PinchComplete").Assign(TouchGestureType.PinchComplete).MapTo(gt => this.pinchCompleteCount++); inputConfiguration.AddEvent("VerticalDrag").Assign(TouchGestureType.VerticalDrag).MapTo(gt => this.verticalDragCount++); var viewport = this.Camera.Viewport; //var size = new Size(viewport.Width, viewport.Height); var s2 = viewport.Size.Scale(0.1f); var backRectangle = new Rectangle(viewport.Width - s2.X * 2, viewport.Height - s2.Y * 2, s2.X, s2.Y); this.visualBackButton = inputConfiguration.AddVisualButton("Back", backRectangle) .Assign(TouchGestureType.Tap) .MapTouchTo(gt => this.isHoveringBackButton = true) .MapClickTo(gt => this.screenNavigation.NavigateBack()); return inputConfiguration; }