コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: Repl.cs プロジェクト: marcusanth/YAMP
 static void OnUserPrompt(Object sender, UserInputEventArgs e)
 {
     Console.WriteLine();
     Console.Write(e.Message);
     Console.Write(": ");
     e.Continue(Console.ReadLine());
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: mneman/PhotoOrganizer
 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();
 }
コード例 #4
0
 protected virtual void OnUserInputError(UserInputEventArgs e)
 {
     EventHandler<UserInputEventArgs> handler = UserInputError;
     if (handler != null)
     {
         handler(this, e);
     }
 }
コード例 #5
0
        private void OnUserInput(object sender, UserInputEventArgs e)
        {
            var context = new Tuple <Scene, UserInputEventArgs>(Parent, e);

            if (CanExecute(context))
            {
                ExecuteAction(e);
            }
        }
コード例 #6
0
        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;
                }
            }
        }
コード例 #7
0
 public void StartNotification()
 {
     args = new UserInputEventArgs();
     while (true)
     {
         args.Key = Console.ReadKey().Key;
         if (args.Key == ConsoleKey.Escape)
         {
             break;
         }
         InputNotification?.Invoke(this, args);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
ファイル: MainViewModel.cs プロジェクト: csuffyy/Sumerics
        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();
            });
        }
コード例 #11
0
 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);
 }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public void ExecuteAction(UserInputEventArgs e)
 {
     Action(Parent, e);
 }
コード例 #15
0
 //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);
 }
コード例 #16
0
 private void HandleUserInput(object sender, UserInputEventArgs userInputEventArgs)
 {
     this.OnUserInput(userInputEventArgs);
 }
コード例 #17
0
 private void OnUserInput(object source, UserInputEventArgs args)
 {
     StartExhaust(args.Direction);
 }
コード例 #18
0
 private void HandleDirectorySorterUserInput(
     object sender,
     UserInputEventArgs userInputEventArgs)
 {
     this.OnUserInput(userInputEventArgs);
 }