public void HeroMove(object sender, UserInputEventArgs args) { //if (!isActive) return; switch (args.Key) { case ConsoleKey.UpArrow: NextPosition.Y--; break; case ConsoleKey.DownArrow: NextPosition.Y++; break; case ConsoleKey.LeftArrow: NextPosition.X--; break; case ConsoleKey.RightArrow: NextPosition.X++; break; } HeroEvent?.Invoke(this, EventArgs.Empty); Update(); color = ConsoleColor.White; }
static void OnUserPrompt(Object sender, UserInputEventArgs e) { Console.WriteLine(); Console.Write(e.Message); Console.Write(": "); e.Continue(Console.ReadLine()); }
private static void HandleApplicationUserInput( object sender, UserInputEventArgs userInputEventArgs) { Console.ForegroundColor = userInputEventArgs.UserInputType != UserInputType.Warning ? ConsoleColor.White : ConsoleColor.Yellow; Console.Write(userInputEventArgs.Message); userInputEventArgs.UserInput = Console.ReadLine(); }
protected virtual void OnUserInputError(UserInputEventArgs e) { EventHandler<UserInputEventArgs> handler = UserInputError; if (handler != null) { handler(this, e); } }
private void OnUserInput(object sender, UserInputEventArgs e) { var context = new Tuple <Scene, UserInputEventArgs>(Parent, e); if (CanExecute(context)) { ExecuteAction(e); } }
private void CleanSourceDirectories( IEnumerable <string> sourceDirectories, ref int deletedDirectories, ref int errorsCount) { string str = (string)null; foreach (string sourceDirectory in sourceDirectories) { try { bool recursive; if (this.systemContext.DirectoryEntries(sourceDirectory).Any <string>()) { if (string.IsNullOrWhiteSpace(str)) { UserInputEventArgs e = new UserInputEventArgs(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.Warning_DeletingNonEmptyDirectory, (object)sourceDirectory), UserInputType.Warning); this.OnUserInput(e); str = (e.UserInput ?? string.Empty).ToUpper(CultureInfo.CurrentCulture); } switch (str) { case "YA": recursive = true; break; case "NA": continue; case "Y": case "YES": str = (string)null; goto case "YA"; default: str = (string)null; continue; } } else { recursive = false; } this.systemContext.DeleteDirectory(sourceDirectory, recursive); ++deletedDirectories; } catch (Exception ex) { this.OnMessageSent(new MessageSentEventArgs(ex.Message, MessageType.Warning)); ++errorsCount; } } }
public void StartNotification() { args = new UserInputEventArgs(); while (true) { args.Key = Console.ReadKey().Key; if (args.Key == ConsoleKey.Escape) { break; } InputNotification?.Invoke(this, args); } }
private bool HandleEmptyCommandLine() { UserInputEventArgs e = new UserInputEventArgs(Resources.Warning_NoCommandLineArgs, UserInputType.Warning); this.OnUserInput(e); string str = string.IsNullOrWhiteSpace(e.UserInput) ? string.Empty : e.UserInput.ToUpper(CultureInfo.CurrentCulture); if (!(str == "Y")) { return(str == "YES"); } return(true); }
public override UserInputResult OnInput(UserInputEventArgs input) { //Apply if (input.down && input.key == UserInputKey.LEFT) { selectedDigit++; } if (input.down && input.key == UserInputKey.RIGHT) { selectedDigit--; } if (input.down && input.key == UserInputKey.UP) { value += (long)Math.Pow(10, selectedDigit); } if (input.down && input.key == UserInputKey.DOWN) { value -= (long)Math.Pow(10, selectedDigit); } //Make sure it's within bounds if (value < minValue) { value = minValue; } if (value > maxValue) { value = maxValue; } //Invalidate Invalidate(); if (input.down && (input.key == UserInputKey.UP || input.key == UserInputKey.DOWN)) { OnValueChanged?.Invoke(value); } //Return result if (selectedDigit < 0) { return(UserInputResult.MoveNext); } else if (selectedDigit >= numberCount) { return(UserInputResult.MovePrevious); } else { return(UserInputResult.HandledSelf); } }
void UserInput(Object sender, UserInputEventArgs e) { Dispatch(() => { var service = Container.Get <IMathInputService>(); var context = new InputViewModel(service); if (!String.IsNullOrEmpty(e.Message)) { context.UserMessage = e.Message; } var window = WindowFactory.Instance.Create(context); window.Closed += (s, ev) => e.Continue(context.Result); window.Show(); }); }
public override UserInputResult OnInput(UserInputEventArgs input) { if (input.down && input.key == UserInputKey.UP) { currentTab = Math.Max(0, currentTab - 1); } if (input.down && input.key == UserInputKey.DOWN) { currentTab = Math.Max(tabs.Length - 1, currentTab + 1); } if (input.down && input.key == UserInputKey.B) { SDR.CloseActiveFrame(); return(UserInputResult.HandledSelf); } Invalidate(); return(UserInputResult.HandledSelf); }
public override UserInputResult OnInput(UserInputEventArgs input) { //Check if we're trying to move if (input.down && input.key == UserInputKey.RIGHT) { return(UserInputResult.MoveNext); } if (input.down && input.key == UserInputKey.LEFT) { return(UserInputResult.MovePrevious); } //Update if (input.down && input.key == UserInputKey.UP) { currentOption++; } if (input.down && input.key == UserInputKey.DOWN) { currentOption--; } //Clamp if (currentOption >= options.Length) { currentOption = 0; } if (currentOption < 0) { currentOption = options.Length - 1; } //Invalidate Invalidate(); if (input.down && (input.key == UserInputKey.DOWN || input.key == UserInputKey.UP)) { OnValueChanged?.Invoke(currentOption); } //Return OK return(UserInputResult.HandledSelf); }
public override UserInputResult OnInput(UserInputEventArgs input) { //Check if we're trying to move if (input.down && input.key == UserInputKey.RIGHT) { return(UserInputResult.MoveNext); } if (input.down && input.key == UserInputKey.LEFT) { return(UserInputResult.MovePrevious); } //Update if (input.down && input.key == UserInputKey.A) { callback(); } //Return OK return(UserInputResult.HandledSelf); }
public void ExecuteAction(UserInputEventArgs e) { Action(Parent, e); }
//Default implementation of what should be done with the event. public virtual void UserInputErrorHandler(object sender, UserInputEventArgs e) { string header = string.Format("{0} - InputError",DisplayName); MessageBox.Show(e.ErrorMessage,header,MessageBoxButton.OK,MessageBoxImage.Exclamation); }
private void HandleUserInput(object sender, UserInputEventArgs userInputEventArgs) { this.OnUserInput(userInputEventArgs); }
private void OnUserInput(object source, UserInputEventArgs args) { StartExhaust(args.Direction); }
private void HandleDirectorySorterUserInput( object sender, UserInputEventArgs userInputEventArgs) { this.OnUserInput(userInputEventArgs); }