Пример #1
0
        private void SetupDrawer()
        {
            _canvas = FindViewById <SKCanvasView>(Resource.Id.canvas);
            _canvas.PaintSurface += OnPaintSample;
            _canvas.Touch        += OnTouch;
            //// deferred update until can get view bounds
            _drawer = new RealmDraw(_canvas.CanvasSize.Width, _canvas.CanvasSize.Height);
            _drawer.CredentialsEditor = () =>
            {
                EditCredentials();
            };

            _drawer.RefreshOnRealmUpdate = () =>
            {
                System.Diagnostics.Debug.WriteLine("Refresh callback triggered by Realm");
                _canvas.Invalidate();
            };

            _drawer.ReportError = (bool isError, string msg) =>
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle(isError ? "Realm Error" : "Warning");
                alert.SetMessage(msg);
                alert.SetPositiveButton("OK", (senderAlert, args) =>
                {
                });

                RunOnUiThread(() =>
                {
                    alert.Show();
                });
            };
        }
Пример #2
0
        private void SetupDrawer()
        {
            // scale bounds to match the pixel dimensions of the SkiaSurface
            _drawer = new RealmDraw(
                _devicePixelMul * (float)View.Bounds.Width,
                _devicePixelMul * (float)View.Bounds.Height);
            _prevBounds = View.Bounds;
            _drawer.CredentialsEditor = () =>
            {
                InvokeOnMainThread(EditCredentials);
            };

            _drawer.RefreshOnRealmUpdate = () =>
            {
                View?.SetNeedsDisplay();  // just refresh on notification, OnPaintSample below triggers DrawTouches
            };

            _drawer.ReportError = (bool isError, string msg) =>
            {
                var alertController = UIAlertController.Create(isError?"Realm Error":"Warning", msg, UIAlertControllerStyle.Alert);
                alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alertController, true, null);
            };
        }