public virtual void OnFailedTry()
        {
            if (_icon != null)
            {
                var animation = new TranslateAnimation(-10, 10, 0, 0)
                {
                    Duration     = 1000,
                    Interpolator = new CycleInterpolator(5)
                };

                animation.SetAnimationListener(this);
                _icon.StartAnimation(animation);
            }
        }
Ejemplo n.º 2
0
        public void ViewInit()
        {
            RelativeLayout relativeLayout = FindViewById <RelativeLayout>(Resource.Id.test);

            TriangleView triangleView = new TriangleView(this);
            {
                triangleView.Id = Resource.Id.triangle_view;
                triangleView.LayoutParameters = new ViewGroup.LayoutParams(Util.DpToPx(100), Util.DpToPx(100));
                triangleView.Visibility       = ViewStates.Gone;

                relativeLayout.AddView(triangleView);
            }

            View rectangleView = LayoutInflater.Inflate(Resource.Layout.rectangle_view_layout, null);
            {
                rectangleView.Id = Resource.Id.rectangle_view;
                rectangleView.LayoutParameters = new RelativeLayout.LayoutParams(Util.DpToPx(100), Util.DpToPx(100));
                rectangleView.Visibility       = ViewStates.Gone;

                relativeLayout.AddView(rectangleView);
            }

            View sideView = LayoutInflater.Inflate(Resource.Layout.side_view_layout, null);
            {
                sideView.Id = Resource.Id.side_view;
                sideView.LayoutParameters = new ViewGroup.LayoutParams(Util.DpToPx(430), ViewGroup.LayoutParams.MatchParent);
                sideView.Visibility       = ViewStates.Gone;

                relativeLayout.AddView(sideView);
            }

            EditText ProjectNameEditText = FindViewById <EditText>(Resource.Id.ProjectNameEditText);

            RelativeLayout PlusButton = FindViewById <RelativeLayout>(Resource.Id.PlusButton);
            {
                PlusButton.Click += (object sender, EventArgs e) =>
                {
                    Console.WriteLine("Plus Button Click");

                    if (rectangleView.Width == Util.DpToPx(100))
                    {
                        ProjectNameEditText.Text = "";

                        RotateAnimation PlusButtonOpenAnimation = new RotateAnimation(0, 90, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f)
                        {
                            Duration = 250
                        };

                        PlusButtonOpenAnimation.SetAnimationListener(new CustomAnimationListener(this, "PlusButtonOpen"));

                        PlusButton.StartAnimation(PlusButtonOpenAnimation);


                        rectangleView.StartAnimation(new ResizeAnimation(rectangleView, new ViewGroup.LayoutParams(Util.DpToPx(400), rectangleView.Height))
                        {
                            Duration = 1000
                        });
                    }
                    else
                    {
                        RotateAnimation PlusButtonCloseAnimation = new RotateAnimation(0, -90, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f)
                        {
                            Duration = 250
                        };

                        PlusButtonCloseAnimation.SetAnimationListener(new CustomAnimationListener(this, "PlusButtonClose"));

                        PlusButton.StartAnimation(PlusButtonCloseAnimation);


                        rectangleView.StartAnimation(new ResizeAnimation(rectangleView, new ViewGroup.LayoutParams(Util.DpToPx(100), rectangleView.Height))
                        {
                            Duration = 1000
                        });
                    }
                };
            }

            RelativeLayout AddButton = FindViewById <RelativeLayout>(Resource.Id.AddButton);
            {
                AddButton.Click += (object sender, EventArgs e) =>
                {
                    Console.WriteLine("Add Button Click");

                    Console.WriteLine("{0}, {1}", CenterLocation.Latitude, CenterLocation.Longitude);

                    ListActivity.Doc = new Document()
                    {
                        Latitude  = CenterLocation.Latitude,
                        Longitude = CenterLocation.Longitude,
                        Title     = ProjectNameEditText.Text
                    };

                    StartActivity(typeof(ListActivity));

                    rectangleView.LayoutParameters = new RelativeLayout.LayoutParams(Util.DpToPx(100), Util.DpToPx(100));

                    ImageView PlusImageView = rectangleView.FindViewById <ImageView>(Resource.Id.PlusImageView);
                    {
                        PlusImageView.SetImageResource(Resource.Drawable.plus);
                    }
                };
            }

            ImageButton imageButton1 = FindViewById <ImageButton>(Resource.Id.imageButton1);
            {
                imageButton1.Click += (object sender, EventArgs e) =>
                {
                    if (!SideViewIsOpen)
                    {
                        TranslateAnimation SideViewSlideIn = new TranslateAnimation(0, -Util.DpToPx(430), 0, 0)
                        {
                            Duration    = 1000,
                            FillEnabled = true
                        };
                        SideViewSlideIn.SetAnimationListener(new CustomAnimationListener(this, "SideViewSlideIn"));
                        sideView.StartAnimation(SideViewSlideIn);

                        SideViewIsOpen = true;
                    }
                    else
                    {
                        TranslateAnimation SideViewSlideOut = new TranslateAnimation(0, Util.DpToPx(430), 0, 0)
                        {
                            Duration    = 1000,
                            FillEnabled = true
                        };
                        SideViewSlideOut.SetAnimationListener(new CustomAnimationListener(this, "SideViewSlideOut"));
                        sideView.StartAnimation(SideViewSlideOut);

                        SideViewIsOpen = false;
                    }

                    imageButton1.SetImageResource(SideViewIsOpen ? Resource.Drawable.icon_note_s : Resource.Drawable.icon_note);
                };
            }

            ImageButton imageButton5 = FindViewById <ImageButton>(Resource.Id.imageButton5);
            {
                imageButton5.Click += (object sender, EventArgs e) =>
                {
                    if (!CanvasEnable)
                    {
                        MapCanvasView mapCanvasView = new MapCanvasView(this, _map);

                        mapCanvasView.Id = Resource.Id.map_canvas_view;
                        mapCanvasView.LayoutParameters = new ViewGroup.LayoutParams(
                            ViewGroup.LayoutParams.MatchParent,
                            ViewGroup.LayoutParams.MatchParent
                            );

                        relativeLayout.AddView(mapCanvasView);

                        relativeLayout.FindViewById(Resource.Id.item_bar).BringToFront();
                        relativeLayout.FindViewById(Resource.Id.triangle_view).BringToFront();
                        relativeLayout.FindViewById(Resource.Id.rectangle_view).BringToFront();
                        relativeLayout.FindViewById(Resource.Id.side_view).BringToFront();

                        relativeLayout.RequestLayout();

                        CanvasEnable = true;
                    }
                    else
                    {
                        relativeLayout.RemoveView(FindViewById(Resource.Id.map_canvas_view));

                        CanvasEnable = false;
                    }

                    imageButton5.SetImageResource(CanvasEnable ? Resource.Drawable.icon_pencil_s : Resource.Drawable.icon_pencil);
                };
            }
        }