/// <summary>
        /// Create buttons which control properties of ImageView
        /// </summary>
        private void CreateButtons()
        {
            // Create tableView used to put PushButton.
            buttonTableView = new TableView(1, caseCount);
            // Set the position of tableView.
            buttonTableView.PositionUsesPivotPoint = true;
            buttonTableView.PivotPoint             = PivotPoint.CenterLeft;
            buttonTableView.ParentOrigin           = ParentOrigin.CenterLeft;
            buttonTableView.Position = buttonTableViewStartPosition;
            // Width of each cell is set to window's width
            for (uint i = 0; i < caseCount; ++i)
            {
                buttonTableView.SetFixedWidth(i, 360);
            }

            root.Add(buttonTableView);

            // Create button for the each case.
            for (uint i = 0; i < caseCount; ++i)
            {
                // Create a button with string.
                Button button = CreateButton(caseString[i], needButton[i]);
                // Bind PushButton's click event to ButtonClick.
                button.TouchEvent += OnButtonTouched;
                button.PointSize   = 3;
                buttonTableView.AddChild(button, new TableView.CellPosition(0, i));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fill TableView component
        /// </summary>
        private void InitTableViewCells()
        {
            movies = new Dictionary <ImageView, string>();

            uint movieNumber = 1;

            for (uint row = 0; row < rows; ++row)
            {
                for (uint col = 0; col < cols; ++col, ++movieNumber)
                {
                    ImageView movieImage = new ImageView(resUrl + "movie" + movieNumber + ".jpg")
                    {
                        WidthResizePolicy  = ResizePolicyType.SizeRelativeToParent,
                        HeightResizePolicy = ResizePolicyType.SizeRelativeToParent,
                        Focusable          = true,
                        Opacity            = 0.8f
                    };
                    table.AddChild(movieImage, new TableView.CellPosition(row, col));
                    movies[movieImage] = movieTitles[movieNumber - 1];

                    movieImage.FocusGained += (obj, e) =>
                    {
                        movieImage.Opacity = 1.0f;
                        title.Text         = movies[movieImage];
                    };
                    movieImage.FocusLost += (obj, e) => { movieImage.Opacity = .8f; };

                    if (row == 0 && col == 0)
                    {
                        FocusManager.Instance.SetCurrentFocusView(movieImage);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create buttons which control properties of ImageView
        /// </summary>
        private void CreateButtons()
        {
            // Create tableView used to put PushButton.
            mButtonTableView = new TableView(1, mCaseCount);
            // Set the position of tableView.
            mButtonTableView.PositionUsesPivotPoint = true;
            mButtonTableView.PivotPoint             = PivotPoint.CenterLeft;
            mButtonTableView.ParentOrigin           = ParentOrigin.CenterLeft;
            mButtonTableView.Position = mButtonTableViewStartPosition;
            // Width of each cell is set to window's width
            for (uint i = 0; i < mCaseCount; ++i)
            {
                mButtonTableView.SetFixedWidth(i, 360);
            }

            Window.Instance.GetDefaultLayer().Add(mButtonTableView);

            // Create button for the each case.
            for (uint i = 0; i < mCaseCount; ++i)
            {
                // Create a button with string.
                PushButton pushButton = CreateButton(mCaseString[i], mNeedButton[i]);
                // Bind PushButton's click event to ButtonClick.
                pushButton.TouchEvent += OnButtonTouched;
                mButtonTableView.AddChild(pushButton, new TableView.CellPosition(0, i));
            }
        }
        /// <summary>
        /// Create buttons which control properties of textField
        /// </summary>
        private void CreateButtons()
        {
            // Create tableView used to put PushButton.
            mTableView = new TableView(1, mPushButtonCount);
            // Set the position of tableView.
            mTableView.PositionUsesPivotPoint = true;
            mTableView.PivotPoint             = PivotPoint.CenterLeft;
            mTableView.ParentOrigin           = ParentOrigin.CenterLeft;
            mTableView.Position = mTableViewStartPosition;
            // Set the each cell
            for (uint i = 0; i < mPushButtonCount; ++i)
            {
                mTableView.SetFixedWidth(i, 360);
            }

            Window.Instance.GetDefaultLayer().Add(mTableView);

            // Create button for the each case.
            mPushButton = new PushButton[mPushButtonCount];
            for (uint i = 0; i < mPushButtonCount; ++i)
            {
                // Creates button
                mPushButton[i] = CreateButton(mPushButtonString[i]);
                // Bind PushButton's click event to ButtonClick.
                mPushButton[i].TouchEvent += OnButtonTouched;
                mTableView.AddChild(mPushButton[i], new TableView.CellPosition(0, i));
            }

            // Set the default state of each button property
            mButtonState = new uint[mPushButtonCount];
            for (uint i = 0; i < mPushButtonCount; ++i)
            {
                mButtonState[i] = 0;
            }
        }
        /// <summary>
        /// Create buttons which run each animation
        /// </summary>
        private void CreateButtons()
        {
            // Create tableView used to put PushButton.
            mTableView = new TableView(1, mButtonCount);
            // Set the position of tableView.
            mTableView.PositionUsesPivotPoint = true;
            mTableView.PivotPoint             = PivotPoint.CenterLeft;
            mTableView.ParentOrigin           = ParentOrigin.CenterLeft;
            mTableView.Position = mTableViewStartPosition;
            for (uint i = 0; i < mButtonCount; ++i)
            {
                mTableView.SetFixedWidth(i, 360);
            }

            mTableView.CellHorizontalAlignment = HorizontalAlignmentType.Center;
            mTableView.CellVerticalAlignment   = VerticalAlignmentType.Center;

            root.Add(mTableView);

            mButton = new Button[mButtonCount];
            for (uint i = 0; i < mButtonCount; ++i)
            {
                // CreateButton with string array
                mButton[i] = CreateButton(mButtonString[i], mButtonString[i]);
                // Bind PushButton's click event to TouchEvent.
                mButton[i].TouchEvent += OnButtonTouched;
                mTableView.AddChild(mButton[i], new TableView.CellPosition(0, i));
            }
        }
Exemplo n.º 6
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            window.BackgroundColor = Color.White;
            windowSize             = window.Size;

            // Create Table
            TableView table = new TableView(mRow, mColumn)
            {
                PositionUsesPivotPoint = true,
                PivotPoint             = PivotPoint.Center,
                ParentOrigin           = ParentOrigin.Center,
                Size            = new Size((float)(windowSize.Width * 0.8), (float)(windowSize.Height * 0.8)),
                BackgroundColor = new Color(0.2f, 0.5f, 0.5f, 1.0f),
                CellPadding     = new Vector2(10, 10),
            };

            window.GetDefaultLayer().Add(table);

            uint exampleCount = 0;

            // Fill the contents in TableView
            for (uint row = 0; row < mRow; row++)
            {
                for (uint column = 0; column < mColumn; column++)
                {
                    TextLabel content = CreateText();
                    content.Name = "TextLabel" + exampleCount;
                    content.Text = "R" + row + " - C" + column;

                    ///////////////////////////////////////////////////////////////////////////////////////////////
                    ///                 How to set Accessibility attribute to components                        ///
                    /// 1. Create AccessibilityManager.                                                         ///
                    /// 2. Set the focus order of each view and the index of order should start 1 (one).        ///
                    /// 3. Set the information of each view's accessibility attribute.                          ///
                    ///    There are four attributes, which will be read by screen reader.                      ///
                    ///    And the order of reading is : Label -> Trait -> Value (Optional) -> Hint (Optional)  ///
                    ///////////////////////////////////////////////////////////////////////////////////////////////

                    AccessibilityManager manager = AccessibilityManager.Instance;
                    manager.SetFocusOrder(content, ++exampleCount);
                    manager.SetAccessibilityAttribute(content,
                                                      AccessibilityManager.AccessibilityAttribute.Label, content.Name);
                    manager.SetAccessibilityAttribute(content,
                                                      AccessibilityManager.AccessibilityAttribute.Trait, "Tile");
                    manager.SetAccessibilityAttribute(content,
                                                      AccessibilityManager.AccessibilityAttribute.Hint, "You can run this example");

                    table.AddChild(content, new TableView.CellPosition(row, column));
                }
            }

            // You can connect with various Accessibility action signals.
            // AccessibilityManager provides functionality of setting the focus and moving forward and backward.
            // All touch interactions for screen will work with one more finger and tap.

            AccessibilityManager.Instance.FocusedViewActivated += OnFocusedView;
        }
Exemplo n.º 7
0
        void Initialize()
        {
            TableView contentContainer = new TableView(3, 1);

            TextLabel label = new TextLabel("Welcome to NUI!");

            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.BackgroundColor     = Color.White;
            label.TextColor           = Color.Black;
            label.PointSize           = 12.0f;
            label.HeightResizePolicy  = ResizePolicyType.FillToParent;
            label.WidthResizePolicy   = ResizePolicyType.FillToParent;
            label.AutomationId        = "label";

            TextLabel test = new TextLabel("test");

            test.HorizontalAlignment = HorizontalAlignment.Center;
            test.VerticalAlignment   = VerticalAlignment.Center;
            test.BackgroundColor     = Color.White;
            test.TextColor           = Color.Black;
            test.PointSize           = 10.0f;
            test.HeightResizePolicy  = ResizePolicyType.FillToParent;
            test.WidthResizePolicy   = ResizePolicyType.FillToParent;
            test.AutomationId        = "test";

            PushButton button = new PushButton();

            button.LabelText          = "Button";
            button.BackgroundColor    = Color.White;
            button.HeightResizePolicy = ResizePolicyType.FillToParent;
            button.WidthResizePolicy  = ResizePolicyType.FillToParent;
            button.AutomationId       = "button";

            button.Clicked += (s, e) =>
            {
                test.Text = "button clicked";
                return(true);
            };

            contentContainer.AddChild(label, new TableView.CellPosition(0));
            contentContainer.AddChild(test, new TableView.CellPosition(1));
            contentContainer.AddChild(button, new TableView.CellPosition(2));

            Window.Instance.Add(contentContainer);
        }
        /// <summary>
        /// Populates the contents (ScrollView) with all the
        /// Examples that have been Added using the AddExample(...)
        /// call
        /// </summary>
        private void Populate()
        {
            Vector2 stagesize = Window.Instance.Size;

            mTotalPages    = (numOfSamples + EXAMPLES_PER_ROW * ROWS_PER_PAGE - 1) / (EXAMPLES_PER_ROW * ROWS_PER_PAGE);
            mpages         = new TableView[mTotalPages];
            tile           = new View[numOfSamples];
            tileBackGround = new View[numOfSamples];

            int iter = 0;
            // Calculate the number of images going across (columns) within a page,
            // according to the screen resolution and dpi.
            ushort margin = 2;
            float  tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW;

            for (int t = 0; t < mTotalPages; t++)
            {
                // Create Table
                TableView page = new TableView(ROWS_PER_PAGE, EXAMPLES_PER_ROW);
                page.PositionUsesPivotPoint = true;
                page.PivotPoint             = PivotPoint.Center;
                page.ParentOrigin           = ParentOrigin.Center;
                page.HeightResizePolicy     = ResizePolicyType.FillToParent;
                page.WidthResizePolicy      = ResizePolicyType.FillToParent;
                page.Position2D             = new Position2D((int)stagesize.Width * t, 0);
                scrollView.Add(page);

                for (uint row = 0; row < ROWS_PER_PAGE; row++)
                {
                    for (uint column = 0; column < EXAMPLES_PER_ROW; column++)
                    {
                        // Calculate the tiles relative pmScrollingosition
                        // on the page (between 0 - 1 in each dimension).
                        Vector2 position = new Vector2(column / (EXAMPLES_PER_ROW - 1.0f), row / (EXAMPLES_PER_ROW - 1.0f));
                        tile[iter]           = CreateTile(samples[iter], samples[iter], new Vector3(tileParentMultiplier, tileParentMultiplier, 1.0f), position);
                        tile[iter].Padding   = new Extents(margin, margin, margin, margin);
                        tileBackGround[iter] = tile[iter].GetChildAt(0);
                        page.AddChild(tile[iter], new TableView.CellPosition(row, column));
                        iter++;
                        if (iter == numOfSamples)
                        {
                            break;
                        }
                    }

                    if (iter == numOfSamples)
                    {
                        break;
                    }
                }

                mpages[t] = page;
                if (iter == numOfSamples)
                {
                    break;
                }
            }
        }
Exemplo n.º 9
0
        Popup CreatePopup()
        {
            Popup confirmationPopup = new Popup();

            View footer = new View();

            footer.Name = ("Footer");
            footer.WidthResizePolicy  = ResizePolicyType.FillToParent;
            footer.HeightResizePolicy = ResizePolicyType.Fixed;
            footer.Size2D             = new Size2D(0, 80);
            footer.PivotPoint         = PivotPoint.Center;

            PushButton okButton = CreateOKButton();

            okButton.PivotPoint         = PivotPoint.Center;
            okButton.WidthResizePolicy  = ResizePolicyType.SizeFixedOffsetFromParent;
            okButton.HeightResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent;
            okButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f));

            PushButton cancelButton = CreateCancelButton();

            cancelButton.PivotPoint         = PivotPoint.Center;
            cancelButton.WidthResizePolicy  = ResizePolicyType.SizeFixedOffsetFromParent;
            cancelButton.HeightResizePolicy = ResizePolicyType.SizeFixedOffsetFromParent;
            cancelButton.SetSizeModeFactor(new Vector3(-20.0f, -20.0f, 0.0f));

            TableView controlLayout = new TableView(1, 2);

            controlLayout.PivotPoint         = PivotPoint.Center;
            controlLayout.WidthResizePolicy  = ResizePolicyType.FillToParent;
            controlLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
            controlLayout.SetCellPadding(new Size2D(10, 10));
            controlLayout.SetRelativeWidth(0, 0.5f);
            controlLayout.SetRelativeWidth(1, 0.5f);
            controlLayout.SetCellAlignment(new TableView.CellPosition(0, 0), HorizontalAlignmentType.Center, VerticalAlignmentType.Center);
            controlLayout.SetCellAlignment(new TableView.CellPosition(0, 1), HorizontalAlignmentType.Center, VerticalAlignmentType.Center);
            controlLayout.AddChild(okButton, new TableView.CellPosition(0, 0));
            controlLayout.AddChild(cancelButton, new TableView.CellPosition(0, 1));

            footer.Add(controlLayout);

            confirmationPopup.SetFooter(footer);
            return(confirmationPopup);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Text Sample Application initialisation.
        /// </summary>
        private void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            //Title to show the sampel name
            guide = new TextLabel();
            guide.HorizontalAlignment    = HorizontalAlignment.Center;
            guide.VerticalAlignment      = VerticalAlignment.Center;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D     = new Size2D(1920, 96);
            guide.FontFamily = "Samsung One 600";
            guide.Position2D = new Position2D(0, 94);
            guide.MultiLine  = false;
            //guide.PointSize = 15.0f;
            guide.PointSize = DeviceCheck.PointSize15;
            guide.Text      = "PixelArea Sample \n";
            guide.TextColor = Color.White;
            //guide.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            Window.Instance.GetDefaultLayer().Add(guide);

            //Create one tableView as a container of all the image.
            tableView        = new TableView(3, 3);
            tableView.Size2D = new Size2D(600, 600);
            tableView.PositionUsesPivotPoint = true;
            tableView.PivotPoint             = PivotPoint.TopLeft;
            tableView.ParentOrigin           = ParentOrigin.TopLeft;
            tableView.Position2D             = new Position2D(660, 275);
            Window.Instance.GetDefaultLayer().Add(tableView);

            //Create p image and add them to tableView
            imageView = new ImageView[9];
            for (uint i = 0; i < 3; i++)
            {
                for (uint j = 0; j < 3; j++)
                {
                    imageView[i * 3 + j] = new ImageView(image_jpg);
                    imageView[i * 3 + j].HeightResizePolicy = ResizePolicyType.FillToParent;
                    imageView[i * 3 + j].WidthResizePolicy  = ResizePolicyType.FillToParent;
                    // Put these imageView at different position.
                    tableView.AddChild(imageView[i * 3 + j], new TableView.CellPosition(i, j));
                }
            }

            //Create button to trrigger the PixelArea animation
            pushButton              = CreateButton("PixelArea", "PixelArea");
            pushButton.PivotPoint   = PivotPoint.Center;
            pushButton.ParentOrigin = ParentOrigin.TopLeft;
            pushButton.Position2D   = tableView.Position2D + new Position2D((int)tableView.SizeWidth / 2 - 200, (int)tableView.SizeHeight + 60);
            pushButton.Clicked     += PixelAreaButtonClick;
            pushButton.Focusable    = true;
            Window.Instance.GetDefaultLayer().Add(pushButton);
            FocusManager.Instance.SetCurrentFocusView(pushButton);
        }
Exemplo n.º 11
0
        /// <summary>
        /// The event will be triggered when onOffButton clicked
        /// </summary>
        /// <param name="source">onOffButton.</param>
        /// <param name="e">event</param>
        /// <returns>the consume flag</returns>
        private bool OnOffButtonClick(object source, EventArgs e)
        {
            if (onoff)
            {
                imageView[0].Unparent();
                onoff = false;
            }
            else
            {
                tableView.AddChild(imageView[0], new TableView.CellPosition(0, 0));
                onoff = true;
            }

            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Create TableView, Create pushButtons and add them to tableView.
        /// </summary>
        private void Populate()
        {
            Vector2 stagesize = Window.Instance.Size;

            //mTotalPages = (numOfSamples + EXAMPLES_PER_ROW * ROWS_PER_PAGE - 1) / (EXAMPLES_PER_ROW * ROWS_PER_PAGE);
            tableView = new TableView(ROWS_PER_PAGE, EXAMPLES_PER_ROW);
            buttons   = new PushButton[numOfSamples];

            tableView.PositionUsesPivotPoint = true;
            //tableView.BackgroundColor = Color.White;
            tableView.Size2D       = new Size2D(1500, 400);
            tableView.PivotPoint   = PivotPoint.TopLeft;
            tableView.ParentOrigin = ParentOrigin.TopLeft;
            tableView.Position2D   = new Position2D(210, 390);

            backGroundView.Add(tableView);
            int    iter                 = 0;
            ushort margin               = 20;
            ushort topmargin            = 30;
            float  tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW;

            for (uint row = 0; row < ROWS_PER_PAGE; row++)
            {
                for (uint column = 0; column < EXAMPLES_PER_ROW; column++)
                {
                    // Calculate the position of each button
                    Vector2 position = new Vector2(column / (EXAMPLES_PER_ROW - 1.0f), row / (EXAMPLES_PER_ROW - 1.0f));
                    buttons[iter]         = CreateTile(samples[iter], samples[iter], new Vector3(tileParentMultiplier, tileParentMultiplier, 1.0f), position);
                    buttons[iter].Padding = new Extents(margin, margin, topmargin, topmargin);
                    tableView.AddChild(buttons[iter], new TableView.CellPosition(row, column));
                    iter++;
                    if (iter == numOfSamples)
                    {
                        break;
                    }
                }

                if (iter == numOfSamples)
                {
                    break;
                }
            }
        }
Exemplo n.º 13
0
        private void Populate()
        {
            Vector2 stageSize = NUIApplication.GetDefaultWindow().WindowSize;

            mTotalPages = (uint)((mExampleList.Count() + EXAMPLES_PER_PAGE - 1) / EXAMPLES_PER_PAGE);

            // Populate ScrollView.
            if (mExampleList.Count() > 0)
            {
                if (mSortAlphabetically)
                {
                    mExampleList.Sort(Example.CompareByTitle);
                }

                int pageCount = mExampleList.Count / (ROWS_PER_PAGE * EXAMPLES_PER_ROW) + ((0 == mExampleList.Count % (ROWS_PER_PAGE * EXAMPLES_PER_ROW)) ? 0 : 1);
                mPages = new View[pageCount];

                int pageIndex = 0;

                uint exampleCount = 0;

                for (int t = 0; t < mTotalPages; t++)
                {
                    // Create Table
                    TableView page = new TableView(ROWS_PER_PAGE, EXAMPLES_PER_ROW);
                    page.PositionUsesPivotPoint = true;
                    page.PivotPoint             = PivotPoint.Center;
                    page.ParentOrigin           = ParentOrigin.Center;
                    page.WidthResizePolicy      = page.HeightResizePolicy = ResizePolicyType.FillToParent;
                    mScrollView.Add(page);

                    // Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi.
                    const float margin = 2.0f;
                    const float tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW;

                    for (uint row = 0; row < ROWS_PER_PAGE; row++)
                    {
                        for (uint column = 0; column < EXAMPLES_PER_ROW; column++)
                        {
                            Example example = mExampleList.ElementAt((int)exampleCount++);

                            // Calculate the tiles relative position on the page (between 0 & 1 in each dimension).
                            Vector2 position = new Vector2((float)(column) / (EXAMPLES_PER_ROW - 1.0f), (float)(row) / (EXAMPLES_PER_ROW - 1.0f));
                            View    tile     = CreateTile(example.Name, example.Title, new Vector3(tileParentMultiplier, tileParentMultiplier, 1.0f), position);

                            tile.SetPadding(new PaddingType((int)margin, (int)margin, (int)margin, (int)margin));
                            page.AddChild(tile, new TableView.CellPosition(row, column));

                            tiles.Add(tile);

                            if (exampleCount == mExampleList.Count)
                            {
                                break;
                            }
                        }

                        if (exampleCount == mExampleList.Count)
                        {
                            break;
                        }
                    }

                    mPages[pageIndex++] = page;

                    if (exampleCount == mExampleList.Count)
                    {
                        break;
                    }
                }
            }

            // Update Ruler info.
            mScrollRulerX = new RulerPtr(new FixedRuler(mPageWidth));
            mScrollRulerY = new RulerPtr(new DefaultRuler());
            mScrollRulerX.SetDomain(new RulerDomain(0.0f, (mTotalPages + 1) * stageSize.Width * TABLE_RELATIVE_SIZE.X * 0.5f, true));
            mScrollRulerY.Disable();
            mScrollView.SetRulerX(mScrollRulerX);
            mScrollView.SetRulerY(mScrollRulerY);
        }
        /// <summary>
        /// Script Layout Sample Application initialization.
        /// </summary>
        private void Initialize()
        {
            //Window.Instance.BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1.0f);
            Window.Instance.BackgroundColor = Color.Black;
            //Window.Instance.BackgroundColor = Color.White;
            View focusIndicator = new View();

            FocusManager.Instance.FocusIndicator = focusIndicator;
            themePath = defaultThemePath;

            // Applies a new theme to the application.
            // This will be merged on top of the default Toolkit theme.
            // If the application theme file doesn't style all controls that the
            // application uses, then the default Toolkit theme will be used
            // instead for those controls.
            StyleManager.Get().ApplyTheme(defaultThemePath);
            //Create the title
            guide                        = new TextLabel();
            guide.StyleName              = "Title";
            guide.HorizontalAlignment    = HorizontalAlignment.Center;
            guide.VerticalAlignment      = VerticalAlignment.Center;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D                 = new Size2D(1920, 96);
            guide.FontFamily             = "Samsung One 600";
            guide.Position2D             = new Position2D(0, 94);
            guide.MultiLine              = false;
            //guide.PointSize = 15.0f;
            guide.PointSize       = DeviceCheck.PointSize15;
            guide.Text            = "Script Sample \n";
            guide.TextColor       = Color.White;
            guide.BackgroundColor = Color.Black;//new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            Window.Instance.GetDefaultLayer().Add(guide);

            //The container of the RadioButtons, CheckBoxButtons, Sliders, and the big ImageView
            TableView content = new TableView(6, 6);

            //content.BackgroundColor = Color.Black;
            content.Position2D             = new Position2D(100, 275);
            content.Size2D                 = new Size2D(1000, 500);
            content.PositionUsesPivotPoint = true;
            content.ParentOrigin           = ParentOrigin.TopLeft;
            content.PivotPoint             = PivotPoint.TopLeft;
            content.CellPadding            = new Vector2(0, 5);
            for (uint i = 0; i < content.Rows; ++i)
            {
                content.SetFitHeight(i);
            }

            for (uint i = 0; i < content.Columns; ++i)
            {
                content.SetFitWidth(i);
            }

            Window.Instance.GetDefaultLayer().Add(content);
            string[] images = { smallImage1, smallImage2, smallImage3 };
            mRadioButtons = new RadioButton[3];
            for (uint i = 0; i <= 2; i++)
            {
                ImageView image = new ImageView(images[i]);
                image.Name   = "thumbnail" + (i + 1);
                image.Size2D = new Size2D(60, 60);

                mRadioButtons[i] = CreateRadioButton((i + 1).ToString());

                if (DeviceCheck.IsSREmul())
                {
                    mRadioButtons[i].StyleName = "RadioButton";
                }
                else
                {
                    mRadioButtons[i].StyleName = "TVRadioButton";
                }
                content.AddChild(mRadioButtons[i], new TableView.CellPosition(i, 0));
                content.AddChild(image, new TableView.CellPosition(i, 1));
                content.SetCellAlignment(new TableView.CellPosition(i, 0), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
                content.SetCellAlignment(new TableView.CellPosition(i, 1), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
            }

            mRadioButtons[0].Selected = true;
            //Set the focus to the first radioButton when the apps loaded
            FocusManager.Instance.SetCurrentFocusView(mRadioButtons[0]);

            string[] checkboxLabels = { "R", "G", "B" };
            mCheckButtons   = new CheckBoxButton[3];
            mChannelSliders = new Slider[3];
            for (uint i = 3; i <= 5; i++)
            {
                mCheckButtons[i - 3]          = CreateCheckBox(checkboxLabels[i - 3]);
                mCheckButtons[i - 3].Selected = true;
                mCheckButtons[i - 3].Name     = "channelActiveCheckBox" + (i - 2).ToString();
                mChannelSliders[i - 3]        = CreateSlider();
                mChannelSliders[i - 3].Name   = "ColorSlider" + (i - 2);
                mChannelSliders[i - 3].Size2D = new Size2D(800, 80);
                // Set the current value of mChannelSliders;
                mChannelSliders[i - 3].KeyEvent     += ChannelSliderKeyEvent;
                mChannelSliders[i - 3].ValueChanged += OnSliderChanged;

                // Set the style according to the target devices
                if (DeviceCheck.IsSREmul())
                {
                    mCheckButtons[i - 3].StyleName = "CheckBoxButton";
                }
                else
                {
                    mCheckButtons[i - 3].StyleName = "TVCheckBoxButton";
                }

                content.AddChild(mCheckButtons[i - 3], new TableView.CellPosition(i, 0));
                content.AddChild(mChannelSliders[i - 3], new TableView.CellPosition(i, 1));
                content.SetCellAlignment(new TableView.CellPosition(i, 0), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
                content.SetCellAlignment(new TableView.CellPosition(i, 1), HorizontalAlignmentType.Left, VerticalAlignmentType.Center);
            }

            mImagePlacement        = new ImageView(bigImage1);
            mImagePlacement.Size2D = new Size2D(500, 500);
            mImagePlacement.PositionUsesPivotPoint = true;
            mImagePlacement.PivotPoint             = PivotPoint.TopLeft;
            mImagePlacement.ParentOrigin           = ParentOrigin.TopLeft;
            mImagePlacement.Position2D             = new Position2D(1320, 230);
            Window.Instance.GetDefaultLayer().Add(mImagePlacement);

            defaultThemeButton            = CreateButton("DefaultTheme", "DefaultTheme", new Size2D(400, 80));
            defaultThemeButton.Position2D = new Position2D(373, 900);
            defaultThemeButton.Clicked   += OnThemeButtonClicked;
            Window.Instance.GetDefaultLayer().Add(defaultThemeButton);
            customThemeButton            = CreateButton("CustomTheme", "CustomTheme", new Size2D(400, 80));
            customThemeButton.Position2D = new Position2D(1146, 900);
            customThemeButton.Clicked   += OnThemeButtonClicked;
            Window.Instance.GetDefaultLayer().Add(customThemeButton);

            if (DeviceCheck.IsSREmul())
            {
                defaultThemeButton.StyleName = "PushButton";
                customThemeButton.StyleName  = "PushButton";
            }
            else
            {
                defaultThemeButton.StyleName = "TVPushButton";
                customThemeButton.StyleName  = "TVPushButton";
            }

            defaultThemeButton.RightFocusableView = customThemeButton;
            customThemeButton.LeftFocusableView   = defaultThemeButton;
            defaultThemeButton.UpFocusableView    = mCheckButtons[2];
            mCheckButtons[2].DownFocusableView    = defaultThemeButton;
            customThemeButton.UpFocusableView     = mChannelSliders[2];
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 15
0
        public void Activate()
        {
            Window.Instance.BackgroundColor = Color.White;
            root            = new SampleLayout();
            root.HeaderText = "Switch";

            if (styles.Length == 0 || applications.Length == 0)
            {
                return;
            }
            colNum = (uint)applications.Length + 1;
            rowNum = (uint)styles.Length + 1;

            table = new TableView(rowNum, colNum)
            {
                Size2D = new Size2D(1080, 1920),
            };
            for (uint i = 1; i < rowNum; i++)
            {
                TextLabel text = new TextLabel();
                text.Size2D              = new Size2D(Width, 150);
                text.PointSize           = 12;
                text.Focusable           = true;
                text.HorizontalAlignment = HorizontalAlignment.Center;
                text.VerticalAlignment   = VerticalAlignment.Center;
                text.Text = styles[i - 1];
                table.AddChild(text, new TableView.CellPosition(i, 0));
            }

            for (uint i = 1; i < colNum; i++)
            {
                TextLabel text = new TextLabel();
                text.Size2D              = new Size2D(Width, 150);
                text.PointSize           = 12;
                text.HorizontalAlignment = HorizontalAlignment.Center;
                text.VerticalAlignment   = VerticalAlignment.Center;
                text.Text      = applications[i - 1];
                text.Focusable = true;
                table.AddChild(text, new TableView.CellPosition(0, i));
            }

            for (uint j = 1; j < colNum; j++)
            {
                for (uint i = 1; i < rowNum; i++)
                {
                    Tizen.NUI.CommonUI.Switch switchControl = new Tizen.NUI.CommonUI.Switch("Switch");
                    switchControl.Size2D = new Size2D(96, 60);
                    if (i == 3)
                    {
                        switchControl.IsEnabled = false;
                    }
                    else if (i == 4)
                    {
                        switchControl.IsEnabled  = false;
                        switchControl.IsSelected = true;
                    }
                    table.AddChild(switchControl, new TableView.CellPosition(i, j));
                }
            }

            for (uint i = 0; i < rowNum; i++)
            {
                table.SetFixedHeight(i, Height);
                for (uint j = 0; j < colNum; j++)
                {
                    table.SetFixedWidth(j, Width);
                    table.SetCellAlignment(new TableView.CellPosition(i, j), HorizontalAlignmentType.Center, VerticalAlignmentType.Center);
                }
            }

            root.Add(table);
        }
Exemplo n.º 16
0
        private void CreateItem(Item item, int idx)
        {
            // Make label for item
            TextLabel itemLabel = new TextLabel("    " + item.name);

            itemLabel.Size2D = new Size2D((int)(_window.Size.Width * 0.2f), (int)(_window.Size.Height * 0.05f));
            itemLabel.HorizontalAlignment = HorizontalAlignment.Begin;
            itemLabel.VerticalAlignment   = VerticalAlignment.Bottom;
            //itemLabel.PointSize = 18.0f;
            _contentContainer.AddChild(itemLabel, new TableView.CellPosition(((uint)idx / 5) * 2, (uint)idx % 5));

            // If item is implemented in public, attach it on window
            if (item.isImplemented)
            {
                if (item.name.CompareTo("PushButton") == 0)
                {
                    PushButton pushButton = new PushButton();
                    pushButton.LabelText          = "Push Button";
                    pushButton.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    pushButton.HeightResizePolicy = ResizePolicyType.FillToParent;
                    pushButton.UnselectedColor    = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
                    pushButton.SelectedColor      = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
                    pushButton.Clicked           += (obj, e) =>
                    {
                        Button sender = obj as Button;
                        sender.LabelText       = "Click Me";
                        sender.UnselectedColor = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
                        return(true);
                    };

                    _contentContainer.AddChild(pushButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("DropDown") == 0)
                {
                }
                if (item.name.CompareTo("Toggle") == 0)
                {
                    ToggleButton  toggleButton = new ToggleButton();
                    PropertyArray array        = new PropertyArray();
                    array.Add(new PropertyValue(_resPath + "/images/star-highlight.png"));
                    array.Add(new PropertyValue(_resPath + "/images/star-mod.png"));
                    array.Add(new PropertyValue(_resPath + "/images/star-dim.png"));
                    toggleButton.StateVisuals = array;

                    PropertyArray tooltips = new PropertyArray();
                    tooltips.Add(new PropertyValue("State A"));
                    tooltips.Add(new PropertyValue("State B"));
                    tooltips.Add(new PropertyValue("State C"));
                    toggleButton.Tooltips = tooltips;

                    toggleButton.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    toggleButton.HeightResizePolicy = ResizePolicyType.FillToParent;
                    toggleButton.Clicked           += (obj, e) =>
                    {
                        Tizen.Log.Debug("NUI", "Toggle button state changed.");
                        return(true);
                    };

                    _contentContainer.AddChild(toggleButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("InputField") == 0)
                {
                }
                if (item.name.CompareTo("AnimateGif") == 0)
                {
                }
                if (item.name.CompareTo("Loading") == 0)
                {
                }
                if (item.name.CompareTo("ProgressBar") == 0)
                {
                    _progressBar = new ProgressBar();
                    _progressBar.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    _progressBar.HeightResizePolicy = ResizePolicyType.Fixed;
                    _progressBar.Size2D             = new Size2D(0, 100);

                    _progressBar.ValueChanged += OnProgressBarValueChanged;

                    _timer       = new Timer(100);
                    _timer.Tick += (obj, e) =>
                    {
                        float progress = (float)Math.Round(_progressBar.ProgressValue, 2);

                        if (progress == 1.0f)
                        {
                            _progressBar.ProgressValue          = 0.0f;
                            _progressBar.SecondaryProgressValue = 0.01f;
                        }
                        else
                        {
                            _progressBar.ProgressValue          = progress + 0.01f;
                            _progressBar.SecondaryProgressValue = progress + 0.21f;
                        }
                        return(true);
                    };
                    _timer.Start();

                    _contentContainer.AddChild(_progressBar, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("ScrollBar") == 0)
                {
                }
                if (item.name.CompareTo("CheckBox") == 0)
                {
                    CheckBoxButton checkBoxButton = new CheckBoxButton();
                    checkBoxButton.LabelText = "Yes";

                    _contentContainer.AddChild(checkBoxButton, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("RadioButton") == 0)
                {
                    TableView tableView = new TableView(2, 1);
                    tableView.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    tableView.HeightResizePolicy = ResizePolicyType.FillToParent;

                    RadioButton rButton = new RadioButton();
                    rButton.LabelText = "Yes";
                    rButton.Selected  = true;
                    tableView.AddChild(rButton, new TableView.CellPosition(0, 0));

                    rButton           = new RadioButton();
                    rButton.LabelText = "No";

                    tableView.AddChild(rButton, new TableView.CellPosition(1, 0));

                    _contentContainer.AddChild(tableView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("Tooltip") == 0)
                {
                    TableView tableView = new TableView(2, 1);
                    tableView.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    tableView.HeightResizePolicy = ResizePolicyType.FillToParent;

                    // Create two push buttons and add them to a table view
                    PushButton buttonWithSimpleTooltip = new PushButton();
                    buttonWithSimpleTooltip.LabelText         = "Tooltip with text only";
                    buttonWithSimpleTooltip.UnselectedColor   = new Vector4(0.5f, 0.5f, 0.7f, 1.0f);
                    buttonWithSimpleTooltip.SelectedColor     = new Vector4(0.7f, 0.5f, 0.7f, 1.0f);
                    buttonWithSimpleTooltip.WidthResizePolicy = ResizePolicyType.FillToParent;
                    tableView.AddChild(buttonWithSimpleTooltip, new TableView.CellPosition(0, 0));

                    PushButton buttonWithIconTooltip = new PushButton();
                    buttonWithIconTooltip.LabelText         = "Tooltip with Text and Icon";
                    buttonWithIconTooltip.WidthResizePolicy = ResizePolicyType.FillToParent;
                    buttonWithIconTooltip.UnselectedColor   = new Vector4(0.5f, 0.5f, 0.7f, 1.0f);
                    buttonWithIconTooltip.SelectedColor     = new Vector4(0.7f, 0.5f, 0.7f, 1.0f);
                    tableView.AddChild(buttonWithIconTooltip, new TableView.CellPosition(1, 0));

                    // Add a simple text only tooltip to the first push button
                    buttonWithSimpleTooltip.TooltipText = "Simple Tooltip";

                    // Create a property map for a tooltip with one icon and one text
                    PropertyArray iconTooltipContent = new PropertyArray();

                    PropertyMap iconVisual = new PropertyMap();
                    iconVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
                    .Add(ImageVisualProperty.URL, new PropertyValue(_resPath + "/images/star-highlight.png"));
                    iconTooltipContent.Add(new PropertyValue(iconVisual));

                    PropertyMap textVisual = new PropertyMap();
                    textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text))
                    .Add(TextVisualProperty.Text, new PropertyValue("Tooltip with Icon"));
                    iconTooltipContent.Add(new PropertyValue(textVisual));

                    PropertyMap iconTooltip = new PropertyMap();
                    iconTooltip.Add(Tizen.NUI.Constants.Tooltip.Property.Content, new PropertyValue(iconTooltipContent))
                    .Add(Tizen.NUI.Constants.Tooltip.Property.Tail, new PropertyValue(true));

                    // Add the tooltip with icon and text to the second push button
                    buttonWithIconTooltip.Tooltip = iconTooltip;

                    _contentContainer.AddChild(tableView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("Popup") == 0)
                {
                    PushButton button = new PushButton();
                    button.LabelText   = "Popup";
                    button.PivotPoint  = PivotPoint.Center;
                    button.MaximumSize = new Size2D(150, 100);
                    _popup             = CreatePopup();
                    _popup.SetTitle(CreateTitle("Popup"));

                    TextLabel text = new TextLabel("This will erase the file permanently. Are you sure?");
                    text.BackgroundColor    = Color.White;
                    text.MultiLine          = true;
                    text.WidthResizePolicy  = ResizePolicyType.FillToParent;
                    text.HeightResizePolicy = ResizePolicyType.DimensionDependency;
                    text.SetPadding(new PaddingType(10.0f, 10.0f, 20.0f, 0.0f));
                    _popup.SetContent(text);
                    _popup.Focusable = (true);
                    _popup.SetDisplayState(Popup.DisplayStateType.Hidden);

                    button.Clicked += (obj, ee) =>
                    {
                        _window.Add(_popup);
                        _popup.SetDisplayState(Popup.DisplayStateType.Shown);
                        FocusManager.Instance.SetCurrentFocusView((_popup.FindChildByName("Footer")).FindChildByName("OKButton"));
                        return(true);
                    };
                    _contentContainer.AddChild(button, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("Toast") == 0)
                {
                    PushButton button = new PushButton();
                    button.LabelText  = "Toast";
                    button.PivotPoint = PivotPoint.Center;
                    button.Clicked   += (obj, ee) =>
                    {
                        Popup toast = new Popup();
                        toast.SizeModeFactor     = new Vector3(0.75f, 0.75f, 0.75f);
                        toast.WidthResizePolicy  = ResizePolicyType.SizeRelativeToParent;
                        toast.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
                        toast.ContextualMode     = Popup.ContextualModeType.NonContextual;
                        toast.AnimationDuration  = 0.65f;
                        toast.TailVisibility     = false;

                        // Disable the dimmed backing.
                        toast.BackingEnabled = false;

                        // The toast popup should fade in (not zoom).
                        toast.AnimationMode = Popup.AnimationModeType.Fade;

                        // The toast popup should auto-hide.
                        toast.AutoHideDelay = 3000;

                        // Align to the bottom of the screen.
                        toast.ParentOrigin = new Position(0.5f, 0.94f, 0.5f);
                        toast.PivotPoint   = PivotPoint.BottomCenter;

                        // Let events pass through the toast popup.
                        toast.TouchTransparent = true;

                        TextLabel text = new TextLabel("This is a Toast.\nIt will auto-hide itself");
                        text.TextColor           = Color.White;
                        text.MultiLine           = true;
                        text.HorizontalAlignment = HorizontalAlignment.Center;
                        toast.SetTitle(text);
                        _window.Add(toast);
                        toast.DisplayState = Popup.DisplayStateType.Shown;

                        return(true);
                    };
                    _contentContainer.AddChild(button, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
                }
                if (item.name.CompareTo("ItemView") == 0)
                {
                }
            }
            else
            {
                ImageView notSupportView = new ImageView(_resPath + "/images/not_yet_sign.png");
                notSupportView.Size2D    = new Size2D((int)(_window.Size.Width * 0.2f), (int)(_window.Size.Height * 0.25f));
                notSupportView.Focusable = (true);
                _contentContainer.AddChild(notSupportView, new TableView.CellPosition(((uint)idx / 5) * 2 + 1, (uint)idx % 5));
            }
        }
Exemplo n.º 17
0
        void CreateLayout()
        {
            window = Window.Instance;
            window.SetTransparency(true);
            window.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.7f);

            titleLayout      = new TableView(2, 1);
            titleLayout.Name = ("TitleLayout");
            titleLayout.PositionUsesPivotPoint = true;
            titleLayout.ParentOrigin           = ParentOrigin.Center;
            titleLayout.PivotPoint             = PivotPoint.Center;
            var layoutSizeWidth  = window.Size.Width * 0.7f;
            var layoutSizeHeight = window.Size.Height * 0.7f;

            titleLayout.Size2D = new Size2D((int)(layoutSizeWidth), (int)(layoutSizeHeight));
            titleLayout.SetCellPadding(new Size2D(10, 10));
            titleLayout.BackgroundColor = Color.Cyan;
            window.Add(titleLayout);

            title      = new TextLabel("Visual Transition / SVG / AGIF Example");
            title.Name = ("Title");
            title.SetStyleName("Title");
            title.WidthResizePolicy   = ResizePolicyType.FillToParent;
            title.HeightResizePolicy  = ResizePolicyType.UseNaturalSize;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            titleLayout.AddChild(title, new TableView.CellPosition(0, 0));
            titleLayout.SetFitHeight(0);

            contentLayout      = new TableView(3, 2);
            contentLayout.Name = ("ContentLayout");
            contentLayout.WidthResizePolicy  = ResizePolicyType.FillToParent;
            contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
            contentLayout.PivotPoint         = PivotPoint.TopLeft;
            contentLayout.SetCellPadding(new Size2D(10, 10));
            contentLayout.BackgroundColor = Color.Magenta;
            titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0));

            //////////////////////////////////////////////////////////////////////
            // Create a content view
            contentView = new VisualView();
            contentView.WidthResizePolicy  = ResizePolicyType.SizeRelativeToParent;
            contentView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
            //contentView.Size2D = new Size2D(250, 250);
            contentView.BackgroundImage = _resPath + "/images/background-blocks.jpg";

            icon                = new ImageVisual();
            icon.URL            = _resPath + "/images/application-icon-0.png";
            icon.DepthIndex     = 1;
            icon.Size           = new Size2D(50, 50);
            icon.SizePolicy     = VisualTransformPolicyType.Absolute;
            icon.Position       = new Position2D(5, 5);
            icon.PositionPolicy = VisualTransformPolicyType.Absolute;
            icon.Origin         = Visual.AlignType.TopBegin;
            icon.AnchorPoint    = Visual.AlignType.TopBegin;
            icon.MixColor       = new Color(0, 1, 0, 0.5f);
            icon.Opacity        = 0.5f;
            contentView.AddVisual("icon_visual1", icon);

            contentLayout.AddChild(contentView, new TableView.CellPosition(0, 0));

            button1              = new PushButton();
            button1.LabelText    = "Toggle Transition";
            button1.Name         = ("ToggleTransition");
            button1.ParentOrigin = ParentOrigin.Center;
            button1.PivotPoint   = PivotPoint.Center;
            button1.Clicked     += (obj, ev) =>
            {
                active = !active;
                StartTransition(active);
                return(true);
            };
            button1.WidthResizePolicy  = ResizePolicyType.FillToParent;
            button1.HeightResizePolicy = ResizePolicyType.FillToParent;
            button1.Focusable          = true;
            button1.UpFocusableView    = button3;
            button1.DownFocusableView  = button2;
            contentLayout.AddChild(button1, new TableView.CellPosition(0, 1));

            //////////////////////////////////////////////////////////////////////
            // make NPatch visual test
            NPatchVisual npatch1 = new NPatchVisual();

            npatch1.URL            = _resPath + "/images/gallery-2.jpg";
            npatch1.Size           = new Size2D(400, 400);
            npatch1.SizePolicy     = VisualTransformPolicyType.Absolute;
            npatch1.Position       = new Position2D(400, 0);
            npatch1.PositionPolicy = VisualTransformPolicyType.Absolute;
            npatch1.Origin         = Visual.AlignType.TopBegin;
            npatch1.AnchorPoint    = Visual.AlignType.TopBegin;
            npatch1.Border         = new Rectangle(100, 100, 100, 100);
            npatch1.DepthIndex     = 2;
            npatch1.MixColor       = new Color(1, 0, 0, 1);
            npatch1.Opacity        = 0.5f;
            contentView.AddVisual("npatchImageVisual1", npatch1);

            //////////////////////////////////////////////////////////////////////
            // make SVG visual test
            visualView1 = new VisualView();
            visualView1.WidthResizePolicy  = ResizePolicyType.FillToParent;
            visualView1.HeightResizePolicy = ResizePolicyType.FillToParent;
            visualView1.BackgroundColor    = Color.Black;
            contentLayout.AddChild(visualView1, new TableView.CellPosition(1, 0));

            svgVisual                = new SVGVisual();
            svgVisual.URL            = _resPath + "/images/Kid1.svg";
            svgVisual.Size           = new Size2D(300, 300);
            svgVisual.SizePolicy     = VisualTransformPolicyType.Absolute;
            svgVisual.Position       = new Position2D(0, 0);
            svgVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
            svgVisual.Origin         = Visual.AlignType.TopBegin;
            svgVisual.AnchorPoint    = Visual.AlignType.TopBegin;
            visualView1.AddVisual("svg_visual1", svgVisual);

            button2                    = new PushButton();
            button2.LabelText          = "SVG Visual Test";
            button2.Name               = ("svg_visual_test");
            button2.PivotPoint         = PivotPoint.Center;
            button2.WidthResizePolicy  = ResizePolicyType.FillToParent;
            button2.HeightResizePolicy = ResizePolicyType.FillToParent;
            button2.Clicked           += (obj, ev) =>
            {
                cnt1++;
                if (cnt1 % 2 == 0)
                {
                    svgVisual.URL = _resPath + "/images/World.svg";
                }
                else
                {
                    svgVisual.URL = _resPath + "/images/Mail.svg";
                }
                Tizen.Log.Fatal(TAG, "svg button clicked!");
                return(true);
            };
            button2.Focusable         = true;
            button2.UpFocusableView   = button1;
            button2.DownFocusableView = button2;
            contentLayout.AddChild(button2, new TableView.CellPosition(1, 1));

            //////////////////////////////////////////////////////////////////////
            // make AnimatedImage visual test
            visualView2 = new VisualView();
            visualView2.WidthResizePolicy  = ResizePolicyType.FillToParent;
            visualView2.HeightResizePolicy = ResizePolicyType.FillToParent;
            visualView2.BackgroundColor    = Color.Blue;
            contentLayout.AddChild(visualView2, new TableView.CellPosition(2, 0));

            gifVisual                = new AnimatedImageVisual();
            gifVisual.URL            = _resPath + "/images/dog-anim.gif";
            gifVisual.Size           = new Size2D(200, 200);
            gifVisual.SizePolicy     = VisualTransformPolicyType.Absolute;
            gifVisual.Position       = new Position2D(0, 0);
            gifVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
            gifVisual.Origin         = Visual.AlignType.TopBegin;
            gifVisual.AnchorPoint    = Visual.AlignType.TopBegin;
            visualView2.AddVisual("gif_visual", gifVisual);

            button3                    = new PushButton();
            button3.LabelText          = "AnimatedImage Visual Test";
            button3.Name               = ("gif_visual_test");
            button3.PivotPoint         = PivotPoint.Center;
            button3.WidthResizePolicy  = ResizePolicyType.FillToParent;
            button3.HeightResizePolicy = ResizePolicyType.FillToParent;
            button3.Clicked           += (obj, ev) =>
            {
                Tizen.Log.Fatal(TAG, "gif button clicked!");
                cnt2++;
                int gifNum = cnt2 % 15;
                gifVisual.URL     = _resPath + "/images/anim-gif/" + gifNum + ".gif";
                button3.LabelText = "file:" + gifNum + ".gif";
                return(true);
            };
            button3.Focusable         = true;
            button3.DownFocusableView = button1;
            button3.UpFocusableView   = button2;
            contentLayout.AddChild(button3, new TableView.CellPosition(2, 1));

            FocusManager.Instance.SetCurrentFocusView(button1);
        }
        /// <summary>
        /// Create a Image
        /// </summary>
        /// <param name="text">Case string</param>
        /// <param name="position">A position this view will be located</param>
        /// <returns>View for the created Image</returns>
        private View CreateImage(string text, Position position)
        {
            View view = null;

            if (text == caseString[0])
            {
                TableView pixelAreaTableView = new TableView(2, 2);

                // Create 4 images and add them to tableView
                ImageView[] imageView = new ImageView[4];
                for (uint i = 0; i < 2; i++)
                {
                    for (uint j = 0; j < 2; j++)
                    {
                        // Create new ImageView to contain each part of Image
                        imageView[i * 2 + j] = new ImageView(pixelAreaImageUrl);
                        imageView[i * 2 + j].HeightResizePolicy = ResizePolicyType.FillToParent;
                        imageView[i * 2 + j].WidthResizePolicy  = ResizePolicyType.FillToParent;
                        // Put these imageView at different position.
                        pixelAreaTableView.AddChild(imageView[i * 2 + j], new TableView.CellPosition(i, j));
                    }
                }

                view = pixelAreaTableView;
            }
            else if (text == caseString[1])
            {
                //Create an imageView to show the SVG file.
                ImageView imageView = new ImageView(svgImageUrl);
                view = imageView;
            }
            else if (text == caseString[2])
            {
                //Create an imageView to show the GIF file.
                ImageView imageView = new ImageView(gifImageUrl);
                view = imageView;
            }
            else if (text == caseString[3])
            {
                //Create an imageView to show the NinePatch file.
                ImageView imageView = new ImageView(ninePatchImageUrl);
                view = imageView;
            }
            else if (text == caseString[4])
            {
                //Create an imageView to show the Mask.
                ImageView   imageView   = new ImageView();
                PropertyMap propertyMap = new PropertyMap();
                // Image Visual with MaskBackgroundImage
                // Set Image properties of the Image View
                propertyMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
                .Add(ImageVisualProperty.URL, new PropertyValue(maskBackgroundImageUrl));
                imageView.Image = propertyMap;
                view            = imageView;
                masked          = false;
            }
            else if (text == caseString[5])
            {
                //Create an imageView to show the Fitting Mode.
                fittingMode = (int)FittingModeType.ShrinkToFit;
                ImageView   imageView   = new ImageView();
                PropertyMap propertyMap = new PropertyMap();
                // Image Visual with default FittingMode
                // Set Image properties of the Image View
                propertyMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
                .Add(ImageVisualProperty.URL, new PropertyValue(fittingModeImageUrl))
                .Add(ImageVisualProperty.DesiredWidth, new PropertyValue(imageSize.Width))
                .Add(ImageVisualProperty.DesiredHeight, new PropertyValue(imageSize.Height))
                .Add(ImageVisualProperty.FittingMode, new PropertyValue(fittingMode))
                .Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)SamplingModeType.Box));
                imageView.Image = propertyMap;
                view            = imageView;
            }

            if (view != null)
            {
                // View position setting
                view.Size = imageSize;
                view.PositionUsesPivotPoint = true;
                view.PivotPoint             = PivotPoint.Center;
                view.ParentOrigin           = ParentOrigin.CenterLeft;
                view.Position = position;
            }
            return(view);
        }
Exemplo n.º 19
0
        void Initialize()
        {
            Window.Instance.KeyEvent += OnKeyEvent;

            image          = new ImageView();
            image.Size2D   = new Size2D(500, 200);
            image.Position = new Position(750, 275, 0);
            image.PositionUsesPivotPoint = true;
            image.PivotPoint             = PivotPoint.TopLeft;
            image.ParentOrigin           = ParentOrigin.TopLeft;
            image.SetImage(DirectoryInfo.Resource + "tizen_image.jpg");
            Window.Instance.GetDefaultLayer().Add(image);

            _opacityButton     = CreateButton("OpacityAnimation");
            _orientationButton = CreateButton("OrientationAnimation");
            _pixelAreaButton   = CreateButton("pixelAreaAnimation");

            _opacityButton.Clicked     += ButtonClick;
            _orientationButton.Clicked += ButtonClick;
            _pixelAreaButton.Clicked   += ButtonClick;

            TableView tableView = new TableView(1, 3);

            tableView.Size2D       = new Size2D(1300, 330);
            tableView.PivotPoint   = PivotPoint.TopLeft;
            tableView.ParentOrigin = ParentOrigin.TopLeft;
            tableView.Position2D   = new Position2D(400, 800);

            tableView.AddChild(_orientationButton, new TableView.CellPosition(0, 0));
            tableView.AddChild(_opacityButton, new TableView.CellPosition(0, 1));
            tableView.AddChild(_pixelAreaButton, new TableView.CellPosition(0, 2));

            Window.Instance.GetDefaultLayer().Add(tableView);

            opacityAnimation     = new Animation();
            orientationAnimation = new Animation();
            pixelAreaAnimation   = new Animation();

            opacityAnimation = new Animation(1500);
            opacityAnimation.AnimateTo(image, "Opacity", 0.5f, 0, 400);
            opacityAnimation.AnimateTo(image, "Opacity", 0.0f, 400, 800);
            opacityAnimation.AnimateTo(image, "Opacity", 0.7f, 800, 1250);
            opacityAnimation.AnimateTo(image, "Opacity", 1.0f, 1250, 1500);
            opacityAnimation.EndAction = Animation.EndActions.StopFinal;

            orientationAnimation = new Animation();
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(200.0f)), PositionAxis.X), 0, 400);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(60.0f)), PositionAxis.Y), 400, 800);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(new Degree(30.0f)), PositionAxis.Z), 800, 1000);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.X), 1000, 1400);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Y), 1400, 1800);
            orientationAnimation.AnimateTo(image, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Z), 1800, 2200);
            orientationAnimation.EndAction = Animation.EndActions.StopFinal;

            pixelAreaAnimation = new Animation(2000);
            RelativeVector4 vec1 = new RelativeVector4(0.0f, 0.0f, 1.0f, 0.3f);
            RelativeVector4 vec2 = new RelativeVector4(0.6f, 0.0f, 1.0f, 0.4f);
            RelativeVector4 vec3 = new RelativeVector4(0.0f, 0.0f, 1.0f, 1.0f);

            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec1, 0, 500);
            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec2, 500, 1000);
            pixelAreaAnimation.AnimateTo(image, "pixelArea", vec3, 1500, 2000);
            pixelAreaAnimation.EndAction = Animation.EndActions.StopFinal;
        }
Exemplo n.º 20
0
        private void CreateTitle()
        {
            Tizen.Log.Fatal("NUI.ChannelList", "CreateTitle...");
            //Title_area W:0.385937 x H:0.112037
            // Title area,title background image
            ImageView titleBackGround = new ImageView(titleBackGroundImage);

            titleBackGround.SizeWidth  = windowSize.Width * (0.323437f + 0.207812f);//0.385937f
            titleBackGround.SizeHeight = windowSize.Height * 0.112037f;
            contentLayout.AddChild(titleBackGround, new TableView.CellPosition(0, 0));

            //Title area, edit icon background:  0.061458 x 0.108333
            View editBackGround = new View();

            editBackGround.BackgroundColor        = new Vector4(1, 1, 1, 0.09f);
            editBackGround.SizeWidth              = windowSize.Width * 0.061458f;
            editBackGround.SizeHeight             = windowSize.Height * 0.108333f;
            editBackGround.PositionUsesPivotPoint = true;
            editBackGround.PivotPoint             = PivotPoint.TopLeft;
            editBackGround.ParentOrigin           = ParentOrigin.TopLeft;
            editBackGround.Position = new Position(windowSize.Width * (0.323437f + 0.001041f), windowSize.Height * 0.001851f, 0.0f);
            titleBackGround.Add(editBackGround);

            //Title area, edit background
            editBackGround1 = new View();
            editBackGround1.BackgroundColor        = new Vector4(1, 1, 1, 0.09f);
            editBackGround1.SizeWidth              = windowSize.Width * (0.207812f - 0.061458f - 0.001041f * 2);
            editBackGround1.SizeHeight             = windowSize.Height * 0.108333f;
            editBackGround1.PositionUsesPivotPoint = true;
            editBackGround1.PivotPoint             = PivotPoint.TopRight;
            editBackGround1.ParentOrigin           = ParentOrigin.TopRight;
            editBackGround1.Position = new Position(-windowSize.Width * 0.001041f, windowSize.Height * 0.001851f, 0.0f);
            titleBackGround.Add(editBackGround1);
            editBackGround1.Hide();

            //edit icon: 0.019791  x 0.035185
            //Title area, edit icon
            ImageView edit = new ImageView(editImage);

            edit.SizeWidth              = windowSize.Width * 0.019791f;
            edit.SizeHeight             = windowSize.Height * 0.035185f;
            edit.PositionUsesPivotPoint = true;
            edit.PivotPoint             = PivotPoint.Center;
            edit.ParentOrigin           = ParentOrigin.Center;
            edit.Hide();
            editBackGround.Add(edit);

            //edit text
            //Title area, edit text
            TextLabel editText = new TextLabel();

            editText.SizeWidth              = windowSize.Width * (0.207812f - 0.061458f - 0.001041f * 2);
            editText.SizeHeight             = windowSize.Height * 0.047037f;//0.037037f
            editText.PositionUsesPivotPoint = true;
            editText.PivotPoint             = PivotPoint.CenterLeft;
            editText.ParentOrigin           = ParentOrigin.CenterLeft;
            editText.Position            = new Position(windowSize.Width * 0.001041f, windowSize.Height * 0.001851f, 0.0f);
            editText.HorizontalAlignment = HorizontalAlignment.Begin;
            editText.VerticalAlignment   = VerticalAlignment.Center;
            editText.TextColor           = new Color(1, 1, 1, 1);
            //editText.PointSize = 8.0f;
            editText.PointSize  = DeviceCheck.PointSize8;
            editText.FontFamily = "SamsungOne 300";
            editText.Text       = "Select";
            editText.Hide();
            editBackGround1.Add(editText);

            //Title_icon image size: 0.041666 x 0.074074
            //Title area, title icon
            titleIcon                        = new ImageView(titleIconAll);
            titleIcon.SizeWidth              = windowSize.Width * 0.041666f;
            titleIcon.SizeHeight             = windowSize.Height * 0.074074f;
            titleIcon.PositionUsesPivotPoint = true;
            titleIcon.PivotPoint             = PivotPoint.CenterLeft;
            titleIcon.ParentOrigin           = ParentOrigin.CenterLeft;
            titleIcon.Position               = new Position(windowSize.Width * 0.011458f, 0, 0);
            titleBackGround.Add(titleIcon);

            //Title_text size width: 0.322395 - 0.011458f - 0.041666f - 0.010416f * 2
            //Title area, title text
            titleText                        = new TextLabel("All Channels");
            titleText.SizeWidth              = windowSize.Width * (0.385937f - 0.011458f - 0.041666f - 0.010416f * 2 - 0.063541f);
            titleText.SizeHeight             = windowSize.Height * 0.074074f;
            titleText.PositionUsesPivotPoint = true;
            titleText.PivotPoint             = PivotPoint.CenterLeft;
            titleText.ParentOrigin           = ParentOrigin.CenterLeft;
            titleText.Position               = new Position(windowSize.Width * (0.011458f + 0.041666f + 0.010416f), 0, 0);
            titleText.HorizontalAlignment    = HorizontalAlignment.Begin;
            titleText.VerticalAlignment      = VerticalAlignment.Center;
            //titleText.PointSize = 48.0f;
            titleText.PointSize  = DeviceCheck.PointSize10;
            titleText.TextColor  = new Vector4(1, 1, 1, 1);
            titleText.FontFamily = "SamsungOne 300";
            titleBackGround.Add(titleText);
        }
Exemplo n.º 21
0
        public void Initialize()
        {
            Window window = Window.Instance;

            window.BackgroundColor = Color.White;

            TableView titleLayout = new TableView(2, 1);

            titleLayout.Name       = ("TitleLayout");
            titleLayout.PivotPoint = PivotPoint.TopLeft;
            titleLayout.Position2D = new Position2D(10, 10);
            titleLayout.Size2D     = new Size2D((int)(window.Size.Width * 0.9f), (int)(window.Size.Height * 0.9f));
            titleLayout.SetCellPadding(new Size2D(10, 10));
            titleLayout.BackgroundColor = Color.Cyan;
            window.Add(titleLayout);

            _title      = new TextLabel("Visual Transition Example");
            _title.Name = ("Title");
            _title.SetStyleName("Title");
            _title.WidthResizePolicy   = ResizePolicyType.FillToParent;
            _title.HeightResizePolicy  = ResizePolicyType.UseNaturalSize;
            _title.HorizontalAlignment = HorizontalAlignment.Center;
            titleLayout.AddChild(_title, new TableView.CellPosition(0, 0));
            titleLayout.SetFitHeight(0);

            TableView contentLayout = new TableView(2, 1);

            contentLayout.Name = ("ContentLayout");
            contentLayout.WidthResizePolicy  = ResizePolicyType.FillToParent;
            contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
            contentLayout.PivotPoint         = PivotPoint.TopLeft;
            contentLayout.SetCellPadding(new Size2D(10, 10));
            contentLayout.BackgroundColor = Color.Magenta;
            titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0));

            // make visual position animation
            _contentView1 = new VisualView();
            _contentView1.WidthResizePolicy  = ResizePolicyType.SizeRelativeToParent;
            _contentView1.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
            //_contentView.Size2D = new Size2D(250, 250);
            _contentView1.BackgroundImage = _resPath + "/images/background-blocks.jpg";

            _icon                = new ImageVisual();
            _icon.URL            = _resPath + "/images/application-icon-0.png";
            _icon.DepthIndex     = 1;
            _icon.Size           = new Size2D(50, 50);
            _icon.SizePolicy     = VisualTransformPolicyType.Absolute;
            _icon.Position       = new Position2D(5, 5);
            _icon.PositionPolicy = VisualTransformPolicyType.Absolute;
            _icon.Origin         = Visual.AlignType.TopBegin;
            _icon.AnchorPoint    = Visual.AlignType.TopBegin;
            _icon.MixColor       = new Color(0, 1, 0, 0.5f);
            _icon.Opacity        = 0.5f;
            _contentView1.AddVisual("icon_visual1", _icon);

            _icon2                = new ImageVisual();
            _icon2.URL            = _resPath + "/images/application-icon-0.png";
            _icon2.DepthIndex     = 1;
            _icon2.Size           = new Size2D(50, 50);
            _icon2.SizePolicy     = VisualTransformPolicyType.Absolute;
            _icon2.Position       = new Position2D(200, 5);
            _icon2.PositionPolicy = VisualTransformPolicyType.Absolute;
            _icon2.Origin         = Visual.AlignType.TopBegin;
            _icon2.AnchorPoint    = Visual.AlignType.TopBegin;
            _icon2.MixColor       = new Color(0, 1, 0, 0.5f);
            _icon2.Opacity        = 0.5f;
            _contentView1.AddVisual("icon_visual2", _icon2);

            _icon3                = new ImageVisual();
            _icon3.URL            = _resPath + "/images/application-icon-0.png";
            _icon3.DepthIndex     = 1;
            _icon3.Size           = new Size2D(50, 50);
            _icon3.SizePolicy     = VisualTransformPolicyType.Absolute;
            _icon3.Position       = new Position2D(5, 200);
            _icon3.PositionPolicy = VisualTransformPolicyType.Absolute;
            _icon3.Origin         = Visual.AlignType.TopBegin;
            _icon3.AnchorPoint    = Visual.AlignType.TopBegin;
            _icon3.MixColor       = new Color(0, 1, 0, 0.5f);
            _icon3.Opacity        = 0.5f;
            _contentView1.AddVisual("icon_visual3", _icon3);

            _icon4                = new ImageVisual();
            _icon4.URL            = _resPath + "/images/application-icon-0.png";
            _icon4.DepthIndex     = 1;
            _icon4.Size           = new Size2D(50, 50);
            _icon4.SizePolicy     = VisualTransformPolicyType.Absolute;
            _icon4.Position       = new Position2D(200, 200);
            _icon4.PositionPolicy = VisualTransformPolicyType.Absolute;
            _icon4.Origin         = Visual.AlignType.TopBegin;
            _icon4.AnchorPoint    = Visual.AlignType.TopBegin;
            _icon4.MixColor       = new Color(0, 1, 0, 0.5f);
            _icon4.Opacity        = 0.5f;
            _contentView1.AddVisual("icon_visual4", _icon4);

            contentLayout.AddChild(_contentView1, new TableView.CellPosition(0, 0));

            _shadowButton1              = new PushButton();
            _shadowButton1.LabelText    = "Toggle Transition Position";
            _shadowButton1.Name         = ("ToggleTransition");
            _shadowButton1.ParentOrigin = ParentOrigin.Center;
            _shadowButton1.PivotPoint   = PivotPoint.Center;
            _shadowButton1.Clicked     += (obj, ev) =>
            {
                _active1 = !_active1;
                StartTransition(_contentView1, _active1);
                return(true);
            };
            _shadowButton1.WidthResizePolicy  = ResizePolicyType.FillToParent;
            _shadowButton1.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
            contentLayout.AddChild(_shadowButton1, new TableView.CellPosition(1, 0));
            contentLayout.SetFitHeight(1);
        }
        /// <summary>
        /// Flex Container Sample Application initialisation.
        /// </summary>
        public void Initialize()
        {
            Window.Instance.BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 1.0f);

            // Create FlexContainer
            flexContainer = new FlexContainer();
            flexContainer.PositionUsesPivotPoint = true;
            flexContainer.PivotPoint             = PivotPoint.TopLeft;
            flexContainer.ParentOrigin           = ParentOrigin.TopLeft;
            flexContainer.Position        = new Position(220, 160, 0);
            flexContainer.SizeWidth       = 700;
            flexContainer.SizeHeight      = 700;
            flexContainer.BackgroundColor = Color.Yellow;
            flexContainer.FlexDirection   = FlexContainer.FlexDirectionType.Column;
            Window.Instance.GetDefaultLayer().Add(flexContainer);

            // Create flex items and add them to the container
            for (int i = 0; i < NUM_FLEX_ITEMS; i++)
            {
                TextLabel flexItem = new TextLabel();
                flexItem.PositionUsesPivotPoint = true;
                flexItem.PivotPoint             = PivotPoint.TopLeft;
                flexItem.ParentOrigin           = ParentOrigin.TopLeft;
                // Set different background colour to help to identify different items
                flexItem.BackgroundColor     = new Vector4(((float)i) / NUM_FLEX_ITEMS, ((float)(NUM_FLEX_ITEMS - i)) / NUM_FLEX_ITEMS, 1.0f, 1.0f);
                flexItem.Text                = i + "";
                flexItem.Name                = i + "";
                flexItem.HorizontalAlignment = HorizontalAlignment.Center;
                flexItem.VerticalAlignment   = VerticalAlignment.Center;
                // Set a fixed size to the items so that we can wrap the line and test these
                // flex properties that only work when there are multiple lines in the layout
                flexItem.WidthResizePolicy  = ResizePolicyType.Fixed;
                flexItem.HeightResizePolicy = ResizePolicyType.Fixed;
                // Make sure there are still extra space in the line after wrapping
                flexItem.SizeWidth  = flexContainer.SizeWidth / NUM_FLEX_ITEMS * 1.25f;
                flexItem.SizeHeight = flexContainer.SizeHeight / NUM_FLEX_ITEMS * 1.25f;
                flexContainer.Add(flexItem);
            }

            // Create the tableView which is the parent of the Pushbuttons
            // which can change the flexcontainer's properties
            tableView                        = new TableView(6, 1);
            tableView.SizeWidth              = 500;
            tableView.SizeHeight             = 400;
            tableView.CellPadding            = new Vector2(5, 5);
            tableView.PositionUsesPivotPoint = true;
            tableView.PivotPoint             = PivotPoint.BottomRight;
            tableView.ParentOrigin           = ParentOrigin.BottomRight;
            tableView.Position               = new Position(-100, -100, 0);
            Window.Instance.GetDefaultLayer().Add(tableView);

            // Create the pushbutton which can change the property of ContentDirection.
            // The default value of flexcontainer's ContentDirection
            // is FlexContainer.ContentDirectionType.Inherit.
            PushButton button0 = new PushButton();

            button0.Name      = "ContentDirection";
            button0.Label     = CreateText("ContentDirection : Inherit");
            button0.SizeWidth = tableView.SizeWidth;
            button0.Focusable = true;
            button0.Clicked  += ButtonClick;
            tableView.AddChild(button0, new TableView.CellPosition(0, 0));

            // Create the pushbutton which can change the property of FlexDirection.
            // The current value of flexcontainer's FlexDirection
            // is FlexContainer.ContentDirectionType.Column
            PushButton button1 = new PushButton();

            button1.Name      = "FlexDirection";
            button1.Label     = CreateText("FlexDirection : Column");
            button1.SizeWidth = tableView.SizeWidth;
            button1.Clicked  += ButtonClick;
            tableView.AddChild(button1, new TableView.CellPosition(1, 0));

            // Create the pushbutton which can change the property of FlexWrap
            // The current value of flexcontainer's FlexWrap
            // is FlexContainer.WrapType.NoWrap
            PushButton button2 = new PushButton();

            button2.Name      = "FlexWrap";
            button2.Label     = CreateText("FlexWrap : NoWrap");
            button2.SizeWidth = tableView.SizeWidth;
            button2.Clicked  += ButtonClick;
            tableView.AddChild(button2, new TableView.CellPosition(2, 0));

            // Create the pushbutton which can change the property of JustifyContent
            // The current value of flexcontainer's JustifyContent
            // is FlexContainer.Justification.JustifyFlexStart
            PushButton button3 = new PushButton();

            button3.Name      = "JustifyContent";
            button3.Label     = CreateText("JustifyContent : JustifyFlexStart");
            button3.SizeWidth = tableView.SizeWidth;
            button3.Clicked  += ButtonClick;
            tableView.AddChild(button3, new TableView.CellPosition(3, 0));

            // Create the pushbutton which can change the property of AlignItems
            // The current value of flexcontainer's AlignItems
            // is FlexContainer.Alignment.AlignStretch
            PushButton button4 = new PushButton();

            button4.Name      = "AlignItems";
            button4.Label     = CreateText("AlignItems : AlignStretch");
            button4.SizeWidth = tableView.SizeWidth;
            button4.Clicked  += ButtonClick;
            tableView.AddChild(button4, new TableView.CellPosition(4, 0));

            // Create the pushbutton which can change the property of AlignContent
            // The current value of flexcontainer's AlignContent
            // is FlexContainer.Alignment.AlignFlexStart
            PushButton button5 = new PushButton();

            button5.Name      = "AlignContent";
            button5.Label     = CreateText("AlignContent : AlignFlexStart");
            button5.SizeWidth = tableView.SizeWidth;
            button5.Clicked  += ButtonClick;
            tableView.AddChild(button5, new TableView.CellPosition(5, 0));

            FocusManager.Instance.SetCurrentFocusView(button0);
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Flex Container Sample Application initialisation.
        /// </summary>
        public void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            View focusIndicator = new View();

            FocusManager.Instance.FocusIndicator = focusIndicator;

            //Create a title, and add it to window
            guide = new TextLabel();
            guide.HorizontalAlignment    = HorizontalAlignment.Center;
            guide.VerticalAlignment      = VerticalAlignment.Center;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D     = new Size2D(1920, 96);
            guide.FontFamily = "Samsung One 600";
            guide.Position2D = new Position2D(0, 94);
            guide.MultiLine  = false;
            //guide.PointSize = 15.0f;
            guide.PointSize = DeviceCheck.PointSize15;
            guide.Text      = "FlexContainer Sample \n";
            guide.TextColor = Color.White;
            //guide.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            Window.Instance.GetDefaultLayer().Add(guide);

            // Create FlexContainer
            flexContainer = new FlexContainer();
            flexContainer.PositionUsesPivotPoint = true;
            flexContainer.PivotPoint             = PivotPoint.TopLeft;
            flexContainer.ParentOrigin           = ParentOrigin.TopLeft;
            flexContainer.Position        = new Position(710, 275, 0);
            flexContainer.SizeWidth       = 400;
            flexContainer.SizeHeight      = 400;
            flexContainer.BackgroundColor = Color.White;
            flexContainer.FlexDirection   = FlexContainer.FlexDirectionType.Column;
            Window.Instance.GetDefaultLayer().Add(flexContainer);

            // Create flex items and add them to the container
            for (int i = 0; i < NUM_FLEX_ITEMS; i++)
            {
                TextLabel flexItem = new TextLabel();
                flexItem.PositionUsesPivotPoint = true;
                flexItem.PivotPoint             = PivotPoint.TopLeft;
                flexItem.ParentOrigin           = ParentOrigin.TopLeft;
                // Set different background colour to help to identify different items
                flexItem.BackgroundColor = new Vector4(((float)i) / NUM_FLEX_ITEMS, ((float)(NUM_FLEX_ITEMS - i)) / NUM_FLEX_ITEMS, 1.0f, 1.0f);
                //flexItem.Text = i + "";
                flexItem.Name = i + "";
                flexItem.HorizontalAlignment = HorizontalAlignment.Center;
                flexItem.VerticalAlignment   = VerticalAlignment.Center;
                // Set a fixed size to the items so that we can wrap the line and test these
                // flex properties that only work when there are multiple lines in the layout
                flexItem.WidthResizePolicy  = ResizePolicyType.Fixed;
                flexItem.HeightResizePolicy = ResizePolicyType.Fixed;
                // Make sure there are still extra space in the line after wrapping
                flexItem.SizeWidth  = flexContainer.SizeWidth / NUM_FLEX_ITEMS * 1.25f;
                flexItem.SizeHeight = flexContainer.SizeHeight / NUM_FLEX_ITEMS * 1.25f;
                flexContainer.Add(flexItem);
            }

            // Create the tableView which is the parent of the Pushbuttons
            // which can change the flexcontainer's properties
            tableView              = new TableView(2, 3);
            tableView.Position2D   = new Position2D(80, 880);
            tableView.SizeWidth    = 1800;
            tableView.SizeHeight   = 180;
            tableView.PivotPoint   = PivotPoint.TopLeft;
            tableView.ParentOrigin = ParentOrigin.TopLeft;
            //tableView.CellPadding = new Vector2(15, 10);
            Window.Instance.GetDefaultLayer().Add(tableView);

            string[] btnName  = { "ContentDirection", "FlexDirection", "FlexWrap", "JustifyContent", "AlignItems", "AlignContent" };
            string[] btnLabel = { "ContentDirection : Inherit", "FlexDirection : Column", "FlexWrap : NoWrap", "JustifyContent : JustifyFlexStart", "AlignItems : AlignStretch", "AlignContent : AlignFlexStart" };

            for (uint row = 0; row < 2; row++)
            {
                for (uint column = 0; column < 3; column++)
                {
                    PushButton button = CreateButton(btnName[row * 3 + column], btnLabel[row * 3 + column]);
                    button.SizeWidth  = 560;
                    button.SizeHeight = 80;
                    button.Focusable  = true;
                    button.Clicked   += ButtonClick;
                    tableView.AddChild(button, new TableView.CellPosition(row, column));
                    if (0 == row && column == 0)
                    {
                        FocusManager.Instance.SetCurrentFocusView(button);
                    }

                    buttonArray[row * 3 + column] = button;
                }
            }

            buttonArray[5].Opacity    = 0.0f;
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Animation Sample Application initialisation.
        /// </summary>
        private void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            View focusIndicator = new View();

            FocusManager.Instance.FocusIndicator = focusIndicator;

            _positionButton             = CreateButton("Position", "PositionAnimation");
            _sizeButton                 = CreateButton("Size", "SizeAnimation");
            _scaleButton                = CreateButton("Scale", "ScaleAnimation");
            _orientationButton          = CreateButton("Orientation", "OrientationAnimation");
            _opacityButton              = CreateButton("Opacity", "OpacityAnimation");
            _pixelAreaButton            = CreateButton("PixelArea", "PixelAreaAnimation");
            _PositionSizeOpacity        = CreateButton("PositionSizeOpacity", "Position + Size + Opacity animation at same time!");
            _PositionSizeOpacity.Size2D = new Size2D(1400, 80);
            //Set the callback of button's clicked event
            _positionButton.ClickEvent      += ButtonClick;
            _sizeButton.ClickEvent          += ButtonClick;
            _scaleButton.ClickEvent         += ButtonClick;
            _orientationButton.ClickEvent   += ButtonClick;
            _opacityButton.ClickEvent       += ButtonClick;
            _pixelAreaButton.ClickEvent     += ButtonClick;
            _PositionSizeOpacity.ClickEvent += ButtonClick;

            //Create a tableView as the container of the pushButton.
            TableView tableView = new TableView(3, 3);

            tableView.Size2D       = new Size2D(1500, 440);
            tableView.PivotPoint   = PivotPoint.TopLeft;
            tableView.ParentOrigin = ParentOrigin.TopLeft;
            tableView.Position2D   = new Position2D(260, 630);

            tableView.AddChild(_positionButton, new TableView.CellPosition(0, 0));
            tableView.AddChild(_sizeButton, new TableView.CellPosition(0, 1));
            tableView.AddChild(_scaleButton, new TableView.CellPosition(0, 2));
            tableView.AddChild(_orientationButton, new TableView.CellPosition(1, 0));
            tableView.AddChild(_opacityButton, new TableView.CellPosition(1, 1));
            tableView.AddChild(_pixelAreaButton, new TableView.CellPosition(1, 2));
            tableView.AddChild(_PositionSizeOpacity, new TableView.CellPosition(2, 0, 1, 3));

            Window.Instance.GetDefaultLayer().Add(tableView);
            FocusManager.Instance.SetCurrentFocusView(_positionButton);

            //This textLable is used to show the title.
            guide = new TextLabel();
            guide.HorizontalAlignment = HorizontalAlignment.Center;
            guide.VerticalAlignment   = VerticalAlignment.Center;
            //guide.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f);
            guide.TextColor = Color.White;
            guide.PositionUsesPivotPoint = true;
            guide.ParentOrigin           = ParentOrigin.TopLeft;
            guide.PivotPoint             = PivotPoint.TopLeft;
            guide.Size2D     = new Size2D(1920, 96);
            guide.FontFamily = "Samsung One 600";
            guide.Position2D = new Position2D(0, 94);
            guide.MultiLine  = false;
            //guide.PointSize = 15.0f;
            guide.PointSize = PointSize15;

            guide.Text = "Animation Sample";
            Window.Instance.GetDefaultLayer().Add(guide);

            // Create the view to animate.
            view          = new ImageView();
            view.Size2D   = new Size2D(200, 200);
            view.Position = new Position(860, 275, 0);
            view.PositionUsesPivotPoint = true;
            view.PivotPoint             = PivotPoint.TopLeft;
            view.ParentOrigin           = ParentOrigin.TopLeft;
            view.ResourceUrl            = resources + "/gallery-2.jpg";

            // Add view on Window.
            Window.Instance.GetDefaultLayer().Add(view);

            // Create the position animation.
            // The duration of the animation is 1.5s;
            positionAnimation          = new Animation();
            positionAnimation.Duration = 1500;
            // Sets the default alpha function for the animation.
            positionAnimation.DefaultAlphaFunction = new AlphaFunction(new Vector2(0.3f, 0), new Vector2(0.15f, 1));
            // To reset the view's position.
            positionAnimation.AnimateTo(view, "Position", new Position(100, 150, 0), 0, 0);
            positionAnimation.AnimateTo(view, "Position", new Position(300, 200, 0), 0, 300);
            positionAnimation.AnimateTo(view, "Position", new Position(500, 200, 0), 0, 800);
            positionAnimation.AnimateTo(view, "Position", new Position(600, 250, 0), 0, 1000);
            positionAnimation.AnimateTo(view, "Position", new Position(860, 265, 0), 0, 1500);
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            positionAnimation.EndAction = Animation.EndActions.StopFinal;

            // Create the size animation using AnimateTo.
            sizeAnimation = new Animation(1000);
            sizeAnimation.AnimateTo(view, "size", new Vector3(view.SizeWidth, view.SizeHeight, 0));
            sizeAnimation.AnimateTo(view, "sizeWidth", view.SizeWidth * 1.25f);
            sizeAnimation.AnimateTo(view, "sizeHeight", view.SizeHeight * 1.25f);
            sizeAnimation.AnimateTo(view, "sizeDepth", 0);
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            sizeAnimation.EndAction = Animation.EndActions.StopFinal;

            // Create the scale animation using AnimateTo.
            scaleAnimation = new Animation(1500);
            scaleAnimation.AnimateTo(view, "scale", new Vector3(1.2f, 1.2f, 1.0f), 0, 200, new AlphaFunction(AlphaFunction.BuiltinFunctions.Sin));
            scaleAnimation.AnimateTo(view, "scaleX", 1.5f, 200, 500, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
            scaleAnimation.AnimateTo(view, "ScaleY", 1.5f, 500, 800, new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce));
            scaleAnimation.AnimateTo(view, "scaleX", 1.0f, 800, 1200, new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce));
            scaleAnimation.AnimateTo(view, "scaleX", 1.0f, 1200, 1500, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            scaleAnimation.EndAction = Animation.EndActions.StopFinal;

            // Create the orientation animation using AnimateTo.
            orientationAnimation = new Animation();
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(new Degree(60.0f)), PositionAxis.X), 0, 400);
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(new Degree(60.0f)), PositionAxis.Y), 400, 800);
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(new Degree(60.0f)), PositionAxis.Z), 800, 1000);
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.X), 1000, 1400);
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Y), 1400, 1800);
            orientationAnimation.AnimateTo(view, "Orientation", new Rotation(new Radian(0.0f), PositionAxis.Z), 1800, 2200);
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            orientationAnimation.EndAction = Animation.EndActions.StopFinal;

            // Create the Opacity animation using AnimateTo.
            opacityAnimation = new Animation(1500);
            opacityAnimation.AnimateTo(view, "Opacity", 0.5f, 0, 400);
            opacityAnimation.AnimateTo(view, "Opacity", 0.0f, 400, 800);
            opacityAnimation.AnimateTo(view, "Opacity", 0.5f, 800, 1250);
            opacityAnimation.AnimateTo(view, "Opacity", 1.0f, 1250, 1500);
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            opacityAnimation.EndAction = Animation.EndActions.StopFinal;

            // Create the pixelArea animation using AnimateTo.
            pixelArealAnimation = new Animation(2000);
            RelativeVector4 vec1 = new RelativeVector4(0.0f, 0.0f, 0.5f, 0.5f);
            RelativeVector4 vec2 = new RelativeVector4(0.0f, 0.0f, 0.0f, 0.0f);
            RelativeVector4 vec3 = new RelativeVector4(0.0f, 0.0f, 1.0f, 1.0f);

            pixelArealAnimation.AnimateTo(view, "pixelArea", vec1, 0, 500);
            pixelArealAnimation.AnimateTo(view, "pixelArea", vec2, 500, 1000);
            pixelArealAnimation.AnimateTo(view, "pixelArea", vec1, 1000, 1500);
            pixelArealAnimation.AnimateTo(view, "pixelArea", vec3, 1500, 2000);
            //StopFinal: If the animation is stopped, the animated property values are saved as if the animation had run to completion
            pixelArealAnimation.EndAction = Animation.EndActions.StopFinal;

            view.Focusable            = true;
            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 25
0
        public void Activate()
        {
            Window.Instance.BackgroundColor = Color.White;
            root            = new SampleLayout();
            root.HeaderText = "CheckBox";

            if (styles.Length == 0 || applications.Length == 0)
            {
                return;
            }
            colNum = (uint)applications.Length + 1;
            rowNum = (uint)styles.Length + 1;

            table = new TableView(rowNum, colNum)
            {
                Size2D = new Size2D(1080, 1920),
            };
            for (uint i = 1; i < rowNum; i++)
            {
                TextLabel text = new TextLabel();
                text.Size2D              = new Size2D(Width, Height);
                text.PointSize           = 12;
                text.Focusable           = true;
                text.HorizontalAlignment = HorizontalAlignment.Center;
                text.VerticalAlignment   = VerticalAlignment.Center;
                text.Text = styles[i - 1];
                table.AddChild(text, new TableView.CellPosition(i, 0));
            }

            for (uint i = 1; i < colNum; i++)
            {
                TextLabel text = new TextLabel();
                text.Size2D              = new Size2D(Width, Height);
                text.PointSize           = 12;
                text.HorizontalAlignment = HorizontalAlignment.Center;
                text.VerticalAlignment   = VerticalAlignment.Center;
                text.Text      = applications[i - 1];
                text.Focusable = true;
                table.AddChild(text, new TableView.CellPosition(0, i));
            }
            group = new CheckBoxGroup[4];
            for (uint j = 1; j < colNum; j++)
            {
                group[j - 1] = new CheckBoxGroup();
                for (uint i = 1; i < rowNum; i++)
                {
                    Tizen.NUI.CommonUI.CheckBox checkBox = new Tizen.NUI.CommonUI.CheckBox("CheckBox");
                    checkBox.Size2D = new Size2D(48, 48);
                    if (i == 3)
                    {
                        checkBox.IsEnabled = false;
                    }
                    else if (i == 4)
                    {
                        checkBox.IsEnabled  = false;
                        checkBox.IsSelected = true;
                    }
                    else
                    {
                        group[j - 1].Add(checkBox);
                    }
                    checkBox.Focusable = true;
                    //checkBox.Text = checkBox.IsSelected.ToString();
                    checkBox.SelectedEvent += CheckBoxSelectedEvent;
                    table.AddChild(checkBox, new TableView.CellPosition(i, j));
                }
            }

            for (uint i = 0; i < rowNum; i++)
            {
                table.SetFixedHeight(i, Height);
                for (uint j = 0; j < colNum; j++)
                {
                    table.SetFixedWidth(j, Width);
                    table.SetCellAlignment(new TableView.CellPosition(i, j), HorizontalAlignmentType.Center, VerticalAlignmentType.Center);
                }
            }

            root.Add(table);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Flex Container Sample Application initialization.
        /// </summary>
        public void Initialize()
        {
            Window.Instance.BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 1.0f);

            // Create a 3 * 3 tableView
            // The tableView will be put nine same images.
            // These images will do PixelArea animation to mosaic a bigger image
            tableView        = new TableView(3, 3);
            tableView.Size2D = new Size2D(600, 600);
            tableView.PositionUsesPivotPoint = true;
            tableView.PivotPoint             = PivotPoint.TopLeft;
            tableView.ParentOrigin           = ParentOrigin.TopLeft;
            tableView.Position2D             = new Position2D(100, 100);
            Window.Instance.GetDefaultLayer().Add(tableView);

            // Create nine image Views whose imageurl are same.
            imageView = new ImageView[9];
            for (uint i = 0; i < 3; i++)
            {
                for (uint j = 0; j < 3; j++)
                {
                    imageView[i * 3 + j] = new ImageView(image_jpg);
                    imageView[i * 3 + j].HeightResizePolicy = ResizePolicyType.FillToParent;
                    imageView[i * 3 + j].WidthResizePolicy  = ResizePolicyType.FillToParent;
                    // Put these imageView at different position.
                    tableView.AddChild(imageView[i * 3 + j], new TableView.CellPosition(i, j));
                }
            }

            // Create a imageView who will show jpg image
            // The ImageView will do the animation that image repeat 3 on  u coordinate
            animatedImage                        = new ImageView();
            animatedImage.SizeWidth              = 200;
            animatedImage.SizeHeight             = 200;
            animatedImage.PositionUsesPivotPoint = true;
            animatedImage.PivotPoint             = PivotPoint.Center;
            animatedImage.ParentOrigin           = ParentOrigin.TopLeft;
            animatedImage.Position2D             = tableView.Position2D + new Position2D((int)(tableView.SizeWidth + animatedImage.SizeWidth * 1.5 + 100), (int)animatedImage.SizeHeight / 2);
            PropertyMap map = new PropertyMap();

            map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.AnimatedImage))
            .Add(ImageVisualProperty.URL, new PropertyValue(image_gif))
            .Add(ImageVisualProperty.WrapModeU, new PropertyValue((int)WrapModeType.Repeat))
            .Add(ImageVisualProperty.WrapModeV, new PropertyValue((int)WrapModeType.Default));
            animatedImage.ImageMap = map;
            Window.Instance.GetDefaultLayer().Add(animatedImage);

            // Create a imageView who will show svg image
            // The SVG <image> element allows for raster images
            // to be rendered within an SVG object.
            svgImage                        = new ImageView(image_svg);
            svgImage.SizeWidth              = 200;
            svgImage.SizeHeight             = 200;
            svgImage.PositionUsesPivotPoint = true;
            svgImage.PivotPoint             = PivotPoint.Center;
            svgImage.ParentOrigin           = ParentOrigin.TopLeft;
            svgImage.Position2D             = animatedImage.Position2D + new Position2D(0, (int)animatedImage.SizeHeight + 200);
            Window.Instance.GetDefaultLayer().Add(svgImage);

            // Create a image which be used to show the property of FittingMode and SamplingMode
            // Set FittingModeType is ShrinkToFit.
            // Set SamplingModeType is Box.
            image        = new ImageView();
            image.Size2D = new Size2D(200, 200);
            pngImageMap  = new PropertyMap();
            pngImageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image))
            .Add(ImageVisualProperty.URL, new PropertyValue(image_png))
            .Add(ImageVisualProperty.DesiredWidth, new PropertyValue(200))
            .Add(ImageVisualProperty.DesiredHeight, new PropertyValue(200))
            .Add(ImageVisualProperty.FittingMode, new PropertyValue((int)FittingModeType.ShrinkToFit))
            .Add(ImageVisualProperty.SamplingMode, new PropertyValue((int)SamplingModeType.Box));
            fittingMode    = (int)FittingModeType.ShrinkToFit;
            samplingMode   = (int)SamplingModeType.Box;
            image.ImageMap = pngImageMap;
            image.PositionUsesPivotPoint = true;
            image.PivotPoint             = PivotPoint.Center;
            image.ParentOrigin           = ParentOrigin.TopLeft;
            image.Position2D             = animatedImage.Position2D + new Position2D((int)(animatedImage.SizeWidth * 1.5 + image.SizeWidth / 2 + 100), 0);
            Window.Instance.GetDefaultLayer().Add(image);

            // Create a PushButton which control imageView[] do the pixelArea animation
            pushButton       = new PushButton();
            pushButton.Label = CreateText("PixelArea");
            pushButton.PositionUsesPivotPoint = true;
            pushButton.PivotPoint             = PivotPoint.Center;
            pushButton.ParentOrigin           = ParentOrigin.TopLeft;
            pushButton.Position2D             = tableView.Position2D + new Position2D((int)tableView.SizeWidth / 2 - 100, (int)tableView.SizeHeight + 50);
            pushButton.Clicked  += PixelAreaButtonClick;
            pushButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(pushButton);

            // Create onOffButton which can make imageview[0] show or hide.
            onOffButton       = new PushButton();
            onOffButton.Label = CreateText("OnOff");
            onOffButton.PositionUsesPivotPoint = true;
            onOffButton.PivotPoint             = PivotPoint.Center;
            onOffButton.ParentOrigin           = ParentOrigin.TopLeft;
            onOffButton.Position2D             = tableView.Position2D + new Position2D((int)tableView.SizeWidth / 2 + 100, (int)tableView.SizeHeight + 50);
            onOffButton.Clicked  += OnOffButtonClick;
            onOffButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(onOffButton);

            // Create animatedButton which can make animatedImage do
            // the animation of PixelArea and Scale
            animatedButton       = new PushButton();
            animatedButton.Label = CreateText("Animate PixelArea & Scale");
            animatedButton.PositionUsesPivotPoint = true;
            animatedButton.PivotPoint             = PivotPoint.Center;
            animatedButton.ParentOrigin           = ParentOrigin.TopLeft;
            animatedButton.Position2D             = animatedImage.Position2D + new Position2D(0, (int)animatedImage.SizeHeight / 2 + 50);
            animatedButton.Clicked  += AnimatedButtonClick;
            animatedButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(animatedButton);

            // Create zoomInButton which can make svgImage bigger
            zoomInButton       = new PushButton();
            zoomInButton.Label = CreateText("Zoom In");
            zoomInButton.PositionUsesPivotPoint = true;
            zoomInButton.PivotPoint             = PivotPoint.Center;
            zoomInButton.ParentOrigin           = ParentOrigin.TopLeft;
            zoomInButton.Position2D             = svgImage.Position2D + new Position2D(-200, (int)svgImage.SizeHeight / 2 + 50);
            zoomInButton.Clicked  += ZoomInButtonClick;
            zoomInButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(zoomInButton);

            // Create zoomOutButton which can make svgImage smaller
            zoomOutButton       = new PushButton();
            zoomOutButton.Label = CreateText("Zoom Out");
            zoomOutButton.PositionUsesPivotPoint = true;
            zoomOutButton.PivotPoint             = PivotPoint.Center;
            zoomOutButton.ParentOrigin           = ParentOrigin.TopLeft;
            zoomOutButton.Position2D             = svgImage.Position2D + new Position2D(0, (int)svgImage.SizeHeight / 2 + 50);
            zoomOutButton.Clicked  += ZoomOutButtonClick;
            zoomOutButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(zoomOutButton);

            // Create resetButton which can make svgImage's size to the original size
            resetButton       = new PushButton();
            resetButton.Label = CreateText("Reset");
            resetButton.PositionUsesPivotPoint = true;
            resetButton.PivotPoint             = PivotPoint.Center;
            resetButton.ParentOrigin           = ParentOrigin.TopLeft;
            resetButton.Position2D             = svgImage.Position2D + new Position2D(200, (int)svgImage.SizeHeight / 2 + 50);
            resetButton.Focusable = true;
            resetButton.Clicked  += (obj, e) =>
            {
                svgScale        = 1;
                svgImage.Size2D = new Vector2(200, 200);
                return(true);
            };
            Window.Instance.GetDefaultLayer().Add(resetButton);

            // Create fittingModeButton which can change image's FittingMode
            fittingModeButton           = new PushButton();
            fittingModeButton.SizeWidth = 400;
            fittingModeButton.Label     = CreateText("FittingMode : ShrinkToFit");
            fittingModeButton.PositionUsesPivotPoint = true;
            fittingModeButton.PivotPoint             = PivotPoint.Center;
            fittingModeButton.ParentOrigin           = ParentOrigin.TopLeft;
            fittingModeButton.Position2D             = image.Position2D + new Position2D(0, (int)image.SizeHeight / 2 + 50);
            fittingModeButton.Clicked  += FittingModeButtonClick;
            fittingModeButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(fittingModeButton);

            // Create samplingModeButton which can change image's SamplingMode
            samplingModeButton           = new PushButton();
            samplingModeButton.SizeWidth = 400;
            samplingModeButton.Label     = CreateText("SamplingMode : Box");
            samplingModeButton.PositionUsesPivotPoint = true;
            samplingModeButton.PivotPoint             = PivotPoint.Center;
            samplingModeButton.ParentOrigin           = ParentOrigin.TopLeft;
            samplingModeButton.Position2D             = image.Position2D + new Position2D(0, (int)image.SizeHeight / 2 + 120);
            samplingModeButton.Clicked  += SamplingModeButtonClick;
            samplingModeButton.Focusable = true;
            Window.Instance.GetDefaultLayer().Add(samplingModeButton);

            // Set pushButton as the current focus view
            FocusManager.Instance.SetCurrentFocusView(pushButton);
            FocusManager.Instance.PreFocusChange += PreFocusChange;

            // Control the rule of moving focus view when the direction key entered
            pushButton.RightFocusableView       = onOffButton;
            onOffButton.RightFocusableView      = zoomInButton;
            onOffButton.LeftFocusableView       = pushButton;
            zoomInButton.LeftFocusableView      = onOffButton;
            zoomInButton.RightFocusableView     = zoomOutButton;
            zoomInButton.UpFocusableView        = animatedButton;
            zoomOutButton.LeftFocusableView     = zoomInButton;
            zoomOutButton.RightFocusableView    = resetButton;
            zoomOutButton.UpFocusableView       = animatedButton;
            resetButton.LeftFocusableView       = zoomOutButton;
            resetButton.UpFocusableView         = animatedButton;
            animatedButton.RightFocusableView   = fittingModeButton;
            animatedButton.DownFocusableView    = zoomInButton;
            fittingModeButton.LeftFocusableView = animatedButton;
            fittingModeButton.DownFocusableView = samplingModeButton;
            samplingModeButton.UpFocusableView  = fittingModeButton;

            Window.Instance.KeyEvent += AppBack;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Create buttons which control properties of textfield/textLabel/textEditor
        /// </summary>
        private void CreateButtons()
        {
            // Create tableView used to put pushButton.
            tableView = new TableView(4, 4);
            // Set the position of tableView.
            tableView.PositionUsesPivotPoint = true;
            tableView.PivotPoint             = PivotPoint.TopCenter;
            tableView.ParentOrigin           = ParentOrigin.TopCenter;
            tableView.Position = new Position(0, 700, 0);
            // The size of tableView is 800 * 300;
            tableView.Size2D          = new Size2D(800, 300);
            tableView.BackgroundColor = Color.Cyan;
            Window.Instance.GetDefaultLayer().Add(tableView);

            pushButton = new PushButton[6];
            // Creates button[0] which control HorizontalAlignment
            pushButton[0]           = new PushButton();
            pushButton[0].Label     = CreateText("HorizontalAlignment");
            pushButton[0].SizeWidth = tableView.SizeWidth / 2;
            // Bind pushButton's click event to ButtonClick.
            pushButton[0].Clicked += ButtonClick;
            tableView.AddChild(pushButton[0], new TableView.CellPosition(0, 0));

            // Creates button[1] which control VerticalAlignment
            pushButton[1]           = new PushButton();
            pushButton[1].Label     = CreateText("VerticalAlignment");
            pushButton[1].SizeWidth = tableView.SizeWidth / 2;
            // Bind pushButton's click event to ButtonClick.
            pushButton[1].Clicked += ButtonClick;
            tableView.AddChild(pushButton[1], new TableView.CellPosition(0, 2));

            // Creates button[2] which control Color
            pushButton[2]           = new PushButton();
            pushButton[2].Label     = CreateText("Color");
            pushButton[2].SizeWidth = tableView.SizeWidth / 4;
            // Bind pushButton's click event to ButtonClick.
            pushButton[2].Clicked += ButtonClick;
            tableView.AddChild(pushButton[2], new TableView.CellPosition(1, 0));

            // Creates button[3] which control pointSize
            pushButton[3]           = new PushButton();
            pushButton[3].Label     = CreateText("Size");
            pushButton[3].SizeWidth = tableView.SizeWidth / 4;
            // Bind pushButton's click event to ButtonClick.
            pushButton[3].Clicked += ButtonClick;
            tableView.AddChild(pushButton[3], new TableView.CellPosition(1, 1));

            // Creates button[5] which control scroll text
            pushButton[5]           = new PushButton();
            pushButton[5].Label     = CreateText("Scroll");
            pushButton[5].SizeWidth = tableView.SizeWidth / 4;
            // Bind pushButton's click event to ButtonClick.
            pushButton[5].Clicked += ButtonClick;
            tableView.AddChild(pushButton[5], new TableView.CellPosition(1, 3));

            // Creates button[6] which control language
            pushButton[4]           = new PushButton();
            pushButton[4].Label     = CreateText("Language");
            pushButton[4].SizeWidth = tableView.SizeWidth / 4;
            // Bind pushButton's click event to ButtonClick.
            pushButton[4].Clicked += ButtonClick;
            tableView.AddChild(pushButton[4], new TableView.CellPosition(1, 2));

            checkBoxButton = new CheckBoxButton[7];
            // Creates checkBoxButton[0] which control multiline
            checkBoxButton[0]       = new CheckBoxButton();
            checkBoxButton[0].Label = CreateText("Multiline");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[0].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[0], new TableView.CellPosition(2, 1));

            // Creates checkBoxButton[1] which control shadow
            checkBoxButton[1]       = new CheckBoxButton();
            checkBoxButton[1].Label = CreateText("Shadow");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[1].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[1], new TableView.CellPosition(2, 2));

            // Creates checkBoxButton[2] which control underline
            checkBoxButton[2]       = new CheckBoxButton();
            checkBoxButton[2].Label = CreateText("Underline");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[2].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[2], new TableView.CellPosition(2, 3));

            // Creates checkBoxButton[3] which control ellipsis
            checkBoxButton[3]       = new CheckBoxButton();
            checkBoxButton[3].Label = CreateText("Ellipsis");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[3].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[3], new TableView.CellPosition(3, 0));

            // Creates checkBoxButton[4] which control bold
            checkBoxButton[4]       = new CheckBoxButton();
            checkBoxButton[4].Label = CreateText("Bold");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[4].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[4], new TableView.CellPosition(3, 1));

            // Creates checkBoxButton[5] which control condensed
            checkBoxButton[5]       = new CheckBoxButton();
            checkBoxButton[5].Label = CreateText("Condensed");
            // Bind checkBoxButton's click event to CheckButtonClick.
            checkBoxButton[5].Clicked += CheckButtonClick;
            tableView.AddChild(checkBoxButton[5], new TableView.CellPosition(2, 0));
        }