Ejemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (UsernameLabel != null)
            {
                UsernameLabel.Dispose();
                UsernameLabel = null;
            }

            if (CheckBoxButton != null)
            {
                CheckBoxButton.Dispose();
                CheckBoxButton = null;
            }

            if (PhotoImageView != null)
            {
                PhotoImageView.Dispose();
                PhotoImageView = null;
            }

            if (OnlineIndicatorView != null)
            {
                OnlineIndicatorView.Dispose();
                OnlineIndicatorView = null;
            }

            if (InactiveContactOverlay != null)
            {
                InactiveContactOverlay.Dispose();
                InactiveContactOverlay = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The event will be triggered when  have key clicked and focus on spin.
        /// </summary>
        /// <param name="source">checkbox.</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private bool CheckBoxStateChanged(object source, EventArgs e)
        {
            CheckBoxButton checkbox = source as CheckBoxButton;

            // Show testText's shadow or not.
            if (checkbox.LabelText == "Shadow")
            {
                if (checkbox.Selected)
                {
                    testText.ShadowOffset = new Vector2(3.0f, 3.0f);
                    testText.ShadowColor  = Color.Black;
                    testText.ShadowOffset = new Vector2(3.0f, 3.0f);
                    testText.ShadowColor  = Color.Black;
                }
                else
                {
                    testText.ShadowOffset = new Vector2(0, 0);
                    testText.ShadowOffset = new Vector2(0, 0);
                }
            }
            // The testText auto scroll or not.
            else if (checkbox.LabelText == "Color")
            {
                if (checkbox.Selected)
                {
                    testText.TextColor = Color.Red;
                }
                else
                {
                    testText.TextColor = Color.White;
                }
            }
            // Show testText's underline or not.
            else if (checkbox.LabelText == "Underline")
            {
                PropertyMap underlineMapSet = new PropertyMap();
                if (checkbox.Selected)
                {
                    underlineMapSet.Add("enable", new PropertyValue("true"));
                    underlineMapSet.Add("color", new PropertyValue("black"));
                    underlineMapSet.Add("height", new PropertyValue("3.0f"));
                }
                else
                {
                    underlineMapSet.Add("enable", new PropertyValue("false"));
                }

                testText.Underline = underlineMapSet;
            }

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Text Sample Application initialisation.
        /// </summary>
        private void Initialize()
        {
            Window.Instance.BackgroundColor = Color.Black;
            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  = DeviceCheck.PointSize15;
            //guide.PointSize = 15.0f;
            guide.Text      = "CheckBox 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);

            testText = new TextLabel();
            testText.HorizontalAlignment    = HorizontalAlignment.Center;
            testText.VerticalAlignment      = VerticalAlignment.Center;
            testText.PositionUsesPivotPoint = true;
            testText.ParentOrigin           = ParentOrigin.TopLeft;
            testText.PivotPoint             = PivotPoint.TopLeft;
            testText.Size2D     = new Size2D(300, 100);
            testText.FontFamily = "Samsung One 600";
            testText.Position2D = new Position2D(810, 200);
            testText.MultiLine  = false;
            //testText.PointSize = 15.0f;
            testText.PointSize       = DeviceCheck.PointSize15;
            testText.Text            = "Test Text \n";
            testText.TextColor       = Color.Black;
            testText.BackgroundColor = Color.White;
            Window.Instance.GetDefaultLayer().Add(testText);


            CheckBoxGroup checkBoxGroup = new CheckBoxGroup();

            checkBoxGroupView = checkBoxGroup.GetCheckBoxGroup();
            CheckBoxButton checkbox1 = checkBoxGroup.GetCheckBox1();
            CheckBoxButton checkbox2 = checkBoxGroup.GetCheckBox2();
            CheckBoxButton checkbox3 = checkBoxGroup.GetCheckBox3();

            checkbox1.StateChanged    += CheckBoxStateChanged;
            checkbox2.StateChanged    += CheckBoxStateChanged;
            checkbox3.StateChanged    += CheckBoxStateChanged;
            checkBoxGroupView.Position = new Position(810, 400, 0);
            Window.Instance.GetDefaultLayer().Add(checkBoxGroupView);
            FocusManager.Instance.SetCurrentFocusView(checkbox1);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// checkboxbutton initialisation.
        /// </summary>
        /// <param name="text">text</param>
        private void OnIntialize(string text)
        {
            _checkboxbutton              = new CheckBoxButton();
            _checkboxbutton.Label        = CreateLabel(text);
            _checkboxbutton.LabelPadding = new Vector4(20, 12, 0, 0);
            _checkboxbutton.Size2D       = new Size2D(300, 48);
            _checkboxbutton.Focusable    = true;
            _checkboxbutton.ParentOrigin = ParentOrigin.TopLeft;
            _checkboxbutton.PivotPoint   = PivotPoint.TopLeft;

            // Create unfocused and unselected visual.
            PropertyMap unselectedMap = new PropertyMap();

            unselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            unselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(normalImagePath));

            // Create focused and unselected visual.
            PropertyMap focusUnselectedMap = new PropertyMap();

            focusUnselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusUnselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusImagePath));

            // Create unfocused and selected visual.
            PropertyMap selectedMap = new PropertyMap();

            selectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            selectedMap.Add(ImageVisualProperty.URL, new PropertyValue(selectImagePath));

            // Create focused and selected visual.
            PropertyMap focusSelectedMap = new PropertyMap();

            focusSelectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusSelectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusSelectImagePath));

            // Set the original visual.
            _checkboxbutton.UnselectedVisual = unselectedMap;
            _checkboxbutton.SelectedVisual   = selectedMap;

            // Change the image when focus changed.
            _checkboxbutton.FocusGained += (obj, e) =>
            {
                _checkboxbutton.SelectedVisual   = focusSelectedMap;
                _checkboxbutton.UnselectedVisual = focusUnselectedMap;
            };

            // Change the image when focus changed.
            _checkboxbutton.FocusLost += (obj, e) =>
            {
                _checkboxbutton.UnselectedVisual = unselectedMap;
                _checkboxbutton.SelectedVisual   = selectedMap;
            };
        }
        void ReleaseDesignerOutlets()
        {
            if (CheckBoxButton != null)
            {
                CheckBoxButton.Dispose();
                CheckBoxButton = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Popups initialisation.
        /// </summary>
        private void OnIntialize()
        {
            _toggleButton              = new CheckBoxButton();
            _toggleButton.Focusable    = true;
            _toggleButton.ParentOrigin = ParentOrigin.TopLeft;
            _toggleButton.PivotPoint   = PivotPoint.TopLeft;
            _toggleButton.Size2D       = new Size2D(150, 80);

            PropertyMap unselectedMap = new PropertyMap();

            unselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            unselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(normalOffImage));

            PropertyMap selectedMap = new PropertyMap();

            selectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            selectedMap.Add(ImageVisualProperty.URL, new PropertyValue(normalOnImage));

            PropertyMap focusUnselectedMap = new PropertyMap();

            focusUnselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusUnselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusedOffImage));

            PropertyMap focusSelectedMap = new PropertyMap();

            focusSelectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusSelectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusedOnImage));

            _toggleButton.UnselectedVisual = unselectedMap;
            _toggleButton.SelectedVisual   = selectedMap;

            _toggleButton.FocusGained += (obj, e) =>
            {
                _toggleButton.UnselectedVisual = focusUnselectedMap;
                _toggleButton.SelectedVisual   = focusSelectedMap;
            };

            _toggleButton.FocusLost += (obj, e) =>
            {
                _toggleButton.UnselectedVisual = unselectedMap;
                _toggleButton.SelectedVisual   = selectedMap;
            };
        }
        /// <summary>
        /// The event will be triggered when  have key clicked and focus on spin.
        /// </summary>
        /// <param name="source">checkbox.</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private bool CheckBoxStateChanged(object source, EventArgs e)
        {
            CheckBoxButton checkbox = source as CheckBoxButton;

            // Show testText's shadow or not.
            if (checkbox.LabelText == "Shadow")
            {
            }
            // The testText auto scroll or not.
            else if (checkbox.LabelText == "Color")
            {
            }
            // Show testText's underline or not.
            else if (checkbox.LabelText == "Underline")
            {
            }

            return(true);
        }
Ejemplo n.º 8
0
        private CheckBoxButton CreateCheckBoxButton(string text)
        {
            CheckBoxButton checkBox = new CheckBoxButton();

            checkBox.Label        = CreateTextVisual(text, Color.White);
            checkBox.LabelPadding = new Vector4(20, 12, 0, 0);
            checkBox.Size2D       = new Size2D(300, 48);
            checkBox.Focusable    = true;
            checkBox.ParentOrigin = ParentOrigin.TopLeft;
            checkBox.PivotPoint   = PivotPoint.TopLeft;

            // Create unfocused and unselected visual.
            PropertyMap unselectedMap = CreateImageVisual(checkBoxNormalImagePath);

            // Create focused and unselected visual.
            PropertyMap focusUnselectedMap = CreateImageVisual(checkBoxFocusImagePath);

            // Create unfocused and selected visual.
            PropertyMap selectedMap = CreateImageVisual(checkBoxSelectImagePath);

            // Create focused and selected visual.
            PropertyMap focusSelectedMap = CreateImageVisual(checkBoxFocusSelectImagePath);

            // Set the original visual.
            checkBox.UnselectedVisual = unselectedMap;
            checkBox.SelectedVisual   = selectedMap;

            // Change the image when focus changed.
            checkBox.FocusGained += (obj, e) =>
            {
                checkBox.SelectedVisual   = focusSelectedMap;
                checkBox.UnselectedVisual = focusUnselectedMap;
            };

            // Change the image when focus changed.
            checkBox.FocusLost += (obj, e) =>
            {
                checkBox.UnselectedVisual = unselectedMap;
                checkBox.SelectedVisual   = selectedMap;
            };

            return(checkBox);
        }
        void ReleaseDesignerOutlets()
        {
            if (CheckBoxButton != null)
            {
                CheckBoxButton.Dispose();
                CheckBoxButton = null;
            }

            if (PhotoImageView != null)
            {
                PhotoImageView.Dispose();
                PhotoImageView = null;
            }

            if (UsernameLabel != null)
            {
                UsernameLabel.Dispose();
                UsernameLabel = null;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Checkbox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public Checkbox(ControlBase parent)
            : base(parent)
        {
            this.MinimumSize           = new System.Drawing.Size(15, 15);
            AutoSizeToContents         = true;
            m_CheckBox                 = new CheckBoxButton(this);
            m_CheckBox.ToolTipProvider = false;
            m_CheckBox.IsTabable       = false;
            m_CheckBox.CheckChanged   += OnCheckChanged;
            m_Label = new Label(this);
            m_Label.ToolTipProvider = false;
            m_Label.TextPadding     = Padding.Two;
            m_Label.Margin          = new Margin(17, 0, 0, 0);
            m_Label.Dock            = Dock.Fill;
            m_Label.Clicked        += delegate(ControlBase Control, ClickedEventArgs args) { m_CheckBox.Press(Control); };
            m_Label.IsTabable       = false;
            Text = "";

            KeyboardInputEnabled = true;
            IsTabable            = true;
        }
        /// <summary>
        /// The event will be triggered when mCheckButton state changed
        /// If state is unselected, turn off the channel's contribution
        /// </summary>
        /// <param name="source">mCheckButton.</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private bool OnCheckButtonChange(object source, EventArgs e)
        {
            CheckBoxButton checkBoxButton = source as CheckBoxButton;

            if (checkBoxButton.Name == "channelActiveCheckBox1")
            {
                if (mCheckButtons[0].Selected)
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorRed"), new PropertyValue(mChannelSliders[0].Value / 100));
                }
                else
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorRed"), new PropertyValue(0));
                }
            }
            else if (checkBoxButton.Name == "channelActiveCheckBox2")
            {
                if (mCheckButtons[1].Selected)
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorGreen"), new PropertyValue(mChannelSliders[1].Value / 100));
                }
                else
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorGreen"), new PropertyValue(0));
                }
            }
            else if (checkBoxButton.Name == "channelActiveCheckBox3")
            {
                if (mCheckButtons[2].Selected)
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorBlue"), new PropertyValue(mChannelSliders[2].Value / 100));
                }
                else
                {
                    mImagePlacement.SetProperty(mImagePlacement.GetPropertyIndex("colorBlue"), new PropertyValue(0));
                }
            }

            return(true);
        }
        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;
        }
Ejemplo n.º 13
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));
            }
        }
Ejemplo n.º 14
0
        private bool MyTimer_Tick(object source, System.EventArgs e)
        {
            //Remove current Scene,
            foreach (View v in myViewList)
            {
                Window.Instance.GetDefaultLayer().Remove(v);
            }

            myViewList.Clear();

            ////Add View

            GC.Collect();
            GC.WaitForPendingFinalizers();

            for (int i = 0; i < 50; i++)
            {
                TextLabel v = new TextLabel();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.Text            = "label " + i;

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 50; i < 100; i++)
            {
                PushButton v = new PushButton();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.LabelText       = "button " + i;

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 100; i < 150; i++)
            {
                ImageView v = new ImageView();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.ResourceUrl     = resourcePath + "/images/gallery-3.jpg";

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 150; i < 200; i++)
            {
                //TextEditor v = new TextEditor();
                TextLabel v = new TextLabel("2");

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.Text            = "editor" + i;

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 200; i < 250; i++)
            {
                //TextField v = new TextField();
                TextLabel v = new TextLabel("1");

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.Text            = "field " + i;

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 250; i < 300; i++)
            {
                CheckBoxButton v = new CheckBoxButton();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);
                v.LabelText       = "check " + i;

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 300; i < 350; i++)
            {
                ScrollBar v = new ScrollBar();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 350; i < 400; i++)
            {
                Slider v = new Slider();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 400; i < 450; i++)
            {
                TableView v = new TableView(1, 1);

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            for (int i = 450; i < numberOfObjects; i++)
            {
                View v = new View();

                float intensity = myRandom.Next(0, 255) / 255.0f;
                v.BackgroundColor = new Color(intensity, intensity, intensity, 1);
                v.Position        = new Position(myRandom.Next(0, 1820), myRandom.Next(0, 980), 0);
                v.PivotPoint      = PivotPoint.TopLeft;
                v.Size2D          = new Size2D(100, 100);

                myViewList.Add(v);

                Window.Instance.GetDefaultLayer().Add(v);
            }

            return(true);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Called by checkBoxButton<br>
        /// </summary>
        /// <param name="source">The clicked checkBoxButton</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private bool CheckButtonClick(object source, EventArgs e)
        {
            // Get the source who trigger this event.
            CheckBoxButton button = source as CheckBoxButton;

            // Set the text on textLabel show in single-line or multi-line layout option.
            // If multiline is true , the text length more than the textLabel's length and
            // textLabel's high can show multiline, text will shown in multiline.
            // If not, The more text over textLabel length, will show "...".
            if (button.LabelText == "Multiline")
            {
                if (button.Selected)
                {
                    textLabel.MultiLine = true;
                }
                else
                {
                    textLabel.MultiLine = false;
                }
            }
            // Set the text on textLabel/textfield have shadow or not.
            else if (button.LabelText == "Shadow")
            {
                if (button.Selected)
                {
                    textLabel.ShadowOffset = new Vector2(3.0f, 3.0f);
                    textLabel.ShadowColor  = Color.Black;
                    textField.ShadowOffset = new Vector2(3.0f, 3.0f);
                    textField.ShadowColor  = Color.Black;
                    textField.Text         = textField.Text;
                }
                else
                {
                    // The drop shadow offset 0 indicates no shadow.
                    textLabel.ShadowOffset = new Vector2(0, 0);
                    textField.ShadowOffset = new Vector2(0, 0);
                    textField.Text         = textField.Text;
                }
            }
            // Set the text on textLabel have Underline or not.
            else if (button.LabelText == "Underline")
            {
                if (button.Selected)
                {
                    // Show the underline.
                    textLabel.UnderlineEnabled = true;
                    // Set underline's color.
                    textLabel.UnderlineColor  = Color.Black;
                    textLabel.UnderlineHeight = 3.0f;
                }
                else
                {
                    // Hide the underline.
                    textLabel.UnderlineEnabled = false;
                }
            }
            // Set textLabel is enable or disable the ellipsis.
            else if (button.LabelText == "Ellipsis")
            {
                if (button.Selected)
                {
                    textLabel.Ellipsis = true;
                    textLabel.Text     = textLabel.Text;
                }
                else
                {
                    textLabel.Ellipsis = false;
                    textLabel.Text     = textLabel.Text;
                }
            }
            // Set textLabel/textfield/textEditor text is bold or not.
            else if (button.LabelText == "Bold")
            {
                if (button.Selected)
                {
                    // The weight of text is bold.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("weight", new PropertyValue("bold"));
                    textLabel.FontStyle  = fontStyle;
                    textField.FontStyle  = fontStyle;
                    textEditor.FontStyle = fontStyle;
                    textField.Text       = textField.Text;
                    textEditor.Text      = textEditor.Text;
                }
                else
                {
                    // The weight of text is normal.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("weight", new PropertyValue("normal"));
                    textLabel.FontStyle  = fontStyle;
                    textField.FontStyle  = fontStyle;
                    textEditor.FontStyle = fontStyle;
                    textField.Text       = textField.Text;
                    textEditor.Text      = textEditor.Text;
                }
            }
            // Set textLabel/textField/textEditor text is condensed or not.
            else if (button.LabelText == "Condensed")
            {
                if (button.Selected)
                {
                    // The width of text is condensed.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("width", new PropertyValue("condensed"));
                    textLabel.FontStyle  = fontStyle;
                    textField.FontStyle  = fontStyle;
                    textEditor.FontStyle = fontStyle;
                    textField.Text       = textField.Text;
                    textEditor.Text      = textEditor.Text;
                }
                else
                {
                    // The width of text is normal.
                    PropertyMap fontStyle = new PropertyMap();
                    fontStyle.Add("width", new PropertyValue("normal"));
                    textLabel.FontStyle  = fontStyle;
                    textField.FontStyle  = fontStyle;
                    textEditor.FontStyle = fontStyle;
                    textField.Text       = textField.Text;
                    textEditor.Text      = textEditor.Text;
                }
            }
            // Set textLabel/textField/textEditor text is italic or not.

            return(true);
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CheckBoxButton obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
        /// <summary>
        /// StateChanged event handling of CheckBox
        /// </summary>
        /// <param name="source">CheckBoxButton</param>
        /// <param name="e">event</param>
        /// <returns>The consume flag</returns>
        private bool OnCheckBoxChanged(object source, EventArgs e)
        {
            // Get the source who trigger this event.
            CheckBoxButton checkBoxButton = source as CheckBoxButton;

            // Change the shadow state of TextLabel
            if (checkBoxButton.LabelText == "Shadow")
            {
                // Make a shadow for the TextLabel
                // Shadow offset is 3.0f
                // Shadow color is Black
                if (checkBoxButton.Selected)
                {
                    mtextLabelCheckBox.ShadowOffset = new Vector2(3.0f, 3.0f);
                    mtextLabelCheckBox.ShadowColor  = Color.Black;
                }
                else
                {
                    // Delete the shadow of the TextLabel
                    mtextLabelCheckBox.ShadowOffset = new Vector2(0, 0);
                }
            }
            // Change the color of the TextLabel
            else if (checkBoxButton.LabelText == "Color")
            {
                // Set the color of the TextLabel to Red
                if (checkBoxButton.Selected)
                {
                    mtextLabelCheckBox.TextColor = Color.Red;
                }
                // Set the color of the TextLabel to Black
                else
                {
                    mtextLabelCheckBox.TextColor = Color.Black;
                }
            }
            // Change the Underline state of the TextLabel
            else if (checkBoxButton.LabelText == "Underline")
            {
                // Create a PropertyMap to change the underline status
                PropertyMap underlineMapSet = new PropertyMap();
                // Make a underline propertymap.
                if (checkBoxButton.Selected)
                {
                    // Underline color is black.
                    // Underline height is 3.0
                    underlineMapSet.Add("enable", new PropertyValue("true"));
                    underlineMapSet.Add("color", new PropertyValue("black"));
                    underlineMapSet.Add("height", new PropertyValue("3.0f"));
                }
                // Delete UnderLine property
                else
                {
                    underlineMapSet.Add("enable", new PropertyValue("false"));
                }

                mtextLabelCheckBox.Underline = underlineMapSet;
            }

            return(true);
        }
        /// <summary>
        /// Create a Control
        /// </summary>
        /// <param name="text">case string of the created control</param>
        /// <param name="position">A position the created control will be located</param>
        /// <returns>View for the created control</returns>
        private View CreateControl(string text, Position position)
        {
            // A View that contain a control element
            View view = new View();

            // CheckBox sample
            if (text == mCaseString[0])
            {
                // TextLabel for the checkbox
                mtextLabelCheckBox        = new TextLabel("CheckBox");
                mtextLabelCheckBox.Size2D = new Size2D(250, 60);
                mtextLabelCheckBox.HorizontalAlignment = HorizontalAlignment.Center;
                mtextLabelCheckBox.VerticalAlignment   = VerticalAlignment.Center;
                // Set the position of checkbox.
                mtextLabelCheckBox.PositionUsesPivotPoint = true;
                mtextLabelCheckBox.PivotPoint             = PivotPoint.Center;
                mtextLabelCheckBox.ParentOrigin           = ParentOrigin.Center;
                mtextLabelCheckBox.Position        = new Position(0, -55, 0);
                mtextLabelCheckBox.PointSize       = mLargePointSize;
                mtextLabelCheckBox.BackgroundColor = Color.White;
                mtextLabelCheckBox.FontFamily      = "SamsungOneUI_200";

                view.Add(mtextLabelCheckBox);

                // Create three CheckBoxs
                Position         checkBoxStartPosition = new Position(100, 0, 0);
                CheckBoxButton[] checkBox = new CheckBoxButton[3];
                for (int i = 0; i < 3; ++i)
                {
                    // New CheckBox
                    checkBox[i] = new CheckBoxButton();
                    // Set the CheckBox position
                    checkBox[i].Position = checkBoxStartPosition + new Position(0, 40, 0) * i;
                    checkBox[i].PositionUsesPivotPoint = true;
                    checkBox[i].PivotPoint             = PivotPoint.CenterLeft;
                    checkBox[i].ParentOrigin           = ParentOrigin.CenterLeft;
                    // Make Image Visual for the selected checkbox visual
                    checkBox[i].SelectedVisual = CreateImageVisual(mResourceUrl + "/CheckBox/Selected.png");
                    // Make Image Visual for the unselected checkbox visual
                    checkBox[i].UnselectedVisual = CreateImageVisual(mResourceUrl + "/CheckBox/Unselected.png");
                    checkBox[i].Scale            = new Vector3(0.8f, 0.8f, 0.8f);
                    // Add a callback function for the StateChanged signal
                    checkBox[i].StateChanged += OnCheckBoxChanged;
                    view.Add(checkBox[i]);
                }
                // Make Text Visual
                // Set the Label of Checkbox
                checkBox[0].Label = CreateTextVisual("Shadow", mMiddlePointSize + 2, Color.White);
                checkBox[1].Label = CreateTextVisual("Color", mMiddlePointSize + 2, Color.White);
                checkBox[2].Label = CreateTextVisual("Underline", mMiddlePointSize + 2, Color.White);
            }
            else if (text == mCaseString[1])
            {
                // TextLabel for the RadioButton
                mtextLabelRadio        = new TextLabel("Radio Button");
                mtextLabelRadio.Size2D = new Size2D(250, 60);
                mtextLabelRadio.HorizontalAlignment = HorizontalAlignment.Center;
                mtextLabelRadio.VerticalAlignment   = VerticalAlignment.Center;
                // Set the position of textLabel.
                mtextLabelRadio.PositionUsesPivotPoint = true;
                mtextLabelRadio.PivotPoint             = PivotPoint.Center;
                mtextLabelRadio.ParentOrigin           = ParentOrigin.Center;
                mtextLabelRadio.Position        = new Position(0, -55, 0);
                mtextLabelRadio.PointSize       = mLargePointSize;
                mtextLabelRadio.BackgroundColor = Color.White;
                mtextLabelRadio.FontFamily      = "SamsungOneUI_200";

                view.Add(mtextLabelRadio);

                // Create three RadioButton
                Position      checkBoxStartPosition = new Position(100, 0, 0);
                RadioButton[] radioButton           = new RadioButton[3];
                for (int i = 0; i < 3; ++i)
                {
                    // New RadioButton
                    radioButton[i] = new RadioButton();
                    // Set the RadioButton position
                    radioButton[i].Position = checkBoxStartPosition + new Position(0, 40, 0) * i;
                    radioButton[i].PositionUsesPivotPoint = true;
                    radioButton[i].PivotPoint             = PivotPoint.CenterLeft;
                    radioButton[i].ParentOrigin           = ParentOrigin.CenterLeft;
                    // Make Image Visual for the selected RadioButton visual
                    radioButton[i].SelectedVisual = CreateImageVisual(mResourceUrl + "/RadioButton/Selected.png");
                    // Make Image Visual for the unselected RadioButton visual
                    radioButton[i].UnselectedVisual = CreateImageVisual(mResourceUrl + "/RadioButton/Unselected.png");
                    radioButton[i].Scale            = new Vector3(0.5f, 0.5f, 0.5f);
                    // Add a callback function for the StateChanged signal
                    radioButton[i].StateChanged += OnRadioButtonChanged;;
                    view.Add(radioButton[i]);
                }
                // Make Text Visual
                // Set the Label of RadioButton
                radioButton[0].Label = CreateTextVisual("Red", mMiddlePointSize * 2.0f, Color.White);
                radioButton[1].Label = CreateTextVisual("Green", mMiddlePointSize * 2.0f, Color.White);
                radioButton[2].Label = CreateTextVisual("Blue", mMiddlePointSize * 2.0f, Color.White);
            }
            else if (text == mCaseString[2])
            {
                // TextLabel for Slider
                TextLabel mtextLabelSlider = new TextLabel("Slider");
                mtextLabelSlider.Size2D = new Size2D(250, 60);
                mtextLabelSlider.HorizontalAlignment = HorizontalAlignment.Center;
                mtextLabelSlider.VerticalAlignment   = VerticalAlignment.Center;
                // Set the position of textLabel.
                mtextLabelSlider.PositionUsesPivotPoint = true;
                mtextLabelSlider.PivotPoint             = PivotPoint.Center;
                mtextLabelSlider.ParentOrigin           = ParentOrigin.Center;
                mtextLabelSlider.Position        = new Position(0, -55, 0);
                mtextLabelSlider.PointSize       = mLargePointSize;
                mtextLabelSlider.BackgroundColor = Color.White;
                mtextLabelSlider.FontFamily      = "SamsungOneUI_200";

                view.Add(mtextLabelSlider);

                // A new Slider
                mSlider = new Slider();
                // Set the Slider position
                mSlider.PositionUsesPivotPoint = true;
                mSlider.PivotPoint             = PivotPoint.Center;
                mSlider.ParentOrigin           = ParentOrigin.Center;
                mSlider.Size2D = new Size2D(300, 25);
                // Set the Popup and Value properties
                mSlider.ShowPopup = false;
                mSlider.ShowValue = false;
                // Set the Lower Bound and Upper Bound values of the Slider
                mSlider.LowerBound = 0.0f;
                mSlider.UpperBound = 100.0f;
                // Set the start value
                mSlider.Value = 50;

                // Create unselected handle visual.
                PropertyMap hanldeUnSelectedVisualMap = new PropertyMap();
                hanldeUnSelectedVisualMap.Add("visualType", new PropertyValue("IMAGE"));
                // Set image visual size
                hanldeUnSelectedVisualMap.Add("size", new PropertyValue(new Vector2(4, 25)));
                // Set image path url
                hanldeUnSelectedVisualMap.Add("url", new PropertyValue(mResourceUrl + "/Slider/img_slider_handler_h_selected.png"));
                mSlider.HandleVisual = hanldeUnSelectedVisualMap;

                // Create progress visual map.
                PropertyMap progressVisualMap = new PropertyMap();
                progressVisualMap.Add("visualType", new PropertyValue("IMAGE"));
                // Set image visual size
                progressVisualMap.Add("size", new PropertyValue(new Vector2(10, 4)));
                // Set image path url
                progressVisualMap.Add("url", new PropertyValue(mResourceUrl + "/Slider/img_slider_progress.png"));
                mSlider.ProgressVisual = progressVisualMap;

                // Create track visual map.
                PropertyMap trackVisualMap = new PropertyMap();
                trackVisualMap.Add("visualType", new PropertyValue("IMAGE"));
                // Set image visual size
                trackVisualMap.Add("size", new PropertyValue(new Vector2(10, 4)));
                // Set image path url
                trackVisualMap.Add("url", new PropertyValue(mResourceUrl + "/Slider/img_slider_track.png"));
                mSlider.TrackVisual = trackVisualMap;

                view.Add(mSlider);
            }
            else if (text == mCaseString[3])
            {
                // TextLabel for ProgressBar
                TextLabel mtextLabelProgressBar = new TextLabel("Progress Bar");
                mtextLabelProgressBar.Size2D = new Size2D(250, 60);
                mtextLabelProgressBar.HorizontalAlignment = HorizontalAlignment.Center;
                mtextLabelProgressBar.VerticalAlignment   = VerticalAlignment.Center;
                // Set the position of textLabel.
                mtextLabelProgressBar.PositionUsesPivotPoint = true;
                mtextLabelProgressBar.PivotPoint             = PivotPoint.Center;
                mtextLabelProgressBar.ParentOrigin           = ParentOrigin.Center;
                mtextLabelProgressBar.Position        = new Position(0, -55, 0);
                mtextLabelProgressBar.PointSize       = mLargePointSize;
                mtextLabelProgressBar.BackgroundColor = Color.White;
                mtextLabelProgressBar.FontFamily      = "SamsungOneUI_200";

                view.Add(mtextLabelProgressBar);

                // A new ProgressBar
                mProgressBar = new ProgressBar();
                // Set the Slider position
                mProgressBar.PositionUsesPivotPoint = true;
                mProgressBar.PivotPoint             = PivotPoint.Center;
                mProgressBar.ParentOrigin           = ParentOrigin.Center;
                mProgressBar.Size2D = new Size2D(300, 4);

                // Create ProgressVisual
                PropertyMap progressMap = new PropertyMap();
                progressMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
                // Set image path url
                progressMap.Add(ImageVisualProperty.URL, new PropertyValue(mResourceUrl + "/ProgressBar/img_viewer_progress_0_129_198_100.9.png"));
                mProgressBar.ProgressVisual = progressMap;

                // Create TrackVisual
                PropertyMap trackMap = new PropertyMap();
                trackMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
                // Set image path url
                trackMap.Add(ImageVisualProperty.URL, new PropertyValue(mResourceUrl + "/ProgressBar/img_viewer_progress_255_255_255_100.9.png"));
                mProgressBar.TrackVisual = trackMap;

                // Set Interminate visual properties
                PropertyArray indeterminateVisualAnimation = new PropertyArray();

                // Create a property map for the IndeterminateVisualAnimation
                PropertyMap transitionMap = new PropertyMap();
                transitionMap.Add("target", new PropertyValue("indeterminateVisual"));
                transitionMap.Add("property", new PropertyValue("offset"));
                transitionMap.Add("initialValue", new PropertyValue(new Vector2(0.0f, 0.0f)));
                transitionMap.Add("targetValue", new PropertyValue(new Vector2(100.0f, 0.0f)));
                PropertyMap animator = new PropertyMap();
                animator.Add("alphaFunction", new PropertyValue("EASE_IN_OUT_BACK"));
                PropertyMap timePeriod = new PropertyMap();
                timePeriod.Add("delay", new PropertyValue(0.5f));
                timePeriod.Add("duration", new PropertyValue(100.0f));
                animator.Add("timePeriod", new PropertyValue(timePeriod));
                transitionMap.Add("animator", new PropertyValue(animator));
                indeterminateVisualAnimation.PushBack(new PropertyValue(transitionMap));

                mProgressBar.Indeterminate                = false;
                mProgressBar.IndeterminateVisual          = trackMap;
                mProgressBar.IndeterminateVisualAnimation = indeterminateVisualAnimation;

                view.Add(mProgressBar);

                // Create TextLabel that notices current progress
                TextLabel progressText = new TextLabel();
                // Set TextLabel position
                progressText.PositionUsesPivotPoint = true;
                progressText.HorizontalAlignment    = HorizontalAlignment.Center;
                progressText.VerticalAlignment      = VerticalAlignment.Center;
                progressText.ParentOrigin           = ParentOrigin.Center;
                progressText.PivotPoint             = PivotPoint.Center;
                progressText.FontFamily             = "Samsung One 400";
                progressText.Position2D             = new Position2D(150, 20);
                progressText.PointSize = mMiddlePointSize;
                // Set the default Text
                progressText.Text = (mProgressBar.ProgressValue * 100).ToString() + "%";
                // Set the text color
                progressText.TextColor = Color.White;
                view.Add(progressText);

                // Create Timer to show the intermediate progress state
                Timer timer = new Timer(50);
                // Timer Callback function
                timer.Tick += (obj, e) =>
                {
                    if (mProgressBar != null)
                    {
                        // Compute current progress
                        float progress = (float)Math.Round(mProgressBar.ProgressValue, 2);

                        // If the progress is complete
                        // Reset the progressValue to 0.0f
                        if (progress == 1.0f)
                        {
                            mProgressBar.ProgressValue = 0.0f;
                            progressText.Text          = (mProgressBar.ProgressValue * 100).ToString() + "%";
                            return(true);
                        }
                        // For the every step, add progressValue uniformly
                        else
                        {
                            mProgressBar.ProgressValue = progress + 0.01f;
                            progressText.Text          = (mProgressBar.ProgressValue * 100).ToString() + "%";
                            return(true);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                };
                timer.Start();
            }
            // Set the common properties
            view.Size2D = mWindowSize;
            view.PositionUsesPivotPoint = true;
            view.PivotPoint             = PivotPoint.CenterLeft;
            view.ParentOrigin           = ParentOrigin.CenterLeft;
            view.Position = position;

            return(view);
        }
        private CheckBoxButton CreateCheckBox(string text)
        {
            CheckBoxButton _checkboxbutton = new CheckBoxButton();

            if (text == "R")
            {
                _checkboxbutton.Label = CreateLabel(text, Color.Red);
            }
            else if (text == "G")
            {
                _checkboxbutton.Label = CreateLabel(text, Color.Green);
            }
            else if (text == "B")
            {
                _checkboxbutton.Label = CreateLabel(text, Color.Blue);
            }

            _checkboxbutton.LabelPadding  = new Vector4(10, 12, 0, 0);
            _checkboxbutton.Size2D        = new Size2D(120, 48);
            _checkboxbutton.Focusable     = true;
            _checkboxbutton.ParentOrigin  = ParentOrigin.TopLeft;
            _checkboxbutton.PivotPoint    = PivotPoint.TopLeft;
            _checkboxbutton.StateChanged += OnCheckButtonChange;

            // Create unfocused and unselected visual.
            PropertyMap unselectedMap = new PropertyMap();

            unselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            // Create unfocused and selected visual.
            PropertyMap selectedMap = new PropertyMap();

            selectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            PropertyMap focusUnselectedMap = new PropertyMap();

            focusUnselectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            PropertyMap focusSelectedMap = new PropertyMap();

            focusSelectedMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            focusUnselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusCheckImagePath));
            focusSelectedMap.Add(ImageVisualProperty.URL, new PropertyValue(focusSelectCheckImagePath));
            unselectedMap.Add(ImageVisualProperty.URL, new PropertyValue(normalCheckImagePath));
            selectedMap.Add(ImageVisualProperty.URL, new PropertyValue(selectCheckImagePath));


            PropertyMap unselectedTheme2Map = new PropertyMap();

            unselectedTheme2Map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            // Create unfocused and selected visual.
            PropertyMap selectedTheme2Map = new PropertyMap();

            selectedTheme2Map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            PropertyMap focusUnselectedTheme2Map = new PropertyMap();

            focusUnselectedTheme2Map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));

            PropertyMap focusSelectedTheme2Map = new PropertyMap();

            focusSelectedTheme2Map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
            focusUnselectedTheme2Map.Add(ImageVisualProperty.URL, new PropertyValue(focusCheckTheme2ImagePath));
            focusSelectedTheme2Map.Add(ImageVisualProperty.URL, new PropertyValue(focusSelectCheckTheme2ImagePath));
            unselectedTheme2Map.Add(ImageVisualProperty.URL, new PropertyValue(normalCheckTheme2ImagePath));
            selectedTheme2Map.Add(ImageVisualProperty.URL, new PropertyValue(selectCheckTheme2ImagePath));

            // Set the original visual.
            _checkboxbutton.UnselectedVisual = unselectedMap;
            _checkboxbutton.SelectedVisual   = selectedMap;

            // Change the image when focus changed.
            _checkboxbutton.FocusGained += (obj, e) =>
            {
                if (themePath == defaultThemePath)
                {
                    _checkboxbutton.SelectedVisual   = focusSelectedMap;
                    _checkboxbutton.UnselectedVisual = focusUnselectedMap;
                }
                else if (themePath == customThemePath)
                {
                    _checkboxbutton.SelectedVisual   = focusSelectedTheme2Map;
                    _checkboxbutton.UnselectedVisual = focusUnselectedTheme2Map;
                }
            };

            // Change the image when focus changed.
            _checkboxbutton.FocusLost += (obj, e) =>
            {
                if (themePath == defaultThemePath)
                {
                    _checkboxbutton.UnselectedVisual = unselectedMap;
                    _checkboxbutton.SelectedVisual   = selectedMap;
                }
                else if (themePath == customThemePath)
                {
                    _checkboxbutton.UnselectedVisual = unselectedTheme2Map;
                    _checkboxbutton.SelectedVisual   = selectedTheme2Map;
                }
            };
            return(_checkboxbutton);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// CheckBoxButtonGroup initialisation.
        /// </summary>
        private void Initialize()
        {
            checkBoxGroup = new View();
            checkBoxGroup.ParentOrigin = ParentOrigin.TopLeft;
            checkBoxGroup.PivotPoint   = PivotPoint.TopLeft;
            checkBoxGroup.Size2D       = new Size2D(300, 200);

            CheckBox radioSample1 = new CheckBox("Shadow");

            checkBox1          = radioSample1.GetCheckBoxButton();
            checkBox1.Position = new Position(0, 0, 0);

            CheckBox radioSample2 = new CheckBox("Color");

            checkBox2          = radioSample2.GetCheckBoxButton();
            checkBox2.Position = new Position(0, 50, 0);

            CheckBox radioSample3 = new CheckBox("Underline");

            checkBox3          = radioSample3.GetCheckBoxButton();
            checkBox3.Position = new Position(0, 100, 0);

            checkBoxGroup.Add(checkBox1);
            checkBoxGroup.Add(checkBox2);
            checkBoxGroup.Add(checkBox3);

            // Move focus from checkBox1.
            checkBox1.KeyEvent += (obj, e) =>
            {
                if (e.Key.KeyPressedName == "Down" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBox2);
                }
                else if (e.Key.KeyPressedName == "Left" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.LeftFocusableView);
                }
                else if (e.Key.KeyPressedName == "Right" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.RightFocusableView);
                }

                return(false);
            };

            // Move focus from checkBox1.
            checkBox2.KeyEvent += (obj, e) =>
            {
                if (e.Key.KeyPressedName == "Down" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBox3);
                }
                else if (e.Key.KeyPressedName == "Up" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBox1);
                }
                else if (e.Key.KeyPressedName == "Left" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.LeftFocusableView);
                }
                else if (e.Key.KeyPressedName == "Right" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.RightFocusableView);
                }

                return(false);
            };

            // Move focus from checkBox3.
            checkBox3.KeyEvent += (obj, e) =>
            {
                if (e.Key.KeyPressedName == "Up" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBox2);
                }
                else if (e.Key.KeyPressedName == "Left" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.LeftFocusableView);
                }
                else if (e.Key.KeyPressedName == "Right" && Key.StateType.Up == e.Key.State)
                {
                    MoveFocusTo(checkBoxGroup.RightFocusableView);
                }

                return(false);
            };
        }