예제 #1
0
        public CheckBox(string displayName, bool defaultValue = true) : base(displayName, DefaultHeight)
        {
            // Initialize properties
            TextObjects.Add(TextHandle = new Text(displayName, DefaultFont)
            {
                Color           = DefaultColorGold,
                TextOrientation = Text.Orientation.Center
            });
            ControlHandle = new CheckBoxHandle();
            CurrentValue  = defaultValue;

            ControlHandle.OnActiveStateChanged += delegate
            {
                // Listen to active state changes
                CurrentValue = ControlHandle.IsActive;

                // Hover even when clicked on text
                if (IsMouseInside && !ControlHandle.IsMouseInside)
                {
                    ControlHandle.CurrentState = ControlHandle.IsActive ? DynamicControl.States.ActiveHover : DynamicControl.States.Hover;
                }
            };

            // Add handle to base
            Add(ControlHandle);

            // Initalize theme specific properties
            OnThemeChange();
        }
예제 #2
0
        public KeyBind(string displayName, bool defaultValue, BindTypes bindType, Tuple <uint, uint> defaultKeys)
            : base(displayName, DefaultHeight)
        {
            // Initialize properties
            ControlHandle = new CheckBoxHandle(bindType)
            {
                IsActive = defaultValue
            };
            TextObjects.Add(TextHandle = new Text(DisplayName, DefaultFont)
            {
                TextOrientation = Text.Orientation.Bottom,
                Color           = DefaultColorGold
            });
            DefaultValue = defaultValue;
            CurrentValue = defaultValue;
            BindType     = bindType;
            Keys         = defaultKeys;
            Buttons      = new Tuple <KeyButtonHandle, KeyButtonHandle>(new KeyButtonHandle(KeyStrings.Item1, this, true), new KeyButtonHandle(KeyStrings.Item2, this));

            // Initalize theme specific properties
            OnThemeChange();

            // Listen to active state changes
            ControlHandle.OnActiveStateChanged += delegate(DynamicControl sender, EventArgs args) { CurrentValue = sender.IsActive; };

            // Add controls to base container
            Add(ControlHandle);
            Add(Buttons.Item1);
            Add(Buttons.Item2);

            // Listen to required events
            Buttons.Item1.OnActiveStateChanged += OnActiveStateChanged;
            Buttons.Item2.OnActiveStateChanged += OnActiveStateChanged;
        }
예제 #3
0
            internal ComboBoxHandle(string defaultText) : base(ThemeManager.SpriteType.ControlComboBox)
            {
                // Initialize properties
                TextObjects.Add(TextHandle = new Text(defaultText, DefaultFont)
                {
                    Color = DefaultColorGold
                });

                // Initalize theme specific properties
                OnThemeChange();
            }
예제 #4
0
        internal Label(string displayName, int height) : base(displayName, height)
        {
            // Initialize properties
            TextObjects.Add(TextHandle = new Text(displayName, DefaultFont)
            {
                Color = DefaultColorGreen
            });
            TextWidthMultiplier = 1;

            // Initalize theme specific properties
            OnThemeChange();
        }
예제 #5
0
            public KeyButtonHandle(string keyText, KeyBind parent, bool isFirstButton = false) : base(ThemeManager.SpriteType.Empty)
            {
                // Initialize properties
                TextObjects.Add(TextHandle = new Text(keyText, DefaultFont)
                {
                    TextAlign = Text.Align.Center,
                    Color     = DefaultColorGold
                });
                KeyText       = keyText;
                ParentHandle  = parent;
                IsFirstButton = isFirstButton;

                // Initalize theme specific properties
                OnThemeChange();
            }
예제 #6
0
 internal void SetText(string text, Text.Align align, int xOffset = 0, int yOffset = 0)
 {
     TextValue = text;
     if (TextHandle == null)
     {
         if (TextDictionary.ContainsKey(CurrentButtonType))
         {
             TextHandle       = TextDictionary[CurrentButtonType](CurrentButtonType == ButtonType.Addon ? text.ToUpper() : text);
             TextHandle.Color = CurrentColorModificationValue.Combine(DefaultColorValues[CurrentButtonType]);
             TextObjects.Add(TextHandle);
         }
         else
         {
             return;
         }
     }
     else
     {
         TextHandle.TextValue = CurrentButtonType == ButtonType.Addon ? text.ToUpper() : text;
     }
     TextHandle.TextAlign = align;
     TextHandle.Padding   = new Vector2(xOffset, yOffset);
     TextHandle.ApplyToControlPosition(this);
 }