Ejemplo n.º 1
0
 public Slider(UIManager manager, IUIElement parent) : base(manager, parent)
 {
     background      = Color.LightGray;
     backgroundHover = Color.White;
     foreground      = foregroundHover = Color.Black;
     handle          = new SliderHandle();
     steps           = -1;
 }
Ejemplo n.º 2
0
        public int GetHandlePosition()
        {
            string attribute = SliderHandle.GetAttribute("style");

            string [] stringNumbers = Regex.Split(attribute, @"\D+");
            stringNumbers = stringNumbers.Where(x => !string.IsNullOrEmpty(x)).ToArray();

            int number = int.Parse(stringNumbers[0]);

            return(number);
        }
Ejemplo n.º 3
0
        public Slider(string displayName, int defaultValue = 0, int minValue = 0, int maxValue = 100)
            : base(displayName, DefaultHeight + ThemeManager.CurrentTheme.Config.SpriteAtlas.Backgrounds.Slider.Height)
        {
            // Initialize properties
            TextObjects.AddRange(new[]
            {
                TextHandle = new Text(displayName, DefaultFont)
                {
                    TextOrientation = Text.Orientation.Top,
                    Color           = DefaultColorGold
                },
                ValueDisplayHandle = new Text("placeholder", DefaultFont)
                {
                    TextOrientation = Text.Orientation.Top,
                    TextAlign       = Text.Align.Right,
                    Color           = DefaultColorGold
                }
            });
            Background = new EmptyControl(ThemeManager.SpriteType.BackgroundSlider)
            {
                DrawBase = true
            };
            ControlHandle = new SliderHandle();
            _minValue     = Math.Min(minValue, maxValue);
            _maxValue     = Math.Max(minValue, maxValue);
            CurrentValue  = defaultValue;

            // Add handle to base
            Add(Background);
            Add(ControlHandle);

            // Listen to required events
            Background.OnLeftMouseDown += delegate
            {
                if (!ControlHandle.IsLeftMouseDown && Background.IsInside(Game.CursorPos2D))
                {
                    MoveOffset = 0 - SliderSize / 2;
                    RecalculateSliderPosition((int)Game.CursorPos2D.X - SliderSize / 2);
                    ControlHandle.IsLeftMouseDown = true;
                }
            };
            ControlHandle.OnLeftMouseDown      += delegate { MoveOffset = (int)((ControlHandle.Position.X - RelativeOffset.X) - Game.CursorPos2D.X); };
            ControlHandle.OnActiveStateChanged += delegate
            {
                if (ControlHandle.IsActive)
                {
                    ControlHandle.IsActive = false;
                }
            };

            // Initalize theme specific properties
            OnThemeChange();
        }
Ejemplo n.º 4
0
 private void StartBakeUI()
 {
     SliderScript = BakeCanvas.GetComponent <SliderHandle>();
     MaxClicks    = SliderScript.GetMaxClicks();
     if (BakeCanvasGroup == null)
     {
         BakeCanvasGroup = BakeCanvas.GetComponent <CanvasGroup>();
     }
     if (BakeCanvasGroup != null)
     {
         EnableCanvas(BakeCanvas, false); //this disables both the canvas and canvasgroup
     }
     SliderScript.enabled = false;
 }
Ejemplo n.º 5
0
 public void MoveSliderHead(IWebElement sliderHead, SliderHandle sliderHandle)
 {
     sliderHead.Click();
     if (sliderHandle == SliderHandle.LEFT)
     {
         for (int i = 0; i < Constants.RANDOM_NUMBER.Next(3, 10); i++)
         {
             sliderHead.SendKeys(Keys.ArrowLeft);
         }
     }
     else
     {
         for (int i = 0; i < Constants.RANDOM_NUMBER.Next(3, 10); i++)
         {
             sliderHead.SendKeys(Keys.ArrowRight);
         }
     }
 }
Ejemplo n.º 6
0
 public void MoveRightSlider(SliderHandle direction)
 {
     base.MoveSliderHead(PriceSliderHeads[1], direction);
 }
Ejemplo n.º 7
0
 public void MoveLeftSlider(SliderHandle direction)
 {
     base.MoveSliderHead(PriceSliderHeads[0], direction);
 }