Ejemplo n.º 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();
        }
Ejemplo n.º 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;
        }