Exemple #1
0
    public ButtonEx(Context context)
        : base(context)
    {
        TransitionDrawable buttonTransition =
            (TransitionDrawable)Resources.GetDrawable(Resource.Drawable.button_transition);

        LinearLayout.LayoutParams layoutParams =
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, Android.DpToPx(45, context));
        this.Background       = buttonTransition;
        this.LayoutParameters = layoutParams;
        this.Orientation      = Orientation.Horizontal;
        imageParams           =
            new LinearLayout.LayoutParams(
                Android.DpToPx(45, context),
                LinearLayout.LayoutParams.MatchParent);
        labelParams =
            new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.MatchParent);
        imageView = new ImageView(context)
        {
            LayoutParameters = imageParams,
        };
        imageView.SetScaleType(ImageView.ScaleType.CenterInside);
        this.AddView(imageView);
        textView = new TextView(context)
        {
            LayoutParameters = labelParams,
            Gravity          = GravityFlags.CenterVertical,
        };
        this.AddView(textView);
    }
Exemple #2
0
        void updateBackground()
        {
            var location = WuClient.Shared.Selected;

            var random = location == null || Settings.RandomBackgrounds;

            var gradients = location.GetTimeOfDayGradient(random);

            using (var gd = new GradientDrawable(GradientDrawable.Orientation.TopBottom, gradients.Item1.ToArray())) {
                gd.SetCornerRadius(0f);

                if (viewPager.Background == null)
                {
                    viewPager.Background = gd;
                }
                else
                {
                    var backgrounds = new Drawable [2];

                    backgrounds [0] = viewPager.Background;
                    backgrounds [1] = gd;

                    var crossfader = new TransitionDrawable(backgrounds);

                    viewPager.Background = crossfader;

                    crossfader.StartTransition(1000);
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.HangmanGame1PlayerLayout);

            _lettersToShowOnUI = FindViewById <TextView>(Resource.Id.guessedLetters);

            // get the image view
            ImageView button = FindViewById <ImageView>(Resource.Id.imageView1);

            _drawable = (TransitionDrawable)button.Drawable;

            _numGuessesTextView = FindViewById <TextView>(Resource.Id.textNumGuessesLeft);

            LinearLayout onePlayerBackground = FindViewById <LinearLayout>(Resource.Id.llPlayer1Game);

            onePlayerBackground.Click += ReshowKeyboardIfHidden;
            onePlayerBackground.SetOnKeyListener(this);

            if (savedInstanceState == null)
            {
                StartNewGame();
            }

            // Create an ActionBar to use to switch languages, get a new word, etc
            ActionBarOverride newActionBar = new ActionBarOverride();
            var a = ActionBar;

            newActionBar.CreateActionBarWithTitleAndMenuButton(ref a, this, "Hangman");

            _menuButton        = ActionBar.CustomView.FindViewById <ImageView>(Resource.Id.toolbar_MenuButton);
            _menuButton.Click += MenuButton_Click;
        }
Exemple #4
0
 public void BackgroundGradientThread(TransitionDrawable transition)
 {
     RunOnUiThread(() =>
     {
         _dashboardLayout.Background = transition;
         transition.StartTransition(NumberConstants.DashboardGradientTransition.DashboardGradientTransitionLengthInMilliseconds);
     });
 }
Exemple #5
0
        private void ChangeColor(Color newColor)
        {
            _tabs.IndicatorColor = Color.White;
            _tabs.TabColor       = newColor;
            _tabs.TextColor      = Color.White;

            // change ActionBar color just if an ActionBar is available
            if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb)
            {
                Drawable      colorDrawable  = new ColorDrawable(newColor);
                Drawable      bottomDrawable = Resources.GetDrawable(Resource.Drawable.actionbar_bottom);
                LayerDrawable ld             = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

                if (_oldBackground == null)
                {
                    if ((int)Build.VERSION.SdkInt < 17)
                    {
                        ld.Callback = _drawableCallback;
                    }
                    else
                    {
                        ActionBar.SetBackgroundDrawable(ld);
                    }
                }
                else
                {
                    TransitionDrawable td = new TransitionDrawable(new Drawable[] { _oldBackground, ld });

                    // workaround for broken ActionBarContainer drawable handling on
                    // pre-API 17 builds
                    // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4
                    if ((int)Build.VERSION.SdkInt < 17)
                    {
                        td.Callback = _drawableCallback;
                    }
                    else
                    {
                        ActionBar.SetBackgroundDrawable(td);
                    }

                    td.StartTransition(200);
                }

                _oldBackground = ld;

                // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
                ActionBar.SetDisplayShowTitleEnabled(false);
                ActionBar.SetDisplayShowTitleEnabled(true);
            }

            _currentColor = newColor;
        }
Exemple #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Activity2_layout);

            // Create your application here
            btnAct2_startTransition = FindViewById <Button>(Resource.Id.btnAct2_startTransition);

            btnAct2_startTransition.Click += delegate
            {
                TransitionDrawable drawable = (TransitionDrawable)FindViewById <ImageView>(Resource.Id.imageView_act_2).Drawable;
                drawable.StartTransition(1500);
            };
        }
Exemple #7
0
 private void Initialize()
 {
     _viewAnimated         = FindViewById <View>(Resource.Id.view_splash_screen_animated_object);
     _imageIcon            = FindViewById <ImageView>(Resource.Id.image_view_icon_splash_screen_animated);
     _mainLayout           = FindViewById <RelativeLayout>(Resource.Id.relative_layout_splash_screen_animated_main);
     _linesContainerLayout = FindViewById <RelativeLayout>(Resource.Id.relative_layout_lines_container);
     _transition           = (TransitionDrawable)_viewAnimated.Background;
     _transition.StartTransition(2000);
     _viewAnimated.Animation = AnimationUtils.LoadAnimation(this, Resource.Animation.SplashScreenAnimation_view);
     _viewAnimated.Animation.AnimationEnd += TerminateAnimationBackgound;
     _imageIcon.Animation            = AnimationUtils.LoadAnimation(this, Resource.Animation.SplashScreenAnimation_icon);
     _linesContainerLayout.Animation = AnimationUtils.LoadAnimation(this, Resource.Animation.SplashScreenAnimation_lines);
     _linesContainerLayout.Animation.AnimationEnd += TerminateAnimationIcon;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            Button buttonTransition = FindViewById <Button>(Resource.Id.buttonTransition);

            buttonTransition.Click += delegate
            {
                TransitionDrawable drawable = (TransitionDrawable)FindViewById <ImageView>(Resource.Id.imageViewPCTransition).Drawable;
                drawable.StartTransition(3000);
            };
        }
Exemple #9
0
        private void ApplyImage(Bitmap bitmap)
        {
            BitmapDrawable bmp            = new BitmapDrawable(bitmap);
            Drawable       targetDrawable = null;

            if (imgView.Drawable != null)
            {
                TransitionDrawable trans = new TransitionDrawable(new Drawable[] { imgView.Drawable, bmp });
                trans.StartTransition(300);
                targetDrawable = trans;
            }
            else
            {
                targetDrawable = bmp;
            }
            imgView.SetImageDrawable(targetDrawable);
        }
        public void onEvent(ThemeSelectedEvent evt)
        {
            mSelectedTheme = evt.theme;
            mScreenController.openScreen(ScreenController.Screen.DIFFICULTY);

            Bitmap bitmap          = GameUtility.ScaleDown(Resource.Drawable.background, GameUtility.ScreenWidth(), GameUtility.ScreenHeight());
            Bitmap backgroundImage = GameThemes.getBackgroundImage(mSelectedTheme);

            backgroundImage = GameUtility.Crop(backgroundImage, GameUtility.ScreenHeight(), GameUtility.ScreenWidth());
            Drawable[] backgrounds = new Drawable[2];
            backgrounds[0] = new BitmapDrawable(Application.Context.Resources, bitmap);
            backgrounds[1] = new BitmapDrawable(Application.Context.Resources, backgroundImage);

            TransitionDrawable crossfader = new TransitionDrawable(backgrounds);

            mBackgroundImage.SetImageDrawable(crossfader);
            crossfader.StartTransition(2000);
        }
Exemple #11
0
        private void ChangeColor(Color newColor)
        {
            tabs.SetBackgroundColor(newColor);

            // change ActionBar color just if an ActionBar is available
            Drawable      colorDrawable  = new ColorDrawable(newColor);
            Drawable      bottomDrawable = new ColorDrawable(Resources.GetColor(Android.Resource.Color.Transparent));
            LayerDrawable ld             = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable });

            if (oldBackground == null)
            {
                SupportActionBar.SetBackgroundDrawable(ld);
            }
            else
            {
                TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld });
                SupportActionBar.SetBackgroundDrawable(td);
                td.StartTransition(200);
            }

            oldBackground = ld;
            currentColor  = newColor;
        }
Exemple #12
0
        void updateBackground()
        {
            var location = WuClient.Shared.Selected;

            var random = location == null || Settings.RandomBackgrounds;

            var gradients = location.GetTimeOfDayGradient(random);

            using (var gd = new GradientDrawable(GradientDrawable.Orientation.TopBottom, gradients.Item1.ToArray()))
            {
                gd.SetCornerRadius(0f);

                if (viewPager.Background == null)
                {
                    viewPager.Background = gd;

                    Window.SetStatusBarColor(gradients.Item1 [0]);
                    Window.SetNavigationBarColor(gradients.Item1 [1]);
                }
                else
                {
                    var backgrounds = new Drawable [2];

                    backgrounds [0] = viewPager.Background;
                    backgrounds [1] = gd;

                    var crossfader = new TransitionDrawable(backgrounds);

                    viewPager.Background = crossfader;

                    crossfader.StartTransition(1000);

                    var statusBarAnimator = ValueAnimator.OfArgb(Window.StatusBarColor, gradients.Item1 [0]);

                    statusBarAnimator.SetDuration(1000);
                    statusBarAnimator.SetInterpolator(new AccelerateDecelerateInterpolator());

                    statusBarAnimator.Update += (sender, e) =>
                    {
                        var val = e.Animation.AnimatedValue as Java.Lang.Integer;

                        var color = new Color((int)val);

                        Window.SetStatusBarColor(color);
                    };

                    var naviationBarAnimator = ValueAnimator.OfArgb(Window.NavigationBarColor, gradients.Item1 [1]);

                    naviationBarAnimator.SetDuration(1000);
                    naviationBarAnimator.SetInterpolator(new AccelerateDecelerateInterpolator());

                    naviationBarAnimator.Update += (sender, e) =>
                    {
                        var val = e.Animation.AnimatedValue as Java.Lang.Integer;

                        var color = new Color((int)val);

                        Window.SetNavigationBarColor(color);
                    };

                    statusBarAnimator.Start();
                    naviationBarAnimator.Start();
                }
            }
        }
        public override void Run()
        {
            if (!_isPaused)
            {
                int first;
                int second;

                switch (_gradient)
                {
                case 0:
                    first  = Resource.Drawable.DashboardGradient1;
                    second = Resource.Drawable.DashboardGradient2;
                    break;

                case 1:
                    first  = Resource.Drawable.DashboardGradient2;
                    second = Resource.Drawable.DashboardGradient3;
                    break;

                case 2:
                    first  = Resource.Drawable.DashboardGradient3;
                    second = Resource.Drawable.DashboardGradient4;
                    break;

                case 3:
                    first  = Resource.Drawable.DashboardGradient4;
                    second = Resource.Drawable.DashboardGradient5;
                    break;

                case 4:
                    first  = Resource.Drawable.DashboardGradient5;
                    second = Resource.Drawable.DashboardGradient6;
                    break;

                case 5:
                    first  = Resource.Drawable.DashboardGradient6;
                    second = Resource.Drawable.DashboardGradient7;
                    break;

                case 6:
                    first  = Resource.Drawable.DashboardGradient7;
                    second = Resource.Drawable.DashboardGradient1;
                    break;

                default:
                    first  = Resource.Drawable.DashboardGradient1;
                    second = Resource.Drawable.DashboardGradient2;
                    break;
                }

                if (_adminDashboard != null)
                {
                    var transition = new TransitionDrawable(new Drawable[]
                    {
                        ResourcesCompat.GetDrawable(_adminDashboard.ApplicationContext.Resources, first, null),
                        ResourcesCompat.GetDrawable(_adminDashboard.ApplicationContext.Resources, second, null)
                    });
                    _adminDashboard.BackgroundGradientThread(transition);
                }

                if (_nonAdminDashBoard != null)
                {
                    var transition = new TransitionDrawable(new Drawable[]
                    {
                        ResourcesCompat.GetDrawable(_nonAdminDashBoard.ApplicationContext.Resources, first, null),
                        ResourcesCompat.GetDrawable(_nonAdminDashBoard.ApplicationContext.Resources, second, null)
                    });
                    _nonAdminDashBoard.BackgroundGradientThread(transition);
                }

                if (_gradient == NumberConstants.DashboardGradientTransition.DashboardGradientCount - 1)
                {
                    _gradient = 0;
                }
                else
                {
                    _gradient++;
                }
            }
        }