Beispiel #1
0
        private async Task InitializeProcess()
        {
            await Task.Delay(100);

            try
            {
                if (enemy.HasVoice)
                {
                    InitializeVoiceList();
                }

                var toolbarColor = enemy.Affiliation switch
                {
                    "SANGVIS FERRI" => Android.Graphics.Color.ParseColor("#441111"),
                    "Mind Map System" => Android.Graphics.Color.ParseColor("#262626"),
                    "KCCO" => Android.Graphics.Color.ParseColor("#47661E"),
                    "Paradeus" => Android.Graphics.Color.ParseColor("#00008B"),
                    "E.L.I.D." => Android.Graphics.Color.ParseColor("#441111"),
                    _ => Android.Graphics.Color.ParseColor("#262626")
                };
                toolbar.SetBackgroundColor(toolbarColor);

                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    Window.SetStatusBarColor(toolbarColor);
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                Toast.MakeText(this, "Fail Initialize Process", ToastLength.Short).Show();
            }
        }
        private async Task InitializeProcess()
        {
            await Task.Delay(100);

            try
            {
                var toolbarColor = equip.Grade switch
                {
                    2 => Android.Graphics.Color.SlateGray,
                    3 => Android.Graphics.Color.ParseColor("#55CCEE"),
                    4 => Android.Graphics.Color.ParseColor("#AACC22"),
                    5 => Android.Graphics.Color.ParseColor("#FFBB22"),
                    _ => Android.Graphics.Color.ParseColor("#C040B0"),
                };
                toolbar.SetBackgroundColor(toolbarColor);

                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    Window.SetStatusBarColor(toolbarColor);
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                Toast.MakeText(this, "Fail Initialize Process", ToastLength.Short).Show();
            }
        }
        private async Task InitializeProcess()
        {
            await Task.Delay(100);

            try
            {
                if (fairy.DicNumber >= 1000)
                {
                    Android.Graphics.Color toolbarColor = Android.Graphics.Color.ParseColor("#C040B0");

                    toolbar.SetBackgroundColor(toolbarColor);

                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        Window.SetStatusBarColor(toolbarColor);
                    }
                }
            }
            catch (Exception ex)
            {
                ETC.LogError(ex, this);
                Toast.MakeText(this, "Fail Initialize Process", ToastLength.Short).Show();
            }
        }
Beispiel #4
0
        void UpdateToolbar()
        {
            if (_disposed)
            {
                return;
            }

            Context  context             = Context;
            AToolbar bar                 = _toolbar;
            ActionBarDrawerToggle toggle = _drawerToggle;

            if (bar == null)
            {
                return;
            }

            bool isNavigated = NavigationPageController.StackDepth > 1;

            bar.NavigationIcon = null;
            Page currentPage = Element.CurrentPage;

            if (isNavigated)
            {
                if (NavigationPage.GetHasBackButton(currentPage) && !Context.IsDesignerContext())
                {
                    if (toggle != null)
                    {
                        toggle.DrawerIndicatorEnabled = false;
                        toggle.SyncState();
                    }

                    var activity = (AppCompatActivity)context.GetActivity();
                    var icon     = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext);
                    icon.Progress      = 1;
                    bar.NavigationIcon = icon;

                    var prevPage = Element.Peek(1);
                    _defaultNavigationContentDescription = bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
                }
                else if (toggle != null && _flyoutPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _flyoutPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }
            else
            {
                if (toggle != null && _flyoutPage != null)
                {
                    toggle.DrawerIndicatorEnabled = _flyoutPage.ShouldShowToolbarButton();
                    toggle.SyncState();
                }
            }

            Color tintColor = Element.BarBackgroundColor;

            if (Forms.IsLollipopOrNewer)
            {
                if (tintColor.IsDefault)
                {
                    bar.BackgroundTintMode = null;
                }
                else
                {
                    bar.BackgroundTintMode = PorterDuff.Mode.Src;
                    bar.BackgroundTintList = ColorStateList.ValueOf(tintColor.ToAndroid());
                }
            }
            else
            {
                if (tintColor.IsDefault && _backgroundDrawable != null)
                {
                    bar.SetBackground(_backgroundDrawable);
                }
                else if (!tintColor.IsDefault)
                {
                    if (_backgroundDrawable == null)
                    {
                        _backgroundDrawable = bar.Background;
                    }
                    bar.SetBackgroundColor(tintColor.ToAndroid());
                }
            }

            Brush barBackground = Element.BarBackground;

            bar.UpdateBackground(barBackground);

            Color textColor = Element.BarTextColor;

            if (!textColor.IsDefault)
            {
                bar.SetTitleTextColor(textColor.ToAndroid().ToArgb());
            }

            Color navIconColor = NavigationPage.GetIconColor(Current);

            if (!navIconColor.IsDefault && bar.NavigationIcon != null)
            {
                DrawableExtensions.SetColorFilter(bar.NavigationIcon, navIconColor, FilterMode.SrcAtop);
            }

            bar.Title = currentPage?.Title ?? string.Empty;

            if (_toolbar.NavigationIcon != null && !textColor.IsDefault)
            {
                var icon = _toolbar.NavigationIcon as DrawerArrowDrawable;
                if (icon != null)
                {
                    icon.Color = textColor.ToAndroid().ToArgb();
                }
            }

            UpdateTitleIcon();

            UpdateTitleView();
        }