public HipsterEngine CreateEngine(int width, int height) { _activity.Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); _renderer = new SKGLRenderer(); _view = new SKGLSurfaceView(_activity); _view.SetRenderer(_renderer); _view.Touch += ViewOnTouch; _renderer.PaintSurface += ViewOnPaintSurface; Engine = new HipsterEngine(width, height); Engine.OnResize(width, height); return(Engine); }
public void Initialize() { SetBackgroundColor(Color.Transparent); _canvas = new SKGLSurfaceView(Context); _canvas.PaintSurface += CanvasOnPaintSurface; AddView(_canvas); _mainLooperHandler = new Handler(Looper.MainLooper); SetViewportSize(); // todo: check if size is available, perhaps we need a load event Map = new Map(); Touch += MapView_Touch; _gestureDetector = new GestureDetector(Context, new GestureDetector.SimpleOnGestureListener()); _gestureDetector.SingleTapConfirmed += OnSingleTapped; _gestureDetector.DoubleTap += OnDoubleTapped; }
public override View Run() { var view = new View { Layout = new LinearLayout { LinearAlignment = LinearLayout.Alignment.Center, LinearOrientation = LinearLayout.Orientation.Vertical, } }; view.UpdateBackgroundColor(Color.FromHex("#618833")); var canvas = new SKCanvasView() { SizeWidth = 300, SizeHeight = 300, }; view.Add(new Label { Text = "ImageView" }); view.Add(canvas); var glSurface = new SKGLSurfaceView() { SizeWidth = 300, SizeHeight = 300, }; view.Add(new Label { Text = "GL Surface View" }); view.Add(glSurface); canvas.PaintSurface += OnPaintSurface; glSurface.PaintSurface += OnPaintSurface; var left = new Button { Text = "<-" }; view.Add(left); left.Clicked += (s, e) => { startX -= 10; canvas.Invalidate(); glSurface.Invalidate(); }; var right = new Button { Text = "->" }; view.Add(right); right.Clicked += (s, e) => { startX += 10; canvas.Invalidate(); glSurface.Invalidate(); }; var add = new Button { Text = "+" }; view.Add(add); add.Clicked += (s, e) => { canvas.SizeWidth += 30; glSurface.SizeWidth += 30; }; return(view); }
public override View Run() { var scrollView = new ScrollView(); scrollView.UpdateBackgroundColor(Color.FromHex("#618833")); scrollView.ContentContainer.Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Vertical }; List <CustomRenderingView> viewList = new List <CustomRenderingView>(); for (int i = 0; i < 5; i++) { var canvas = new SKCanvasView() { Margin = new Extents(5, 5, 5, 5), SizeWidth = 300, SizeHeight = 300, }; var glSurface = new SKGLSurfaceView() { Margin = new Extents(5, 5, 5, 5), SizeWidth = 300, SizeHeight = 300, }; var hlayout = new View { SizeHeight = 310, Layout = new LinearLayout { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, } }; canvas.PaintSurface += Draw; glSurface.PaintSurface += Draw; hlayout.Add(canvas); hlayout.Add(glSurface); viewList.Add(canvas); viewList.Add(glSurface); scrollView.Add(hlayout); } timer = new Timer(10); timer.Tick += (s, e) => { startx += 10; starty += 1; if (startx + 100 >= 300) { startx = 0; } if (starty + 100 >= 300) { starty = 0; } foreach (var view in viewList) { view.Invalidate(); } return(true); }; scrollView.RemovedFromWindow += (s, e) => { timer.Stop(); }; timer.Start(); return(scrollView); }