Exemplo n.º 1
0
        private static void DrawLabel(Graphics gfx, string str, Vector pos)
        {
            // Computes bounding rectangle for label background
            var rect = TextLayout.Measure(str, Font.Default, 32);

            rect.Offset(pos);
            rect.Inflate(8);

            // Draw label background
            gfx.Color = FlatColors.MidnightBlue;
            gfx.DrawRect(rect);

            // Draw text
            gfx.Color = FlatColors.Emerald;
            gfx.DrawText(str, pos, Font.Default, 32);
        }
Exemplo n.º 2
0
        public void SetLabel(string iconStr, string iconFont, float iconSize, string labelStr, string labelFont, float labelSize, uint textColor, uint bgColor, EventHandler onClick)
        {
            // don't allow changing WHILE we're animating
            if (Animating == false)
            {
                // setup the banner
                BannerLayout.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(bgColor));

                // setup the icon
                Icon.Text = iconStr;
                Icon.SetTypeface(FontManager.Instance.GetFont(iconFont), global::Android.Graphics.TypefaceStyle.Normal);
                Icon.SetTextSize(ComplexUnitType.Dip, iconSize);
                Icon.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(textColor));

                // setup the label
                Label.Text = labelStr;
                Label.SetTypeface(FontManager.Instance.GetFont(labelFont), global::Android.Graphics.TypefaceStyle.Normal);
                Label.SetTextSize(ComplexUnitType.Dip, labelSize);
                Label.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(textColor));

                if (OnClickAction != null)
                {
                    OverlayButton.Click -= OnClickAction;
                }

                OverlayButton.Click += onClick;
                OnClickAction        = onClick;

                // resize the button to fit over the full banner
                int widthMeasureSpec  = View.MeasureSpec.MakeMeasureSpec(TextLayout.LayoutParameters.Width, MeasureSpecMode.Unspecified);
                int heightMeasureSpec = View.MeasureSpec.MakeMeasureSpec(TextLayout.LayoutParameters.Height, MeasureSpecMode.Unspecified);
                TextLayout.Measure(widthMeasureSpec, heightMeasureSpec);

                OverlayButton.LayoutParameters.Width  = TextLayout.MeasuredWidth;
                OverlayButton.LayoutParameters.Height = TextLayout.MeasuredHeight;

                BannerLayout.LayoutParameters.Width  = TextLayout.MeasuredWidth;
                BannerLayout.LayoutParameters.Height = TextLayout.MeasuredHeight;

                // default it to hidden and offscreen
                Visibility = ViewStates.Gone;
                SetX(ScreenWidth);
            }
        }
Exemplo n.º 3
0
            void GotoNextBenchmark()
            {
                // Move to next index (if possible)
                if (benchmarkIndex < benchmarks.Length)
                {
                    benchmarkIndex++;
                }

                // If still a valid index, initialize stage
                if (benchmarkIndex < benchmarks.Length)
                {
                    var benchmark = benchmarks[benchmarkIndex];
                    benchmark.Initialize(in bounds);
                }
                else
                {
                    var cpu = Application.CpuInfo;
                    var gpu = Application.GpuInfo;

                    // Results
                    var results = new BenchmarkResults(gpu, cpu);
                    foreach (var benchmark in benchmarks)
                    {
                        results.Scores[benchmark.Name.ToIdentifier()] = benchmark.Score;
                    }

                    // Write
                    using var fs = new FileStream(results.GenerateFilename(), FileMode.Create);
                    using var wr = new StreamWriter(fs);
                    wr.Write(BenchmarkResults.ToJson(results));

                    // Leave fullscreen
                    window.Graphics.Performance.OverlayMode = PerformanceOverlayMode.Disabled;
                    window.EndFullscreen();

                    // Size window
                    var rect = TextLayout.Measure(GetResultsText(benchmarks), Font.Default, 32);
                    window.Size = (IntSize)rect.Size + (32, 32);
                }
            }
Exemplo n.º 4
0
            protected internal override void Draw(Graphics ctx, float dt)
            {
                ctx.Clear(BackgroundColor);

                var text     = $"LOADING\n{Progress.Message}";
                var textSize = TextLayout.Measure(text, (400, ctx.Surface.Height), Font.Default, 32).Size;

                textSize.Width = Calc.Max(400, textSize.Width);

                // Compute centered text rectangle
                var x        = (ctx.Surface.Bounds.Width - textSize.Width) / 2F;
                var y        = (ctx.Surface.Bounds.Height - textSize.Height) / 2F;
                var textRect = new Rectangle((x, y), textSize);

                textRect = Rectangle.Inflate(textRect, 8);

                var progRect = textRect;

                progRect.Y     += 4 + textRect.Height;
                progRect.Height = 4;

                // Draw text container
                ctx.Color = Color.White;
                ctx.DrawRect(textRect);

                // Draw text
                ctx.Color = Color.DarkGray;
                ctx.DrawText(text, Rectangle.Inflate(textRect, -8), Font.Default, 32, TextAlign.Center);

                // Draw percent bar container
                ctx.Color = Color.Gray;
                ctx.DrawRect(progRect);

                // Draw percent bar
                ctx.Color      = Color.Pink;
                progRect.Width = Progress.Percent * progRect.Width;
                ctx.DrawRect(progRect);
            }