Beispiel #1
0
        private void Initialize()
        {
            // Added gradient background
            VisualView visualView = new VisualView();

            visualView.AddVisual("gradientVisual", CreateGradientVisual());
            visualView.WidthResizePolicy  = ResizePolicyType.FillToParent;
            visualView.HeightResizePolicy = ResizePolicyType.FillToParent;
            visualView.LowerToBottom();
            GetWindow().Add(visualView);

            // Initialize toolbar before any example try to use it.
            InitializeToolbar();

            // Setup change layout button
            nextLayout      = new Button();
            nextLayout.Name = "next-layout-button";
            nextLayout.WidthSpecification  = LayoutParamPolicies.WrapContent;
            nextLayout.HeightSpecification = LayoutParamPolicies.WrapContent;
            nextLayout.Text = "change layout";
            toolbar.Add(nextLayout);

            // Initialize title and add to toolbar.
            InitializeTitle();

            // Toolbar added to Layer so content can be added to window.
            toolbarLayer = new Layer();
            GetWindow().AddLayer(toolbarLayer);
            toolbarLayer.Add(toolbar);

            layoutingExamples.Add(new PanningExample());
            layoutingExamples.Add(new LinearExample());
            layoutingExamples.Add(new NestedLayoutExample());
            layoutingExamples.Add(new FlexExample());
            layoutingExamples.Add(new ScrollingListExample());
            layoutingExamples.Add(new PagesExample());
            layoutingExamples.Add(new MessageExample());
            layoutingExamples.Add(new ChildAddedToViewExample());
            layoutingExamples.Add(new GridExample());
            layoutingExamples.Add(new NoLayoutExample());
            layoutingExamples.Add(new ChangingLayoutsExample());
            layoutingExamples.Add(new ChangingSizeExample());
            layoutingExamples.Add(new AbsoluteExample());
            layoutingExamples.Add(new MultiRootsExample());
            layoutingExamples.Add(new NestedLayoutTestExample());
            layoutingExamples.Add(new DerivedViewExample());
            layoutingExamples.Add(new PaddingExample());

            layoutIndex = 0;
            layoutingExamples[layoutIndex].Create();

            string currentExampleLabel = layoutingExamples[layoutIndex].GetLabel();

            // Set up clicked callback for button to change layout.
            nextLayout.Clicked += (sender, e) =>
            {
                if (layoutingExamples.Count != 0)
                {
                    layoutingExamples[layoutIndex].Remove();
                    layoutIndex = (layoutIndex + 1) % layoutingExamples.Count;
                    layoutingExamples[layoutIndex].Create();
                    currentExampleLabel           = layoutingExamples[layoutIndex].GetLabel();
                    exampleTitle.Text             = currentExampleLabel;
                    exampleTitle.EnableAutoScroll = true;
                }
            };

            // Set initial title
            exampleTitle.Text = currentExampleLabel;

            // Respond to key events
            Window.Instance.KeyEvent += OnKeyEvent;
        }