Beispiel #1
0
        public static Task ShowChartDialog(Chart chart, string title = "", string close = "关闭")
        {
            var     dbtask  = new DismissByTask();
            Context context = MainActivity.ActivityContext;
            var     builder = new AlertDialog.Builder(context);

            chart.LabelTextSize = MainActivity.Dip2Px(12);
            LayoutInflater layoutInflater = LayoutInflater.From(context);
            var            chartLayout    = layoutInflater.Inflate(HSResource.Layout.SkiaChart, null);

            builder.SetView(chartLayout);

            var canvasView = chartLayout.FindViewById <SKCanvasView>(HSResource.Id.skia_chart_canvas);

            canvasView.PaintSurface += (sender, args) =>
            {
                chart.Draw(args.Surface.Canvas, args.Info.Width, args.Info.Height);
            };

            builder.SetTitle(title);
            builder.SetPositiveButton(close, (sender, args) => { });
            builder.SetOnDismissListener(dbtask);
            var dialog = builder.Create();

            dialog.Show();

            IWindowManager            manager = MainActivity.Instance.WindowManager;
            Display                   d       = manager.DefaultDisplay;
            Window                    window  = dialog.Window;
            WindowManagerLayoutParams param   = window.Attributes;

            param.Height             = MainActivity.Dip2Px(340);
            param.Gravity            = GravityFlags.CenterHorizontal;
            dialog.Window.Attributes = param;

            return(dbtask.EndTask);
        }