Beispiel #1
0
 private void OnStateChanged(object sender, Slider.StateChangedArgs args)
 {
     if (sender is Tizen.NUI.Components.Slider)
     {
         Tizen.NUI.Components.Slider slider = sender as Tizen.NUI.Components.Slider;
         if (slider != null)
         {
             // Do something
         }
     }
 }
        /// <summary>
        /// RadioButton 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 = 15.0f;
            guide.PointSize = DeviceCheck.PointSize15;
            guide.Text      = "Slider 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);

            userGuide = new TextLabel();
            userGuide.HorizontalAlignment    = HorizontalAlignment.Begin;
            userGuide.VerticalAlignment      = VerticalAlignment.Top;
            userGuide.PositionUsesPivotPoint = true;
            userGuide.ParentOrigin           = ParentOrigin.TopLeft;
            userGuide.PivotPoint             = PivotPoint.TopLeft;
            userGuide.FontFamily             = "Samsung One 400";
            userGuide.Position  = new Position(200, 200, 0);
            userGuide.MultiLine = true;
            //userGuide.PointSize = 10.0f;
            userGuide.PointSize = DeviceCheck.PointSize10;
            userGuide.Text      = "KEY Left: Decrease the value.\n" +
                                  "KEY Right: Increase the value.\n";
            userGuide.TextColor = Color.White;
            Window.Instance.GetDefaultLayer().Add(userGuide);

            Sliders sliderSample = new Sliders();

            sliderView          = sliderSample.GetHorizentalSlider();
            sliderView.Position = new Position(760, 550, 0);
            slider = sliderSample.GetSlider();
            Window.Instance.GetDefaultLayer().Add(sliderView);
            FocusManager.Instance.SetCurrentFocusView(slider);
        }
        /// <summary>
        /// Initial the horizontal view.
        /// </summary>
        private void InitializeHorizontalView()
        {
            TextLabel leftValueHor = new TextLabel();

            leftValueHor.TextColor    = Color.White;
            leftValueHor.ParentOrigin = ParentOrigin.TopLeft;
            leftValueHor.Position2D   = new Position2D(0, 15);
            //leftValueHor.PointSize = 8.0f;
            leftValueHor.PointSize = DeviceCheck.PointSize8;

            TextLabel rightValueHor = new TextLabel();

            rightValueHor.TextColor    = Color.White;
            rightValueHor.ParentOrigin = ParentOrigin.TopLeft;
            rightValueHor.Position2D   = new Position2D((sliderWidth + 35), 15);
            //rightValueHor.PointSize = 8.0f;
            rightValueHor.PointSize = DeviceCheck.PointSize8;

            TextLabel currentValueHor = new TextLabel();

            currentValueHor.TextColor    = Color.White;
            currentValueHor.ParentOrigin = ParentOrigin.TopLeft;
            //currentValueHor.PointSize = 8.0f;
            currentValueHor.PointSize  = DeviceCheck.PointSize8;
            currentValueHor.Position2D = new Position2D(170, 50);

            horizontalView.Add(leftValueHor);
            horizontalView.Add(rightValueHor);
            horizontalView.Add(currentValueHor);

            horizontalSlider = new Tizen.NUI.Components.Slider();
            horizontalSlider.ParentOrigin          = ParentOrigin.TopLeft;
            horizontalSlider.Position2D            = new Position2D(25, 12);
            horizontalSlider.Size2D                = new Size2D(sliderWidth, 30);
            horizontalSlider.MinValue              = 0.0f;
            horizontalSlider.MaxValue              = 100.0f;
            horizontalSlider.CurrentValue          = 100;
            currentValueHor.Position2D             = new Position2D((int)GetHorizontalSliderPosition(), currentValueHor.Position2D.Y);
            horizontalSlider.ThumbImageURLSelector = new StringSelector()
            {
                Normal  = handleUnSelectedVisual,
                Pressed = handleSelectedVisual
            };
            horizontalSlider.ThumbImageBackgroundURLSelector = new StringSelector()
            {
                All = trackVisual
            };
            horizontalSlider.ValueChangedEvent += (obj, e) =>
            {
                float radio     = horizontalSlider.CurrentValue / (horizontalSlider.MinValue - horizontalSlider.MaxValue);
                float positionX = GetHorizontalSliderPosition();

                currentValueHor.Position2D = new Position2D((int)positionX, currentValueHor.Position2D.Y);
                currentValueHor.Text       = ((int)horizontalSlider.CurrentValue).ToString();
            };


            leftValueHor.Text    = ((int)horizontalSlider.MinValue).ToString();
            rightValueHor.Text   = ((int)horizontalSlider.MaxValue).ToString();
            currentValueHor.Text = "0";
            horizontalView.Add(horizontalSlider);

            horizontalSlider.Focusable = true;
            FocusManager.Instance.SetCurrentFocusView(horizontalSlider);

            horizontalSlider.KeyEvent += (obj, ee) =>
            {
                if ("Left" == ee.Key.KeyPressedName && Key.StateType.Up == ee.Key.State)
                {
                    if (horizontalSlider.CurrentValue > 0)
                    {
                        horizontalSlider.CurrentValue--;
                    }
                }
                else if ("Right" == ee.Key.KeyPressedName && Key.StateType.Up == ee.Key.State)
                {
                    if (horizontalSlider.CurrentValue < 100)
                    {
                        horizontalSlider.CurrentValue++;
                    }
                }
                else if ("Up" == ee.Key.KeyPressedName && Key.StateType.Up == ee.Key.State)
                {
                    MoveFocusTo(horizontalView.UpFocusableView);
                }

                return(false);
            };
        }