Example #1
0
        private void RegisterToggle(LayerModel layerModel, int index)
        {
            Action downAction = null;
            Action upAction   = null;

            switch (ToggleType)
            {
            case ToggleType.EnableHeldDown:
                layerModel.RenderAllowed = false;
                downAction = () => layerModel.RenderAllowed = true;
                upAction   = () => layerModel.RenderAllowed = false;
                break;

            case ToggleType.DisableHeldDown:
                downAction = () => layerModel.RenderAllowed = false;
                upAction   = () => layerModel.RenderAllowed = true;
                break;
            }

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, downAction);
                _upKeybind   = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", HotKey, PressType.Up, upAction);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, downAction);
                _upKeybind   = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", MouseButtons.Value, PressType.Up, upAction);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
            KeybindManager.AddOrUpdate(_upKeybind);
            return;
        }
Example #2
0
        private void RegisterEvent(LayerModel layerModel, int index)
        {
            Action action = () =>
            {
                layerModel.EventProperties.TriggerEvent(layerModel);
            };

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, action);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, action);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
        }
Example #3
0
        private void RegisterRegular(LayerModel layerModel, int index)
        {
            // Bind Enable, Disable or Toggle
            Action action = null;

            switch (ToggleType)
            {
            case ToggleType.Enable:
                // Apply RenderAllowed only if this is the first keybind
                if (index == 0)
                {
                    layerModel.RenderAllowed = false;
                }
                action = () => layerModel.RenderAllowed = true;
                break;

            case ToggleType.Disable:
                // Apply RenderAllowed only if this is the first keybind
                if (index == 0)
                {
                    layerModel.RenderAllowed = false;
                }
                action = () => layerModel.RenderAllowed = false;
                break;

            case ToggleType.Toggle:
                action = () => layerModel.RenderAllowed = !layerModel.RenderAllowed;
                break;
            }

            // Either bind HotKey or mouse buttons depending on what isn't null
            if (HotKey != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, action);
            }
            else if (MouseButtons != null)
            {
                _downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, action);
            }
            KeybindManager.AddOrUpdate(_downKeybind);
        }