Exemplo n.º 1
0
 void CreateNextFeatureButton()
 {
     featureIndex      = ExampleFeature.SET_PARENT_HORIZONTAL_LAYOUT;
     nextFeatureButton = new Button();
     nextFeatureButton.ParentOrigin           = ParentOrigin.BottomCenter;
     nextFeatureButton.PivotPoint             = PivotPoint.BottomCenter;
     nextFeatureButton.PositionUsesPivotPoint = true;
     nextFeatureButton.Text     = "Set Horizontal Layout";
     nextFeatureButton.Clicked += (sender, e) =>
     {
         NextFeature();
     };
 }
Exemplo n.º 2
0
        // Execute different features to test
        public void NextFeature()
        {
            switch (featureIndex)
            {
            // Parent container assigned a layout after tree constructed.
            // Children should now be laid out horizontally .
            case ExampleFeature.SET_PARENT_HORIZONTAL_LAYOUT:
            {
                _parentContainer.Layout     = createHbox();
                nextFeatureButton.LabelText = "Add child with no layout";
                featureIndex = ExampleFeature.ADD_CHILD_VIEW_WITH_NO_LAYOUT;
                break;
            }

            // Add a View without a layout but with 2 children.
            // 2 children will be overlapping.
            case ExampleFeature.ADD_CHILD_VIEW_WITH_NO_LAYOUT:
            {
                _childView = new View();
                for (var i = 0; i < 2; i++)
                {
                    _childView.Add(CreateImageView("3rdSet"));
                }
                _imageViewContainer2.Add(_childView);
                nextFeatureButton.LabelText = "Add linear layout to last added child";
                featureIndex = ExampleFeature.ADD_LINEAR_LAYOUT_TO_LAST_ADDED_CHILD;
                break;
            }

            // A horizontal layout added to the View that had no layout.
            // It's children should now be laid out horizontally too.
            case ExampleFeature.ADD_LINEAR_LAYOUT_TO_LAST_ADDED_CHILD:
            {
                LayoutingExample.GetToolbar().Add(helpButton);
                _childView.Layout = createHbox();
                LayoutingExample.GetWindow().Remove(nextFeatureButton);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Exemplo n.º 3
0
        public override void Remove()
        {
            Window window = LayoutingExample.GetWindow();

            if (helpImageView)
            {
                window.Remove(helpImageView);
                helpImageView = null;
            }
            helpShowing = false;
            LayoutingExample.GetToolbar().Remove(helpButton);
            window.Remove(_parentContainer);
            window.Remove(nextFeatureButton);
            nextFeatureButton    = null;
            helpButton           = null;
            _parentContainer     = null;
            _imageViewContainer2 = null;
            _childView           = null;
            featureIndex         = ExampleFeature.SET_PARENT_VERTICAL_LAYOUT;
        }
Exemplo n.º 4
0
        // Demonstrate a different feature depending on state
        public void NextGridFeature()
        {
            switch (featureIndex)
            {
            case ExampleFeature.GRID_EXACT_WIDTH:
            {
                SetExactWidth();
                nextFeatureButton.Text = "Set Child Margin";
                featureIndex           = ExampleFeature.ITEMS_WITH_MARGINS;
                break;
            }

            case ExampleFeature.ITEMS_WITH_MARGINS:
            {
                AddMarginToItems();
                featureIndex           = ExampleFeature.GRID_MATCH_PARENT;
                nextFeatureButton.Text = "Set width MATCH_PARENT";
                break;
            }

            case ExampleFeature.GRID_MATCH_PARENT:
            {
                RemoveMarginsFromItems();
                MatchParentOnWidth();
                nextFeatureButton.Text = "Set width WRAP_CONTENT";
                featureIndex           = ExampleFeature.GRID_WRAP_CONTENT;
                break;
            }

            case ExampleFeature.GRID_WRAP_CONTENT:
            {
                WrapContentOnWidth();
                nextFeatureButton.Text = "Add item";
                featureIndex           = ExampleFeature.ADD_ITEMS;
                break;
            }

            case ExampleFeature.ADD_ITEMS:
            {
                if (childItems.Count < MAX_NUMBER_OF_ITEMS)
                {
                    AddItemsInteractively();
                }

                if (childItems.Count == MAX_NUMBER_OF_ITEMS)
                {
                    // Remove button when no more items to add
                    featureIndex           = ExampleFeature.CHANGE_TO_3_COLUMNS;
                    nextFeatureButton.Text = "Change Columns";
                }
                break;
            }

            case ExampleFeature.CHANGE_TO_3_COLUMNS:
            {
                ChangeTo3Columns();
                featureIndex = ExampleFeature.GRID_EXACT_WIDTH;
                Window window = LayoutingExample.GetWindow();
                window.Remove(nextFeatureButton);
                nextFeatureButton = null;
                break;
            }

            default:
            {
                featureIndex = ExampleFeature.GRID_EXACT_WIDTH;
                break;
            }
            }
        }