/// <summary>
        /// Create an Button.
        /// </summary>
        /// <param name="text">The string to use button's name and Label text</param>
        /// <returns>return a PushButton</returns>
        private PushButton CreateButton(string text)
        {
            // New PushButton
            PushButton button = new PushButton();

            button.Name   = text;
            button.Size2D = mButtonSize;
            button.ClearBackground();

            button.Position = new Position(50, 0, 0);

            // Create text map for the selected state.
            PropertyMap unSelectedTextMap = CreateTextVisual(text, Color.White);
            // Create ColorVisual property for the unselected states.
            PropertyMap unSelectedMap = CreateColorVisual(new Vector4(0.1f, 0.1f, 0.1f, 0.9f));

            // Create ColorVisual property for the selected states
            PropertyMap selectedMap = CreateColorVisual(new Vector4(0.5f, 0.5f, 0.5f, 1.0f));

            // Set each label and text properties.
            button.Label = unSelectedTextMap;
            button.SelectedBackgroundVisual   = selectedMap;
            button.UnselectedBackgroundVisual = unSelectedMap;

            return(button);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create an Button.
        /// </summary>
        /// <param name="text">The string to use button's name and Label text</param>
        /// <param name="needButton">If this argument is false, the created button do not show any action</param>
        /// <returns>return a PushButton</returns>
        private PushButton CreateButton(string text, bool needButton)
        {
            PushButton button = new PushButton();

            button.Name   = text;
            button.Size2D = mButtonSize;
            button.ClearBackground();

            button.Position = new Position(50, 0, 0);

            // Create text map for the selected state.
            PropertyMap unSelectedTextMap = CreateTextVisual(text, Color.White);
            // Create ColorVisual property for the unselected states.
            PropertyMap unSelectedMap = CreateColorVisual(new Vector4(0.1f, 0.1f, 0.1f, 0.9f));

            // Create ColorVisual property for the selected states
            PropertyMap selectedMap = CreateColorVisual(new Vector4(0.5f, 0.5f, 0.5f, 1.0f));

            // Set each label and text properties.
            button.Label = unSelectedTextMap;
            button.SelectedBackgroundVisual   = selectedMap;
            button.UnselectedBackgroundVisual = unSelectedMap;
            if (!needButton)
            {
                // If the case don't need button(gif case), do not make any changes.
                PropertyMap needlessButtonMap = CreateColorVisual(Color.Black);
                button.SelectedBackgroundVisual   = needlessButtonMap;
                button.UnselectedBackgroundVisual = needlessButtonMap;
            }

            return(button);
        }
        /// <summary>
        /// Reset properties for the style change
        /// </summary>
        private void ResetProperties()
        {
            // Reset title pointsize
            mTitle.PointSize = mLargePointSize;
            // Reset radio button title pointsize
            mRadioButtonTitle.PointSize = mMiddlePointSize;
            // Reset checkbox title pointsize
            mCheckBoxButtonTitle.PointSize = mMiddlePointSize;
            // Reset Text visual of each checkbox label
            for (int i = 0; i < 2; ++i)
            {
                mCheckBoxButtons[i].Label = CreateTextVisual(mCheckBoxButtons[i].LabelText, mMiddlePointSize + 1.0f, Color.White);
            }
            // Reset Pushbutton's Background
            mPushButton.ClearBackground();
            // Reset Text properties of label of pushbutton
            PropertyMap normalTextMap = CreateTextVisual("Change Theme", mMiddlePointSize, Color.White);

            mPushButton.Label = normalTextMap;
        }
        void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            mWindowSize = Window.Instance.Size;

            // 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(mCustomThemeUrl);

            // Create Title TextLabel
            mTitle = new TextLabel("Script");
            mTitle.HorizontalAlignment = HorizontalAlignment.Center;
            mTitle.VerticalAlignment   = VerticalAlignment.Center;
            // Set Text color to White
            mTitle.TextColor = Color.White;
            mTitle.PositionUsesPivotPoint = true;
            mTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mTitle.PivotPoint             = PivotPoint.TopCenter;
            mTitle.Position2D             = new Position2D(0, mWindowSize.Height / 10);
            // Use Samsung One 600 font
            mTitle.FontFamily = "Samsung One 600";
            // Not use MultiLine of TextLabel
            mTitle.MultiLine = false;
            mTitle.PointSize = mLargePointSize;
            Window.Instance.GetDefaultLayer().Add(mTitle);

            // Create subTitle TextLabel
            mRadioButtonTitle = new TextLabel("Radio Button");
            mRadioButtonTitle.HorizontalAlignment = HorizontalAlignment.Center;
            mRadioButtonTitle.VerticalAlignment   = VerticalAlignment.Center;
            // Set Text color to White
            mRadioButtonTitle.TextColor = Color.White;
            mRadioButtonTitle.PositionUsesPivotPoint = true;
            mRadioButtonTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mRadioButtonTitle.PivotPoint             = PivotPoint.TopLeft;
            mRadioButtonTitle.Position2D             = new Position2D(-150, 110);
            // Use Samsung One 600 font
            mRadioButtonTitle.FontFamily = "Samsung One 600";
            // Not use MultiLine of TextLabel
            mRadioButtonTitle.MultiLine = false;
            mRadioButtonTitle.PointSize = mMiddlePointSize;
            Window.Instance.GetDefaultLayer().Add(mRadioButtonTitle);

            // Create RadioButtons
            mRadioButtons = new RadioButton[2];
            for (int i = 0; i < 2; ++i)
            {
                // Create new RadioButton
                mRadioButtons[i] = new RadioButton();
                // Set RadioButton size
                mRadioButtons[i].Size2D = new Size2D(300, 65);
                mRadioButtons[i].PositionUsesPivotPoint = true;
                mRadioButtons[i].ParentOrigin           = ParentOrigin.Center;
                mRadioButtons[i].PivotPoint             = PivotPoint.CenterLeft;
                // Set RadioButton Position
                mRadioButtons[i].Position = new Position(-150, -20, 0) + new Position(160, 0, 0) * i;
                mRadioButtons[i].Label    = CreateTextVisual(ButtonText[i], mMiddlePointSize * 2.0f, Color.White);
                mRadioButtons[i].Scale    = new Vector3(0.5f, 0.5f, 0.5f);
                // Add click event callback function
                mRadioButtons[i].Clicked += OnRadioButtonClicked;

                Window.Instance.GetDefaultLayer().Add(mRadioButtons[i]);
            }

            mRadioButtons[0].Selected = true;

            // Create TextLabel for the CheckBox Button
            mCheckBoxButtonTitle = new TextLabel("CheckBox Button");
            mCheckBoxButtonTitle.HorizontalAlignment    = HorizontalAlignment.Center;
            mCheckBoxButtonTitle.VerticalAlignment      = VerticalAlignment.Center;
            mCheckBoxButtonTitle.TextColor              = Color.White;
            mCheckBoxButtonTitle.PositionUsesPivotPoint = true;
            mCheckBoxButtonTitle.ParentOrigin           = ParentOrigin.TopCenter;
            mCheckBoxButtonTitle.PivotPoint             = PivotPoint.TopLeft;
            mCheckBoxButtonTitle.Position2D             = new Position2D(-150, 190);
            mCheckBoxButtonTitle.FontFamily             = "Samsung One 600";
            mCheckBoxButtonTitle.MultiLine              = false;
            mCheckBoxButtonTitle.PointSize              = mMiddlePointSize;
            Window.Instance.GetDefaultLayer().Add(mCheckBoxButtonTitle);

            // Create CheckBoxButton
            mCheckBoxButtons = new CheckBoxButton[2];
            for (int i = 0; i < 2; ++i)
            {
                // Create new CheckBox Button
                mCheckBoxButtons[i] = new CheckBoxButton();
                mCheckBoxButtons[i].PositionUsesPivotPoint = true;
                mCheckBoxButtons[i].ParentOrigin           = ParentOrigin.Center;
                mCheckBoxButtons[i].PivotPoint             = PivotPoint.CenterLeft;
                mCheckBoxButtons[i].Position      = new Position(-150, 60, 0) + new Position(160, 0, 0) * i;
                mCheckBoxButtons[i].Label         = CreateTextVisual(ButtonText[1], mMiddlePointSize + 1.0f, Color.White);
                mCheckBoxButtons[i].Scale         = new Vector3(0.8f, 0.8f, 0.8f);
                mCheckBoxButtons[i].StateChanged += OnCheckBoxButtonClicked;

                Window.Instance.GetDefaultLayer().Add(mCheckBoxButtons[i]);
            }

            // Create PushButton
            mPushButton = new PushButton();
            mPushButton.PositionUsesPivotPoint = true;
            mPushButton.ParentOrigin           = ParentOrigin.BottomCenter;
            mPushButton.PivotPoint             = PivotPoint.BottomCenter;
            mPushButton.Name   = "ChangeTheme";
            mPushButton.Size2D = new Size2D(230, 35);
            mPushButton.ClearBackground();
            mPushButton.Position = new Position(0, -50, 0);
            PropertyMap normalTextMap = CreateTextVisual("Change Theme", mMiddlePointSize, Color.White);

            mPushButton.Label    = normalTextMap;
            mPushButton.Clicked += OnPushButtonClicked;
            Window.Instance.GetDefaultLayer().Add(mPushButton);

            Window.Instance.KeyEvent += OnKey;
        }