Beispiel #1
0
    public void Run(string[] args)
    {
        ProjectCommandLineApplication userJwts = new(_reporter)
        {
            Name = "dotnet user-jwts"
        };

        userJwts.HelpOption("-h|--help");

        // dotnet user-jwts list
        ListCommand.Register(userJwts);
        // dotnet user-jwts create
        CreateCommand.Register(userJwts);
        // dotnet user-jwts print ecd045
        PrintCommand.Register(userJwts);
        // dotnet user-jwts remove ecd045
        RemoveCommand.Register(userJwts);
        // dotnet user-jwts clear
        ClearCommand.Register(userJwts);
        // dotnet user-jwts key
        KeyCommand.Register(userJwts);

        // Show help information if no subcommand/option was specified.
        userJwts.OnExecute(() => userJwts.ShowHelp());

        try
        {
            userJwts.Execute(args);
        }
        catch (Exception ex)
        {
            _reporter.Error(ex.Message);
        }
    }
}
        public void HandlePlayerMovement(KeyCommand direction, bool fastForward = false)
        {
            switch (direction)
            {
            case KeyCommand.Down:
                HandleDownKeyPress(fastForward);
                break;

            case KeyCommand.Left:
                HandleLeftKeyPress();
                break;

            case KeyCommand.Right:
                HandleRightKeyPress();
                break;

            case KeyCommand.Up:
                HandleUpKeyPress();
                break;

            case KeyCommand.Escape:
                _game.Suicide();
                break;
            }
        }
Beispiel #3
0
 internal IMetaKey Add(ICombination combination, KeyEvent keyEvent, KeyCommand command,
                       string stateTree = KeyStateTrees.Default)
 {
     return(Add(new List <ICombination> {
         combination
     }, keyEvent, command, stateTree));
 }
        public override void OnKeyCommand(KeyCommand command)
        {
            switch (command)
            {
            case KeyCommand.Copy:
                _viewModel.CopyCommand.Execute(null);
                CopyInputToClipboardAnimation();
                break;

            case KeyCommand.Paste:
                _viewModel.PasteCommand.Execute(null);
                break;

            case KeyCommand.RootOperator:
                SquareRootButton.Command.Execute(SquareRootButton.CommandParameter);
                break;

            case KeyCommand.Calculate:
                CalculateButton.Command.Execute(null);
                break;

            case KeyCommand.Delete:
                DeleteButton.Command.Execute(null);
                break;
            }
        }
Beispiel #5
0
        public static KeyCommand GetDirection()
        {
            KeyCommand resultKeyCommand = KeyCommand.None;

            while (Console.KeyAvailable)
            {
                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.LeftArrow:
                    resultKeyCommand = KeyCommand.Left;
                    break;

                case ConsoleKey.RightArrow:
                    resultKeyCommand = KeyCommand.Right;
                    break;

                case ConsoleKey.UpArrow:
                    resultKeyCommand = KeyCommand.Up;
                    break;

                case ConsoleKey.DownArrow:
                    resultKeyCommand = KeyCommand.Down;
                    break;

                case ConsoleKey.Enter:
                    resultKeyCommand = KeyCommand.Enter;
                    break;

                case ConsoleKey.Escape:
                    resultKeyCommand = KeyCommand.Escape;
                    break;
                }
            }
            return(resultKeyCommand);
        }
Beispiel #6
0
        private void ExecuteCommand(KeyCommand toExecute)
        {
            Type declaringType = toExecute.commandMethod.DeclaringType;

            UnityEngine.Object[] objects = FindObjectsOfType(declaringType);

            ParameterInfo[] parameters = toExecute.commandMethod.GetParameters();

            if (parameters.Length == 0)
            {
                for (int i = 0; i < objects.Length; i++)
                {
                    toExecute.commandMethod.Invoke(objects[i], null);
                }
            }
            else
            {
                if (toExecute.parameters != null && toExecute.parameters.Length == parameters.Length)
                {
                    for (int i = 0; i < objects.Length; i++)
                    {
                        toExecute.commandMethod.Invoke(objects[i], toExecute.parameters);
                    }
                }
                else
                {
                    Debug.LogWarning($"Command with trigger '<color=red><b>{toExecute.commandKeyTriggers}<b></color>' has incorrect amount of parameters.");
                }
            }
        }
Beispiel #7
0
            public virtual void ParseCsv(string[] csv)
            {
                int i = 0;

                type     = int.Parse(csv[i++]);
                text     = csv[i++];
                page     = int.Parse(csv[i++]);
                x        = float.Parse(csv[i++]);
                y        = float.Parse(csv[i++]);
                value    = ParseString(csv[i++]);
                up       = ParseString(csv[i++]);
                shift    = ParseString(csv[i++]);
                capslock = ParseString(csv[i++]);
                //
                if (value.StartsWith("@"))
                {
                    cmd = (KeyCommand)System.Enum.Parse(typeof(KeyCommand), value.Substring(1));
                }
                else
                {
                    cmd = KeyCommand.Text;
                    if (string.IsNullOrEmpty(shift))
                    {
                        shift = value.ToUpper();
                    }
                    if (string.IsNullOrEmpty(capslock))
                    {
                        capslock = value.ToUpper();
                    }
                }
            }
Beispiel #8
0
        private void FindAllCommands()
        {
            // Find all MonoBehaviours.
            MonoBehaviour[] behaviours = FindObjectsOfType <MonoBehaviour>();
            for (int i = 0; i < behaviours.Length; i++)
            {
                // Find all methods.
                MethodInfo[] methodInfos = behaviours[i].GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static);

                // Find ConsoleCommand attribute.
                for (int ii = 0; ii < methodInfos.Length; ii++)
                {
                    if (Attribute.GetCustomAttribute(methodInfos[ii], typeof(KeyCommandAttribute)) is KeyCommandAttribute attribute)
                    {
                        KeyCommand newCommand = new KeyCommand
                        {
                            commandKeyTriggers = attribute.KeyCodes ?? new KeyCode[] { attribute.KeyCode },
                            pressType          = attribute.PressType,
                            commandMethod      = methodInfos[ii],
                            parameters         = attribute.Parameters ?? null
                        };

                        if (!commands.Contains(newCommand))
                        {
                            commands.Add(newCommand);
                        }
                    }
                }
            }
        }
	void Start()
    {
        keysCombined = false;
        // Dimension array
        PressedKeys = new Queue(maxkeys);
        RecentKeys = new Queue(maxkeys);
        {
            // Initialize array elements to blank
            
            for (int key = 0; key < maxkeys; key++)
            {
                KeyCommand newKey = new KeyCommand();
                KeyCommand blankKey = new KeyCommand();

                newKey.keyPressed = "";
                newKey.framePressed = 0;

                blankKey.keyPressed = "";
                blankKey.framePressed = 0;

                RecentKeys.Enqueue(newKey); // add blank key to keyqueue
                PressedKeys.Enqueue(blankKey);
            }
             
        }


        // Set up keys and combos
        if(ValidKeys.Length > 0)
        {
            KEY_FIRE = ValidKeys[0];
            KEY_WATER = ValidKeys[1];
            KEY_EARTH = ValidKeys[2];
            KEY_AIR = ValidKeys[3];

            // two-key combinations!

            TWOKEYS_FIREWATER   = KEY_FIRE + KEY_WATER;
            TWOKEYS_FIREEARTH   = KEY_FIRE + KEY_EARTH;
            TWOKEYS_FIREAIR     = KEY_FIRE + KEY_AIR;

            TWOKEYS_WATERFIRE   = KEY_WATER + KEY_FIRE;
            TWOKEYS_WATEREARTH  = KEY_WATER + KEY_EARTH;
            TWOKEYS_WATERAIR    = KEY_WATER + KEY_AIR;

            TWOKEYS_EARTHFIRE   = KEY_EARTH + KEY_FIRE;
            TWOKEYS_EARTHWATER  = KEY_EARTH + KEY_WATER;
            TWOKEYS_EARTHAIR    = KEY_EARTH + KEY_AIR;

            TWOKEYS_AIRFIRE     = KEY_AIR   + KEY_FIRE;
            TWOKEYS_AIRWATER    = KEY_AIR   + KEY_WATER;
            TWOKEYS_AIREARTH    = KEY_AIR   + KEY_EARTH;
        }


        // Generate all the spells.
        SpellCombos.GenerateSpells();

    }
        public override void OnKeyCommand(KeyCommand command)
        {
            var newItem = new Item()
            {
                Text = command.ToString(), Description = string.Empty
            };

            _viewModel.AddItemCommand.Execute(newItem);
        }
        public CustomToggleButton(ToggleButtonSpecs specs) : base(specs.Style)
        {
            SetResourceReference(StyleProperty, typeof(StyleToggleButton));

            KeyCommand = specs.KeyCommand;

            // Event binding
            Checked   += HandleChecked;
            Unchecked += HandleUnchecked;
        }
 void UpdateCommandQueue()
 {
     /*If we can move we want to update the current command*/
     /*If we have a different command queued*/
     if (_currentKeyCommand != _queuedCommand && _queuedCommand != KeyCommand.None)
     {
         /*Make sure we prefer the queued input*/
         _currentKeyCommand = _queuedCommand;
     }
 }
Beispiel #13
0
        /// <summary>
        /// Ctor.
        /// </summary>
        public MainViewModel()
        {
            SettingsViewModel  = new SettingsViewModel();
            StatisticViewModel = new StatisticViewModel();

            if (SettingsViewModel.EnableStatisticTracking)
            {
                StatisticViewModel.Startups++;
            }

            _checkBoxFilter             = "";
            _imagePathFilter            = "";
            _imagePathList              = new ObservableCollection <FileInfo>();
            _directoryList              = new ObservableCollection <SenpaiDirectory>();
            IncludeFolderSubDirectories = true;
            DeleteImage     = true;
            ResetCheckBoxes = true;
            LoadIgnoredPaths();
            LoadFavoritePaths();
            HotkeyPressedCommand = new KeyCommand(HotkeyPressed);
            TaskbarProgress      = new TaskbarItemInfo()
            {
                ProgressState = TaskbarItemProgressState.Normal
            };
            VlcPlayer = new VlcPlayer()
            {
                EndBehavior = EndBehavior.Repeat
            };
            if (Environment.Is64BitProcess)
            {
                VlcPlayer.LibVlcPath = @"..\..\..\Libs\Vlc\lib\x64-libs";
            }
            else
            {
                VlcPlayer.LibVlcPath = @"..\..\..\Libs\Vlc\lib\x86-libs";
            }

            ReverseImageSearchButtonImage     = "pack://application:,,,/SenpaiCopy;component/Resources/google-favicon.png";
            _reverseImageSearchWorker         = new BackgroundWorker();
            _reverseImageSearchWorker.DoWork += new DoWorkEventHandler(GoogleReverseImageSearch);
            _dispatcher = Dispatcher.CurrentDispatcher;
        }
Beispiel #14
0
        private void SpawnTail(KeyCommand currentDirection, Transform _transform)
        {
            Vector3 offset = Vector3.zero;

            switch (currentDirection)
            {
            case KeyCommand.None:
                break;

            case KeyCommand.MoveUp:
                offset = new Vector3(0, 1) * _tailOffset;

                break;

            case KeyCommand.MoveDown:
                offset = new Vector3(0, -1) * _tailOffset;

                break;

            case KeyCommand.MoveLeft:
                offset = new Vector3(-1, 0) * _tailOffset;

                break;

            case KeyCommand.MoveRight:
                offset = new Vector3(1, 0) * _tailOffset;

                break;

            default:
                break;
            }

            var tail = Instantiate(_tailPrefab, _transform.position - offset, Quaternion.identity);

            _tails.Add(tail);

            var tailBehav = (TailBehaviour)tail.GetComponent(typeof(TailBehaviour));

            tailBehav.SetUp(_movementSystem);
            _tailBehaviours.Add(tailBehav);
        }
Beispiel #15
0
        internal IMetaKey Add(IList <ICombination> sequence, KeyEvent keyEvent, KeyCommand command,
                              string stateTree = KeyStateTrees.Default)
        {
            foreach (var combination in sequence)
            {
                foreach (var keyInChord in combination.Chord)
                {
                    foreach (var code in keyInChord.Codes)
                    {
                        var key = (Key)code;
                        if (!key.IsCommonChordKey())
                        {
                            var keyStateTree = KeyStateTree.GetOrCreateStateTree(KeyStateTrees.ChordMap);
                            if (!keyStateTree.Contains(key))
                            {
                                MapOnHit(key.ToCombination(), key.ToCombination(), e => !e.IsVirtual, false);
                            }
                        }
                    }
                }
            }

            return(_hook.Add(sequence, new KeyEventCommand(keyEvent, command), stateTree));
        }
    public void CombineKeypresses()
    {
        // Attempt to combine keypresses into combined keypresses.
        PressedKeys.Clear();
        object[] checkArray = RecentKeys.ToArray();
        if (checkArray.Length > 0)
        {
            KeyCommand prevKeyCmd = (KeyCommand)checkArray[0];
            for (int key = 0; key < checkArray.Length; key++)
            {
                KeyCommand currentCheckKey = (KeyCommand)checkArray[key];
                KeyCommand combinedKey = new KeyCommand();

                // Check to see if the command was entered during the 15 frames of leniency
                //if ((Math.Abs(currentCheckKey.framePressed - prevKeyCmd.framePressed) <= 7) &&
                //    (currentCheckKey.keyPressed != prevKeyCmd.keyPressed))
                //{
                //    // Combine these keys.
                //    combinedKey.keyPressed = prevKeyCmd.keyPressed + currentCheckKey.keyPressed;
                //    combinedKey.framePressed = currentCheckKey.framePressed;
                //    currentCheckKey.combined = true;
                    
                    
                //    combinedKey.combined = true;
                //    combinedKey.pressed = true;
                //}
                //else
                {
                    combinedKey = currentCheckKey;
                    
                }
                
                PressedKeys.Enqueue(combinedKey);
                

                prevKeyCmd = currentCheckKey;

            }
            
        }

        keysCombined = true;
    }
    public void ResetQueues()
    {
        RecentKeys.Clear();
        PressedKeys.Clear();
        for (int key = 0; key < maxkeys; key++)
        {
            KeyCommand newKey = new KeyCommand();
            KeyCommand blankKey = new KeyCommand();

            newKey.keyPressed = "";
            newKey.framePressed = 0;
            newKey.pressed = false;

            blankKey.keyPressed = "";
            blankKey.framePressed = 0;
            blankKey.pressed = false;

            RecentKeys.Enqueue(newKey); // add blank key to keyqueue
            PressedKeys.Enqueue(blankKey);
        }
    }
	void Update()
    {
        // Ensure ValidKeys have been set in the editor
        if (ValidKeys.Length > 0)
        {
            // Check each validkey
            foreach (string key in ValidKeys)
            {
                // If the key is down, add to the array
                if (Input.GetKeyDown(key))
                {
                    // Push all the other keys back one 
                    


                    // Store what was pressed, and when.
                    KeyCommand newKey = new KeyCommand();
                    newKey.keyPressed = key;
                    newKey.framePressed = Time.renderedFrameCount;
                    newKey.combined = false;
                    newKey.pressed = false;

                    if (RecentKeys.Count > 0)
                    {
                        RecentKeys.Dequeue();
                    }
                    RecentKeys.Enqueue(newKey);

                    keysCombined = false;
               
                   
                }
            }
        }


        
        if(Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            CastSpell();
        }
        
        



        



	}
		public KeyNode(KeyCommand command, Gdk.Key key)
        {
			this.Key = key;
			commandString = KeyCommandToString(command);
			this.keyCommand = command;
			Pressed = false;
		}
	protected void DoKeyCommand(KeyCommand? command){
		if(command == null){
			return;
		}
		switch(command){
			case KeyCommand.Backward:
				SendVehicleCommand();
			break;
			case KeyCommand.DecMotor3Speed:
				Gtk.Application.Invoke (delegate {
					motor3SpeedScale.Value -= IncStep;
				});
				SendMotorCommand();
			break;
			case KeyCommand.DecTurnPercent:
				Gtk.Application.Invoke (delegate {
					vehicleTurnRatioScale.Value -= IncStep;
				});
				SendVehicleCommand();
			break;
		 	case KeyCommand.DecVehicleSpeed:
				Gtk.Application.Invoke (delegate {
					vehicleSpeedScale.Value -= IncStep;
				});
				SendVehicleCommand();
			break;
			case KeyCommand.Forward:
				SendVehicleCommand();
			break;
			case KeyCommand.IncMotor3Speed:
				Gtk.Application.Invoke (delegate {
					motor3SpeedScale.Value += IncStep;
				});
				SendMotorCommand();
			break;
			case KeyCommand.IncTurnPercent:
				Gtk.Application.Invoke (delegate {
					vehicleTurnRatioScale.Value += IncStep;
				});
				SendVehicleCommand();
			break;
			case KeyCommand.IncVehicleSpeed:
				Gtk.Application.Invoke (delegate {
					vehicleSpeedScale.Value += IncStep;
				});
				SendVehicleCommand();
			break;
			case KeyCommand.Motor3Fwd:
				SendMotorCommand();
			break;
			case KeyCommand.Motor3Rev:
				SendMotorCommand();
			break;
			case KeyCommand.SpinLeft:
				SendVehicleCommand();
			break;
			case KeyCommand.SpinRight:
				SendVehicleCommand();
			break;
			case KeyCommand.IncSpinSpeed:
				Gtk.Application.Invoke (delegate {
					spinSpeedScale.Value += IncStep;
				});
				SendVehicleCommand();
			break;
			case KeyCommand.DecSpinSpeed:
				Gtk.Application.Invoke (delegate {
					spinSpeedScale.Value -= IncStep;
				});
				SendVehicleCommand();
			break;
			case KeyCommand.ReadSensor1:
				OnReadSensor1ButtonClicked(null,null);
			break;
			case KeyCommand.ReadSensor2:
				OnReadSensor2ButtonClicked(null,null);
			break;
			case KeyCommand.ReadSensor3:
				OnReadSensor3ButtonClicked(null,null);
			break;
			case KeyCommand.ReadSensor4:
				OnReadSensor4ButtonClicked(null,null);
			break;
			case KeyCommand.SendMessage1:
				this.SendMessageSetting(0);
			break;
			case KeyCommand.SendMessage2:
				this.SendMessageSetting(1);
			break;
			case KeyCommand.SendMessage3:
				this.SendMessageSetting(2);
			break;
			case KeyCommand.SendMessage4:
				this.SendMessageSetting(3);
			break;
			case KeyCommand.SendMessage5:
				this.SendMessageSetting(4);
			break;


		}
	}
		private string KeyCommandToString(KeyCommand command){
			string s = "test";
			switch(command){
				case KeyCommand.Backward:
					s = "Vehicle Backward";
				break;
				case KeyCommand.DecMotor3Speed:
					s = "Dec. motor speed";
				break;
				case KeyCommand.DecTurnPercent:
					s = "Dec. turn-percent";
				break;
			 	case KeyCommand.DecVehicleSpeed:
					s = "Dec. vehicle speed";
				break;
				case KeyCommand.Forward:
					s = "Vehicle forward";
				break;
				case KeyCommand.IncMotor3Speed:
					s = "Inc. motor speed";
				break;
				case KeyCommand.IncTurnPercent:
					s = "Inc. turn-percent";
				break;
				case KeyCommand.IncVehicleSpeed:
					s = "Inc. vehicle speed";
				break;
				case KeyCommand.Motor3Fwd:
					s = "Motor forward";
				break;
				case KeyCommand.Motor3Rev:
					s = "Motor reverse";
				break;
				case KeyCommand.SpinLeft:
					s = "Spin left";
				break;
				case KeyCommand.SpinRight:
					s = "Spin right";
				break;
				case KeyCommand.IncSpinSpeed:
					s = "Inc. spin speed";
				break;
				case KeyCommand.DecSpinSpeed:
					s = "Dec. spin speed";
				break;
				case KeyCommand.ReadSensor1:
					s = "Read sensor 1";
				break;
				case KeyCommand.ReadSensor2:
					s = "Read sensor 2";
				break;
				case KeyCommand.ReadSensor3:
					s = "Read sensor 3";
				break;
				case KeyCommand.ReadSensor4:
					s = "Read sensor 4";
				break;
				case KeyCommand.SendMessage1:
					s = "Send Message 1";
				break;
				case KeyCommand.SendMessage2:
					s = "Send Message 2";
				break;
				case KeyCommand.SendMessage3:
					s = "Send Message 3";
				break;
				case KeyCommand.SendMessage4:
					s = "Send Message 4";
				break;
				case KeyCommand.SendMessage5:
					s = "Send Message 5";
				break;
			}
			return s;
		}
	protected void SaveKeyCommand(KeyCommand command, Gdk.Key key){
		switch(command){
			case KeyCommand.Backward:
				settings.Backward = (int) key;
			break;
			case KeyCommand.DecMotor3Speed:
				settings.DecMotor3Speed = (int) key;
			break;
			case KeyCommand.DecTurnPercent:
				settings.DecTurnPercent = (int) key;
			break;
		 	case KeyCommand.DecVehicleSpeed:
				settings.DecVehicleSpeed = (int) key;
			break;
			case KeyCommand.Forward:
				settings.Forward = (int) key;
			break;
			case KeyCommand.IncMotor3Speed:
				settings.IncMotor3Speed = (int) key;
			break;
			case KeyCommand.IncTurnPercent:
				settings.IncTurnPercent = (int) key;
			break;
			case KeyCommand.IncVehicleSpeed:
				settings.IncVehicleSpeed = (int) key;
			break;
			case KeyCommand.Motor3Fwd:
				settings.Motor3Fwd = (int) key;
			break;
			case KeyCommand.Motor3Rev:
				settings.Motor3Rev = (int) key;
			break;
			case KeyCommand.SpinLeft:
				settings.SpinLeft = (int) key;
			break;
			case KeyCommand.SpinRight:
				settings.SpinRight = (int) key;
			break;
			case KeyCommand.IncSpinSpeed:
				settings.IncSpinSpeed = (int) key;
			break;
			case KeyCommand.DecSpinSpeed:
				settings.DecSpinSpeed = (int) key;
			break;
			case KeyCommand.ReadSensor1:
				settings.ReadKeySensor1 = (int) key;
			break;
			case KeyCommand.ReadSensor2:
				settings.ReadKeySensor2 = (int) key;
			break;
			case KeyCommand.ReadSensor3:
				settings.ReadKeySensor3 = (int) key;
			break;
			case KeyCommand.ReadSensor4:
				settings.ReadKeySensor4 = (int) key;
			break;
			case KeyCommand.SendMessage1:
				settings.SendMessage1 = (int) key;
			break;
			case KeyCommand.SendMessage2:
				settings.SendMessage2 = (int) key;
			break;
			case KeyCommand.SendMessage3:
				settings.SendMessage3 = (int) key;
			break;
			case KeyCommand.SendMessage4:
				settings.SendMessage4 = (int) key;
			break;
			case KeyCommand.SendMessage5:
				settings.SendMessage5 = (int) key;
			break;
		}
		settings.Save();
	}