Esempio n. 1
0
    public void UpdateModifiedValue()
    {
        var valueToAdd = 0;

        for (int i = 0; i < modifiers.Count; i++)
        {
            modifiers[i].AddValue(ref valueToAdd);
        }
        ModifiedValue = baseValue + valueToAdd;
        if (OnValueModified != null)
        {
            OnValueModified.Invoke();
        }
    }
Esempio n. 2
0
        public override void Update(DwarfTime time)
        {
            if (IsMouseOver && Focused)
            {
                MouseState mouse = Mouse.GetState();
                if (mouse.LeftButton == ButtonState.Pressed)
                {
                    const int padding     = 5;
                    const int fieldWidth  = 64;
                    const int fieldHeight = 32;
                    float     w           = GlobalBounds.Width - padding * 2 - fieldWidth;
                    float     d           = (mouse.X - (GlobalBounds.X + padding)) / w;

                    if (Orient == Orientation.Vertical)
                    {
                        w = GlobalBounds.Height - padding * 2 - fieldHeight;
                        d = (mouse.Y - (GlobalBounds.Y - padding)) / w;
                    }

                    if (d > 1.0f)
                    {
                        d = 1.0f;
                    }
                    else if (d < 0)
                    {
                        d = 0.0f;
                    }


                    if (InvertValue)
                    {
                        d = (1.0f - d);
                    }

                    SliderValue = d * (MaxValue - MinValue) + MinValue;

                    OnValueModified.Invoke(SliderValue);
                }
            }
            else
            {
                Focused = false;
            }

            base.Update(time);
        }