예제 #1
0
		static void Main()
		{
			var rootWindow = new RootWindow();
			var selectBox = new SelectBox(new string[] { "First", "Second", "Last", "Another",
			                                             "2",
			                                             "3",
			                                             "4",
			                                             "5",
			                                             "6",
			                                             "7",
			                                             "8",
			                                             "9",
			                                             "10",
			                                             "11",
			                                             "12",});

			while (true)
			{
				rootWindow.Update();
				var info = rootWindow.ReadKey();

				if (info.Key == ConsoleKey.Escape)
				{
					return;
				}
				selectBox.FeedInput(info);
				selectBox.Update();
				selectBox.OnSelect += (selection) => {
					rootWindow.RootArea.Move(new Position(10,20));
					rootWindow.RootArea.ClearLine();
					rootWindow.RootArea.AddString($"You selected '{selection}'");
				};
				selectBox.OnFocus += (selection) => {
					rootWindow.RootArea.Move(new Position(10, 22));
					rootWindow.RootArea.ClearLine();
					rootWindow.RootArea.AddString($"You focused '{selection}'");
				};
				rootWindow.RootArea.Copy(selectBox.Area, new Position((rootWindow.RootArea.Size.Width - selectBox.Area.Size.Width) / 2, 0));
				Thread.Sleep(33);
			}
		}