Пример #1
0
        public override void Create()
        {
            Window window = LayoutingExample.GetWindow();

            view      = new View();
            view.Name = "ChangingLayout";
            view.WidthSpecification  = LayoutParamPolicies.WrapContent;
            view.HeightSpecification = LayoutParamPolicies.WrapContent;

            // Position layout within Window.
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;

            // Start with a GridLayout
            SetGridLayout(view);

            // Add child image-views to the created view
            foreach (String image in TestImages.s_images)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(100, 100));
                view.Add(imageView);
                view.MinimumSize = new Size2D(200, 200);
            }

            LayoutingExample.GetWindow().Add(view);

            // Setup button to switch layouts.
            PushButton changeLayoutButton = new PushButton();

            changeLayoutButton.Name = "changeLayout-button";
            LayoutingExample.SetUnselectedIcon(changeLayoutButton, "./res/images/iconLinear.png");
            LayoutingExample.SetSelectedIcon(changeLayoutButton, "./res/images/iconLinearSelected.png");
            changeLayoutButton.ParentOrigin           = new Vector3(0.33f, 1.0f, 0.5f);
            changeLayoutButton.PivotPoint             = PivotPoint.BottomCenter;
            changeLayoutButton.PositionUsesPivotPoint = true;
            changeLayoutButton.MinimumSize            = new Vector2(75, 75);
            changeLayoutButton.Clicked += (sender, e) =>
            {
                if (gridLayout)
                {
                    SetLinearLayout(view);
                    LayoutingExample.SetUnselectedIcon(changeLayoutButton, "./res/images/iconGrid.png");
                    LayoutingExample.SetSelectedIcon(changeLayoutButton, "./res/images/iconGridSelected.png");
                }
                else
                {
                    SetGridLayout(view);
                    LayoutingExample.SetUnselectedIcon(changeLayoutButton, "./res/images/iconLinear.png");
                    LayoutingExample.SetSelectedIcon(changeLayoutButton, "./res/images/iconLinearSelected.png");
                }

                return(true);
            };

            LayoutingExample.GetWindow().Add(changeLayoutButton);
            buttons.Add(changeLayoutButton);
        }
Пример #2
0
        public override void Create()
        {
            _view                        = new View();
            _view.Name                   = "PaddingExample";
            _view.Background             = CreateGradientVisual().OutputVisualMap;
            _view.ParentOrigin           = ParentOrigin.Center;
            _view.PivotPoint             = PivotPoint.Center;
            _view.PositionUsesPivotPoint = true;
            _view.WidthSpecification     = LayoutParamPolicies.WrapContent;
            _view.HeightSpecification    = LayoutParamPolicies.WrapContent;

            _view.Layout = new LinearLayout();

            // Add child image-views to the created _view
            foreach (String image in TestImages.s_images)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(100, 100));
                imageView.BackgroundColor = Color.Black;
                imageView.TouchEvent     += (sender, e) =>
                {
                    if (sender is ImageView && e.Touch.GetState(0) == PointStateType.Down)
                    {
                        Console.WriteLine("ImageViewTouched\n");
                        ImageView touchedImageView = (ImageView)sender;
                        if (touchedImageView.Padding.EqualTo(new Extents(0, 0, 0, 0)))
                        {
                            Console.WriteLine("Adding Padding\n");
                            touchedImageView.Padding = new Extents(10, 10, 10, 10);
                        }
                        else
                        {
                            Console.WriteLine("Padding removed\n");
                            touchedImageView.Padding = new Extents(0, 0, 0, 0);
                        }
                    }
                    return(true);
                };

                _view.Add(imageView);
            }

            Window window = LayoutingExample.GetWindow();

            window.Add(_view);

            _nextFeatureButton = new Button();
            _nextFeatureButton.ParentOrigin           = ParentOrigin.BottomCenter;
            _nextFeatureButton.PivotPoint             = PivotPoint.BottomCenter;
            _nextFeatureButton.PositionUsesPivotPoint = true;
            _nextFeatureButton.Text     = featureArray[_featureIndex].featureName;
            _nextFeatureButton.Clicked += (sender, e) =>
            {
                ExampleFeature();
                return;
            };

            window.Add(_nextFeatureButton);
        }
Пример #3
0
        public override void Create()
        {
            Window window = Window.Instance;

            // Absolute Layout is created automatically in Window.
            View view = new View();

            view.Name                   = "demo-absoluteLayout";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.WrapContent;
            view.HeightSpecification    = LayoutParamPolicies.WrapContent;
            view.BackgroundColor        = Color.Blue;

            var layout = new AbsoluteLayout();

            view.Layout = layout;

            // Add child image-views to the created view
            ImageView imageView = LayoutingExample.CreateChildImageView("./res/images/gallery-small-23.jpg", new Size2D(100, 100), new Position2D(0, 0));

            view.Add(imageView);
            imageView = LayoutingExample.CreateChildImageView("./res/images/gallery-small-23.jpg", new Size2D(100, 100), new Position2D(100, 0));
            view.Add(imageView);
            imageView = LayoutingExample.CreateChildImageView("./res/images/gallery-small-23.jpg", new Size2D(100, 100), new Position2D(0, 100));
            view.Add(imageView);
            imageView = LayoutingExample.CreateChildImageView("./res/images/gallery-small-23.jpg", new Size2D(200, 200), new Position2D(100, 100));
            view.Add(imageView);

            this.view = view;

            sizeButton                        = new PushButton();
            sizeButton.Name                   = "absolute-size-change-button";
            sizeButton.ParentOrigin           = ParentOrigin.BottomCenter;
            sizeButton.PivotPoint             = PivotPoint.BottomCenter;
            sizeButton.PositionUsesPivotPoint = true;
            sizeButton.LabelText              = "change size";
            sizeButton.Clicked               += (sender, e) =>
            {
                if (!fullSize)
                {
                    this.view.WidthSpecification  = LayoutParamPolicies.MatchParent;
                    this.view.HeightSpecification = LayoutParamPolicies.MatchParent;
                }
                else
                {
                    this.view.WidthSpecification  = LayoutParamPolicies.WrapContent;
                    this.view.HeightSpecification = LayoutParamPolicies.WrapContent;
                }
                fullSize = !fullSize;
                return(true);
            };

            window.Add(view);
            window.Add(sizeButton);
        }
Пример #4
0
        void AddItemsInteractively()
        {
            if (childItems.Count < MAX_NUMBER_OF_ITEMS)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(TestImages.sample_images[0], new Size2D(100, 100));
                childItems.Add(imageView);
                view.Add(imageView);

                // Add item button shows how many items left to add.
                int    numberOfAdditonalImageViews = MAX_NUMBER_OF_ITEMS - INITIAL_NUMBER_OF_ITEMS;
                int    remainingImageViews         = MAX_NUMBER_OF_ITEMS - (childItems.Count);
                string buttonLabel = "Add item[" + (numberOfAdditonalImageViews - remainingImageViews).ToString() + "/"
                                     + (numberOfAdditonalImageViews).ToString() + "]";

                nextFeatureButton.Text = buttonLabel;
            }
        }
Пример #5
0
        // Create GridLayout Example
        public override void Create()
        {
            // Absolute Layout is created automatically in Window.
            view                        = new View();
            view.Name                   = "GridExample";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.WidthSpecification     = LayoutParamPolicies.WrapContent;
            view.HeightSpecification    = LayoutParamPolicies.WrapContent;
            view.BackgroundColor        = Color.Blue;

            var layout = new GridLayout();

            layout.Columns = INITAL_NUMBER_OF_COLUMNS;
            view.Layout    = layout;

            // Add child image-views to the created view
            childItems = new List <ImageView>();
            for (int i = 0; i < INITIAL_NUMBER_OF_ITEMS; i++)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(TestImages.sample_images[0], new Size2D(100, 100));
                childItems.Add(imageView);
                view.Add(imageView);
            }

            Window window = LayoutingExample.GetWindow();

            nextFeatureButton = new PushButton();
            nextFeatureButton.ParentOrigin           = ParentOrigin.BottomCenter;
            nextFeatureButton.PivotPoint             = PivotPoint.BottomCenter;
            nextFeatureButton.PositionUsesPivotPoint = true;
            nextFeatureButton.LabelText = " Set exact width to Grid ";
            nextFeatureButton.Clicked  += (sender, e) =>
            {
                NextGridFeature();
                return(true);
            };

            window.Add(view);
            window.Add(nextFeatureButton);
        }
Пример #6
0
 // Shows a thumbnail of the expected output
 private void CreateHelpButton()
 {
     helpButton          = new Button();
     helpButton.Text     = "Help";
     helpButton.Clicked += (sender, e) =>
     {
         if (!helpShowing)
         {
             Window window = Window.Instance;
             helpImageView            = LayoutingExample.CreateChildImageView("./res/images/multirootsExampleHelp.png", new Size2D(200, 200));
             helpImageView.Position2D = new Position2D(0, helpButton.Size2D.Height);
             helpShowing = true;
             window.Add(helpImageView);
         }
         else
         {
             Window window = Window.Instance;
             window.Remove(helpImageView);
             helpShowing = false;
         }
     };
 }
Пример #7
0
 // Shows a thumbnail of the expected output
 private void CreateHelpButton()
 {
     helpButton          = new Button();
     helpButton.Text     = "Help";
     helpButton.Name     = "help-button";
     helpButton.Clicked += (sender, e) =>
     {
         Window window = LayoutingExample.GetWindow();
         if (!helpShowing)
         {
             helpImageView            = LayoutingExample.CreateChildImageView("./res/images/nestedLayoutTestHelp3.png", new Size2D(200, 200));
             helpImageView.Position2D = new Position2D(0, helpButton.Size2D.Height);
             helpShowing = true;
             window.Add(helpImageView);
         }
         else
         {
             window.Remove(helpImageView);
             helpShowing = false;
         }
     };
 }
Пример #8
0
 // Shows a thumbnail of the expected output
 private void CreateHelpButton()
 {
     helpButton           = new PushButton();
     helpButton.LabelText = "Help";
     helpButton.Clicked  += (sender, e) =>
     {
         if (!helpShowing)
         {
             Window window = Window.Instance;
             helpImageView            = LayoutingExample.CreateChildImageView("./res/images/child-added-to-view-example.png", new Size2D(200, 200));
             helpImageView.Position2D = new Position2D(0, helpButton.Size2D.Height);
             helpShowing = true;
             window.Add(helpImageView);
         }
         else
         {
             Window window = Window.Instance;
             window.Remove(helpImageView);
             helpShowing = false;
         }
         return(true);
     };
 }
Пример #9
0
        public override void Create()
        {
            Window window = Window.Instance;

            view                        = new View();
            view.Name                   = "FlexExample";
            view.ParentOrigin           = ParentOrigin.TopLeft;
            view.PivotPoint             = PivotPoint.TopLeft;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            int viewHeight = (int)(window.Size.Height * .90);

            view.HeightSpecification = viewHeight;

            view.PositionY = window.Size.Height - viewHeight;

            view.Padding = new Extents(190, 150, 100, 100);
            var layout = new FlexLayout();

            layout.WrapType       = FlexLayout.FlexWrapType.NoWrap;
            layout.ItemsAlignment = FlexLayout.AlignmentType.Center;
            view.Layout           = layout;
            view.LayoutDirection  = ViewLayoutDirectionType.LTR;

            // Add child image-views to the created view

            foreach (String image in TestImages.s_images)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(100, 100));
                view.Add(imageView);
            }

            window.Add(view);

            PushButton directionButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
            LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
            directionButton.ParentOrigin           = new Vector3(0.2f, 1.0f, 0.5f);
            directionButton.PivotPoint             = PivotPoint.BottomCenter;
            directionButton.PositionUsesPivotPoint = true;
            directionButton.MinimumSize            = new Vector2(75, 75);
            directionButton.Clicked += (sender, e) =>
            {
                if (this.view.LayoutDirection == ViewLayoutDirectionType.LTR)
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.RTL;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-play-selected.png");
                }
                else
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.LTR;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
                }
                return(true);
            };

            window.Add(directionButton);
            buttons.Add(directionButton);


            PushButton wrapButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(wrapButton, "./res/images/icon-w.png");
            LayoutingExample.SetSelectedIcon(wrapButton, "./res/images/icon-w-selected.png");
            wrapButton.ParentOrigin           = new Vector3(0.4f, 1.0f, 0.5f);
            wrapButton.PivotPoint             = PivotPoint.BottomCenter;
            wrapButton.PositionUsesPivotPoint = true;
            wrapButton.MinimumSize            = new Vector2(75, 75);
            wrapButton.Clicked += (sender, e) =>
            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;
                if (flexLayout.WrapType == FlexLayout.FlexWrapType.Wrap)
                {
                    view.Padding              = new Extents(0, 0, 0, 0);
                    flexLayout.WrapType       = FlexLayout.FlexWrapType.NoWrap;
                    flexLayout.Alignment      = FlexLayout.AlignmentType.Center;
                    flexLayout.ItemsAlignment = FlexLayout.AlignmentType.Center;
                }
                else
                {
                    view.Padding              = new Extents(25, 25, 75, 75);
                    flexLayout.WrapType       = FlexLayout.FlexWrapType.Wrap;
                    flexLayout.Alignment      = FlexLayout.AlignmentType.FlexStart;
                    flexLayout.ItemsAlignment = FlexLayout.AlignmentType.FlexStart;
                }
                return(true);
            };

            window.Add(wrapButton);
            buttons.Add(wrapButton);

            PushButton justifyButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(justifyButton, "./res/images/icon-item-view-layout-grid.png");
            LayoutingExample.SetSelectedIcon(justifyButton, "./res/images/icon-item-view-layout-grid-selected.png");
            justifyButton.ParentOrigin           = new Vector3(0.6f, 1.0f, 0.5f);
            justifyButton.PivotPoint             = PivotPoint.BottomCenter;
            justifyButton.PositionUsesPivotPoint = true;
            justifyButton.MinimumSize            = new Vector2(75, 75);
            justifyButton.Clicked += (sender, e) =>

            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;

                if (flexLayout.Justification == FlexLayout.FlexJustification.FlexStart)
                {
                    flexLayout.Justification = FlexLayout.FlexJustification.Center;
                }
                else
                {
                    flexLayout.Justification = FlexLayout.FlexJustification.FlexStart;
                }

                return(true);
            };
            window.Add(justifyButton);
            buttons.Add(justifyButton);


            PushButton rotateButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(rotateButton, "./res/images/icon-reset.png");
            LayoutingExample.SetSelectedIcon(rotateButton, "./res/images/icon-reset-selected.png");
            rotateButton.ParentOrigin           = new Vector3(0.8f, 1.0f, 0.5f);
            rotateButton.PivotPoint             = PivotPoint.BottomCenter;
            rotateButton.PositionUsesPivotPoint = true;
            rotateButton.MinimumSize            = new Vector2(75, 75);

            rotateButton.Clicked += (sender, e) =>
            {
                FlexLayout flexLayout = (FlexLayout)this.view.Layout;

                if (flexLayout.Direction == FlexLayout.FlexDirection.Row)
                {
                    flexLayout.Direction = FlexLayout.FlexDirection.Column;
                }
                else
                {
                    flexLayout.Direction = FlexLayout.FlexDirection.Row;
                }
                return(true);
            };
            window.Add(rotateButton);
            buttons.Add(rotateButton);
        }
Пример #10
0
        public override void Create()
        {
            view                        = new View();
            view.Name                   = "MainLinearLayout";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            view.HeightSpecification    = LayoutParamPolicies.MatchParent;

            var layout = new LinearLayout();

            layout.LinearAlignment = LinearLayout.Alignment.Center;
            view.Layout            = layout;
            view.LayoutDirection   = ViewLayoutDirectionType.LTR;

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for Adding an ImageView
            //  ImageView positioned instantly
            //  A delayed opacity increases to 1.0f after siblings moved to make space
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents instantPosition = new TransitionComponents();

            instantPosition.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            instantPosition.Delay         = 0;
            instantPosition.Duration      = 1;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Add,
                                                         AnimatableProperties.Position,
                                                         0.0,
                                                         instantPosition);

            TransitionComponents delayedInsertion = new TransitionComponents();

            delayedInsertion.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            delayedInsertion.Delay         = 100;
            delayedInsertion.Duration      = 200;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Add,
                                                         AnimatableProperties.Opacity,
                                                         1.0f,
                                                         delayedInsertion);

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for siblings after ADDing an ImageView to the View
            //  Siblings are moved using AlphaFunction.BuiltinFunctions.EaseInOutSine
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents slowEaseInOutSine = new TransitionComponents();

            slowEaseInOutSine.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
            slowEaseInOutSine.Duration      = 164;
            slowEaseInOutSine.Delay         = 0;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnAdd,
                                                         AnimatableProperties.Position,
                                                         0.0,
                                                         slowEaseInOutSine);

            ///////////////////////////////////////////////////////////////////////////////////////
            //  Custom transitions for Removing an ImageView
            //  The opacity animates to .2f
            ///////////////////////////////////////////////////////////////////////////////////////
            TransitionComponents fadeOut = new TransitionComponents();

            fadeOut.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            fadeOut.Duration      = 600;
            fadeOut.Delay         = 0;
            float targetOpacityOut = .2f;

            view.LayoutTransition = new LayoutTransition(TransitionCondition.Remove,
                                                         AnimatableProperties.Opacity,
                                                         targetOpacityOut,
                                                         fadeOut);

            // Add child image-views to the created view
            var index = 0;

            foreach (String image in TestImages.s_images)
            {
                // Set a delayed custom transition for each Image View so each moves into place after it's
                // adjacent sibbling.
                TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * index;
                easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * TestImages.s_images.Length;

                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(80, 80));

                // Override LayoutChanged transition so different for each ImageView in the Linear layout.
                // In this case each moves with a increasing delay.
                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnRemove,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.TouchEvent += (sender, e) =>
                {
                    if (sender is ImageView && e.Touch.GetState(0) == PointStateType.Down)
                    {
                        ImageView touchedImageView = (ImageView)sender;
                        if (touchedImageView.Weight == 1.0f)
                        {
                            touchedImageView.Weight = 0.0f;
                        }
                        else
                        {
                            touchedImageView.Weight = 1.0f;
                        }
                    }
                    return(true);
                };

                view.Add(imageView);
                index++;
            }

            LayoutingExample.GetWindow().Add(view);

            PushButton directionButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
            LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
            directionButton.Name                   = "directionButton";
            directionButton.ParentOrigin           = new Vector3(0.33f, 1.0f, 0.5f);
            directionButton.PivotPoint             = PivotPoint.BottomCenter;
            directionButton.PositionUsesPivotPoint = true;
            directionButton.MinimumSize            = new Vector2(75, 75);
            directionButton.Clicked               += (sender, e) =>
            {
                if (this.view.LayoutDirection == ViewLayoutDirectionType.LTR)
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.RTL;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play.png");
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play-selected.png");
                }
                else
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.LTR;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
                }
                return(true);
            };
            LayoutingExample.GetWindow().Add(directionButton);
            buttons.Add(directionButton);

            PushButton rotateButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(rotateButton, "./res/images/icon-reset.png");
            LayoutingExample.SetSelectedIcon(rotateButton, "./res/images/icon-reset-selected.png");
            rotateButton.Name                   = "rotateButton";
            rotateButton.ParentOrigin           = new Vector3(0.66f, 1.0f, 0.5f);
            rotateButton.PivotPoint             = PivotPoint.BottomCenter;
            rotateButton.PositionUsesPivotPoint = true;
            rotateButton.MinimumSize            = new Vector2(75, 75);
            rotateButton.Clicked               += (sender, e) =>
            {
                LinearLayout linearLayout = (LinearLayout)this.view.Layout;
                if (linearLayout.LinearOrientation == LinearLayout.Orientation.Horizontal)
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
                }
                else
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Horizontal;
                }
                return(true);
            };

            LayoutingExample.GetWindow().Add(rotateButton);
            buttons.Add(rotateButton);

            PushButton addItemButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(addItemButton, "./res/images/icon-plus.png");
            LayoutingExample.SetSelectedIcon(addItemButton, "./res/images/icon-plus.png");
            addItemButton.Name                   = "addItemButton";
            addItemButton.ParentOrigin           = new Vector3(.9f, 1.0f, 0.5f);
            addItemButton.PivotPoint             = PivotPoint.BottomCenter;
            addItemButton.PositionUsesPivotPoint = true;
            addItemButton.MinimumSize            = new Vector2(75, 75);
            addItemButton.Clicked               += (sender, e) =>
            {
                Button button = sender as Button;
                if (!addedItem)
                {
                    ImageView            imageView            = LayoutingExample.CreateChildImageView(TestImages.s_images[0], new Size2D(80, 80));
                    TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                    easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                    easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * (index); // index was the last item added
                    easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * (index + 1);
                    imageView.LayoutTransition         = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                              AnimatableProperties.Position,
                                                                              0.0,
                                                                              easeInOutSineDelayed);
                    imageView.Opacity = 0.0f;
                    imageView.Name    = "ImageViewBeingAdded-png";
                    view.Add(imageView);
                    LayoutingExample.SetUnselectedIcon(button, "./res/images/icon-minus.png");
                    addedItem = true;
                }
                else
                {
                    foreach (View item in view.Children)
                    {
                        if (item.Name == "ImageViewBeingAdded-png")
                        {
                            view.Remove(item);
                            addedItem = false;
                            LayoutingExample.SetUnselectedIcon(button, "./res/images/icon-plus.png");
                            break;
                        }
                    }
                }
                return(true);
            };

            LayoutingExample.GetWindow().Add(addItemButton);
            buttons.Add(addItemButton);
        }
Пример #11
0
        public override void Create()
        {
            Window window = Window.Instance;

            View01 = new View()
            {
                BackgroundColor = Color.Green,
                Position2D      = new Position2D(0, window.Size.Height / 8),
                Size2D          = new Size2D(window.Size.Width / 2, (window.Size.Height / 8) * 7),
                Name            = "View01"
            };
            window.Add(View01);

            View02 = new View()
            {
                Position2D          = new Position2D(window.Size.Width / 2, window.Size.Height / 8),
                WidthSpecification  = (window.Size.Width / 2),
                HeightSpecification = (window.Size.Height / 8) * 7,
                BackgroundColor     = Color.Blue,
                Layout = new LinearLayout(),
                Name   = "View02LinearView",
            };
            window.Add(View02);

            View03 = new View()
            {
                BackgroundColor = Color.Yellow,
                Name            = "View03",
                Size2D          = new Size2D(20, (window.Size.Height / 8) * 7)
            };
            View01.Add(View03);

            LinearLayout verticalLayout = new LinearLayout();

            verticalLayout.LinearOrientation = LinearLayout.Orientation.Vertical;

            View04 = new View()
            {
                BackgroundColor     = Color.Cyan,
                PositionX           = View03.Size2D.Width,
                WidthSpecification  = LayoutParamPolicies.WrapContent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Layout = verticalLayout,
                Name   = "View04LinearView",
            };
            View01.Add(View04);

            View07 = new View()
            {
                BackgroundColor = Color.Blue,
                Size2D          = new Size2D(200, 200),
                Name            = "View07"
            };
            View03.Add(View07);

            ImageView06      = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(100, 100));
            ImageView06.Name = "imageView-06";
            View04.Add(ImageView06);

            ImageView04      = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(200, 200));
            ImageView04.Name = "imageView-04";
            View07.Add(ImageView04);

            View08 = new View()
            {
                BackgroundColor = Color.Magenta,
                Size2D          = new Size2D(280, 280),
                Name            = "View08"
            };
            View04.Add(View08);

            ImageView03      = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(100, 100));
            ImageView03.Name = "imageView-03";
            View08.Add(ImageView03);

            View05 = new View()
            {
                BackgroundColor = Color.Yellow,
                Name            = "View05",
                Size2D          = new Size2D(10, 100)
            };
            View02.Add(View05);

            FlexContainer legacyContainer = new FlexContainer();

            legacyContainer.FlexDirection = FlexContainer.FlexDirectionType.Column;
            legacyContainer.Size2D        = new Size2D(View02.Size2D.Width / 2, 280);
            legacyContainer.Name          = "legacyFlexContainer";
            View02.Add(legacyContainer);

            ImageView02      = LayoutingExample.CreateChildImageView("res/images/application-icon-103.png", new Size2D(100, 100));
            ImageView02.Name = "imageView-02";
            legacyContainer.Add(ImageView02);
            ImageView01      = LayoutingExample.CreateChildImageView("res/images/application-icon-104.png", new Size2D(100, 100));
            ImageView01.Name = "imageView-01";
            legacyContainer.Add(ImageView01);

            ImageView05      = LayoutingExample.CreateChildImageView("res/images/application-icon-102.png", new Size2D(100, 100));
            ImageView05.Name = "imageView-05";
            View05.Add(ImageView05);

            CreateHelpButton();
            LayoutingExample.GetToolbar().Add(helpButton);
        }
Пример #12
0
        public override void Create()
        {
            view                        = new View();
            view.Name                   = "LinearExample";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.WrapContent;
            view.HeightSpecification    = LayoutParamPolicies.WrapContent;

            var layout = new LinearLayout();

            view.Layout          = layout;
            view.LayoutDirection = ViewLayoutDirectionType.LTR;

            // Add child image-views to the created view
            foreach (String image in TestImages.s_images)
            {
                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(100, 100));
                view.Add(imageView);
            }

            LayoutingExample.GetWindow().Add(view);

            PushButton directionButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
            LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
            directionButton.Name                   = "directionButton";
            directionButton.ParentOrigin           = new Vector3(0.33f, 1.0f, 0.5f);
            directionButton.PivotPoint             = PivotPoint.BottomCenter;
            directionButton.PositionUsesPivotPoint = true;
            directionButton.MinimumSize            = new Vector2(75, 75);
            directionButton.Clicked               += (sender, e) =>
            {
                if (this.view.LayoutDirection == ViewLayoutDirectionType.LTR)
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.RTL;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play.png");
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-play-selected.png");
                }
                else
                {
                    this.view.LayoutDirection = ViewLayoutDirectionType.LTR;
                    LayoutingExample.SetUnselectedIcon(directionButton, "./res/images/icon-reverse.png");
                    LayoutingExample.SetSelectedIcon(directionButton, "./res/images/icon-reverse-selected.png");
                }
                return(true);
            };
            LayoutingExample.GetWindow().Add(directionButton);
            buttons.Add(directionButton);

            PushButton rotateButton = new PushButton();

            LayoutingExample.SetUnselectedIcon(rotateButton, "./res/images/icon-reset.png");
            LayoutingExample.SetSelectedIcon(rotateButton, "./res/images/icon-reset-selected.png");
            rotateButton.Name                   = "rotateButton";
            rotateButton.ParentOrigin           = new Vector3(0.66f, 1.0f, 0.5f);
            rotateButton.PivotPoint             = PivotPoint.BottomCenter;
            rotateButton.PositionUsesPivotPoint = true;
            rotateButton.MinimumSize            = new Vector2(75, 75);
            rotateButton.Clicked               += (sender, e) =>
            {
                LinearLayout linearLayout = (LinearLayout)this.view.Layout;
                if (linearLayout.LinearOrientation == LinearLayout.Orientation.Horizontal)
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
                }
                else
                {
                    linearLayout.LinearOrientation = LinearLayout.Orientation.Horizontal;
                }
                return(true);
            };

            LayoutingExample.GetWindow().Add(rotateButton);
            buttons.Add(rotateButton);
        }
Пример #13
0
        public override void Create()
        {
            windowWidth = LayoutingExample.GetWindow().WindowSize.Width;

            view                        = new View();
            view.Name                   = "MainLinearLayout";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            view.HeightSpecification    = LayoutParamPolicies.MatchParent;

            var layout = new LinearLayout();

            layout.LinearAlignment = LinearLayout.Alignment.Center;
            view.Layout            = layout;
            view.LayoutDirection   = ViewLayoutDirectionType.LTR;

            // Add child image-views to the created view
            var index = 0;

            foreach (String image in TestImages.s_images)
            {
                // Set a delayed custom transition for each Image View so each moves into place after it's
                // adjacent sibbling.
                TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * index;
                easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * TestImages.s_images.Length;

                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(80, 80));

                // Override LayoutChanged transition so different for each ImageView in the Linear layout.
                // In this case each moves with a increasing delay.
                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnRemove,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                view.Add(imageView);
                index++;
            }

            LayoutingExample.GetWindow().Add(view);

            InitializePanControl();
            LayoutingExample.GetWindow().Add(panControl);

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(panControl);
            panGestureDetector.Detected += OnPanGestureDetected;

            instructionsLabel = new TextLabel(instructions)
            {
                Position2D = new Position2D(10, (int)(LayoutingExample.GetWindow().WindowSize.Height *0.90f)),
                MultiLine  = true,
            };
            LayoutingExample.GetWindow().Add(instructionsLabel);
        }