protected override void DoDisplayContent(ControlDisplay display) { foreach ((TKey key, TValue value) in Items) { DisplayLine(display, key, value); } }
void Awake() { instance = this; sceneAnimators = transform.root.GetComponentsInChildren <Animator>(); commandDisplay = transform.parent.FindChild("UI").FindChild("Command").GetComponent <CommandDisplay>(); controlDisplay = transform.parent.FindChild("UI").FindChild("Control Display").GetComponent <ControlDisplay>(); }
protected override void DoDisplayContent(ControlDisplay display) { foreach (string line in hangingMan.GetStickFigure()) { display.WriteRow(line); } }
/// <summary> /// Displays the label and waits for the user to provide a value. /// </summary> protected override void DoDisplayContent(ControlDisplay display) { switch (ReadWriteMode) { case ReadWriteMode.Unknown: break; case ReadWriteMode.Read: { ReadValue(); } break; case ReadWriteMode.Write: { if (Label != null && ShowLabel) Label.Display(); if (Value != null) WriteValue(display); } break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Displays the menu and waits for the user to choose an item. /// This method blocks until the user chooses an item. /// </summary> protected override void DoDisplayContent(ControlDisplay display) { menuItems.CurrentIndexChanged += HandleCurrentIndexChanged; try { menuLocation = CalculateMenuLocation(); Size itemsSize = CalculateItemsSize(); //InnerSize = new Size(itemsSize.Width, InnerSize.Height + itemsSize.Height); itemsLocation = CalculateMenuLocation(); foreach (IMenuItem menuItem in menuItems) { if (!menuItem.IsVisible) { continue; } int left = itemsLocation.Left; int top = Console.CursorTop; Console.SetCursorPosition(left, top); Size menuItemSize = new Size(itemsSize.Width, 1); menuItem.Display(menuItemSize, false); Console.WriteLine(); } if (SelectFirstByDefault) { menuItems.SelectFirst(); } ReadUserSelection(); } finally { if (!KeepHighlightingOnClose) { menuItems.SelectNone(); } menuItems.CurrentIndexChanged -= HandleCurrentIndexChanged; int lastMenuLine = menuLocation.Top + InnerSize.Height - 1; Console.SetCursorPosition(0, lastMenuLine); Console.WriteLine(); } }
/// <summary> /// Displays the question to the user and waits for the answer. /// </summary> protected override void DoDisplayContent(ControlDisplay display) { if (QuestionText != null) { DisplayQuestion(); } DisplayPossibleAnswersList(); if (SpaceAfterQuestion > 0) { DisplaySpaceAfterQuestion(); } Answer = ReadAnswerInternal(); }
/// <summary> /// Displays the menu and waits for the user to choose an item. /// This method blocks until the user chooses an item. /// </summary> protected override void DoDisplayContent(ControlDisplay display) { bool success = false; while (!success && !closeWasRequested) { WriteLeftMargin(); display.StartRow(); string text = TextFormat == null ? Text : string.Format(TextFormat, Text); CustomConsole.Write(text); success = ReadUserInput(); display.EndRow(); WriteRightMargin(); } }
protected override void DoDisplayContent(ControlDisplay display) { var oldColor = CustomConsole.EmphasiesColor; if (Won) { CustomConsole.EmphasiesColor = ConsoleColor.Green; CustomConsole.WriteEmphasies("CONGRATULATIONS! YOU WON!!!"); CustomConsole.WriteLine(); } else { CustomConsole.EmphasiesColor = ConsoleColor.Red; CustomConsole.WriteEmphasies("YOU LOST... :("); CustomConsole.WriteLine(); } CustomConsole.EmphasiesColor = oldColor; }
private static void DisplayLine(ControlDisplay display, object key, object value) { display.StartRow(); display.Write($"{key}: "); if (value is bool boolValue) { ConsoleColor foregroundColor = boolValue ? CustomConsole.SuccessColor : CustomConsole.ErrorColor; display.Write(foregroundColor, null, value.ToString()); } else { display.Write(value.ToString()); } display.EndRow(); }
private void WriteValue(ControlDisplay display) { display.WriteRow(Value?.ToString()); }